DSL Tips and Tricks :: dsl2unc



v0.2 - Testers wanted.

Now converts multiple dsls.
(Indenting seems to get lost when posting unfortunately).
==========================================

Code Sample
#!/bin/bash

# dsl2unc v0.2

# Just automates Robert's instructions for making a unc extension from a dsl.
# WDef Sept 2006

# Changelog v0.2

# Handles symlinks, opt and empty directories in user.tar.gz.
# Current working directory is assumed if path to argument extension is not given.
# Runs in batch mode: converts all argument .dsls to .uncs
#- eg to process somedirectory full of extensions, if dsl2unc is in PATH:
#- cd somedirectory; dsl2unc *
# Directory $DIR for $WORK and output is now settable.
# More lurid coloring :=)

#==========================// USER SETTING//===============================

# Put DIR on a hard drive partition if insufficient room in /ramdisk/home/dsl
DIR=/home/dsl

#==========================// FNS //========================================

help(){
cat <<"EOF"
dsl2unc v0.2 - convert .dsl extension to .unc
Usage: dsl2unc </path/to/ext1.dsl /path/to/ext2.dsl ..>
Creates a work dir in $DIR
New unc(s) is output in $DIR
Default DIR=/home/dsl
EOF
exit
}


dir_filter(){
# Filter out non-empty dir lines from stdin
while read LM; do
if [ -d "${WORK}/$LM" ]; then
if [ $(ls -1A ${WORK}/$LM| wc -l) -eq 0 ]; then
# empty dir - ok
echo ${LM}
fi
else
# files, symlinks - ok
echo ${LM}
fi
done
}

#======================================================================


. /etc/init.d/dsl-functions # for ANSI colors

results=/tmp/dsl2unc_results

rm -f ${results}

if [ "${1}" = -h ] || [ "${1}" = --help ] || [ $# -eq 0 ]; then help; fi

CURRENTD="${PWD}"
APP=""

for APP in $*; do

# If no path supplied, assume current working dir
[ $(echo ${APP} | tr '/' ' '| wc -w) -eq 1 ] && APP="${CURRENTD}/${APP}"

if [ ! -e "${APP}" ]; then
echo "${RED}Can't find ${APP}${NORMAL}" >>${results}
continue
fi

if [ ${APP##*.} != dsl ]; then echo "${RED}${APP} is not a .dsl extension.${NORMAL}" >>${results}; continue; fi

NAME=$(basename ${APP} .dsl)
WORK=${DIR}/$NAME

if [ -e "${WORK}" ]; then echo "${RED}${WORK} already exists.${NORMAL}" >>${results}; continue; fi

mkdir ${WORK}

echo
echo "${WHITE}Making ${GREEN}$NAME.unc${WHITE} from ${YELLOW}$NAME.dsl ..${NORMAL}"
echo

cd ${WORK}
tar -zxvf ${APP}
find home opt tmp 2>/dev/null | dir_filter | xargs tar -czvf user.tar.gz 2>/dev/null
rm -rf home opt tmp

cd ..

mkisofs -R -hide-rr-moved -cache-inodes -pad ${WORK} | create_compressed_fs - 65536 >$NAME.unc
if [ $? -ne 0 ]; then echo "${RED}Error making $NAME.unc" >>${results}; continue; fi
echo
echo "${GREEN}Now test your new ${YELLOW}$NAME.unc!${NORMAL}"

echo "${YELLOW}$NAME.dsl${WHITE} --> ${GREEN}$NAME.unc${NORMAL}" >>${results}
done

echo
echo "======================================================================"
echo
echo "${WHITE}DSL2UNC ${WHITE}RESULTS:${NORMAL}"
echo
cat ${results}
echo
echo "======================================================================"
echo "${GREEN}Finished.${NORMAL}"

exit 0

I had trouble with this (v2)
It had many errors and created a 2.6k unc from a 160k .dsl..
It also managed to !change! the md5sum of the .dsl!!

So improvement requested....

Pls provide some more information viz.
which extension were you trying to convert?

grub-splash. About half of the errors were from tar, but I don't remember them anymore..
Though it works when installing it..

The result unc only had one file, /sbin/grub-floppy (that's what read there) and the working dir also had only that..

I don't think that's posted yet.

Can you email it to me or upload it somewhere so I can attempt to replicate your issue?

Next Page...
original here.