X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=fremantle%2Feasy-deb-chroot%2Fsrc%2Fhome%2Fuser%2Fimg-install%2Fdebian-installer.sh;fp=fremantle%2Feasy-deb-chroot%2Fsrc%2Fhome%2Fuser%2Fimg-install%2Fdebian-installer.sh;h=bc9021b317ea635cfeeed3c0ecd9cdeb899c8265;hb=2a0f1e69e356b51d8781956aab8807fa6eadacc3;hp=0000000000000000000000000000000000000000;hpb=4f4a995b7b3d318f037f36b6ea0fb84e92045cb9;p=easy-deb-chroot diff --git a/fremantle/easy-deb-chroot/src/home/user/img-install/debian-installer.sh b/fremantle/easy-deb-chroot/src/home/user/img-install/debian-installer.sh new file mode 100755 index 0000000..bc9021b --- /dev/null +++ b/fremantle/easy-deb-chroot/src/home/user/img-install/debian-installer.sh @@ -0,0 +1,170 @@ +#!/bin/sh + +## New! Ask where the user wishes to install the package with gxmessage: + +export GXMSG=`printf "\ +Where do you want your Debian image file installed?\n\ +You need approximately 1.3GB initially.\n\ +Free space left in internal memory or your memory card:\n\n"; \ +df -h | grep "mmcblk.p1" | awk '{print $6 ": " $4 " free, " $2 " total (" $5 " full)"}' | sort` +gxmessage -center -buttons MyDocs:1,MicroSD:2 -geometry 690x380 -title "Choose Memory Card" "$GXMSG" +export SDNO=$? + +case "$SDNO" in + 1) + export SDCARD="/home/user/MyDocs" + ;; + *) + export SDCARD="/media/mmc1" + ;; +esac + +echo "Downloading and extracting to $SDCARD..." + +#exit 0 + +## HERE ARE THE VARIABLES: + +export INSTPATH="/home/user/img-install" +export TARPATH="$SDCARD" +export DLURL="http://qole.org/files" +export BZ2CMD1="bzip2 -d " +export BZ2CMD2="$TARPATH" +#This doesn't work: +#export BZ2CMD1="bzcat" +#export BZ2CMD2="| tar xf -" +export GZCMD1="tar -xzf" + +export EXTPATH1=$TARPATH +export PKGNAME1="EASY DEBIAN IMAGE FILE" +export BIGTAR1="debian-squeeze-m5-img.bz2" +export TARCMD1="$BZ2CMD1 $TARPATH/$BIGTAR1 $BZ2CMD2" +export MD51="f769bb84c99f75821bdfa37e5ea34e86" +export EXTCMD1="" + +#Set SKIPPKG2=1 to skip the second package. + +export SKIPPKG2=1 +export EXTPATH2=$EXTPATH1 +export PKGNAME2="SECOND TEST" +export BIGTAR2="test2.tgz" +export TARCMD2="$GZCMD1 $TARPATH/$BIGTAR2" +export MD52="ec3ccde37f4cd026fd03911df7579d6a" +export EXTCMD2="" + +#export CLEANUP="sudo rm -r $INSTPATH ; sudo rm /usr/share/applications/image-install.desktop " +export CLEANUP="echo All done!" + +## HERE'S THE SCRIPT: + +# Download first package + +export GOTIT="no" + +if [ -f $TARPATH/$BIGTAR1 ] ; then + echo You already have the big image file! + echo Checking to see if it is good... + if [ "`$INSTPATH/md5sum $TARPATH/$BIGTAR1 | awk '{print $1}'`" = "$MD51" ] ; then + export GOTIT="yes" + fi +fi + +echo " " +echo "Downloading $PKGNAME1 package..." + +export GOOD=1 +export TEST=2 + +while test $TEST != $GOOD +do + cd $TARPATH + if [ ! "$GOTIT" = "yes" ] ; then + wget -c $DLURL/$BIGTAR1 + fi + + if test -e $TARPATH/$BIGTAR1 + then + + cd $INSTPATH + export GOOD=$MD51 + if [ ! "$GOTIT" = "yes" ] ; then + echo Testing the file to see if it is good. + export TEST=`$INSTPATH/md5sum $TARPATH/$BIGTAR1 | awk '{print $1}'` + else + export TEST=$MD51 + fi + + if test $TEST = $GOOD + then + + cd $EXTPATH1 + echo Extracting the image file. This will take some time. + TARERR=`$TARCMD1 2>&1` + if [ "$?" = 0 ] ; then + rm -rf $TARPATH/$BIGTAR1 + $EXTCMD1 + export MSG1=`printf "CONGRATULATIONS!\n\nAll has gone well!\n\nSuccess installing $PKGNAME1 package!"` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "SUCCESS!" "$MSG1" + else + export ERR1=`printf "ERROR! TAR FAILED!\nUnable to install $PKGNAME1\n$TARERR"` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x380 -title "TAR ERROR" "$ERR1" + exit 99 + fi + else + export ERR1=`printf "$PKGNAME1 package appears damaged.\nPress OK to try downloading again.\nCancel keeps the damaged file."` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0,GTK_STOCK_CANCEL:1 -geometry 640x100 -title "DOWNLOAD ERROR" "$ERR1" + if [ "$?" = 1 ] ; then + exit 99 + fi + rm $TARPATH/$BIGTAR1 + fi + fi +done + +# Stop if only getting one package + +if test $SKIPPKG2 == 1 + then + $CLEANUP + exit 0 +fi + +# Download second package + +echo " " +echo "Downloading $PKGNAME2 package..." +export GOOD2=1 +export TEST2=2 + +while test $TEST2 != $GOOD2 +do + cd $INSTPATH + wget -c $DLURL/$BIGTAR2 + if test -e $TARPATH/$BIGTAR2 + then + + export GOOD2=$MD52 + export TEST2=`$INSTPATH/md5sum $TARPATH/$BIGTAR2 | awk '{print $1}'` + + if test $TEST2 = $GOOD2 + then + cd $EXTPATH2 + TARERR=`$TARCMD2 2>&1` + if [ "$?" = 0 ] ; then + rm -rf $TARPATH/$BIGTAR2 + $EXTCMD2 + export MSG2=`printf "CONGRATULATIONS!\n\nAll has gone well!\n\nSuccess installing $PKGNAME2 package!"` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "SUCCESS!" "$MSG2" + else + export ERR2=`printf "ERROR! ERROR! ERROR!\nTAR FAILED!\n\nUnable to install $PKGNAME2\n\n$TARERR"` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "TAR ERROR" "$ERR2" + exit 99 + fi + else + echo "$PKGNAME2 package seems damaged, trying again!" + fi + fi +done + +$CLEANUP +exit 0