diff options
39 files changed, 562 insertions, 133 deletions
diff --git a/GNUmakefile b/GNUmakefile index 0cdb67d..0bb8100 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,10 +4,22 @@ # Most of the complexity is dancing around to avoid having any # possibly conflicting identifiers. +# The flags that we actually want to pass to Make. +desired_MAKEFLAGS = --no-builtin-rules +desired_MAKEFLAGS += --no-builtin-variables +desired_MAKEFLAGS += --warn-undefined-variables +# Setting GNUMAKEFLAGS is important so that --no-builtin-variables +# with --warn-undefined-variables doesn't cause Make (as of 4.4.1) to +# print spurious warnings about it being undefined for internal use. +desired_MAKEFLAGS += GNUMAKEFLAGS='' + +# Quiet this parent Make a bit. MAKEFLAGS += --no-print-directory + +# Main. rest = $(wordlist 2,$(words $1),$1) target = $(or $(firstword $(MAKECMDGOALS)),default) $(or $(call rest,$(MAKECMDGOALS)),_$(target)): $(target) @: $(target): - @+$(MAKE) -f Makefile --no-builtin-rules --no-builtin-variables --warn-undefined-variables $(MAKECMDGOALS) + @$(MAKE) -f Makefile $(desired_MAKEFLAGS) $(MAKECMDGOALS) diff --git a/INSTALL-VCS b/INSTALL-VCS index be80d41..e0cf2f0 100644 --- a/INSTALL-VCS +++ b/INSTALL-VCS @@ -9,9 +9,9 @@ INSTALL file. If the `$(devtoolsdir)` directory does not exist, but all of the copied files exist in the libretools directory, they will simply be used. -In the distribution tarball includes the copies of the devtools files, -so it is not necessary to download the devtools source separately -when using the tarball. +The distribution tarball includes the copies of the devtools files, so +it is not necessary to download the devtools source separately when +using the tarball. Once you have the devtools source taken care of, you can build and install like normal. diff --git a/po/es/libretools.po b/po/es/libretools.po index 57a8e19..fbd4122 100644 --- a/po/es/libretools.po +++ b/po/es/libretools.po @@ -1072,6 +1072,11 @@ msgstr "No deshabilita la conexión a internet durante build() y " "package(). POR FAVOR no use esta opción al menos que tenga una razón " "en especial, su uso es una violación a la política de Parabola." +#: src/chroot-tools/libremakepkg:194 +msgid "Don't make the startdir read-only. PLEASE don't use this unless you " + "have a special reason, its use is a violation of Parabola policy." +msgstr "" + #: src/chroot-tools/libremakepkg:184 msgid "Repackage contents of the package without rebuilding" msgstr "Reempaqueta los contenidos del paquete sin recompilar" diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff index 28031a2..b5e6331 100755 --- a/src/abslibre-tools/libredbdiff +++ b/src/abslibre-tools/libredbdiff @@ -3,6 +3,7 @@ # # Copyright (C) 2014 Esteban Carnevale <alfplayer@mailoo.org> # Copyright (C) 2014, 2017-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2018 Omar Vega Ramos <ovruni@gnu.org.pe> # # License: GNU GPLv3+ # diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease index 8ebdc54..a887ce4 100755 --- a/src/abslibre-tools/librerelease +++ b/src/abslibre-tools/librerelease @@ -5,7 +5,8 @@ # Copyright (C) 2010-2012 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com> # Copyright (C) 2010-2013 Nicolás Reynolds <fauno@parabola.nu> # Copyright (C) 2013 Michał Masłowski <mtjm@mtjm.eu> -# Copyright (C) 2013-2014, 2017-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2013-2014, 2017-2018, 2024 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2019 Bill Auger <mr.j.spam.me@gmail.com> # # For just the create_signature() function: # Copyright (C) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org> @@ -300,7 +301,7 @@ release_packages() { local packages=${file_list} # TODO: parse package names? - this is gonna be messy local login=${REPODEST_userinfo:-somebody} ; login=${login%%:*} ; ssh ${REPODEST_port:+-p "$REPODEST_port"} "${REPODEST_userhost}" \ - "which pbot-say && pbot-say ${login} just published: ${packages}" + "if type pbot-say &>/dev/null-say; then pbot-say ${login} just published: ${packages}; fi" return $EXIT_SUCCESS } diff --git a/src/abslibre-tools/librestage b/src/abslibre-tools/librestage index c68b61b..7098aac 100755 --- a/src/abslibre-tools/librestage +++ b/src/abslibre-tools/librestage @@ -5,6 +5,7 @@ # Copyright (C) 2010-2012 Nicolás Reynolds <fauno@parabola.nu> # Copyright (C) 2011 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com> # Copyright (C) 2013-2014, 2017-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2020 Andreas Grapentin <andreas@grapentin.org> # # License: GNU GPLv3+ # diff --git a/src/chroot-tools/hooks-distcc.sh b/src/chroot-tools/hooks-distcc.sh index b19c223..414696e 100644 --- a/src/chroot-tools/hooks-distcc.sh +++ b/src/chroot-tools/hooks-distcc.sh @@ -1,5 +1,5 @@ #!/hint/bash -euE -o pipefail -# Copyright (C) 2013, 2017-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2013, 2017-2018, 2024 Luke Shumaker <lukeshu@parabola.nu> # # License: GNU GPLv2+ # @@ -75,9 +75,11 @@ distcc_start_odaemon() { rewritten_DISTCC_HOSTS=$("$_distcc_tool" rewrite "${DISTCC_HOSTS:-}") install -Dm644 /dev/stdin "$home/.config/pacman/makepkg.conf" <<-eot - trap 'jobs -p | xargs -r kill --' EXIT - /bin/distcc-tool idaemon ${DISTCC_HOSTS@Q} </dev/null &>/dev/null & - DISTCC_HOSTS=${rewritten_DISTCC_HOSTS@Q} + if [[ \${INFAKEROOT:-} == 0 ]]; then + trap 'jobs -p | xargs -r kill --' EXIT + /bin/distcc-tool idaemon ${DISTCC_HOSTS@Q} </dev/null &>/dev/null & + DISTCC_HOSTS=${rewritten_DISTCC_HOSTS@Q} + fi eot install -Dm644 /dev/stdin "$home/.ssh/config" <<-'eot' diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 1c76661..e3c390a 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -7,6 +7,7 @@ set -euE # Copyright (C) 2012 Michał Masłowski <mtjm@mtjm.eu> # Copyright (C) 2012-2018 Luke Shumaker <lukeshu@parabola.nu> # Copyright (C) 2018 Andreas Grapentin <andreas@grapentin.org> +# Copyright (C) 2019 Bill Auger <mr.j.spam.me@gmail.com> # # License: GNU GPLv2+ # diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index a526ca2..d3dd160 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -5,7 +5,8 @@ set -euE # Copyright (C) 2010-2012 Nicolás Reynolds <fauno@parabola.nu> # Copyright (C) 2010-2012 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com> # Copyright (C) 2012 Michał Masłowski <mtjm@mtjm.eu> -# Copyright (C) 2012-2015, 2017-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2012-2015, 2017-2018, 2024 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2019, 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> # # License: GNU GPLv2+ # @@ -36,6 +37,7 @@ umask 0022 readonly _indent="$(librelib chroot/indent)" readonly INCHROOT=$([[ -f /.arch-chroot ]] && echo true || echo false) NONET=true # can be changed with the -N flag +ROSTARTDIR=true # can be changed with the -W flag # {PKG,SRC,SRCPKG,LOG}DEST set at runtime by makepkg.conf # MAKEFLAGS, PACKAGER set at runtime by makepkg.conf # LIBREUSER, LIBREHOME are set by conf.sh @@ -124,11 +126,19 @@ build() ( local run_ynet=() local run_nnet=() if $INCHROOT; then - local _run=(sh -c "cd ${startdir@Q} && \$@" --) + if $ROSTARTDIR; then + local _run=(sh -c "mount --bind -o ro -- ${startdir@Q} ${startdir@Q} && cd ${startdir@Q} && \$@" --) + else + local _run=(sh -c "cd ${startdir@Q} && \$@" --) + fi run_ynet=(unshare --mount -- "${_run[@]}") run_nnet=(unshare --mount --net -- "${_run[@]}") else - librechroot_flags+=(-w "$startdir:/startdir") + if $ROSTARTDIR; then + librechroot_flags+=(-r "$startdir:/startdir") + else + librechroot_flags+=(-w "$startdir:/startdir") + fi run_ynet=(librechroot "${librechroot_flags[@]}" run) run_nnet=(librechroot "${librechroot_flags[@]}" -N run) fi @@ -181,6 +191,10 @@ usage() { build(), and package(). PLEASE don't use this unless you have a special reason, its use is a violation of Parabola policy." \ + '-W' "Don't make the startdir read-only. PLEASE + don't use this unless you have a special + reason, its use is a violation of Parabola + policy." \ '-R' 'Repackage contents of the package without rebuilding' \ "-S <$(_ SRCPKGFILE)>" 'Use an existing --allsource source-package' \ @@ -203,7 +217,7 @@ main() { local srcpkg='' # Parse command line options ########################################### - while getopts 'n:l:w:r:NRS:h' flag ; do + while getopts 'n:l:w:r:NWRS:h' flag ; do case "${flag}" in n) if $INCHROOT; then err_chflag "$flag"; else chroot=$OPTARG; fi;; @@ -212,6 +226,7 @@ main() { w|r) if $INCHROOT; then err_chflag "$flag"; else librechroot_flags+=(-$flag "$OPTARG"); fi;; N) NONET=false;; + W) ROSTARTDIR=false;; R) repack=true; makepkg_args+=(-R);; S) srcpkg=$OPTARG;; h) usage; exit $EXIT_SUCCESS;; diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh index 84333e8..d36502e 100755 --- a/src/lib/blacklist.sh +++ b/src/lib/blacklist.sh @@ -99,24 +99,21 @@ blacklist-get-pkg() { # Usage: blacklist-cat | blacklist-get-rep # Prints only the replacement package field of the blacklist line(s) on stdin. blacklist-get-rep() { - local -a targets=($(blacklist-get-pkg)) - expac -Ss '%r/%n %n %P %R' | awk -v arr="${targets[*]}" ' - { - gsub("[=<>]+[^[:blank:]]*", "", $0) # discard versioning - # build pkg -> providers table from pkg -> provides - for (provided = 2; provided <= NF; ++provided) { - if (! seen[$1 " " $provided]++) { - providers[$provided] = providers[$provided] $1 " " - } - } - } - END { - split(arr, targets, " ") - for (pkg in targets) { - sub("[ \t]+$", "", providers[targets[pkg]]) - print providers[targets[pkg]] - } - }' + # TODO(lukeshu): I am confident that this could be done more + # efficiently with Python+pyalpm than with awk+expac. + blacklist-normalize | awk -F: ' + # trust blacklist.txt for packages re-packaged with the same name + # (otherwise there would be a bootstrapping problem). + $2 == $1 { + print $2 + } + # but otherwise, do not trust blacklist.txt to have an accurate + # state of the repos and what replacements exist. + $2 != $1 { + cmd="expac -S '\''%r/%n %P : %R '\'' | sed -E '\''s/[=<>]+\\S*//g'\'' | grep '\'' " $1 " .*:.* " $1 " '\'' | awk '\''{print $1}'\''" + cmd | getline rep + print rep + }' } # Usage: blacklist-cat | blacklist-get-url diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in index c7d3f53..bd9bde3 100644 --- a/src/lib/conf.sh.in +++ b/src/lib/conf.sh.in @@ -2,6 +2,7 @@ # This may be included with or without `set -euE` # Copyright (C) 2012-2015, 2017-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> # # License: GNU GPLv2+ # diff --git a/src/lib/librelib b/src/lib/librelib index b3fb9c2..27649f8 100755 --- a/src/lib/librelib +++ b/src/lib/librelib @@ -1,6 +1,7 @@ #!/usr/bin/env bash # Copyright (C) 2013-2014, 2017-2018 Luke Shumaker <lukeshu@parabola.nu> -# +# Copyright (C) 2020 Andreas Grapentin <andreas@grapentin.org> + # License: GNU GPLv2+ # # This program is free software; you can redistribute it and/or modify diff --git a/src/lib/librelib.1.ronn b/src/lib/librelib.1.ronn index fe64e92..9d1fbc4 100644 --- a/src/lib/librelib.1.ronn +++ b/src/lib/librelib.1.ronn @@ -19,13 +19,13 @@ path: * The install path can change in the future without having to change programs that use them. * The install directory can be configured at runtime, by setting - `LIBRETOOLS_LIBDIR`, similar to `LD_PRELOAD` (this is used when - running the test suite). + `LIBRETOOLS_LIBRARY_PATH`, similar to `LD_PRELOAD` (this is used + when running the test suite). * The naming scheme of a library can change (such as between `libreNAME` and `NAME.sh` without changing programs that use it. By default, `librelib` looks in `/usr/lib/libretools`, but that can be -changed by setting the `LIBRETOOLS_LIBDIR` environmental variable to +changed by setting the `LIBRETOOLS_LIBRARY_PATH` environmental variable to the directory it should look in. When searching for a library, `librelib` first strips `libre` from the diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index c1ff548..9b04837 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -1,7 +1,8 @@ #!/usr/bin/env bash # librefetch # -# Copyright (C) 2013-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2013-2018, 2024 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2020 Bill Auger <mr.j.spam.me@gmail.com> # # For just the create_signature() function: # Copyright (C) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org> @@ -221,6 +222,7 @@ doit() { mv -f "$base_dst" "$dst" fi else + export PKGEXT=${base_dst##*/} # so the file uses the correct compression export PKGDEST=${dst%/*} export pkg_file=$dst @@ -321,23 +323,23 @@ modified_makepkg() { # a string to be appended pkgbuild_append=' +declare _librefetch_i + # do not do split packages -if [[ ${#pkgname[@]} -gt 1 ]]; then - if [[ -n $pkgbase ]]; then - pkgname=("$pkgbase") - else - pkgname=("$pkgname") - fi -fi +declare _librefetch_pkgname="${pkgbase:-$pkgname}" +for _librefetch_i in "${pkgname[@]}"; do + unset -f "package_${_librefetch_i}" +done +unset pkgname +pkgname=$_librefetch_pkgname # copy source variables source=("${mksource[@]}") ; unset "source_${CARCH}" noextract=("${mknoextract[@]}") -declare algo -for algo in "${known_hash_algos[@]}"; do - eval "${algo}sums=(\"\${mk${algo}sums[@]}\")" - unset "${algo}sums_${CARCH}" +for _librefetch_i in "${known_hash_algos[@]}"; do + eval "${_librefetch_i}sums=(\"\${mk${_librefetch_i}sums[@]}\")" + unset "${_librefetch_i}sums_${CARCH}" done depends=() ; unset "depends_${CARCH}" diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index 27dfac0..63dfae9 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -179,7 +179,8 @@ Other changes: The following modifications are made to makepkg: * Allow us to manipulate the output file (<$pkg_file>) - * Do not include metadata in the output file (<${comp_files[@]}>) + * Do not include metadata in the output file (`.PKGINFO`, + `.BUILDINFO`, and `.MTREE`) * Force 'ustar' tar format, don't allow it to upgrade to 'pax' to store extended file attributes. * Don't symlink the resulting file into the current directory. diff --git a/src/librefetch/librefetchdir/Makefile b/src/librefetch/librefetchdir/Makefile index 4391efb..ed7b510 100644 --- a/src/librefetch/librefetchdir/Makefile +++ b/src/librefetch/librefetchdir/Makefile @@ -2,7 +2,7 @@ # note: This file is part of LibreFetch itself, not part of the # build-system. # -# Copyright (C) 2016 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2016, 2024 Luke Shumaker <lukeshu@parabola.nu> # # License: GNU GPLv3+ # @@ -31,7 +31,7 @@ new_makepkg = $(new)/makepkg new_library = $(new)/libmakepkg targets += $(new_makepkg) -targets += $(patsubst $(old_library)/%,$(new_library)/%,$(shell find $(old_library) -type f)) +targets += $(patsubst $(old_library)/%,$(new_library)/%,$(shell find $(old_library) -type f -not -name ext.sh)) targets += $(new_library)/tidy/~source_date_epoch.sh all: $(targets) diff --git a/src/librefetch/librefetchdir/makepkg.gen b/src/librefetch/librefetchdir/makepkg.gen index dfe68f5..31cdfe6 100755 --- a/src/librefetch/librefetchdir/makepkg.gen +++ b/src/librefetch/librefetchdir/makepkg.gen @@ -1,7 +1,7 @@ #!/usr/bin/sed -rf # librefetchdir/makepkg.gen # -# Copyright (C) 2013-2018 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2013-2018, 2024 Luke Shumaker <lukeshu@parabola.nu> # # License: GNU GPLv3+ # @@ -22,12 +22,12 @@ /LIBRARY=/iexport LIBRARY="${0%/*}/libmakepkg" -/list_package_files\(\) \{/,/^\}$/ { - # Don't include dotfiles - s,\(.*; (.* \| LC_ALL=C sort)\),\1, -} - /create_package\(\) \{/,/^\}$/ { + # Don't generate metadata files + /PKGINFO/d + /BUILDINFO/d + /msg2.*MTREE/,/touch.*MTREE/d + # allow us to set pkg_file /pkg_file=/d } diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree index ccc846b..6bec280 100755 --- a/src/pkgbuild-check-nonfree +++ b/src/pkgbuild-check-nonfree @@ -5,7 +5,7 @@ # Copyright (C) 2011 Joseph Graham (Xylon) <joe@t67.eu> # Copyright (C) 2010-2011 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com> # Copyright (C) 2010-2012 Nicolás Reynolds <fauno@parabola.nu> -# Copyright (C) 2012-2013, 2017 Luke Shumaker <lukeshu@parabola.nu> +# Copyright (C) 2012-2013, 2017, 2024 Luke Shumaker <lukeshu@parabola.nu> # # License: GNU GPLv3+ # @@ -57,7 +57,11 @@ usage() { echo flag '-h' 'Show this message' } -# Make sure these match pkgbuild-summarize-nonfree + +# Make sure these match: +# - the usage() text above +# - pkgbuild-summarize-nonfree +# - pkgbuild-check-nonfree.bats declare -ri _E_OK=0 declare -ri _E_ERROR=1 declare -ri _E_LIC_UNKNOWN=2 @@ -217,15 +221,29 @@ check_dep() { # Checks for ${pkgname} in the blacklist check_pkg() { [[ $# == 1 ]] || panic 'malformed call to check_pkg' - check_dep "$@" - case $? in - $_E_OK) - return $_E_OK;; - $_E_DEP_NONFREE) - return $_E_PKG_NONFREE;; - *) - panic 'unexpected return code from check_dep';; - esac + local pkg=$1 + + local line rep + line="$(blacklist-cat|blacklist-lookup "$pkg")" + rep="$(blacklist-get-rep <<<"$line")" + if [[ -z $line ]]; then + # not mentioned in blacklist; free + info '%s: not blacklisted' "$pkg" + return $_E_OK + elif [[ -z $rep ]]; then + # non-free with no replacement + plain '%s: blacklisted' "$pkg" + return $_E_PKG_NONFREE + else + # non-free with free replacement + if [[ "$rep" == "$pkg" ]]; then + info '%s: repackaged with the same name' "$pkg" + return $_E_OK + else + info '%s: replaced by %s (update blacklist.txt first if you would like to repackage it with the same name)' "$pkg" "$rep" + return $_E_PKG_NONFREE + fi + fi panic 'code should never be reached' } diff --git a/test/cases/lib-blacklist.bats b/test/cases/lib-blacklist.bats index 2388b15..ba74d04 100644 --- a/test/cases/lib-blacklist.bats +++ b/test/cases/lib-blacklist.bats @@ -130,3 +130,9 @@ load ../lib/common [[ "$(sed 1q $tmpdir/stdout)" == 'Usage: libreblacklist cat' ]] empty $tmpdir/stderr } + +@test "libreblacklist checks for replacements from the repos" { + libreblacklist get-rep <<<'linux' >$tmpdir/stdout 2>$tmpdir/stderr + [[ "$(cat $tmpdir/stdout)" == 'libre/linux-libre' ]] + empty $tmpdir/stderr +} diff --git a/test/cases/librechroot.bats b/test/cases/librechroot.bats index 7d05ebc..ca61e1e 100644 --- a/test/cases/librechroot.bats +++ b/test/cases/librechroot.bats @@ -49,19 +49,31 @@ load ../lib/common @test "librechroot obeys depends in PKGBUILD" { require network sudo || skip - # Make sure it's not in the base install + # NB: We chown `/startdir` because chcleanup runs `makepkg + # --printsrcinfo > .SRCINFO` as the user that owns + # `/startdir/PKGBUILD`, and `makepkg` doesn't like to be run + # as root. Unfortunately, this test runs with a chroot that + # doesn't have the `builduser` set up, and it'd be a pain to + # set it up. So choose an arbitrary user from + # `/usr/lib/sysusers.d/arch.conf`. + local builduser_uid="${SUDO_UID:-$UID}" + local builduser_gid="$(id -g "$builduser_uid")" + testsudo librechroot -l "$BATS_TEST_NAME" run sh -c " + echo 'builduser:x:${builduser_gid}:' >>/etc/group + echo 'builduser:x:${builduser_uid}:${builduser_gid}:builduser:/build:/bin/bash' >>/etc/passwd + echo 'builduser:!!:$(( $(date -u +%s) / 86400 ))::::::' >>/etc/shadow" + + # Pre-flight: Make sure `lsof` isn't in the base install not testsudo librechroot -l "$BATS_TEST_NAME" run lsof - # Make sure it removes it without the PKGBUILD + # Make sure librechroot removes `lsof` when the PKGBUILD is not present. testsudo librechroot -l "$BATS_TEST_NAME" install-name lsof testsudo librechroot -l "$BATS_TEST_NAME" run lsof testsudo librechroot -l "$BATS_TEST_NAME" clean-pkgs not testsudo librechroot -l "$BATS_TEST_NAME" run lsof - # Make sure it leaves it with the PKGBUILD + # Make sure librechroot keeps `lsof` when the PKGBUILD is present. testsudo librechroot -l "$BATS_TEST_NAME" install-name lsof testsudo librechroot -l "$BATS_TEST_NAME" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat fixtures/librechroot/PKGBUILD-arches)" - # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. - # https://bugs.archlinux.org/task/56828 - testsudo librechroot -l "$BATS_TEST_NAME" run chown -R 99:99 /startdir + testsudo librechroot -l "$BATS_TEST_NAME" run chown -R builduser: /startdir testsudo librechroot -l "$BATS_TEST_NAME" clean-pkgs testsudo librechroot -l "$BATS_TEST_NAME" run lsof } @@ -69,12 +81,21 @@ load ../lib/common @test "librechroot can install libretools with chcleanup" { require network sudo || skip + # NB: We chown `/startdir` because chcleanup runs `makepkg + # --printsrcinfo > .SRCINFO` as the user that owns + # `/startdir/PKGBUILD`, and `makepkg` doesn't like to be run + # as root. + local builduser_uid="${SUDO_UID:-$UID}" + local builduser_gid="$(id -g "$builduser_uid")" + testsudo librechroot -l "$BATS_TEST_NAME" run sh -c " + echo 'builduser:x:${builduser_gid}:' >>/etc/group + echo 'builduser:x:${builduser_uid}:${builduser_gid}:builduser:/build:/bin/bash' >>/etc/passwd + echo 'builduser:!!:$(( $(date -u +%s) / 86400 ))::::::' >>/etc/shadow" + not testsudo librechroot -l "$BATS_TEST_NAME" run test -f /usr/bin/chcleanup testsudo librechroot -l "$BATS_TEST_NAME" run mkdir /startdir testsudo librechroot -l "$BATS_TEST_NAME" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat fixtures/librechroot/PKGBUILD-libretools)" - # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. - # https://bugs.archlinux.org/task/56828 - testsudo librechroot -l "$BATS_TEST_NAME" run chown -R 99:99 /startdir + testsudo librechroot -l "$BATS_TEST_NAME" run chown -R builduser: /startdir testsudo librechroot -l "$BATS_TEST_NAME" clean-pkgs testsudo librechroot -l "$BATS_TEST_NAME" run test -f /usr/bin/chcleanup } diff --git a/test/cases/librefetch.bats b/test/cases/librefetch.bats index 8f03494..21150bb 100644 --- a/test/cases/librefetch.bats +++ b/test/cases/librefetch.bats @@ -12,7 +12,6 @@ setup() { BUILDDIR="" source ${_librelib_conf_sh_sysconfdir@Q}/makepkg.d/librefetch.conf eot - export MAKEPKG_CONF="$XDG_CONFIG_HOME/pacman/makepkg.conf" install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/librefetch.conf" <<-eot MIRRORS=("phony://example.com/dir/") @@ -130,3 +129,31 @@ setup() { empty "$tmpdir/workdir/srcdest/$srcball" gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null } + +@test "librefetch handles split packages" { + cp fixtures/librefetch/* "$tmpdir/" + cd "$tmpdir" + mv PKGBUILD{-split,} + + makepkg -g +} + +@test "librefetch uses the specified compression" { + cp fixtures/librefetch/* "$tmpdir/" + cd "$tmpdir" + local srcball + + # Both gzip and bzip2 are in 'base', so this choice of + # compression methods doesn't add anything to our list of + # dependencies. + + srcball=testpkg-1.0.tar.gz + mv PKGBUILD{-mksource,} + makepkg -g + gzip -d <"$tmpdir/workdir/srcdest/$srcball" >/dev/null + + srcball=testpkg-bz2-1.0.tar.bz2 + mv PKGBUILD{-bz2,} + makepkg -g + bzip2 -d <"$tmpdir/workdir/srcdest/$srcball" >/dev/null +} diff --git a/test/cases/libremakepkg.bats b/test/cases/libremakepkg.bats index 2184de2..34db6e3 100644 --- a/test/cases/libremakepkg.bats +++ b/test/cases/libremakepkg.bats @@ -1,5 +1,7 @@ load ../lib/common +shopt -s extglob + setup() { common_setup @@ -25,7 +27,7 @@ teardown() { testsudo libremakepkg -l "$BATS_TEST_NAME" - globfile libretools-hello-1.0-1-any.pkg.tar.?z + globfile libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) } @test "libremakepkg disables networking during prepare" { @@ -34,9 +36,9 @@ teardown() { cd "$tmpdir" not testsudo libremakepkg -l "$BATS_TEST_NAME" - not globfile libretools-netprepare-1.0-1-any.pkg.tar.?z + not globfile libretools-netprepare-1.0-1-any.pkg.tar?(.!(sig|*.*)) testsudo libremakepkg -l "$BATS_TEST_NAME" -N - globfile libretools-netprepare-1.0-1-any.pkg.tar.?z + globfile libretools-netprepare-1.0-1-any.pkg.tar?(.!(sig|*.*)) } @test "libremakepkg disables networking during build" { @@ -45,9 +47,9 @@ teardown() { cd "$tmpdir" not testsudo libremakepkg -l "$BATS_TEST_NAME" - not globfile libretools-netbuild-1.0-1-any.pkg.tar.?z + not globfile libretools-netbuild-1.0-1-any.pkg.tar?(.!(sig|*.*)) testsudo libremakepkg -l "$BATS_TEST_NAME" -N - globfile libretools-netbuild-1.0-1-any.pkg.tar.?z + globfile libretools-netbuild-1.0-1-any.pkg.tar?(.!(sig|*.*)) } @test "libremakepkg disables networking during package" { @@ -56,9 +58,9 @@ teardown() { cd "$tmpdir" not testsudo libremakepkg -l "$BATS_TEST_NAME" - not globfile libretools-netpackage-1.0-1-any.pkg.tar.?z + not globfile libretools-netpackage-1.0-1-any.pkg.tar?(.!(sig|*.*)) testsudo libremakepkg -l "$BATS_TEST_NAME" -N - globfile libretools-netpackage-1.0-1-any.pkg.tar.?z + globfile libretools-netpackage-1.0-1-any.pkg.tar?(.!(sig|*.*)) } @test "libremakepkg cleans the chroot before building" { @@ -88,7 +90,7 @@ teardown() { # This next line is actually a separate test, but it fits in well with this test, and chroot tests are slow. # @test "libremakepkg doesnt cache local packages" { - not testsudo librechroot -l "$BATS_TEST_NAME" run test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar.?z + not testsudo librechroot -l "$BATS_TEST_NAME" run bash -O extglob -c 'test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar?(.!(sig|*.*))' cd "$tmpdir/3" testsudo libremakepkg -l "$BATS_TEST_NAME" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } @@ -102,7 +104,7 @@ teardown() { testsudo env PKGDEST="$tmpdir/dest/pkgdest" libremakepkg -l "$BATS_TEST_NAME" - globfile dest/pkgdest/libretools-hello-1.0-1-any.pkg.tar.?z + globfile dest/pkgdest/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) } @test "libremakepkg displays help as normal user" { @@ -152,14 +154,14 @@ teardown() { # first make sure that the engine works testsudo libremakepkg -l "$BATS_TEST_NAME" - globfile libretools-hello-1.0-1-any.pkg.tar.?z - rm -f -- libretools-hello-1.0-1-any.pkg.tar.?z + globfile libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) + rm -f -- libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) # now throw a wrench in it testsudo librechroot -l "$BATS_TEST_NAME" run touch /bin/distcc-tool # and make sure that the engine broke testsudo libremakepkg -l "$BATS_TEST_NAME" || status=$? [[ $status != 0 ]] - not globfile libretools-hello-1.0-1-any.pkg.tar.?z + not globfile libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) } @test "libremakepkg forwards distcc ports" { @@ -185,7 +187,7 @@ teardown() { cd "$tmpdir" testsudo librechroot -l "$chrootname" install-name distcc-nozeroconf socat testsudo libremakepkg -l "$chrootname" - globfile libretools-distcc-1.0-1-any.pkg.tar.?z + globfile libretools-distcc-1.0-1-any.pkg.tar?(.!(sig|*.*)) } @test "libremakepkg doesnt symlink outputs" { @@ -198,10 +200,10 @@ teardown() { testsudo libremakepkg -l "$BATS_TEST_NAME" - not stat libretools-hello-1.0-1-any.pkg.tar.?z - not stat libretools-hello-1.0-1-any.src.tar.?z - globfile "$tmpdir/workdir/pkgdest"/libretools-hello-1.0-1-any.pkg.tar.?z - globfile "$tmpdir/workdir/srcpkgdest"/libretools-hello-1.0-1-any.src.tar.?z + not stat libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) + not stat libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*)) + globfile "$tmpdir/workdir/pkgdest"/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) + globfile "$tmpdir/workdir/srcpkgdest"/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*)) } @test "libremakepkg succeeds with good signatures" { @@ -236,12 +238,23 @@ teardown() { testsudo libremakepkg -l "$BATS_TEST_NAME" - globfile libretools-pkgver-1-1-any.pkg.tar.?z - not globfile libretools-pkgver-2-1-any.pkg.tar.?z + globfile libretools-pkgver-1-1-any.pkg.tar?(.!(sig|*.*)) + not globfile libretools-pkgver-2-1-any.pkg.tar?(.!(sig|*.*)) popd diff -u fixtures/libremakepkg/PKGBUILD-pkgver "$tmpdir/PKGBUILD" } +@test "libremakepkg has a flag to make startdir rw" { + require network sudo || skip + cp fixtures/libremakepkg/PKGBUILD-rwstartdir "$tmpdir/PKGBUILD" + cd "$tmpdir" + + not testsudo libremakepkg -l "$BATS_TEST_NAME" + not globfile libretools-rwstartdir-1.0-1-any.pkg.tar?(.!(sig|*.*)) + testsudo libremakepkg -l "$BATS_TEST_NAME" -W + globfile libretools-rwstartdir-1.0-1-any.pkg.tar?(.!(sig|*.*)) +} + @test "libremakepkg can re-use source-packages" { require network sudo || skip @@ -253,16 +266,16 @@ teardown() { # 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) + globfile libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*)) + globfile libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) + a_stime=$(stat -c %Y -- libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))) + a_ptime=$(stat -c %Y -- libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))) + + testsudo libremakepkg -l "$BATS_TEST_NAME" -S libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*)) + globfile libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*)) + globfile libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) + b_stime=$(stat -c %Y -- libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))) + b_ptime=$(stat -c %Y -- libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))) (( a_stime == b_stime )) (( a_ptime < b_ptime )) diff --git a/test/cases/librerelease.bats b/test/cases/librerelease.bats index 93a04e3..3b83651 100644 --- a/test/cases/librerelease.bats +++ b/test/cases/librerelease.bats @@ -12,7 +12,7 @@ setup() { PasswordAuthentication no AcceptEnv TMPDIR AcceptEnv _HOME GNUPGHOME XDG_CACHE_HOME XDG_CONFIG_HOME - AcceptEnv _PATH LIBRETOOLS_LIBDIR _librelib_conf_sh_sysconfdir _librelib_conf_sh_pkgconfdir + AcceptEnv _PATH LIBRETOOLS_LIBRARY_PATH _librelib_conf_sh_sysconfdir _librelib_conf_sh_pkgconfdir AcceptEnv GPGKEY ForceCommand HOME=\$_HOME; PATH=\$_PATH; eval "\$SSH_ORIGINAL_COMMAND" eot diff --git a/test/cases/librestage.bats b/test/cases/librestage.bats index 1bc5c25..4551d1e 100644 --- a/test/cases/librestage.bats +++ b/test/cases/librestage.bats @@ -1,5 +1,7 @@ load ../lib/common +shopt -s extglob + @test "librestage displays usage text" { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librestage -h >$tmpdir/stdout 2>$tmpdir/stderr @@ -38,8 +40,8 @@ load ../lib/common librestage find "$tmpdir" -not -type d -exec ls -ld -- {} + - globfile $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar.?z - $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z + globfile $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) + $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*)) } @test "librestage stages packages without PKGDEST" { @@ -61,6 +63,6 @@ load ../lib/common librestage repo1 find "$tmpdir" -not -type d -exec ls -ld -- {} + - globfile $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.?z - $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z + globfile $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*)) + $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*)) } diff --git a/test/cases/pkgbuild-check-nonfree.bats b/test/cases/pkgbuild-check-nonfree.bats index 36f6619..ffd8de8 100644 --- a/test/cases/pkgbuild-check-nonfree.bats +++ b/test/cases/pkgbuild-check-nonfree.bats @@ -9,57 +9,170 @@ setup() { eot install -Dm644 /dev/stdin "$XDG_CACHE_HOME/libretools/blacklist.txt" <<-eot linux:linux-libre:nonfree blobs and firmwares + rubygemsx:rubygemsx:repackaged skype eot } +# Make sure these match pkgbuild-check-nonfree +declare -rig _E_OK=0 +declare -rig _E_ERROR=1 +declare -rig _E_LIC_UNKNOWN=2 +declare -rig _E_LIC_NOGPL=4 +declare -rig _E_LIC_NONFREE=8 +declare -rig _E_DEP_NONFREE=16 +declare -rig _E_PKG_NONFREE=32 + +# Make sure these match pkgbuild-summarize-nonfree (libremessages) +declare -rig EXIT_SUCCESS=0 +declare -rig EXIT_FAILURE=1 + +# basic operation ############################################################## + @test "pkgbuild-check-nonfree displays usage text" { # This test seems silly, but it makes sure that it is executable, - # syntactically correct, and loading libraries works. - LC_ALL=C pkgbuild-check-nonfree -h >$tmpdir/stdout 2>$tmpdir/stderr - status=$? - + # syntactically correct, and loading libraries works. + LC_ALL=C pkgbuild-check-nonfree -h >$tmpdir/stdout 2>$tmpdir/stderr || status=$? [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] empty $tmpdir/stderr - [[ $status == 0 ]] + [[ $status == $_E_OK ]] } +@test "pkgbuild-check-nonfree errors on invalid flags" { + pkgbuild-check-nonfree -x >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_ERROR ]] +} + +@test "pkgbuild-check-nonfree fails when there is no blacklist" { + rm $XDG_CACHE_HOME/libretools/blacklist.txt + + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_ERROR ]] +} + +# PKGBUILD codes ############################################################### + +# basic _E_OK @test "pkgbuild-check-nonfree succeeds for free depends" { pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_OK ]] +} +# _E_DEP_LIC_UNKNOWN +@test "pkgbuild-check-nonfree warns about unknown licenses" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-unknown >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_LIC_UNKNOWN ]] + + local pcn_stat=$status + status=0 + + pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? empty $tmpdir/stdout not empty $tmpdir/stderr - [[ $status == 0 ]] + [[ $status == $EXIT_SUCCESS ]] } -@test "pkgbuild-check-nonfree succeeds for nonfree depend with replacement" { - pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || status=$? +# _E_DEP_LIC_NOGPL +@test "pkgbuild-check-nonfree warns about GPL-incompatible licenses" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nogpl >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_LIC_NOGPL ]] + + local pcn_stat=$status + status=0 + + pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $EXIT_SUCCESS ]] +} +# _E_DEP_LIC_NONFREE +@test "pkgbuild-check-nonfree fails on nonfree licenses" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nonfree >$tmpdir/stdout 2>$tmpdir/stderr || status=$? empty $tmpdir/stdout not empty $tmpdir/stderr - [[ $status == 0 ]] + [[ $status == $_E_LIC_NONFREE ]] + + local pcn_stat=$status + status=0 + + pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $EXIT_FAILURE ]] } +# _E_DEP_NONFREE +@test "pkgbuild-check-nonfree succeeds for repackaged depend" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-repackaged >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_OK ]] +} +@test "pkgbuild-check-nonfree succeeds for nonfree depend with replacement" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_OK ]] +} @test "pkgbuild-check-nonfree fails for nonfree depend" { - pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - [[ $status != 0 ]] + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-nonfree >$tmpdir/stdout 2>$tmpdir/stderr || status=$? empty $tmpdir/stdout not empty $tmpdir/stderr + [[ $status == $_E_DEP_NONFREE ]] local pcn_stat=$status + status=0 pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - [[ $status != 0 ]] empty $tmpdir/stdout not empty $tmpdir/stderr + [[ $status == $EXIT_FAILURE ]] } -@test "pkgbuild-check-nonfree fails when there is no blacklist" { - rm $XDG_CACHE_HOME/libretools/blacklist.txt +# _E_PKG_NONFREE +@test "pkgbuild-check-nonfree succeeds for repackaged package" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-repackaged >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_OK ]] +} +@test "pkgbuild-check-nonfree fails for package with replacement" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + echo [[ $status == $_E_PKG_NONFREE ]] + [[ $status == $_E_PKG_NONFREE ]] - pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + local pcn_stat=$status + status=0 + pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $EXIT_FAILURE ]] +} +@test "pkgbuild-check-nonfree fails for nonfree package" { + pkgbuild-check-nonfree fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == $_E_PKG_NONFREE ]] + + local pcn_stat=$status + status=0 + + pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? empty $tmpdir/stdout not empty $tmpdir/stderr - [[ $status != 0 ]] && [[ $status != 15 ]] + [[ $status == $EXIT_FAILURE ]] } diff --git a/test/fixtures/librefetch/PKGBUILD-bz2 b/test/fixtures/librefetch/PKGBUILD-bz2 new file mode 100644 index 0000000..0d688b8 --- /dev/null +++ b/test/fixtures/librefetch/PKGBUILD-bz2 @@ -0,0 +1,19 @@ +pkgname=testpkg-bz2 +pkgver=1.0 +pkgrel=1 +pkgdesc=foo +arch=(any) +source=("libre://$pkgname-$pkgver.tar.bz2"{,.sig}) +backup=(etc/testpkg.conf) + +mksource() { + mkdir "$srcdir/bar" + local file + for file in '~foo' '~a' a A; do + touch "$srcdir/bar/$file" + done +} + +package() { + :; +} diff --git a/test/fixtures/librefetch/PKGBUILD-split b/test/fixtures/librefetch/PKGBUILD-split new file mode 100644 index 0000000..a979f08 --- /dev/null +++ b/test/fixtures/librefetch/PKGBUILD-split @@ -0,0 +1,24 @@ +pkgbase=testpkg-split +pkgname=(testpkg-split testpkg-split-secondary) +pkgver=1.0 +pkgrel=1 +pkgdesc=foo +arch=(any) +source=("libre://$pkgname-$pkgver.tar.gz"{,.sig}) +backup=(etc/testpkg.conf) + +mksource() { + mkdir "$srcdir/bar" + local file + for file in '~foo' '~a' a A; do + touch "$srcdir/bar/$file" + done +} + +package_testpkg-split() { + :; +} + +package_testpkg-split-secondary() { + :; +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-rwstartdir b/test/fixtures/libremakepkg/PKGBUILD-rwstartdir new file mode 100644 index 0000000..feadfa0 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-rwstartdir @@ -0,0 +1,15 @@ +pkgname='libretools-rwstartdir' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) + +build() { + echo foo >"$startdir/file" +} + +package() { + install -Dm644 "$startdir/file" "$pkgdir/etc/file" +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-nonfree index 3a7afa4..3a7afa4 100644 --- a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-nonfree diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree-replacement b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-nonfree-replacement index 7855bdc..7855bdc 100644 --- a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree-replacement +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-nonfree-replacement diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-repackaged b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-repackaged new file mode 100644 index 0000000..2d98f1e --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.dep-repackaged @@ -0,0 +1,18 @@ +pkgname=wmii +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('MIT') +url="http://wmii.suckless.org/" +depends=('rubygemsx') # random package that is repackaged with the same name +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nogpl b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nogpl new file mode 100644 index 0000000..f351864 --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nogpl @@ -0,0 +1,18 @@ +pkgname=wmii +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('custom:BSD4') +url="http://wmii.suckless.org/" +depends=('libxft' 'libxrandr' 'libxinerama' 'dash') +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nonfree b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nonfree new file mode 100644 index 0000000..0fc3b0b --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-nonfree @@ -0,0 +1,18 @@ +pkgname=wmii +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('JSON') +url="http://wmii.suckless.org/" +depends=('libxft' 'libxrandr' 'libxinerama' 'dash') +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-unknown b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-unknown new file mode 100644 index 0000000..f4b136b --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.lic-unknown @@ -0,0 +1,18 @@ +pkgname=wmii +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('custom:my-very-special-license') +url="http://wmii.suckless.org/" +depends=('libxft' 'libxrandr' 'libxinerama' 'dash') +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree new file mode 100644 index 0000000..da3f416 --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree @@ -0,0 +1,18 @@ +pkgname=skype +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('MIT') +url="http://wmii.suckless.org/" +depends=('libxft' 'libxrandr' 'libxinerama' 'dash') +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree-replacement b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree-replacement new file mode 100644 index 0000000..5242121 --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-nonfree-replacement @@ -0,0 +1,18 @@ +pkgname=linux +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('MIT') +url="http://wmii.suckless.org/" +depends=('libxft' 'libxrandr' 'libxinerama' 'dash') +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-repackaged b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-repackaged new file mode 100644 index 0000000..5a101b3 --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.pkg-repackaged @@ -0,0 +1,18 @@ +pkgname=rubygemsx +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('MIT') +url="http://wmii.suckless.org/" +depends=('libxft' 'libxrandr' 'libxinerama' 'dash') +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/lib/common.bash b/test/lib/common.bash index 1a16ae0..90b6f04 100644 --- a/test/lib/common.bash +++ b/test/lib/common.bash @@ -1,6 +1,6 @@ #!/hint/bash -if [[ -z $LIBRETOOLS_LIBDIR || -z $_librelib_conf_sh_sysconfdir || -z $_librelib_conf_sh_pkgconfdir ]]; then +if [[ -z $LIBRETOOLS_LIBRARY_PATH || -z $_librelib_conf_sh_sysconfdir || -z $_librelib_conf_sh_pkgconfdir ]]; then libremessages error 'Must be run with ./testenv' exit 1 fi @@ -26,10 +26,15 @@ common_setup() { mkdir -p -- "$GNUPGHOME" chmod 700 -- "$GNUPGHOME" gpg --quiet --no-tty --batch --gen-key <<-eot - Key-Type: default + Key-Type: DSA + Key-Length: 1024 + Subkey-Type: ECDSA + Subkey-Curve: nistp256 + Key-Usage: sign Name-Real: Bob Tester Name-Email: tester@localhost + Expire-Date: 0 %no-protection %commit diff --git a/test/testenv b/test/testenv index 11a46ee..09fd328 100755 --- a/test/testenv +++ b/test/testenv @@ -54,7 +54,7 @@ # Set up the environment export PATH="$destdir/usr/bin:$PATH" - export LIBRETOOLS_LIBDIR="$destdir/usr/lib/libretools" + export LIBRETOOLS_LIBRARY_PATH="$destdir/usr/lib/libretools" export _librelib_conf_sh_sysconfdir="$destdir/etc" export _librelib_conf_sh_pkgconfdir="$destdir/etc/libretools.d" sed -i 's,/usr/bin/librefetch,$(which librefetch),' \ @@ -66,7 +66,7 @@ vars=( TMPDIR GNUPGHOME XDG_CACHE_HOME XDG_CONFIG_HOME - PATH LIBRETOOLS_LIBDIR _librelib_conf_sh_sysconfdir _librelib_conf_sh_pkgconfdir + PATH LIBRETOOLS_LIBRARY_PATH _librelib_conf_sh_sysconfdir _librelib_conf_sh_pkgconfdir GPGKEY ) env=() @@ -98,7 +98,7 @@ vars=( TMPDIR _HOME GNUPGHOME XDG_CACHE_HOME XDG_CONFIG_HOME - _PATH LIBRETOOLS_LIBDIR _librelib_conf_sh_sysconfdir _librelib_conf_sh_pkgconfdir + _PATH LIBRETOOLS_LIBRARY_PATH _librelib_conf_sh_sysconfdir _librelib_conf_sh_pkgconfdir GPGKEY ) export _HOME="$HOME" |