Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (6) </ 1 2 [3] 4 5 6 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: dsl2unc, .unc extensions made easy< Next Oldest | Next Newest >
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Mar. 23 2007,21:22 QUOTE

That's now posted in testing... http://damnsmalllinux.org/cgi-bin....8;st=20
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Mar. 24 2007,00:41 QUOTE

Curago, I don't seem to get any errors and your extension is converting to a unc ok.

I'm just doing

Code Sample
# ./dsl2unc grub-splash.dsl


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.
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Mar. 24 2007,01:01 QUOTE

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.

Try this:

===================================================

#!/bin/bash

# dsl2unc v0.3

# 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

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

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
}

#===============================//MAIN //=======================================


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

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}"

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
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Mar. 24 2007,09:53 QUOTE

I also changed the working dir from /home/dsl to /temp/temp and ran it as root.. That directory did exist before trying it...

If you wish, just post the unc you made of it, I don't feel like messing with that for now.

But yea, I think I did something like that.. BTW, WDef, ever played Final Fantasy? It's curaga

EDIT: yea, but that was with v2


--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Mar. 24 2007,13:18 QUOTE

Not a big games person myself. I'll aim to get your nic right in future, typos notwithstanding.

I'm emailing you the unc so you can test it and post it.

EDIT:  /temp/temp works.
Back to top
Profile PM 
25 replies since Sep. 14 2006,19:06 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (6) </ 1 2 [3] 4 5 6 >/
reply to topic new topic new poll
Quick Reply: dsl2unc

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code