2005-09-15 16:55:11 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# This script gets and installs a package from the Website.
|
|
|
|
# It is called by getpack package1 ...
|
|
|
|
# A package must be in the form of pack.tar.bz2 and must
|
|
|
|
# include a build script that makes and installs it.
|
|
|
|
# The build script should succeed if installation works, else fail
|
|
|
|
|
|
|
|
# Examples:
|
|
|
|
# easypack awk elle telnet # fetch and install 3 packages
|
|
|
|
# easypack -o awk elle telnet # fetch and replace existing packs
|
|
|
|
|
|
|
|
SOURCE_DIR=/usr/src/commands # where the source is deposited
|
|
|
|
OVERWRITE=0 # can an installed package be overwritten?
|
|
|
|
SOFTWARE_DIR="http://www.minix3.org/software" # Tested and approved S/W
|
|
|
|
BETA_DIR="http://www.minix3.org/beta_software" # Untested software
|
|
|
|
|
|
|
|
|
|
|
|
# Check for at least one parameter
|
|
|
|
case $# in
|
|
|
|
0) echo Usage: $0 package ...
|
|
|
|
exit ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Change to source directory
|
|
|
|
ORIG_DIR=`pwd`
|
2005-12-12 15:07:03 +01:00
|
|
|
rm -f Log # remove old debugging log
|
|
|
|
cd $SOURCE_DIR || exit
|
|
|
|
|
|
|
|
if [ "`id -u`" -ne 0 ]
|
|
|
|
then
|
|
|
|
# Check for write permission here
|
|
|
|
if test ! -w .
|
|
|
|
then echo You do not have write permission for $SOURCE_DIR
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-09-15 16:55:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for -o flag; if found, set OVERWRITE
|
|
|
|
if test $1 = "-o"
|
|
|
|
then OVERWRITE=1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Loop on the packages
|
|
|
|
for i
|
|
|
|
do # Check to see if it exists. Don't overwrite unless -o given
|
2005-11-02 13:05:01 +01:00
|
|
|
echo " " ; echo Start fetching package $i
|
2005-09-15 16:55:11 +02:00
|
|
|
echo " " >>$ORIG_DIR/Log
|
|
|
|
echo ------------- Start fetching $i ------------------ >>$ORIG_DIR/Log
|
|
|
|
if test -r $i
|
|
|
|
then # Directory already exists. May it be overwritten?
|
|
|
|
if test $OVERWRITE = 0
|
|
|
|
then echo $i already exists. Skipping this package
|
|
|
|
continue
|
|
|
|
else # Remove the directory
|
|
|
|
rm -rf $i
|
|
|
|
echo Existing directory $i removed
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove any junk from previous attempts
|
2005-12-12 15:07:03 +01:00
|
|
|
rm -f $i.tar.bz2 $i.tar
|
2005-09-15 16:55:11 +02:00
|
|
|
|
|
|
|
# Get the package
|
|
|
|
URL=$SOFTWARE_DIR/$i.tar.bz2
|
|
|
|
URL1=$URL
|
2005-12-12 15:07:03 +01:00
|
|
|
TARBZ=$i.tar.bz2
|
2006-02-21 17:06:28 +01:00
|
|
|
if urlget $URL >$TARBZ 2>/dev/null
|
2006-02-02 19:12:21 +01:00
|
|
|
then :
|
|
|
|
else # It is not in the directory of tested software. Try beta dir.
|
2005-12-12 15:07:03 +01:00
|
|
|
URL=$BETA_DIR/$TARBZ
|
2006-02-21 17:06:28 +01:00
|
|
|
if urlget $URL >$TARBZ 2>/dev/null
|
2006-02-02 19:12:21 +01:00
|
|
|
then :
|
|
|
|
else
|
|
|
|
echo Cannot get $i.
|
2005-09-15 16:55:11 +02:00
|
|
|
echo " " Tried $URL1
|
|
|
|
echo " " Tried $URL
|
|
|
|
echo " " Skipping this package
|
2005-12-12 15:07:03 +01:00
|
|
|
rm -f $TARBZ
|
2005-09-15 16:55:11 +02:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# We got it. Unpack it.
|
2005-11-02 21:01:37 +01:00
|
|
|
echo Package $i fetched
|
2005-12-12 15:07:03 +01:00
|
|
|
bunzip2 $TARBZ || smallbunzip2 $TARBZ
|
2005-09-15 16:55:11 +02:00
|
|
|
tar xf $i.tar
|
|
|
|
if test ! -d $i
|
|
|
|
then echo Unable to unpack $i
|
|
|
|
continue
|
2005-11-02 13:05:01 +01:00
|
|
|
else echo Package $i unpacked
|
2005-09-15 16:55:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# It is now unpacked. Build it
|
|
|
|
cd $i
|
2006-02-02 18:12:16 +01:00
|
|
|
binsizes big
|
2006-03-22 16:08:36 +01:00
|
|
|
if [ -f build.minix ]
|
|
|
|
then sh build.minix >>$ORIG_DIR/Log 2>&1
|
|
|
|
r=$?
|
|
|
|
else sh build >>$ORIG_DIR/Log 2>&1
|
|
|
|
r=$?
|
|
|
|
fi
|
|
|
|
if [ $r -eq 0 ]
|
2005-11-02 13:05:01 +01:00
|
|
|
then echo Package $i installed
|
2005-11-02 21:01:37 +01:00
|
|
|
else echo Package $i failed to install, see Log
|
2005-09-15 16:55:11 +02:00
|
|
|
fi
|
2006-02-02 18:12:16 +01:00
|
|
|
binsizes normal
|
2005-09-15 16:55:11 +02:00
|
|
|
|
|
|
|
# Clean up
|
|
|
|
cd ..
|
2005-12-12 15:07:03 +01:00
|
|
|
rm -f $i.tar $TARBZ # Remove whatever is still lying around
|
2005-09-15 16:55:11 +02:00
|
|
|
done
|
|
|
|
|