#!/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 # Changes: remove: install a package from the Website #(Roman V. Ignatov, ignatov@minix3.ru) # 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? # Check for at least one parameter case $# in 0) echo Usage: $0 package ... exit ;; esac # Change to source directory ORIG_DIR=`pwd` rm -rf Log # remove old debugging log cd $SOURCE_DIR # Check for write permission here if test ! -w . then echo You do not have write permission for $SOURCE_DIR exit 1 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 echo " " ; echo Start fetching package $i 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 # We got it. Unpack it. echo Package $i fetched bunzip2 $i.tar.bz2 || smallbunzip2 $i.tar.bz2 tar xf $i.tar if test ! -d $i then echo Unable to unpack $i continue else echo Package $i unpacked fi # It is now unpacked. Build it cd $i if sh build >>$ORIG_DIR/Log 2>&1 then echo Package $i installed else echo Package $i failed to install, see Log fi # Clean up cd .. # rm -rf $i.tar* done