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=0bb0979473b845ebe4ccecc2e4a38b4e9f6ae468;hb=f2bac74be02abdb9577c5caee98db6a78e878881;hp=1b3780adfc8699790b23ee40502b7476d1248674;hpb=dab6b987af82acf4a4c93bf02418bc725c537bc5;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 index 1b3780a..0bb0979 100755 --- 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 @@ -1,58 +1,86 @@ #!/bin/sh +## Download the list of images. Also use this opportunity to check +## the Internet connection and availability of the server. + +IMGLIST="imagelist-0.9.40" + +mv $IMGLIST $IMGLIST.old +wget -t 3 http://qole.org/$IMGLIST +if [ $? != 0 ] ; then + MSG1=`printf "\ +Cannot download the list of available images.\n\ +$? \ +Something is wrong with either your Internet connection\n\ +or the qole.org file server.\n\n\ +Check your Internet connection and the status\n\ +of the server by browsing to http://qole.org"` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "Download Error" "$MSG1" + exit +fi + +gxmessage -buttons \ + "`awk -F ',' '/^[0-9],/ {print $2":"$1","}' $IMGLIST`Cancel:0" \ + "`awk -F ',' '/^[0-9],/ {print $2":"$6}' $IMGLIST`" +IMGCHOICE=$? + +#Both 0 and 1 are Cancel + +if [ "$IMGCHOICE" -le "1" ] ; then + exit 9 +fi + +DLURL=`awk -F"," '$1=='$IMGCHOICE' {print $3}' $IMGLIST` +PKGNAME1=`awk -F"," '$1=='"$IMGCHOICE"' {print $6}' $IMGLIST` +BIGTAR1=`awk -F"," '$1=='"$IMGCHOICE"' {print $4"."$5}' $IMGLIST` +BIGIMG1=`awk -F"," '$1=='"$IMGCHOICE"' {print $4}' $IMGLIST` +MD51=`awk -F"," '$1=='"$IMGCHOICE"' {print $7}' $IMGLIST` +IMGCMPRSS=`awk -F"," '$1=='"$IMGCHOICE"' {print $5}' $IMGLIST` + +#echo $DLURL +#echo $PKGNAME1 +#echo $BIGTAR1 +#echo $BIGIMG1 +#echo $MD51 +#echo $IMGCMPRSS + +## Make sure the chroot is closed, to avoid spurious mounts + +sudo closechroot >/dev/null + ## 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\ +You need approximately 2.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" +gxmessage -center -buttons MyDocs:2,MicroSD:3 -geometry 690x380 -title "Choose Memory Card" "$GXMSG" export SDNO=$? case "$SDNO" in - 1) + 2) export SDCARD="/home/user/MyDocs" ;; - *) + 3) export SDCARD="/media/mmc1" ;; + *) + exit 9 + ;; esac -echo "Downloading and extracting to $SDCARD..." +echo "Downloading and extracting $BIGIMG1 to $SDCARD..." -#exit 0 +# exit 0 -## HERE ARE THE VARIABLES: +## HERE ARE THE REST OF THE VARIABLES: export INSTPATH="/home/user/img-install" export TARPATH="$SDCARD" -export DLURL="http://qole.org/files" -#This doesn't work: -export GZCMD1="tar -xzf" - export EXTPATH1=$TARPATH -export PKGNAME1="EASY DEBIAN IMAGE FILE" -export BIGTAR1="debian-m5-v2.img.ext2.bz2" -export BIGIMG1="debian-m5-v2.img.ext2" -# export BZ2CMD1="bzip2 -d " -# export BZ2CMD2=" > $TARPATH/$BIGIMG1" -# export BZ2CMD1="cat " -# export BZ2CMD2=" | bunzip2 > " -# export TARCMD1="cat $TARPATH/$BIGTAR1 | bunzip2 > $TARPATH/$BIGIMG1" -export MD51="1c02d35d6453fd35390ae025bd930ba2" 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!" @@ -60,6 +88,9 @@ export CLEANUP="echo All done!" # Download first package +echo " " +echo "Downloading $PKGNAME1 package..." + export GOTIT="no" if [ -f $TARPATH/$BIGTAR1 ] ; then @@ -70,9 +101,6 @@ if [ -f $TARPATH/$BIGTAR1 ] ; then fi fi -echo " " -echo "Downloading $PKGNAME1 package..." - export GOOD=1 export TEST=2 @@ -99,23 +127,30 @@ do then cd $EXTPATH1 - echo Extracting the image file. This will take some time. - # echo $TARCMD1 - # echo 'cat $TARPATH/$BIGTAR1 | bunzip2 > $TARPATH/$BIGIMG1' - # TARERR=`$TARCMD1 2>&1` - TARERR="Unknown bzip2 error" +# Warn the user that the decompression is going to take a long time. + + export MSG1=`printf "\ +Extracting the image file.\n\ +This could take a very long time and could\n\ +cause your device to become unresponsive."` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x250 -title "Decompressing" "$MSG1" & + + echo " " + echo "Extracting $BIGTAR1 package..." + + TARERR="Unknown lzma error" # read -p 'press enter' key #$TARCMD1 - cat $TARPATH/$BIGTAR1 | bunzip2 > $TARPATH/$BIGIMG1 + lzma -kd $TARPATH/$BIGTAR1 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" + export ERR1=`printf "ERROR! DECOMPRESSION FAILED!\nUnable to install $PKGNAME1\n$TARERR"` + gxmessage -center -alignbuttons right -buttons GTK_STOCK_OK:0 -geometry 640x380 -title "DECOMPRESSION ERROR" "$ERR1" exit 99 fi else @@ -129,50 +164,5 @@ do 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