as root with both script and extension in /home/dsl (I use an older dsl while on the web so dsl2unc is in my home directory).
EDIT: Which reminds me I need to update this to try to preserve perms.Ah-ha! Let me guess - you're running it something like
Code Sample
./dsl2unc somedir/grub-splash.dsl
That does go haywire. The problem is I got lazy on sorting out the relative paths. What's worse, I wrote a v3 that fixed this months ago and forgot about it. Mea culpa.
# Just automates Robert's instructions for making a unc extension from a dsl. # WDef Mar 2007
# Changelog v0.3
# Relative paths handled # Added checks for work dir and filesystem # Run as root to keep perms
# 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. # Even more lurid coloring.
#==========================// USER SETTING//===============================
# Put DIR on a hard drive _linux_ partition if insufficient room in /ramdisk/home/dsl DIR=/mnt/hda3/work
help(){ cat <<"EOF" dsl2unc v0.3 - make unc extensions from dsl extensions Usage: dsl2unc <ext1.dsl ext2.dsl ..> Creates a work dir in $DIR New unc is output in $DIR Default DIR=/home/dsl EOF exit }
check_work_dir(){ # Check work directory looks ok if [ -z "$DIR" ]; then "${RED}User setting work dir is unset.${NORMAL}"; exit 1; fi case ${DIR} in /mnt/*) D=$(echo ${DIR} | awk -F/ '{print "/" $2 "/" $3 }' ) FS=$(grep ${D} /proc/mounts | awk '{print $3}') if [ -z "$FS" ]; then echo "${RED}$D not mounted.${NORMAL}"; exit 1; fi case $FS in ext2|ext3|reiser*);; *fat*|ms*) echo "${RED}$DIR on $FS can't preserve perms - use linux filesystem.${NORMAL}"; exit 1;; ntfs) echo "${RED}Writing to ntfs may not be a good idea ${NORMAL}"; exit 1 ;; esac;; /*|/ramdisk/*);; *) echo "${RED}Err .. where exactly _is_ this $DIR anyway?"${NORMAL}; exit 1;; esac if [ ! -d "${DIR}" ] || [ ! -w "${DIR}" ]; then echo "${RED}$DIR not a dir or not writeable.${NORMAL}"; exit 1 fi }
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 }
if [ "${1}" = -h ] || [ "${1}" = --help ] || [ $# -eq 0 ]; then help; fi
check_work_dir
results=/tmp/dsl2unc_results
rm -f ${results}
CURRENTD="${PWD}" APP=""
for APP in $*; do
# If no path supplied, assume current working dir
if echo ${APP} | grep -q -v '^/'; then APP="${CURRENTD}/${APP}"; fi
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 -zxpvf ${APP} find home opt tmp 2>/dev/null | dir_filter | xargs tar -czpvf 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}"