diff options
Diffstat (limited to 'upkg')
-rwxr-xr-x | upkg | 59 |
1 files changed, 30 insertions, 29 deletions
@@ -1,5 +1,10 @@ #!/bin/bash +die() { + echo "$( basename $0 ): $@" 1>&2 + exit 1 +} + OUTPUT=${OUTPUT:-/tmp} if [ -z "$ARCH" ]; then @@ -11,41 +16,42 @@ if [ -z "$ARCH" ]; then fi # if no package name, see if we're in a SlackBuild dir. -# if so, build a package if one doesn't exist in $OUTPUT. -# either way, install the package for the current dir. +# if so, install the package for the current dir, if one +# exists in $OUTPUT. Read .info file for version number and +# extract BUILD from the SlackBuild. + if [ -z "$@" ]; then - pkgname=$(basename `pwd`) - if [ ! -e "$pkgname.info" ]; then - echo "not in a proper SlackBuild dir and no package given, bailing" 1>&2 - exit 1 - fi + infofile=$( echo *.info ) + + [ "$infofile" = '*.info' ] && die "no .info file in current dir" + + infofile1=$( echo *.info | cut -d' ' -f1 ) + [ "$infofile" != "$infofile1" ] && die "multiple .info files found in current dir" + + pkgname=$(basename $infofile .info) + [ ! -e "$pkgname.SlackBuild" ] && die "$pkgname.SlackBuild not found in current dir" source ./$pkgname.info - if [ -z "$PRGNAM" -o -z "$VERSION" ]; then - echo "bad/incomplete .info file, bailing" 1>&2 - exit 1 - fi + [ -z "$PRGNAM" -o -z "$VERSION" ] && die "bad/incomplete .info file, bailing" + + [ "$PRGNAM" != "$pkgname" ] && die "bad PRGNAM=$PRGNAM in $pkgname.info" + + buildline=$(grep "^ *BUILD=" $pkgname.SlackBuild) + [ -z "$buildline" ] && die "missing BUILD= in $pkgname.SlackBuild" - if [ "$PRGNAM" != "$pkgname" ]; then - echo "bad PRGNAM=$PRGNAM in $pkgname.info" - exit 1 - fi + eval $buildline for myarch in noarch "$ARCH"; do - myglob="$OUTPUT/$PRGNAM-$VERSION-$myarch*t?z" + myglob="$OUTPUT/$PRGNAM-$VERSION-$myarch-$BUILD*.t?z" myfile=$( echo $myglob ) if [ "$myglob" = "$myfile" ]; then : # do naught elif [ "$( /bin/ls $myfile 2>/dev/null | wc -l )" -gt "1" ]; then - echo "Multiple packages match, not installing anything:" - /bin/ls $myfile - exit 1 + die "Multiple packages match, not installing anything: $( /bin/ls $myfile )" else if [ -n "$found" ]; then - echo "Multiple packages/arches, not installing anything:" - echo $myfile $found - exit 1 + die "Multiple packages/arches, not installing anything: $myfile $found" else found=$myfile echo found $found @@ -53,14 +59,9 @@ if [ -z "$@" ]; then fi done - if [ -z "$found" ]; then -#echo "No package in $OUTPUT, building" -#sudo ./$pkgname.SlackBuild && exec $0 - echo "No package in $OUTPUT, build one!" - exit 1 - fi + [ -z "$found" ] && die "No $PRGNAM-$VERSION-(noarch|$ARCH)-$BUILD*.t?z package in $OUTPUT, build one!" set "$found" fi -sudo upgradepkg --reinstall --install-new "$@" +echo sudo upgradepkg --reinstall --install-new "$@" |