diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2018-06-10 12:57:51 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-06-10 12:57:51 -0400 |
commit | 9233d18f7487c2d2b969a4b72ae9976f1dc757cd (patch) | |
tree | 38fe08e9fd88237ceddc23213b387284655dbf63 | |
parent | 5189a00cd7e3cc415f13fb8aa867fd7c8c6711fa (diff) | |
parent | 812724e0e098634294f25f36d7b5c6c5eefbf7f0 (diff) |
Merge branch 'lukeshu/tests'parabola/20180610
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | db-import-archlinux32.conf | 4 | ||||
-rw-r--r-- | db-import-archlinuxarm.conf | 4 | ||||
-rw-r--r-- | db-import-community.conf | 4 | ||||
-rw-r--r-- | db-import-packages.conf | 4 | ||||
-rw-r--r-- | test/cases/db-import-pkg.bats | 304 | ||||
-rw-r--r-- | test/fixtures/pkg-any32/PKGBUILD | 13 | ||||
-rw-r--r-- | test/fixtures/pkg-any64/PKGBUILD | 13 | ||||
-rw-r--r-- | test/fixtures/slavery/PKGBUILD | 13 | ||||
-rw-r--r-- | test/lib/common.bash | 9 | ||||
-rwxr-xr-x | test/lib/runserver | 39 |
11 files changed, 403 insertions, 5 deletions
@@ -8,3 +8,4 @@ yftime src* pkg* +!/test/fixtures/pkg-*/ diff --git a/db-import-archlinux32.conf b/db-import-archlinux32.conf index 4ca684a..d03e3d9 100644 --- a/db-import-archlinux32.conf +++ b/db-import-archlinux32.conf @@ -20,3 +20,7 @@ ABS_ROOT='/srv/repo/db-import-archlinux32-src/abs/' ABS_SERVER="${ARCHMIRROR#rsync://}/" ALARM_GIT='https://github.com/archlinux32/packages' ALARM_ROOT='/srv/repo/db-import-archlinux32-src/archlinux32/' + +if [[ -n ${DBIMPORT_CONFIG} ]]; then + source "${DBIMPORT_CONFIG}" +fi diff --git a/db-import-archlinuxarm.conf b/db-import-archlinuxarm.conf index 611d38f..160f0ca 100644 --- a/db-import-archlinuxarm.conf +++ b/db-import-archlinuxarm.conf @@ -20,3 +20,7 @@ ABS_ROOT='/srv/repo/db-import-archlinuxarm-src/abs/' ABS_SERVER="${ARCHMIRROR#rsync://}/" ALARM_GIT='https://github.com/archlinuxarm/PKGBUILDs' ALARM_ROOT='/srv/repo/db-import-archlinuxarm-src/alarm/' + +if [[ -n ${DBIMPORT_CONFIG} ]]; then + source "${DBIMPORT_CONFIG}" +fi diff --git a/db-import-community.conf b/db-import-community.conf index 20965de..c829f28 100644 --- a/db-import-community.conf +++ b/db-import-community.conf @@ -23,3 +23,7 @@ ABSLIBRE_ROOT=/srv/repo/db-import-archlinux-src/abslibre ABSLIBRE_GIT=https://git.parabola.nu/abslibre.git/ ABS_ROOT="/srv/repo/db-import-archlinux-src/abs/" ABS_SERVER="rsync.archlinux.org" + +if [[ -n ${DBIMPORT_CONFIG} ]]; then + source "${DBIMPORT_CONFIG}" +fi diff --git a/db-import-packages.conf b/db-import-packages.conf index 295797f..1ba399b 100644 --- a/db-import-packages.conf +++ b/db-import-packages.conf @@ -23,3 +23,7 @@ ABSLIBRE_ROOT=/srv/repo/db-import-archlinux-src/abslibre ABSLIBRE_GIT=https://git.parabola.nu/abslibre.git/ ABS_ROOT="/srv/repo/db-import-archlinux-src/abs/" ABS_SERVER="rsync.archlinux.org" + +if [[ -n ${DBIMPORT_CONFIG} ]]; then + source "${DBIMPORT_CONFIG}" +fi diff --git a/test/cases/db-import-pkg.bats b/test/cases/db-import-pkg.bats new file mode 100644 index 0000000..da5ecce --- /dev/null +++ b/test/cases/db-import-pkg.bats @@ -0,0 +1,304 @@ +load ../lib/common + +httpserver() { + read -r verb path version || exit + if [[ $verb != GET ]]; then + printf "HTTP/1.1 405 Method Not Allowed\r\nContent-Type: text/plain\r\nContent-length: 0\r\n\r\n" + exit + fi + path="$(cd / && realpath -ms "$path")" + if ! [[ -f "$1/$path" ]]; then + printf "HTTP/1.1 404 Not found\r\nContent-Type: text/plain\r\nContent-length: 0\r\n\r\n" + exit + fi + printf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-length: %d\r\n\r\n" $(stat -L -c %s "$1/$path") + cat "$1/$path" +} + +eval "__common_$(declare -f setup)" +setup() { + __common_setup + + # Set up rsync server + cat <<-eot >"${TMP}/rsyncd.conf" + use chroot = no + [archlinux] + path = ${TMP}/rsyncd/archlinux + [archlinux32] + path = ${TMP}/rsyncd/archlinux32 + eot + local rsyncport + rsyncport=$(./lib/runserver "$TMP/rsyncd.pid" \ + rsync --daemon --config "${TMP}/rsyncd.conf") + + # Set up rsync contents + mkdir -p -- "${TMP}/rsyncd/archlinux/core/os/x86_64" + touch -- "${TMP}/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" + ln -s core.db.tar.gz "${TMP}/rsyncd/archlinux/core/os/x86_64/core.db" + mkdir -p -- "${TMP}/rsyncd/archlinux"/{pool,sources}/{packages,community} + date +%s > "${TMP}/rsyncd/archlinux/lastupdate" + date +%s > "${TMP}/rsyncd/archlinux/lastsync" + + mkdir -p -- "${TMP}/rsyncd/archlinux32/i686/core" + touch -- "${TMP}/rsyncd/archlinux32/i686/core/core.db.tar.gz" + ln -s core.db.tar.gz "${TMP}/rsyncd/archlinux32/i686/core/core.db" + date +%s > "${TMP}/rsyncd/archlinux32/lastupdate" + date +%s > "${TMP}/rsyncd/archlinux32/lastsync" + + # Configure db-import to use that rsyncd server + cat <<-eot >"${TMP}/db-import-archlinux.local.conf" + ARCHTAGS=('core-x86_64') + ARCHMIRROR=rsync://localhost:${rsyncport@Q}/archlinux/"\${ARCHMIRROR#rsync://*/*/}" + eot + cat <<-eot >"${TMP}/db-import-archlinux32.local.conf" + ARCHTAGS=('core-i686') + ARCHMIRROR=rsync://localhost:${rsyncport@Q}/archlinux32/"\${ARCHMIRROR#rsync://*/*/}" + eot + + # Set up HTTP server + local httpport + httpport=$(./lib/runserver "$TMP/httpd.pid" \ + bash -c "$(declare -f httpserver); httpserver \"\$@\"" -- "$TMP/httpd") + + # Set up HTTP contents + mkdir -- "$TMP/httpd" + cat <<-eot >"$TMP/httpd/blacklist.txt" + slavery:freedom:fsf:slavekit:Obviously + eot + + # Configure db-import to use that HTTP server + mkdir "$XDG_CONFIG_HOME"/libretools + cat <<-eot >"$XDG_CONFIG_HOME"/libretools/libretools.conf + BLACKLIST=http://localhost:${httpport@Q}/blacklist.txt + eot + + # Set up repo contents + mkdir -p -- "${TMP}/ftp/core/os"/{x86_64,i686} + touch -- "${TMP}"/ftp/core/os/{x86_64,i686}/core.db.tar.gz + ln -s core.db.tar.gz "${TMP}/ftp/core/os/x86_64/core.db" + ln -s core.db.tar.gz "${TMP}/ftp/core/os/i686/core.db" + mkdir -p -- "${TMP}/ftp"/{pool,sources}/{packages,community,archlinux32} + date +%s > "${TMP}/ftp/lastupdate" + date +%s > "${TMP}/ftp/lastsync" +} +eval "__common_$(declare -f teardown)" +teardown() { + xargs -a "${TMP}/httpd.pid" kill -- + xargs -a "${TMP}/rsyncd.pid" kill -- + __common_teardown +} + +###################################################################### + +# Run the command in a new mount namespace with /tmp remounted +# read-only, but with $TMP (which might be under /tmp) still writable. +# +# Arguments are passed as arguments to `sudo`. +__withRoTmp() { + local mount="mount -o bind ${TMP@Q}{,} && mount -o bind,remount,ro /tmp{,}" + local env=( + "DBIMPORT_CONFIG=${DBIMPORT_CONFIG}" + "DBSCRIPTS_CONFIG=${DBSCRIPTS_CONFIG}" + "XDG_CONFIG_HOME=${XDG_CONFIG_HOME}" + ) + sudo -- unshare -m -- sh -c "${mount} && sudo -u ${USER@Q} ${env[*]@Q} \$@" -- "$@" +} + +__db-import-pkg() { + local ret=0 + # Since common.bash->config.local sets TMPDIR=${TMP}/tmp, + # TMPDIR is necessarily != /tmp. + # Which means that if we try to write anything directly under /tmp, + # then we are erroneously disregarding TMPDIR. + # So, make /tmp read-only to make that be an error. + __withRoTmp db-import-pkg "$@" || ret=$? + # Verify that it cleaned up after itself and TMPDIR is empty + find "$TMPDIR" -mindepth 1 | diff - /dev/null + return $ret +} + +# releaseImportedPackage PKGBASE ARCH DBFILE [POOLDIR] +# +# This is different from common.bash:releasePackage because +# - it doesn't mess with SVN +# - it adds the package to the .db file +__releaseImportedPackage() { + local pkgbase=$1 + local arch=$2 + local dbfile=$3 + local pooldir=$4 + local repodir="${dbfile%/*}" + local dir restore pkgfiles pkgfile pkgs + + dir="$TMP/import-build/$pkgbase" + if ! [[ -d "$dir" ]]; then + mkdir -p -- "$dir" + cp -t "$dir" -- "fixtures/${pkgbase}"/* + fi + pushd "$dir" + __buildPackage + restore="$(shopt -p nullglob || true)" + shopt -s nullglob + pkgfiles=(*-{"$arch",any}$PKGEXT{,.sig}) + $restore + popd + + mkdir -p "$repodir" + if [[ -z $pooldir ]]; then + mv -t "$repodir" -- "${pkgfiles[@]/#/"$dir/"}" + else + mkdir -p "$pooldir" + mv -t "$pooldir" -- "${pkgfiles[@]/#/"$dir/"}" + ln -sr -t "$repodir" -- "${pkgfiles[@]/#/"$pooldir/"}" + fi + + pushd "$repodir" + pkgs=() + for pkgfile in "${pkgfiles[@]}"; do + if [[ "$pkgfile" = *.sig ]]; then + continue + fi + pkgs+=("$pkgfile") + done + repo-add -q "${dbfile##*/}" "${pkgs[@]}" + popd +} + +__updateImportedPackage() { + pushd "$TMP/import-build/$1" + local pkgrel + pkgrel=$(. PKGBUILD; expr ${pkgrel} + 1) + sed "s/pkgrel=.*/pkgrel=${pkgrel}/" -i PKGBUILD + popd +} + +__isLinkTo() { + [[ -L $1 ]] + [[ $1 -ef $2 ]] +} + +__doesNotExist() { + local file + for file in "$@"; do + if stat "$file" 2>/dev/null; then + echo "TEST ERROR: File shouldn't exist, but does: $file" + return 1 + fi + done +} + +###################################################################### + +@test "imports no blacklisted packages (x86_64)" { + __releaseImportedPackage slavery x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + __releaseImportedPackage pkg-simple-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-simple-a-1-1-x86_64.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-simple-a-1-1-x86_64.pkg.tar.xz" + __doesNotExist "$TMP"/ftp/{core/os/x86_64,pool/packages,sources/packages}/slavery-* +} + +@test "imports no blacklisted packages (i686)" { + __releaseImportedPackage slavery i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + __releaseImportedPackage pkg-simple-a i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux32.local.conf" __db-import-pkg archlinux32 + + __isLinkTo "$TMP/ftp/core/os/i686/pkg-simple-a-1-1-i686.pkg.tar.xz" "$TMP/ftp/pool/archlinux32/pkg-simple-a-1-1-i686.pkg.tar.xz" + __doesNotExist "$TMP"/ftp/{core/os/i686,pool/archlinux32,sources/archlinux32}/slavery-* +} + +@test "imports DBs with no blacklisted packages" { + __releaseImportedPackage pkg-simple-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-simple-a-1-1-x86_64.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-simple-a-1-1-x86_64.pkg.tar.xz" +} + +@test "imports updated packages" { + __releaseImportedPackage slavery x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + __releaseImportedPackage pkg-simple-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-simple-a-1-1-x86_64.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-simple-a-1-1-x86_64.pkg.tar.xz" + + __updateImportedPackage pkg-simple-a + __releaseImportedPackage pkg-simple-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-simple-a-1-2-x86_64.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-simple-a-1-2-x86_64.pkg.tar.xz" +} + +@test "imports .db files as 0664 (x86_64)" { + __releaseImportedPackage slavery x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + __releaseImportedPackage pkg-simple-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-simple-a-1-1-x86_64.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-simple-a-1-1-x86_64.pkg.tar.xz" + __doesNotExist "$TMP"/ftp/{core/os/x86_64,pool/packages,sources/packages}/slavery-* + [[ "$(stat -c '%a' -- "$TMP/ftp/core/os/x86_64/core.db.tar.gz")" = 664 ]] +} + +@test "imports .db files as 0664 (i686)" { + __releaseImportedPackage slavery i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + __releaseImportedPackage pkg-simple-a i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux32.local.conf" __db-import-pkg archlinux32 + + __isLinkTo "$TMP/ftp/core/os/i686/pkg-simple-a-1-1-i686.pkg.tar.xz" "$TMP/ftp/pool/archlinux32/pkg-simple-a-1-1-i686.pkg.tar.xz" + __doesNotExist "$TMP"/ftp/{core/os/i686,pool/archlinux32,sources/archlinux32}/slavery-* + stat -- "$TMP/ftp/core/os/i686/core.db.tar.gz" + [[ "$(stat -c '%a' -- "$TMP/ftp/core/os/i686/core.db.tar.gz")" = 664 ]] +} + +@test "imports fully-masked upstream" { + __releaseImportedPackage pkg-any-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + __releaseImportedPackage pkg-any-a i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + DBIMPORT_CONFIG="${TMP}/db-import-archlinux32.local.conf" __db-import-pkg archlinux32 + + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-any-a-1-1-any.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-any-a-1-1-any.pkg.tar.xz" + __isLinkTo "$TMP/ftp/core/os/i686/pkg-any-a-1-1-any.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-any-a-1-1-any.pkg.tar.xz" +} + +@test "import errors on pkgpool selection failures" { + # pkg-simple-a is just to make sure that the "fully-masked + # upstream" bug isn't being tested here + __releaseImportedPackage pkg-any-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + __releaseImportedPackage pkg-simple-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + __updateImportedPackage pkg-any-a + __releaseImportedPackage pkg-any-a x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-any-a-1-2-any.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-any-a-1-2-any.pkg.tar.xz" + + # This assumes that a package nested too deelply under /pool/ + # is filtered from being downloaded, but isn't found when + # poolifying. + mkdir -- "$TMP/ftp/pool/nested" + mv -T -- "$TMP/ftp/pool/packages" "$TMP/ftp/pool/nested/packages" + __releaseImportedPackage pkg-any-a i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + __releaseImportedPackage pkg-simple-a i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + + local status=0 + DBIMPORT_CONFIG="${TMP}/db-import-archlinux32.local.conf" __db-import-pkg archlinux32 || status=$? + [[ $status != 0 ]] + __doesNotExist "$TMP/ftp/core/os/i686/pkg-any-a-1-2-any.pkg.tar.xz" +} + +@test "imports arch=any packages with sub-pkgrel" { + # This is modeled after the situation with 'asp' and 'asp32' + + __releaseImportedPackage pkg-any64 x86_64 "$TMP/rsyncd/archlinux/core/os/x86_64/core.db.tar.gz" "$TMP/rsyncd/archlinux/pool/packages" + DBIMPORT_CONFIG="${TMP}/db-import-archlinux.local.conf" __db-import-pkg packages + __isLinkTo "$TMP/ftp/core/os/x86_64/pkg-any-2-1-any.pkg.tar.xz" "$TMP/ftp/pool/packages/pkg-any-2-1-any.pkg.tar.xz" + + __releaseImportedPackage pkg-any32 i686 "$TMP/rsyncd/archlinux32/i686/core/core.db.tar.gz" + DBIMPORT_CONFIG="${TMP}/db-import-archlinux32.local.conf" __db-import-pkg archlinux32 + __isLinkTo "$TMP/ftp/core/os/i686/pkg-any-1-1.2-any.pkg.tar.xz" "$TMP/ftp/pool/archlinux32/pkg-any-1-1.2-any.pkg.tar.xz" +} diff --git a/test/fixtures/pkg-any32/PKGBUILD b/test/fixtures/pkg-any32/PKGBUILD new file mode 100644 index 0000000..e0421da --- /dev/null +++ b/test/fixtures/pkg-any32/PKGBUILD @@ -0,0 +1,13 @@ +pkgname=pkg-any +pkgver=1 +pkgrel=1.2 +pkgdesc="A package called ${pkgname} (32)" +arch=('any') +url='http://www.archlinux.org/' +license=('GPL') +options=(!strip) + +package() { + install -d -m755 "${pkgdir}"/usr/share/${pkgname} + echo 'test' > "${pkgdir}"/usr/share/${pkgname}/test +} diff --git a/test/fixtures/pkg-any64/PKGBUILD b/test/fixtures/pkg-any64/PKGBUILD new file mode 100644 index 0000000..1290ebd --- /dev/null +++ b/test/fixtures/pkg-any64/PKGBUILD @@ -0,0 +1,13 @@ +pkgname=pkg-any +pkgver=2 +pkgrel=1 +pkgdesc="A package called ${pkgname} (64)" +arch=('any') +url='http://www.archlinux.org/' +license=('GPL') +options=(!strip) + +package() { + install -d -m755 "${pkgdir}"/usr/share/${pkgname} + echo 'test' > "${pkgdir}"/usr/share/${pkgname}/test +} diff --git a/test/fixtures/slavery/PKGBUILD b/test/fixtures/slavery/PKGBUILD new file mode 100644 index 0000000..93cc079 --- /dev/null +++ b/test/fixtures/slavery/PKGBUILD @@ -0,0 +1,13 @@ +pkgname=slavery +pkgver=1 +pkgrel=1 +pkgdesc="A package called ${pkgname}" +arch=('any') +url='http://www.archlinux.org/' +license=('GPL') +options=(!strip) + +package() { + install -d -m755 "${pkgdir}"/usr/share/${pkgname} + echo 'test' > "${pkgdir}"/usr/share/${pkgname}/test +} diff --git a/test/lib/common.bash b/test/lib/common.bash index bf17d46..aa8febe 100644 --- a/test/lib/common.bash +++ b/test/lib/common.bash @@ -23,7 +23,7 @@ __buildPackage() { local cache local pkgarches local tarch - local pkgnames + local pkgfiles if [[ -n ${BUILDDIR} ]]; then cache=${BUILDDIR}/$(__getCheckSum PKGBUILD) @@ -38,16 +38,16 @@ __buildPackage() { for tarch in ${pkgarches[@]}; do if [ "${tarch}" == 'any' ]; then sudo librechroot -n "dbscripts@${tarch}" sync + mapfile -tO "${#pkgfiles[@]}" pkgfiles < <(PKGDEST=${pkgdest} PKGEXT=${PKGEXT} makepkg --packagelist) else sudo librechroot -n "dbscripts@${tarch}" -A "$tarch" sync + mapfile -tO "${#pkgfiles[@]}" pkgfiles < <(PKGDEST=${pkgdest} PKGEXT=${PKGEXT} CARCH=${tarch} makepkg --packagelist) fi sudo librechroot -n "dbscripts@${tarch}" run bash -c "$(printf '%q ' echo "PKGEXT=${PKGEXT@Q}") >> /etc/makepkg.conf" sudo PKGDEST="${pkgdest}" libremakepkg -n "dbscripts@${tarch}" done - pkgnames=($(. PKGBUILD; print_all_package_names)) - pushd ${pkgdest} - for p in ${pkgnames[@]/%/${PKGEXT}}; do + for p in ${pkgfiles[@]}; do # Manually sign packages as "makepkg --sign" is buggy gpg -v --detach-sign --no-armor --use-agent ${p} @@ -55,7 +55,6 @@ __buildPackage() { cp -Lv ${p}{,.sig} ${cache}/ fi done - popd } setup() { diff --git a/test/lib/runserver b/test/lib/runserver new file mode 100755 index 0000000..7705e40 --- /dev/null +++ b/test/lib/runserver @@ -0,0 +1,39 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use IO::Socket::INET; +use Fcntl; + +my $socket = IO::Socket::INET->new( + LocalAddr => "localhost:0", + Listen => 1 +); + +sysopen(my $fh, $ARGV[0], O_WRONLY|O_CREAT|O_EXCL, 0666) or die "open: $ARGV[0]: $!"; +my $pid = fork(); +if ($pid > 0) { + print $fh $pid; + print $socket->sockport()."\n"; + exit; +} +close($fh); +open(STDIN, '</dev/null'); +open(STDOUT, '</dev/null'); + +my @cmd = @ARGV; +shift @cmd; + +while (1) { + my $conn = $socket->accept(); + my $worker = fork(); + if ($worker == 0) { + open(STDIN, '<&', $conn); + open(STDOUT, '>&', $conn); + close($conn); + close($socket); + exec @cmd; + exit + } + close($conn); +} |