2006-02-03 16:41:58 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2007-01-08 16:10:27 +01:00
|
|
|
TAG=`uname -p`-`uname -r`.`uname -v`
|
2006-08-15 17:56:42 +02:00
|
|
|
PACKDIR=`uname -p`/`uname -r`.`uname -v`
|
2006-02-03 16:41:58 +01:00
|
|
|
RC=/usr/etc/rc.package
|
|
|
|
CDDIR=PACKAGES
|
2006-03-26 17:48:55 +02:00
|
|
|
CDMP=/mnt
|
|
|
|
CDPACK=${CDMP}/install/packages
|
|
|
|
CDSRC=${CDMP}/install/package-sources
|
2007-01-22 16:42:40 +01:00
|
|
|
SRC=/usr/bigsrc
|
2007-01-08 16:10:27 +01:00
|
|
|
LISTFILE=/etc/packages-$TAG
|
|
|
|
LISTURL=http://www.minix3.org/packages/$PACKDIR/List
|
2006-03-16 15:36:07 +01:00
|
|
|
TMPDIR=/usr/tmp/packages
|
|
|
|
mkdir -p $TMPDIR
|
2006-08-15 17:56:42 +02:00
|
|
|
URL1=http://www.minix3.org/packages/$PACKDIR
|
2006-03-22 18:06:53 +01:00
|
|
|
SRCURL1=http://www.minix3.org/software
|
2006-10-25 15:40:36 +02:00
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
2006-02-03 16:41:58 +01:00
|
|
|
|
2006-04-04 16:52:22 +02:00
|
|
|
# can we execute bunzip2?
|
|
|
|
if bunzip2 --help 2>&1 | grep usage >/dev/null
|
|
|
|
then BUNZIP2=bunzip2
|
|
|
|
else BUNZIP2=smallbunzip2
|
|
|
|
fi
|
|
|
|
|
2006-03-26 17:48:55 +02:00
|
|
|
if id | fgrep "uid=0(" >/dev/null
|
|
|
|
then :
|
|
|
|
else echo "Please run $0 as root."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-03-26 18:46:37 +02:00
|
|
|
chmod 700 $TMPDIR
|
|
|
|
|
2006-02-03 16:41:58 +01:00
|
|
|
if [ -f "$RC" ]
|
|
|
|
then . "$RC"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd /
|
|
|
|
|
2007-03-12 17:55:02 +01:00
|
|
|
# Make sure there is a $SRC dir
|
|
|
|
if [ ! -d "$SRC" ]
|
|
|
|
then mkdir $SRC || exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Is there a usable CD to install packages from?
|
2006-03-26 17:48:55 +02:00
|
|
|
cdpackages=""
|
2006-02-03 16:41:58 +01:00
|
|
|
if [ -n "$cddrive" ]
|
2006-03-15 16:34:12 +01:00
|
|
|
then pack=${cddrive}p2
|
|
|
|
umount $pack >/dev/null 2>&1 || true
|
2006-03-26 17:48:55 +02:00
|
|
|
if mount -r $pack $CDMP
|
|
|
|
then fn="$CDPACK/List"
|
|
|
|
cdpackages=$fn
|
|
|
|
if [ ! -f $cdpackages ]
|
|
|
|
then cdpackages=""
|
|
|
|
echo "No package list found on CD in $fn."
|
|
|
|
fi
|
|
|
|
else echo "CD mount failed."
|
2006-03-15 16:34:12 +01:00
|
|
|
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
|
|
|
|
2006-03-26 18:46:37 +02:00
|
|
|
TMPF=$TMPDIR/.list.$$
|
|
|
|
rm -f $TMPF
|
|
|
|
rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|
|
|
|
|
2007-03-12 17:55:02 +01:00
|
|
|
# Check for network packages too
|
2006-03-26 17:48:55 +02:00
|
|
|
netpackages=""
|
2006-03-26 21:30:33 +02:00
|
|
|
if ( : </dev/tcp ) 2>/dev/null
|
2007-01-11 15:35:29 +01:00
|
|
|
then echo -n "Update package list from network? (Y/n) "
|
|
|
|
read y
|
|
|
|
if [ "$y" != n -a "$y" != N ]
|
2007-01-08 16:10:27 +01:00
|
|
|
then echo "Fetching package list from $LISTURL."
|
2006-03-27 13:08:04 +02:00
|
|
|
urlget $LISTURL >$TMPF && mv $TMPF $LISTFILE || echo "Update not successful."
|
2006-03-16 15:36:07 +01:00
|
|
|
fi
|
2006-03-26 17:48:55 +02:00
|
|
|
netpackages=$LISTFILE
|
|
|
|
if [ ! -f "$netpackages" -o ! `cat "$netpackages" 2>/dev/null | wc -l | awk '{ print $1 }'` -gt 1 ]
|
|
|
|
then netpackages=""
|
|
|
|
fi
|
|
|
|
else echo "No working network detected."
|
|
|
|
fi
|
|
|
|
|
2007-03-12 17:55:02 +01:00
|
|
|
# Is there at least one package type?
|
|
|
|
if [ ! -n "$netpackages" -a ! -n "$cdpackages" ]
|
|
|
|
then echo "No packages found."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Is there more than one package type?
|
|
|
|
if [ -n "$netpackages" -a -n "$cdpackages" ]
|
|
|
|
then echo -n "Would you like to install from (C)D or (N)etwork? [C] "
|
|
|
|
read whichsrc
|
|
|
|
if [ "$whichsrc" = N -o "$whichsrc" = n ]
|
|
|
|
then unset cdpackages
|
|
|
|
else unset netpackages
|
2006-03-26 17:48:55 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-03-12 17:55:02 +01:00
|
|
|
if [ -n "$netpackages" ]
|
|
|
|
then source=net
|
|
|
|
else source=cdrom
|
|
|
|
fi
|
|
|
|
|
2006-03-26 17:48:55 +02:00
|
|
|
cont=y
|
|
|
|
while [ "$cont" = y ]
|
|
|
|
do cd $TMPDIR
|
|
|
|
echo ""
|
|
|
|
echo "Showing you a list of packages using more. Press q when"
|
|
|
|
echo "you want to leave the list."
|
|
|
|
echo -n "Press RETURN to continue.."
|
|
|
|
read xyzzy
|
|
|
|
echo "Package list:"
|
2007-03-12 17:55:02 +01:00
|
|
|
( echo "No.|Package|Description"
|
2006-03-26 17:48:55 +02:00
|
|
|
(
|
|
|
|
if [ -f "$netpackages" ]
|
2007-03-12 17:55:02 +01:00
|
|
|
then cat $netpackages
|
2006-03-26 17:48:55 +02:00
|
|
|
fi
|
|
|
|
if [ -f "$cdpackages" ]
|
2007-03-12 17:55:02 +01:00
|
|
|
then cat $cdpackages
|
2006-03-26 17:48:55 +02:00
|
|
|
fi
|
2006-03-26 18:46:37 +02:00
|
|
|
) | sort -t'|' +1 | awk '{ n++; printf "%d|%s\n", n, $0 }'
|
2006-03-26 17:48:55 +02:00
|
|
|
) >$TMPF
|
2007-04-02 14:09:43 +02:00
|
|
|
highest="`wc -l $TMPF | awk '{ print $1 - 1 }'`"
|
2007-03-12 17:55:02 +01:00
|
|
|
awk -F'|' <$TMPF '{ printf "%3s %-15s %s\n", $1, $2, $3 }' | more
|
|
|
|
echo "Format examples: '3', '3,6', '3-9', '3-9,11-15', 'all'"
|
2007-04-02 16:44:16 +02:00
|
|
|
echo -n "Package(s) to install (RETURN or q to exit)? "
|
2007-03-12 17:55:02 +01:00
|
|
|
read packnolist
|
2007-04-02 16:44:16 +02:00
|
|
|
if [ "$packnolist" = "" -o "$packnolist" = "q" ]
|
2007-03-21 10:54:09 +01:00
|
|
|
then exit 0
|
|
|
|
fi
|
2007-03-12 17:55:02 +01:00
|
|
|
if [ "$packnolist" = all ]
|
|
|
|
then packnolist=1-$highest
|
|
|
|
fi
|
|
|
|
IFS=','
|
|
|
|
set $packnolist
|
|
|
|
echo -n "Get source(s) too? (y/N) "
|
|
|
|
read getsources
|
|
|
|
for packrange in $packnolist
|
|
|
|
do
|
|
|
|
# Get a-b range.
|
|
|
|
IFS='-'
|
|
|
|
set $packrange
|
|
|
|
start=$1
|
|
|
|
if [ $# = 2 ]
|
|
|
|
then end=$2
|
|
|
|
else end=$1
|
|
|
|
fi
|
|
|
|
IFS=' '
|
|
|
|
# use awk to make the range list
|
|
|
|
for packno in `awk </dev/null "BEGIN { for(i=$start; i<=$end; i++) { printf \"%d \", i } }"`
|
|
|
|
do
|
2006-03-26 18:46:37 +02:00
|
|
|
ok=y
|
|
|
|
pat="^$packno|"
|
2007-03-12 17:55:02 +01:00
|
|
|
if [ "`grep -c $pat $TMPF`" -ne 1 ]
|
2006-03-26 18:46:37 +02:00
|
|
|
then if [ "$packno" ]
|
2007-03-12 17:55:02 +01:00
|
|
|
then echo "$packno: Wrong package number."
|
2006-03-26 18:46:37 +02:00
|
|
|
fi
|
|
|
|
ok=n
|
|
|
|
fi
|
|
|
|
if [ $ok = y ]
|
2007-03-12 17:55:02 +01:00
|
|
|
then
|
|
|
|
packagename="`grep $pat $TMPF | awk -F'|' '{ print $2 }'`"
|
|
|
|
file=$packagename.tar.bz2
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
if [ -f $file ]
|
|
|
|
then echo "Skipping $file - it's already in $TMPDIR."
|
|
|
|
echo "Remove that file if you want to re-retrieve and install this package."
|
|
|
|
else
|
2006-03-26 17:48:55 +02:00
|
|
|
case $source in
|
2007-03-12 17:55:02 +01:00
|
|
|
net*) echo "Retrieving $packno ($packagename) from primary location into $TMPDIR .."
|
2006-03-26 17:48:55 +02:00
|
|
|
srcurl=""
|
|
|
|
if urlget $URL1/$file >$file
|
2006-03-26 18:46:37 +02:00
|
|
|
then echo "Retrieved ok. Installing .."
|
2006-03-26 17:51:34 +02:00
|
|
|
packit $file && echo Installed ok.
|
2006-03-26 17:48:55 +02:00
|
|
|
srcurl=$SRCURL1/$file
|
2006-08-15 17:56:42 +02:00
|
|
|
else echo "Retrieval failed."
|
2006-03-16 15:36:07 +01:00
|
|
|
fi
|
2007-03-12 17:55:02 +01:00
|
|
|
if [ "$getsources" = y -o "$getsources" = Y ]
|
2006-03-26 17:48:55 +02:00
|
|
|
then ( cd $SRC || exit
|
|
|
|
srcfile=${packagename}-src.tar.bz2
|
|
|
|
echo "Retrieving source from $srcurl .."
|
|
|
|
urlget $srcurl >$srcfile || exit
|
|
|
|
echo "Source retrieved in $SRC/$srcfile."
|
2006-04-04 16:52:22 +02:00
|
|
|
$BUNZIP2 -dc $srcfile | tar xf - >/dev/null || exit
|
2006-03-26 17:48:55 +02:00
|
|
|
echo "Source unpacked in $SRC."
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
cdrom*)
|
2006-03-26 18:46:37 +02:00
|
|
|
if [ -f $CDPACK/$file ]
|
|
|
|
then echo "Installing from $CDPACK/$file .."
|
2007-03-12 17:55:02 +01:00
|
|
|
packit $CDPACK/$file && echo Installed ok.
|
2006-03-26 18:46:37 +02:00
|
|
|
else echo "$CDPACK/$file not found."
|
2006-03-26 17:48:55 +02:00
|
|
|
fi
|
2006-03-26 18:46:37 +02:00
|
|
|
srcfile=$CDSRC/${packagename}-src.tar.bz2
|
2007-03-12 17:55:02 +01:00
|
|
|
if [ -f $srcfile -a $getsources = y ]
|
|
|
|
then
|
|
|
|
( cd $SRC || exit
|
2006-04-04 16:52:22 +02:00
|
|
|
$BUNZIP2 -dc $srcfile | tar xf - || exit
|
2006-03-26 18:46:37 +02:00
|
|
|
echo "Source $srcfile unpacked in $SRC."
|
|
|
|
)
|
2006-03-26 17:48:55 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2007-03-12 17:55:02 +01:00
|
|
|
fi
|
2006-03-26 17:48:55 +02:00
|
|
|
else cont=n
|
|
|
|
fi
|
2007-03-12 17:55:02 +01:00
|
|
|
done # Iterate package range
|
|
|
|
done # Iterate package range list
|
2006-03-26 17:48:55 +02:00
|
|
|
done
|
2006-03-26 18:46:37 +02:00
|
|
|
|
|
|
|
rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|