From 08fc49c449581066018bd758de523d2ec17631f6 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 8 Aug 2015 07:47:25 -0400 Subject: Add upkg script (wrapper for upgradepkg) --- upkg | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 upkg (limited to 'upkg') diff --git a/upkg b/upkg new file mode 100755 index 0000000..c0c6b4d --- /dev/null +++ b/upkg @@ -0,0 +1,66 @@ +#!/bin/bash + +OUTPUT=${OUTPUT:-/tmp} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +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 [ -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 + + source ./$pkgname.info + if [ -z "$PRGNAM" -o -z "$VERSION" ]; then + echo "bad/incomplete .info file, bailing" 1>&2 + exit 1 + fi + + if [ "$PRGNAM" != "$pkgname" ]; then + echo "bad PRGNAM=$PRGNAM in $pkgname.info" + exit 1 + fi + + for myarch in noarch "$ARCH"; do + myglob="$OUTPUT/$PRGNAM-$VERSION-$myarch*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 + else + if [ -n "$found" ]; then + echo "Multiple packages/arches, not installing anything:" + echo $myfile $found + exit 1 + else + found=$myfile + echo found $found + fi + 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 + + set "$found" +fi + +sudo upgradepkg --reinstall --install-new "$@" -- cgit v1.2.3