minix/commands/scripts/packman.sh

115 lines
2.8 KiB
Bash
Raw Normal View History

2006-02-03 16:41:58 +01:00
#!/bin/sh
RC=/usr/etc/rc.package
CDDIR=PACKAGES
MP=/mnt
CDPACK=${MP}/install/packages
CDSRC=${MP}/install/package-sources
2006-03-25 01:00:23 +01:00
SRC=/usr/src/commands
LISTFILE=/etc/packages
2006-03-16 15:46:57 +01:00
LISTURL=http://www.minix3.org/packages/List
TMPDIR=/usr/tmp/packages
mkdir -p $TMPDIR
2006-03-16 15:46:57 +01:00
URL1=http://www.minix3.org/packages
URL2=http://www.minix3.org/beta_packages
SRCURL1=http://www.minix3.org/software
SRCURL2=http://www.minix3.org/beta_software
2006-02-03 16:41:58 +01:00
if [ -f "$RC" ]
then . "$RC"
fi
cd /
if [ -n "$cddrive" ]
then pack=${cddrive}p2
umount $pack >/dev/null 2>&1 || true
2006-03-17 15:00:26 +01:00
if mount -r $pack $MP
then
cd $CDPACK
2006-03-22 17:44:45 +01:00
for package in `ls *.tar.bz2`
2006-03-17 15:02:17 +01:00
do grep $package List
echo -n "Install $package (y/N) ? "
read y
if [ "$y" = y -o "$y" = Y ]
then echo "Extracting $CDPACK/$package .."
cat $package | packit -
2006-03-22 17:44:45 +01:00
srcname="`echo $package | sed 's/.tar.bz2/-src.tar.bz2/'`"
srcarc="$CDSRC/$srcname"
if [ -f "$srcarc" ]
then echo -n "Install its source (y/N) ? "
read y
if [ "$y" = y -o "$y" = Y ]
then echo "Installing $srcarc into $SRC."
2006-03-17 15:46:38 +01:00
smallbunzip2 -dc "$srcarc" | (cd $SRC && tar xf - )
fi
2006-03-17 16:32:14 +01:00
else :
fi
fi
done
else echo "CD mount failed - skipping CD packages."
fi
2006-03-17 16:32:14 +01:00
else echo "Don't know where the install CD is. You can set it in $RC."
2006-02-03 16:41:58 +01:00
fi
2006-02-06 11:55:38 +01:00
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 }'`"
2006-03-22 17:44:45 +01:00
url=$file.tar.bz2
srcfile=$file.tar.bz2
if [ -n "$url" ]
then echo -n "Try to get source too? (y/N) "
read src
echo "Trying to fetch from $URL1/$url.."
srcurl=$SRCURL1/$srcfile
if urlget $URL1/$url >$url
then echo Installing.
packit $url
else echo "Trying to fetch from $URL2/$url.."
srcurl=$SRCURL2/$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