aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2015-08-08 07:47:25 -0400
committerB. Watson <yalhcru@gmail.com>2015-08-08 07:47:25 -0400
commit08fc49c449581066018bd758de523d2ec17631f6 (patch)
treea702c94d923866bd7ca62c8fcc056da2a382dfe9
parent09e8113d7c05157cd54e16f820f6c7ce471d53b7 (diff)
downloadsbostuff-08fc49c449581066018bd758de523d2ec17631f6.tar.gz
Add upkg script (wrapper for upgradepkg)
-rwxr-xr-xupkg66
1 files changed, 66 insertions, 0 deletions
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 "$@"