Slightly more flexible packman.
This commit is contained in:
parent
9843d7a625
commit
5c4a1e5c95
1 changed files with 75 additions and 102 deletions
|
@ -36,6 +36,12 @@ fi
|
||||||
|
|
||||||
cd /
|
cd /
|
||||||
|
|
||||||
|
# Make sure there is a $SRC dir
|
||||||
|
if [ ! -d "$SRC" ]
|
||||||
|
then mkdir $SRC || exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Is there a usable CD to install packages from?
|
||||||
cdpackages=""
|
cdpackages=""
|
||||||
if [ -n "$cddrive" ]
|
if [ -n "$cddrive" ]
|
||||||
then pack=${cddrive}p2
|
then pack=${cddrive}p2
|
||||||
|
@ -52,83 +58,11 @@ then pack=${cddrive}p2
|
||||||
else echo "Don't know where the install CD is. You can set it in $RC."
|
else echo "Don't know where the install CD is. You can set it in $RC."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For local testing
|
|
||||||
#cdpackages=/usr/bigports/Packages/List
|
|
||||||
#CDPACK=/usr/bigports/Packages
|
|
||||||
#CDSRC=/usr/bigports/Sources
|
|
||||||
|
|
||||||
if [ ! -d "$SRC" ]
|
|
||||||
then mkdir $SRC || exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$cdpackages" = "" ]
|
|
||||||
then echo "Skipping CD packages."
|
|
||||||
else cont=y
|
|
||||||
while [ $cont = y ]
|
|
||||||
do n="`wc -l $cdpackages | awk '{ print $1 }'`"
|
|
||||||
sourcef=$CDSRC/SizeMB
|
|
||||||
binf=$CDPACK/SizeMB
|
|
||||||
if [ -f $binf -a -f $sourcef ]
|
|
||||||
then sourcemb="`cat $sourcef`"
|
|
||||||
binmb="`cat $binf`"
|
|
||||||
sourcesize=" (`expr $binmb + $sourcemb` MB uncompressed)"
|
|
||||||
else sourcesize=""
|
|
||||||
fi
|
|
||||||
if [ -f $binf ]
|
|
||||||
then binmb="`cat $binf`"
|
|
||||||
binsize=" ($binmb MB uncompressed)"
|
|
||||||
else binsize=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "There are $n CD packages."
|
|
||||||
echo "Please choose:"
|
|
||||||
echo " 1 Install all $n binary packages$binsize from CD"
|
|
||||||
echo " 2 Install all $n binary packages + sources from CD$sourcesize"
|
|
||||||
echo " 3 Display the list of packages on CD"
|
|
||||||
echo " 4 Let me select individual packages to install from CD or network."
|
|
||||||
echo " 5 Exit."
|
|
||||||
echo -n "Choice: [4] "
|
|
||||||
read in
|
|
||||||
case "$in" in
|
|
||||||
1|2)
|
|
||||||
cd $CDPACK || exit
|
|
||||||
echo " * Installing binaries .."
|
|
||||||
for f in *.tar.bz2
|
|
||||||
do echo "Installing $f binaries .."
|
|
||||||
packit $f && echo Installed $f
|
|
||||||
done
|
|
||||||
if [ "$in" = 2 ]
|
|
||||||
then
|
|
||||||
cd $SRC || exit
|
|
||||||
echo " * Installing sources in $SRC .."
|
|
||||||
for f in $CDSRC/*.tar.bz2
|
|
||||||
do echo "$f .."
|
|
||||||
$BUNZIP2 -dc $f | tar xf -
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
3)
|
|
||||||
( echo "Displaying list; press q to leave it, space for more."
|
|
||||||
cat "$CDPACK/List" | awk -F'|' '{ printf "%-20s %s\n", $1, $2 }'
|
|
||||||
) | more
|
|
||||||
;;
|
|
||||||
""|4)
|
|
||||||
echo "Ok, showing packages to install." ; echo
|
|
||||||
cont=n
|
|
||||||
;;
|
|
||||||
5)
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
echo -n "Press RETURN to continue .. "
|
|
||||||
read xyzzy
|
|
||||||
fi
|
|
||||||
|
|
||||||
TMPF=$TMPDIR/.list.$$
|
TMPF=$TMPDIR/.list.$$
|
||||||
rm -f $TMPF
|
rm -f $TMPF
|
||||||
rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|
rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|
||||||
|
|
||||||
|
# Check for network packages too
|
||||||
netpackages=""
|
netpackages=""
|
||||||
if ( : </dev/tcp ) 2>/dev/null
|
if ( : </dev/tcp ) 2>/dev/null
|
||||||
then echo -n "Update package list from network? (Y/n) "
|
then echo -n "Update package list from network? (Y/n) "
|
||||||
|
@ -144,14 +78,27 @@ then echo -n "Update package list from network? (Y/n) "
|
||||||
else echo "No working network detected."
|
else echo "No working network detected."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$netpackages" = "" ]
|
# Is there at least one package type?
|
||||||
then echo "Skipping network packages."
|
if [ ! -n "$netpackages" -a ! -n "$cdpackages" ]
|
||||||
if [ "$cdpackages" = "" ]
|
then echo "No packages found."
|
||||||
then echo "No packages found."
|
|
||||||
exit 1
|
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
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$netpackages" ]
|
||||||
|
then source=net
|
||||||
|
else source=cdrom
|
||||||
|
fi
|
||||||
|
|
||||||
cont=y
|
cont=y
|
||||||
while [ "$cont" = y ]
|
while [ "$cont" = y ]
|
||||||
do cd $TMPDIR
|
do cd $TMPDIR
|
||||||
|
@ -161,35 +108,63 @@ do cd $TMPDIR
|
||||||
echo -n "Press RETURN to continue.."
|
echo -n "Press RETURN to continue.."
|
||||||
read xyzzy
|
read xyzzy
|
||||||
echo "Package list:"
|
echo "Package list:"
|
||||||
( echo "No.|Source|Package|Description"
|
( echo "No.|Package|Description"
|
||||||
(
|
(
|
||||||
if [ -f "$netpackages" ]
|
if [ -f "$netpackages" ]
|
||||||
then sed <$netpackages 's/^/net\|/'
|
then cat $netpackages
|
||||||
fi
|
fi
|
||||||
if [ -f "$cdpackages" ]
|
if [ -f "$cdpackages" ]
|
||||||
then sed <$cdpackages 's/^/cdrom\|/'
|
then cat $cdpackages
|
||||||
fi
|
fi
|
||||||
) | sort -t'|' +1 | awk '{ n++; printf "%d|%s\n", n, $0 }'
|
) | sort -t'|' +1 | awk '{ n++; printf "%d|%s\n", n, $0 }'
|
||||||
) >$TMPF
|
) >$TMPF
|
||||||
awk -F'|' <$TMPF '{ printf "%3s %-6s %-15s %s\n", $1, $2, $3, $4 }' | more
|
highest="`wc -l $TMPF | awk '{ print $1 }'`"
|
||||||
echo -n "Package to install? [RETURN for none] "
|
awk -F'|' <$TMPF '{ printf "%3s %-15s %s\n", $1, $2, $3 }' | more
|
||||||
read packno
|
echo "Format examples: '3', '3,6', '3-9', '3-9,11-15', 'all'"
|
||||||
|
echo -n "Package(s) to install? "
|
||||||
|
read packnolist
|
||||||
|
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
|
||||||
ok=y
|
ok=y
|
||||||
pat="^$packno|"
|
pat="^$packno|"
|
||||||
if [ "`grep $pat $TMPF | wc -l | awk '{ print $1 }'`" -ne 1 ]
|
if [ "`grep -c $pat $TMPF`" -ne 1 ]
|
||||||
then if [ "$packno" ]
|
then if [ "$packno" ]
|
||||||
then echo "Wrong package number."
|
then echo "$packno: Wrong package number."
|
||||||
fi
|
fi
|
||||||
ok=n
|
ok=n
|
||||||
fi
|
fi
|
||||||
if [ $ok = y ]
|
if [ $ok = y ]
|
||||||
then source="`grep $pat $TMPF | awk -F'|' '{ print $2 }'`"
|
then
|
||||||
packagename="`grep $pat $TMPF | awk -F'|' '{ print $3 }'`"
|
packagename="`grep $pat $TMPF | awk -F'|' '{ print $2 }'`"
|
||||||
file=$packagename.tar.bz2
|
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
|
||||||
case $source in
|
case $source in
|
||||||
net*) echo -n "Get source of $packagename? (y/N) "
|
net*) echo "Retrieving $packno ($packagename) from primary location into $TMPDIR .."
|
||||||
read src
|
|
||||||
echo "Retrieving binary from primary location into $TMPDIR .."
|
|
||||||
srcurl=""
|
srcurl=""
|
||||||
if urlget $URL1/$file >$file
|
if urlget $URL1/$file >$file
|
||||||
then echo "Retrieved ok. Installing .."
|
then echo "Retrieved ok. Installing .."
|
||||||
|
@ -197,7 +172,7 @@ do cd $TMPDIR
|
||||||
srcurl=$SRCURL1/$file
|
srcurl=$SRCURL1/$file
|
||||||
else echo "Retrieval failed."
|
else echo "Retrieval failed."
|
||||||
fi
|
fi
|
||||||
if [ "$src" = y -o "$src" = Y ]
|
if [ "$getsources" = y -o "$getsources" = Y ]
|
||||||
then ( cd $SRC || exit
|
then ( cd $SRC || exit
|
||||||
srcfile=${packagename}-src.tar.bz2
|
srcfile=${packagename}-src.tar.bz2
|
||||||
echo "Retrieving source from $srcurl .."
|
echo "Retrieving source from $srcurl .."
|
||||||
|
@ -211,26 +186,24 @@ do cd $TMPDIR
|
||||||
cdrom*)
|
cdrom*)
|
||||||
if [ -f $CDPACK/$file ]
|
if [ -f $CDPACK/$file ]
|
||||||
then echo "Installing from $CDPACK/$file .."
|
then echo "Installing from $CDPACK/$file .."
|
||||||
packit $CDPACK/$file
|
packit $CDPACK/$file && echo Installed ok.
|
||||||
else echo "$CDPACK/$file not found."
|
else echo "$CDPACK/$file not found."
|
||||||
fi
|
fi
|
||||||
srcfile=$CDSRC/${packagename}-src.tar.bz2
|
srcfile=$CDSRC/${packagename}-src.tar.bz2
|
||||||
if [ -f $srcfile ]
|
if [ -f $srcfile -a $getsources = y ]
|
||||||
then
|
then
|
||||||
echo -n "Get source of $packagename? (y/N) "
|
( cd $SRC || exit
|
||||||
read src
|
|
||||||
if [ "$src" = y -o "$src" = Y ]
|
|
||||||
then ( cd $SRC || exit
|
|
||||||
$BUNZIP2 -dc $srcfile | tar xf - || exit
|
$BUNZIP2 -dc $srcfile | tar xf - || exit
|
||||||
echo "Source $srcfile unpacked in $SRC."
|
echo "Source $srcfile unpacked in $SRC."
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
else echo "No source on CD for $packagename."
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
else cont=n
|
else cont=n
|
||||||
fi
|
fi
|
||||||
|
done # Iterate package range
|
||||||
|
done # Iterate package range list
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|
rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|
||||||
|
|
Loading…
Reference in a new issue