From 24073402dd3d4324f117f12abc3c921cc3dc3750 Mon Sep 17 00:00:00 2001
From: Luke Shumaker <LukeShu@sbcglobal.net>
Date: Sun, 2 Jun 2013 00:23:36 -0600
Subject: fix up mipsrelease/fullpkg-build/HOOKLOCALRELEASE

HOOKLOCALRELEASE:
 - set to librestage by default, because the mips value is mipsrelease,
   which calls librestage
 - document what arguments it is given.

fullpkg-build:
 - Run HOOKLOCALRELEASE in a way that is consistent with treepkg does and
   what mipsrelease takes.  Note that what fullpkg-build did is what
   mipsrelease documentation said, but not what it actually did.
 - Don't run librestage; if we want it to run, run it with HOOKLOCALRELEASE

mipsrelease: Telling diff to ignore whitespace helps with this one.
 - use get_full_version from common.sh/libremessages
 - give a code path to display usage()
 - correct usage()
 - fix a little quoting
 - make sure makepkg.conf variables are set
---
 src/fullpkg/fullpkg-build      |  4 +--
 src/libretools.conf            |  4 +--
 src/mips64el-tools/mipsrelease | 72 ++++++++++++++++++++----------------------
 3 files changed, 37 insertions(+), 43 deletions(-)

(limited to 'src')

diff --git a/src/fullpkg/fullpkg-build b/src/fullpkg/fullpkg-build
index e52bff1..cbaea91 100755
--- a/src/fullpkg/fullpkg-build
+++ b/src/fullpkg/fullpkg-build
@@ -67,11 +67,9 @@ succesfull_build() {
     if source .INFO && [ -n "$repo" ]; then
 
         if [ ! -z "$HOOKLOCALRELEASE" ]; then
-            find -name "*.pkg.tar.?z" -print0 | xargs -0 "$HOOKLOCALRELEASE" "$repo"
+            "$HOOKLOCALRELEASE" "$repo"
         fi
 
-        librestage $repo || echo "unstaged:$(basename $PWD)" >>$build_dir/log
-
         msg "Updating pacman db and packages"
         sudo pacman -Sy || true
 
diff --git a/src/libretools.conf b/src/libretools.conf
index 2c7ccdd..78e6fb8 100644
--- a/src/libretools.conf
+++ b/src/libretools.conf
@@ -70,8 +70,8 @@ FULLBUILDCMD="sudo libremakepkg"
 #FULLBUILDCMD="makepkg -sL --noconfirm"
 
 # Locally release the package or any other action after running FULLBUILDCMD
-# succesfully.
-HOOKLOCALRELEASE=":"
+# succesfully.  When run, it is given a repository name as a single argument.
+HOOKLOCALRELEASE="librestage"
 #HOOKLOCALRELEASE="mipsrelease"
 
 ################################################################################
diff --git a/src/mips64el-tools/mipsrelease b/src/mips64el-tools/mipsrelease
index 393ca08..30ebb46 100755
--- a/src/mips64el-tools/mipsrelease
+++ b/src/mips64el-tools/mipsrelease
@@ -10,57 +10,53 @@
 . libremessages
 . $(librelib conf.sh)
 load_files makepkg
+check_vars makepkg CARCH PKGDEST PKGEXT || exit 1
 load_files libretools
 check_vars libretools WORKDIR || exit 1
 
 usage() {
-    echo "$0 repo package1 [ package2 ... packageN ]"
-    echo
-    echo " release packages locally on ${PKGDEST}/stage3."
-    echo " and make a clean ABS sync "
+	echo "$0 repo"
+	echo
+	echo " release packages locally on \${PKGDEST}/stage3."
+	echo " and make a clean ABS sync "
 }
 
-##
-#  usage : get_full_version( $epoch, $pkgver, $pkgrel )
-# return : full version spec, including epoch (if necessary), pkgver, pkgrel
-##
-get_full_version() {
-    if [[ $1 -eq 0 ]]; then
-        # zero epoch case, don't include it in version
-        echo $2-$3
-    else
-        echo $1:$2-$3
-    fi
-}
+main() {
+	if [[ $# != 1 ]]; then
+		usage
+		exit 1
+	fi
 
-repo=$1; shift
+	repo=$1
 
-if [ -z "${repo}" ]; then
-    error "Empty repo"
-    exit 1
-fi
+	if [ -z "${repo}" ]; then
+		error "Empty repo"
+		exit 1
+	fi
 
-# Get all needed sources
-source PKGBUILD
-fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})
-pkgs=()
-makepkg --source -f --skippgpcheck
+	# Get all needed sources
+	source PKGBUILD
+	fullver=$(get_full_version)
+	pkgs=()
+	makepkg --source -f --skippgpcheck
 
-msg "Adding packages to [stage3]..."
-for name in ${pkgname[@]}; do
-    msg2 "${name} ${fullver}"
-    pkgs+=("${PKGDEST}/${name}-${fullver}-*.pkg.tar.*")
-done
+	msg "Adding packages to [stage3]..."
+	for name in "${pkgname[@]}"; do
+		msg2 "${name} ${fullver}"
+		pkgs+=(${PKGDEST}/${name}-${fullver}-*.pkg.tar.*)
+	done
 
-repo-add ${PKGDEST}/stage3.db.tar.gz ${pkgs[@]}
+	repo-add ${PKGDEST}/stage3.db.tar.gz "${pkgs[@]}"
 
-librestage ${repo}
+	librestage ${repo}
 
+	mkdir -p ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null
 
-mkdir -p ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null
+	pushd ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null
+	tar xvf $SRCPKGDEST/${pkgbase:-${pkgname[0]}}-${fullver}${SRCEXT}
+	popd >/dev/null
 
-pushd ${WORKDIR}/abs/${CARCH}/${repo} >/dev/null
-  tar xvf $SRCPKGDEST/${pkgbase:-${pkgname[0]}}-${fullver}${SRCEXT}
-popd >/dev/null
+	exit $?
+}
 
-exit $?
+main "$@"
-- 
cgit v1.2.3-2-g168b