#!/bin/sh # This script gets and installs a package from the Website. # It is called by easypack 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 setglobal SOURCE_DIR = '/usr/local/src' # where the source is deposited setglobal OVERWRITE = '0' # can an installed package be overwritten? setglobal SOFTWARE_DIR = '"http://www.minix3.org/software'" # Check for at least one parameter match $Argc { with 0 echo Usage: $0 package ... exit } # Change to source directory setglobal ORIG_DIR = $[pwd] rm -f Log # remove old debugging log mkdir $SOURCE_DIR || true cd $SOURCE_DIR || exit if test $[id -u] -ne 0 { # Check for write permission here if test ! -w . { echo You do not have write permission for $SOURCE_DIR exit 1 } } # Check for -o flag; if found, set OVERWRITE if test $1 = "-o" { setglobal OVERWRITE = '1' shift }for i in @ARGV { # Check to see if it exists. Don't overwrite unless -o given echo " " ; echo Start fetching package $i echo " " >>$ORIG_DIR/Log echo ------------- Start fetching $i ------------------ >>$ORIG_DIR/Log if test -r $i { # Directory already exists. May it be overwritten? if test $OVERWRITE = 0 { echo $i already exists. Skipping this package continue } else { # Remove the directory rm -rf $i echo Existing directory $i removed } } # Remove any junk from previous attempts rm -f $i.tar.bz2 $i.tar # Get the package setglobal URL = "$SOFTWARE_DIR/$i.tar.bz2" setglobal TARBZ = "$i.tar.bz2" if urlget $URL >$TARBZ 2>/dev/null { : } else { echo Cannot get $i. echo " " Tried $URL echo " " Skipping this package rm -f $TARBZ continue } # We got it. Unpack it. echo Package $i fetched bunzip2 $TARBZ || smallbunzip2 $TARBZ pax -r <$i.tar if test ! -d $i { echo Unable to unpack $i continue } else { echo Package $i unpacked } # It is now unpacked. Build it cd $i binsizes big if test -f build.minix { sh build.minix >>$ORIG_DIR/Log 2>&1 setglobal r = $Status } else { sh build >>$ORIG_DIR/Log 2>&1 setglobal r = $Status } if test $r -eq 0 { echo Package $i installed } else { echo Package $i failed to install, see Log } if test -f .postinstall { echo Running postinstall script. sh -e .postinstall } binsizes normal # Clean up cd .. rm -f $i.tar $TARBZ # Remove whatever is still lying around }