diff options
author | B. Watson <urchlay@slackware.uk> | 2023-10-31 04:10:48 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2023-10-31 04:10:48 -0400 |
commit | 380ac487a921d23bb7439219bc4e8f6d7d68bd41 (patch) | |
tree | 661f324ce1aff5095ea233f3cbee75294143f9ae /upkg | |
parent | 6bd351bcabe2f43b479978daf7f29bde6d5a53cd (diff) | |
download | sbostuff-380ac487a921d23bb7439219bc4e8f6d7d68bd41.tar.gz |
sbrun: better support for PRINT_PACKAGE_NAME.
Diffstat (limited to 'upkg')
-rwxr-xr-x | upkg | 78 |
1 files changed, 46 insertions, 32 deletions
@@ -35,53 +35,67 @@ if [ -z "$ARCH" ]; then fi case "$ARCH" in - i?86) ARCH="i686 i586 i486 i386" ;; - *) ;; + i?86) ARCHES="i686 i586 i486 i386" ;; + *) ARCHES="$ARCH" ;; esac -# if no package name, see if we're in a SlackBuild 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 no package name, see if we're in a SlackBuild dir. if so, +# install the package for the current dir, if one exists in $OUTPUT. +# If PRINT_PACKAGE_NAME is found in the script, use it to get +# the package filename. Otherwise, read .info file for version number +# and extract BUILD from the SlackBuild. if [ -z "$@" ]; then - infofile=$( echo *.info ) + script="$( echo *.SlackBuild)" + [ "$script" = '*.SlackBuild' ] && die "no .SlackBuild file in current dir" + script1=$( echo *.SlackBuild | cut -d' ' -f1 ) + [ "$script" != "$script1" ] && die "multiple .SlackBuild files found in current dir" + if grep -q PRINT_PACKAGE_NAME $script; then + pkgfile="$( PRINT_PACKAGE_NAME=1 sh $script )" + if [ -e "$OUTPUT/$pkgfile" ]; then + found="$OUTPUT/$pkgfile" + else + die "No $pkgfile found in $OUTPUT, build one!" + fi + else + infofile=$( echo *.info ) - [ "$infofile" = '*.info' ] && die "no .info file in current dir" + [ "$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" + 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" + pkgname=$(basename $infofile .info) + [ ! -e "$pkgname.SlackBuild" ] && die "$pkgname.SlackBuild not found in current dir" - source ./$pkgname.info - [ -z "$PRGNAM" -o -z "$VERSION" ] && die "bad/incomplete .info file, bailing" + source ./$pkgname.info + [ -z "$PRGNAM" -o -z "$VERSION" ] && die "bad/incomplete .info file, bailing" - [ "$PRGNAM" != "$pkgname" ] && die "bad PRGNAM=$PRGNAM in $pkgname.info" + [ "$PRGNAM" != "$pkgname" ] && die "bad PRGNAM=$PRGNAM in $pkgname.info" - buildline=$(grep "^ *BUILD=" $pkgname.SlackBuild) - [ -z "$buildline" ] && die "missing BUILD= in $pkgname.SlackBuild" + buildline=$(grep "^ *BUILD=" $pkgname.SlackBuild) + [ -z "$buildline" ] && die "missing BUILD= in $pkgname.SlackBuild" - eval $buildline + eval $buildline - for myarch in noarch $ARCH; do - myglob="$OUTPUT/$PRGNAM-$VERSION-$myarch-$BUILD*.t?z" - myfile=$( echo $myglob ) + for myarch in noarch $ARCHES; do + 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 - die "Multiple packages match, not installing anything: $( /bin/ls $myfile )" - else - if [ -n "$found" ]; then - die "Multiple packages/arches, not installing anything: $myfile $found" + if [ "$myglob" = "$myfile" ]; then + : # do naught + elif [ "$( /bin/ls $myfile 2>/dev/null | wc -l )" -gt "1" ]; then + die "Multiple packages match, not installing anything: $( /bin/ls $myfile )" else - found=$myfile - echo found $found + if [ -n "$found" ]; then + die "Multiple packages/arches, not installing anything: $myfile $found" + else + found=$myfile + echo found $found + fi fi - fi - done + done + fi [ -z "$found" ] && die "No $PRGNAM-$VERSION-(noarch|$ARCH)-$BUILD*.t?z package in $OUTPUT, build one!" |