]> Zhao Yanbai Git Server - minix.git/commitdiff
Packme - CD and network interface to packit
authorBen Gras <ben@minix3.org>
Thu, 16 Mar 2006 14:36:07 +0000 (14:36 +0000)
committerBen Gras <ben@minix3.org>
Thu, 16 Mar 2006 14:36:07 +0000 (14:36 +0000)
commands/scripts/packme.sh

index 465755ba0886f9345c6882882140385186067f06..f89016a1dd26d3bcd723e870f4c939e94251b338 100644 (file)
@@ -8,6 +8,12 @@ MP=/mnt
 CDPACK=${MP}/install/packages
 CDSRC=${MP}/install/package-sources
 SRC=/usr/bigports
+LISTFILE=/etc/packages
+LISTURL=http://www.1st.minix3.org/packages/List
+TMPDIR=/usr/tmp/packages
+mkdir -p $TMPDIR
+URL1=http://www.1st.minix3.org/packages
+URL2=http://www.1st.minix3.org/beta_packages
 
 if [ -f "$RC" ]
 then   . "$RC"
@@ -46,3 +52,63 @@ then pack=${cddrive}p2
 else   echo "Don't know where the install CD is."
 fi
 
+TMPF=/tmp/list.$$
+
+if </dev/tcp
+then   if [ -f $LISTFILE ]
+       then    echo -n "Update package list from network? (y/N) "
+               read y
+       else    y=y
+       fi
+       if [ "$y" = y -o "$y" = Y ]
+       then    echo "Fetching package list."
+               urlget $LISTURL >$TMPF && mv $TMPF $LISTFILE || echo Not done.
+       fi
+       cont=y
+       while [ "$cont" = y ]
+       do      cd $TMPDIR
+               echo "Package list:"
+               awk -F'|' <$LISTFILE '{ printf "%3s %-20s %s\n", $1, $2, $3 }' | more
+               echo -n "Package to install? [RETURN for none] "
+               read packno
+               if [ -n "$packno" ]
+               then    file="`grep "^$packno|" $LISTFILE | awk -F'|' '{ print $2 }'`"
+                       url=$file.tar.bz
+                       srcfile=$file-src.tar.bz
+                       if [ -n "$url" ]
+                       then    echo -n "Try to get source too? (y/N) "
+                               read src
+                               echo "Trying to fetch from $URL1/$url.."
+                               srcurl=$URL1/$srcfile
+                               if urlget $URL1/$url >$url
+                               then    echo Installing.
+                                       packit $url
+                               else    echo "Trying to fetch from $URL2/$url.."
+                                       srcurl=$URL2/$srcfile
+                                       if urlget $URL2/$url >$url
+                                       then    echo Installing Beta.
+                                               packit $url
+                                       else    echo "Retrieval failed."
+                                       fi
+                               fi
+                               if [ "$src" = y -o "$src" = Y ]
+                               then    cd $SRC
+                                       echo "Trying $srcurl"
+                                       if urlget $srcurl >$srcfile
+                                       then    echo "Extracting source into $SRC"
+                                               smallbunzip2 -dc $srcfile | tar xf -
+                                               echo "Done"
+                                       else    echo "$srcurl not retrieved."
+                                       fi
+                               fi
+                       else    echo "Package $packno not found."
+                       fi
+                       echo "Press RETURN to continue .."
+                       read xyzzy
+               else    cont=n
+               fi
+       done
+else   echo "No working network detected.
+Please re-run this script with networking enabled to download
+packages."
+fi