diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-10-14 21:05:31 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2018-10-15 14:51:18 -0400 |
commit | 0a8afc0fae040ee20650c935094f4ceb34ef8b22 (patch) | |
tree | f6cb0dcd68223f432953f20e0ec8df2f62c4fa12 | |
parent | d9588459d035cc3d890892c8a8b3adbd466797e5 (diff) |
libremakepkg: Add -S flag to use an existing source package
"Ignore space change" might be helpful when viewing this diff.
-rw-r--r-- | po/es/libretools.po | 42 | ||||
-rwxr-xr-x | src/chroot-tools/libremakepkg | 71 | ||||
-rw-r--r-- | test/cases/libremakepkg.bats | 28 |
3 files changed, 100 insertions, 41 deletions
diff --git a/po/es/libretools.po b/po/es/libretools.po index 0a3dbc4..3d1dc27 100644 --- a/po/es/libretools.po +++ b/po/es/libretools.po @@ -165,7 +165,7 @@ msgid "Don't update anything, just compare already downloaded files." msgstr "No actualice nada, simplemente compare archivos ya descargados." #: src/abslibre-tools/libredbdiff:159 src/abslibre-tools/librerelease:134 -#: src/chroot-tools/librechroot:295 src/chroot-tools/libremakepkg:186 +#: src/chroot-tools/librechroot:295 src/chroot-tools/libremakepkg:187 #: src/devtools/find-libdeps:39 src/librefetch/librefetch:92 #: src/pkgbuild-check-nonfree:58 src/pkgbuild-summarize-nonfree:41 #: src/toru/toru-path:51 @@ -954,7 +954,7 @@ msgstr "El comando `%s` requiere al menos un argumento" msgid "This program must be run as root." msgstr "Este programa debe ser ejecutado como root." -#: src/chroot-tools/librechroot:435 src/chroot-tools/libremakepkg:278 +#: src/chroot-tools/librechroot:435 src/chroot-tools/libremakepkg:288 msgid "Waiting for existing lock on chroot copy to be released: [%s]" msgstr "Esperando que el bloqueo existente en la copia de chroot sea " "liberado: [%s]" @@ -1076,48 +1076,64 @@ msgstr "No deshabilita la conexión a internet durante build() y " msgid "Repackage contents of the package without rebuilding" msgstr "Reempaqueta los contenidos del paquete sin recompilar" -#: src/chroot-tools/libremakepkg:192 +#: src/chroot-tools/libremakepkg:186 +msgid "SRCPKGFILE" +msgstr "" + +#: src/chroot-tools/libremakepkg:186 +msgid "Use an existing --allsource source-package" +msgstr "" + +#: src/chroot-tools/libremakepkg:193 msgid "The -%s flag does not make sense inside of a chroot" msgstr "La opción -%s no tiene sentido dentro de un chroot" -#: src/chroot-tools/libremakepkg:220 +#: src/chroot-tools/libremakepkg:223 msgid "Extra arguments: %s" msgstr "Argumentos extras: %s" -#: src/chroot-tools/libremakepkg:252 +#: src/chroot-tools/libremakepkg:255 msgid "This program must be run as root" msgstr "Este programa debe ejecutarse como root" -#: src/chroot-tools/libremakepkg:258 +#: src/chroot-tools/libremakepkg:261 +msgid "Source package does not exist: %s" +msgstr "" + +#: src/chroot-tools/libremakepkg:267 msgid "PKGBUILD does not exist." msgstr "El PKGBUILD no existe." -#: src/chroot-tools/libremakepkg:269 +#: src/chroot-tools/libremakepkg:279 msgid "Waiting for existing lock on build directory to be released" msgstr "Esperando a que se libere el bloqueo existente en el directorio de " "compilación" -#: src/chroot-tools/libremakepkg:280 +#: src/chroot-tools/libremakepkg:290 msgid "Initializing the chroot..." msgstr "Iniciando el chroot..." -#: src/chroot-tools/libremakepkg:290 +#: src/chroot-tools/libremakepkg:300 msgid "Starting pre-build activities..." msgstr "Iniciando actividades previas a la compilación..." -#: src/chroot-tools/libremakepkg:293 +#: src/chroot-tools/libremakepkg:304 +msgid "Using existing source package %s" +msgstr "" + +#: src/chroot-tools/libremakepkg:307 msgid "Downloading sources..." msgstr "Descargando las fuentes..." -#: src/chroot-tools/libremakepkg:301 +#: src/chroot-tools/libremakepkg:315 msgid "Something went funny with makepkg --allsource" msgstr "" -#: src/chroot-tools/libremakepkg:320 +#: src/chroot-tools/libremakepkg:335 msgid "Starting to build the package..." msgstr "Comenzando a compilar el paquete..." -#: src/chroot-tools/libremakepkg:325 +#: src/chroot-tools/libremakepkg:340 msgid "Starting post-build activities..." msgstr "Iniciando actividades posteriores a la compilación..." 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...' diff --git a/test/cases/libremakepkg.bats b/test/cases/libremakepkg.bats index 9ddfd2e..2184de2 100644 --- a/test/cases/libremakepkg.bats +++ b/test/cases/libremakepkg.bats @@ -241,3 +241,31 @@ teardown() { popd diff -u fixtures/libremakepkg/PKGBUILD-pkgver "$tmpdir/PKGBUILD" } + +@test "libremakepkg can re-use source-packages" { + require network sudo || skip + + cp fixtures/libremakepkg/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + # I'm tempted to use file checksums here, but that would break + # when we gain support for reproducible builds. So just use + # timestamps. + + testsudo libremakepkg -l "$BATS_TEST_NAME" + globfile libretools-hello-1.0-1-any.src.tar.?z + globfile libretools-hello-1.0-1-any.pkg.tar.?z + a_stime=$(stat -c %Y -- libretools-hello-1.0-1-any.src.tar.?z) + a_ptime=$(stat -c %Y -- libretools-hello-1.0-1-any.pkg.tar.?z) + + testsudo libremakepkg -l "$BATS_TEST_NAME" -S libretools-hello-1.0-1-any.src.tar.?z + globfile libretools-hello-1.0-1-any.src.tar.?z + globfile libretools-hello-1.0-1-any.pkg.tar.?z + b_stime=$(stat -c %Y -- libretools-hello-1.0-1-any.src.tar.?z) + b_ptime=$(stat -c %Y -- libretools-hello-1.0-1-any.pkg.tar.?z) + + (( a_stime == b_stime )) + (( a_ptime < b_ptime )) + (( a_ptime > a_stime )) + (( b_ptime > a_stime )) +} |