From 0a8afc0fae040ee20650c935094f4ceb34ef8b22 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 14 Oct 2018 21:05:31 -0400 Subject: libremakepkg: Add -S flag to use an existing source package "Ignore space change" might be helpful when viewing this diff. --- src/chroot-tools/libremakepkg | 71 ++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 013b6d0..b427fd0 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -183,6 +183,7 @@ usage() { use is a violation of Parabola policy." \ '-R' 'Repackage contents of the package without rebuilding' \ + "-S <$(_ SRCPKGFILE)>" 'Use an existing --allsource source-package' \ '-h' 'Show this message' } @@ -199,9 +200,10 @@ main() { local makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg) local repack=false local chroot='' + local srcpkg='' # Parse command line options ########################################### - while getopts 'n:l:w:r:NRh' flag ; do + while getopts 'n:l:w:r:NRS:h' flag ; do case "${flag}" in n) if $INCHROOT; then err_chflag "$flag"; else chroot=$OPTARG; fi;; @@ -211,6 +213,7 @@ main() { librechroot_flags+=(-$flag "$OPTARG"); fi;; N) NONET=false;; R) repack=true; makepkg_args+=(-R);; + S) srcpkg=$OPTARG;; h) usage; exit $EXIT_SUCCESS;; *) usage >&2; exit $EXIT_INVALIDARGUMENT;; esac @@ -253,10 +256,17 @@ main() { exit $EXIT_NOPERMISSION fi - if [[ ! -f PKGBUILD ]]; then - # This is the message used by makepkg - error "PKGBUILD does not exist." - exit $EXIT_FAILURE + if [[ -n $srcpkg ]]; then + if [[ ! -f $srcpkg ]]; then + error 'Source package does not exist: %s' "$srcpkg" + exit $EXIT_INVALIDARGUMENT + fi + else + if [[ ! -f PKGBUILD ]]; then + # This is the message used by makepkg + error "PKGBUILD does not exist." + exit $EXIT_FAILURE + fi fi # Make sure that the various *DEST directories exist @@ -290,31 +300,36 @@ main() { msg 'Starting pre-build activities...' run_hook check_pkgbuild - msg 'Downloading sources...' - local srcpkgdest srcpkg - srcpkgdest="$(mktemp -d)" - chown "$LIBREUSER:" "$srcpkgdest" - trap "rm -rf -- ${srcpkgdest@Q}" EXIT - SRCPKGDEST="$srcpkgdest" download_sources "$copydir" "$LIBREUSER" |& indent - srcpkg=("$srcpkgdest"/*) - if (( ${#srcpkg[@]} != 1 )); then - error 'Something went funny with makepkg --allsource' - return $EXIT_FAILURE - fi - # We want to inject "-$pkgarch" in to srcpkg's filename, right before $SRCEXT - local srcext pkgarch srcpkg_filename - srcext="$(MAKEPKG_CONF=$copydir/etc/makepkg.conf get_var makepkg SRCEXT)" - if [[ "$(bsdtar xfO "$srcpkg" --include='*/.SRCINFO' | grep $'\tarch =')" = $'\tarch = any' ]]; then - pkgarch=any + if [[ -n $srcpkg ]]; then + msg 'Using existing source package %s' "$srcpkg" + # TODO: symlink $srcpkg to ${SRCPKGDEST}/${pkgbase}-${evr}-${CARCH}${SRCEXT} else - pkgarch=$CARCH + msg 'Downloading sources...' + local srcpkgdest + srcpkgdest="$(mktemp -d)" + chown "$LIBREUSER:" "$srcpkgdest" + trap "rm -rf -- ${srcpkgdest@Q}" EXIT + SRCPKGDEST="$srcpkgdest" download_sources "$copydir" "$LIBREUSER" |& indent + srcpkg=("$srcpkgdest"/*) + if (( ${#srcpkg[@]} != 1 )); then + error 'Something went funny with makepkg --allsource' + return $EXIT_FAILURE + fi + # We want to inject "-$pkgarch" in to srcpkg's filename, right before $SRCEXT + local srcext pkgarch srcpkg_filename + srcext="$(MAKEPKG_CONF=$copydir/etc/makepkg.conf get_var makepkg SRCEXT)" + if [[ "$(bsdtar xfO "$srcpkg" --include='*/.SRCINFO' | grep $'\tarch =')" = $'\tarch = any' ]]; then + pkgarch=any + else + pkgarch=$CARCH + fi + srcpkg_filename=${srcpkg##*/} + srcpkg_filename=${srcpkg_filename%"${srcext}"}-${pkgarch}${srcext} + mv -T -- "$srcpkg" "$SRCPKGDEST/${srcpkg_filename}" + srcpkg="$SRCPKGDEST/${srcpkg_filename}" + rmdir -- "${srcpkgdest}" + trap EXIT fi - srcpkg_filename=${srcpkg##*/} - srcpkg_filename=${srcpkg_filename%"${srcext}"}-${pkgarch}${srcext} - mv -T -- "$srcpkg" "$SRCPKGDEST/${srcpkg_filename}" - srcpkg="$SRCPKGDEST/${srcpkg_filename}" - rmdir -- "${srcpkgdest}" - trap EXIT # Build msg 'Starting to build the package...' -- cgit v1.2.2