[9] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 | # This script gets and installs a package from the Website.
|
---|
| 4 | # It is called by getpack package1 ...
|
---|
| 5 | # A package must be in the form of pack.tar.bz2 and must
|
---|
| 6 | # include a build script that makes and installs it.
|
---|
| 7 | # The build script should succeed if installation works, else fail
|
---|
| 8 |
|
---|
| 9 | # Examples:
|
---|
| 10 | # easypack awk elle telnet # fetch and install 3 packages
|
---|
| 11 | # easypack -o awk elle telnet # fetch and replace existing packs
|
---|
| 12 |
|
---|
| 13 | SOURCE_DIR=/usr/src/commands # where the source is deposited
|
---|
| 14 | OVERWRITE=0 # can an installed package be overwritten?
|
---|
| 15 | SOFTWARE_DIR="http://www.minix3.org/software" # Tested and approved S/W
|
---|
| 16 | BETA_DIR="http://www.minix3.org/beta_software" # Untested software
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | # Check for at least one parameter
|
---|
| 20 | case $# in
|
---|
| 21 | 0) echo Usage: $0 package ...
|
---|
| 22 | exit ;;
|
---|
| 23 | esac
|
---|
| 24 |
|
---|
| 25 | # Change to source directory
|
---|
| 26 | ORIG_DIR=`pwd`
|
---|
| 27 | rm -f Log # remove old debugging log
|
---|
| 28 | cd $SOURCE_DIR || exit
|
---|
| 29 |
|
---|
| 30 | if [ "`id -u`" -ne 0 ]
|
---|
| 31 | then
|
---|
| 32 | # Check for write permission here
|
---|
| 33 | if test ! -w .
|
---|
| 34 | then echo You do not have write permission for $SOURCE_DIR
|
---|
| 35 | exit 1
|
---|
| 36 | fi
|
---|
| 37 | fi
|
---|
| 38 |
|
---|
| 39 | # Check for -o flag; if found, set OVERWRITE
|
---|
| 40 | if test $1 = "-o"
|
---|
| 41 | then OVERWRITE=1
|
---|
| 42 | shift
|
---|
| 43 | fi
|
---|
| 44 |
|
---|
| 45 | # Loop on the packages
|
---|
| 46 | for i
|
---|
| 47 | do # Check to see if it exists. Don't overwrite unless -o given
|
---|
| 48 | echo " " ; echo Start fetching package $i
|
---|
| 49 | echo " " >>$ORIG_DIR/Log
|
---|
| 50 | echo ------------- Start fetching $i ------------------ >>$ORIG_DIR/Log
|
---|
| 51 | if test -r $i
|
---|
| 52 | then # Directory already exists. May it be overwritten?
|
---|
| 53 | if test $OVERWRITE = 0
|
---|
| 54 | then echo $i already exists. Skipping this package
|
---|
| 55 | continue
|
---|
| 56 | else # Remove the directory
|
---|
| 57 | rm -rf $i
|
---|
| 58 | echo Existing directory $i removed
|
---|
| 59 | fi
|
---|
| 60 | fi
|
---|
| 61 |
|
---|
| 62 | # Remove any junk from previous attempts
|
---|
| 63 | rm -f $i.tar.bz2 $i.tar
|
---|
| 64 |
|
---|
| 65 | # Get the package
|
---|
| 66 | URL=$SOFTWARE_DIR/$i.tar.bz2
|
---|
| 67 | URL1=$URL
|
---|
| 68 | TARBZ=$i.tar.bz2
|
---|
| 69 | if urlget $URL >$TARBZ 2>/dev/null
|
---|
| 70 | then :
|
---|
| 71 | else # It is not in the directory of tested software. Try beta dir.
|
---|
| 72 | URL=$BETA_DIR/$TARBZ
|
---|
| 73 | if urlget $URL >$TARBZ 2>/dev/null
|
---|
| 74 | then :
|
---|
| 75 | else
|
---|
| 76 | echo Cannot get $i.
|
---|
| 77 | echo " " Tried $URL1
|
---|
| 78 | echo " " Tried $URL
|
---|
| 79 | echo " " Skipping this package
|
---|
| 80 | rm -f $TARBZ
|
---|
| 81 | continue
|
---|
| 82 | fi
|
---|
| 83 | fi
|
---|
| 84 |
|
---|
| 85 | # We got it. Unpack it.
|
---|
| 86 | echo Package $i fetched
|
---|
| 87 | bunzip2 $TARBZ || smallbunzip2 $TARBZ
|
---|
| 88 | tar xf $i.tar
|
---|
| 89 | if test ! -d $i
|
---|
| 90 | then echo Unable to unpack $i
|
---|
| 91 | continue
|
---|
| 92 | else echo Package $i unpacked
|
---|
| 93 | fi
|
---|
| 94 |
|
---|
| 95 | # It is now unpacked. Build it
|
---|
| 96 | cd $i
|
---|
| 97 | binsizes big
|
---|
| 98 | if [ -f build.minix ]
|
---|
| 99 | then sh build.minix >>$ORIG_DIR/Log 2>&1
|
---|
| 100 | r=$?
|
---|
| 101 | else sh build >>$ORIG_DIR/Log 2>&1
|
---|
| 102 | r=$?
|
---|
| 103 | fi
|
---|
| 104 | if [ $r -eq 0 ]
|
---|
| 105 | then echo Package $i installed
|
---|
| 106 | else echo Package $i failed to install, see Log
|
---|
| 107 | fi
|
---|
| 108 | if [ -f .postinstall ]
|
---|
| 109 | then echo Running postinstall script.
|
---|
| 110 | sh -e .postinstall
|
---|
| 111 | fi
|
---|
| 112 | binsizes normal
|
---|
| 113 |
|
---|
| 114 | # Clean up
|
---|
| 115 | cd ..
|
---|
| 116 | rm -f $i.tar $TARBZ # Remove whatever is still lying around
|
---|
| 117 | done
|
---|
| 118 |
|
---|