From 3b725b58434b92e93ff90164fae8d76c4761706a Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 3 Sep 2017 03:53:39 -0400 Subject: makechrootpkg: Fix unconditionally running namcap Fixes regression in 2fd5931a8c67289a8a4acd327b3ce99a5d64c8c7 $run_namcap will always be set to "" `if $not_a_var; then ...; fi` is always truthful when $not_a_var is unset or equal to "" and the `then` clause will always be run. I'm not sure why global state variables need to be cloned locally for their sole explicit purpose. But for now this patch implements the minimum necessary work to properly pass the "do I want namcap" variable into prepare_chroot() according to the current logic flow. Note that I have still not thorougly tested makechrootpkg. Signed-off-by: Eli Schwartz --- makechrootpkg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 511e519..02c91bc 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -409,7 +409,7 @@ main() { download_sources "$copydir" "$makepkg_user" - prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" + prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" "$run_namcap" if arch-nspawn "$copydir" \ --bind="$PWD:/startdir" \ -- cgit v1.2.3-54-g00ecf From 48b2f8dcc49d88e60bd9e4ee97c92fea8ac90721 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 3 Sep 2017 03:53:40 -0400 Subject: makechrootpkg: Fix anti-pattern when checking for enabled features Don't use error-prone logic e.g. foo=true; if $foo ... This completely fails to act as expected when the variable is unset because of unrelated bugs. While this merely causes the default behavior to be "false" rather than "true" in such cases, it is better to fail to enable explicitly requested behavior (which will be noticed by the user) than to simply upgrade to this behavior for free (which may not seem to have any obvious cause). Signed-off-by: Eli Schwartz --- makechrootpkg.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 02c91bc..c7fe076 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -165,7 +165,7 @@ prepare_chroot() { local keepbuilddir=$3 local run_namcap=$4 - $keepbuilddir || rm -rf "$copydir/build" + [[ $keepbuilddir = true ]] || rm -rf "$copydir/build" local builduser_uid builduser_gid builduser_uid="${SUDO_UID:-$UID}" @@ -208,7 +208,7 @@ EOF declare -p SOURCE_DATE_EPOCH 2>/dev/null printf '_chrootbuild "$@" || exit\n' - if $run_namcap; then + if [[ $run_namcap = true ]]; then declare -f _chrootnamcap printf '_chrootnamcap || exit\n' fi -- cgit v1.2.3-54-g00ecf From c9e287e845973e4c04e21fc513caaea4907e604e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 15 Jan 2018 17:57:00 +0100 Subject: arch-nspawn: make sure that makepkg.conf is always parsed as text https://lists.parabola.nu/pipermail/dev/2017-June/005576.html --- arch-nspawn.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index c55f498..3949ee1 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -107,7 +107,7 @@ fi build_mount_args copy_hostconf -eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")" +eval "$(grep -a '^CARCH=' "$working_dir/etc/makepkg.conf")" [[ -z $nosetarch ]] || unset CARCH -- cgit v1.2.3-54-g00ecf From 5ab8f8430a2c865656cd800c03ac21cb17a86d3c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 15 Jan 2018 17:57:00 +0100 Subject: arch-nspawn: Remove pointless $(echo ...) subshell --- arch-nspawn.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index 3949ee1..7a7a274 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -91,7 +91,7 @@ copy_hostconf () { cp -T "$file" "$working_dir$file" done - sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n "${cache_dirs[@]}")|g" -i "$working_dir/etc/pacman.conf" + sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${cache_dirs[*]}|g" -i "$working_dir/etc/pacman.conf" } # }}} -- cgit v1.2.3-54-g00ecf From aee72cae3231811058d6993d71f97e449e477d8f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 15 Jan 2018 17:57:00 +0100 Subject: lib/common.sh: Adjust to work properly with `set -u` Support for working with `set -u` was broken by 94160d6. Egg on my face; I'm the one who wants `set -u` support, and I'm the author of that commit! libmakepkg does not work with `set -u`; but mostly because of the include guards! So we just need to temporarily disable `set -u` (nounset) while loading libmakepkg. Instead of introducing a new variable, just store the initial nounset status in _INCLUDE_COMMON_SH; rather than a useless fixed-string "true". While we're at it, disable POSIX-mode (just in case we're running as "sh" instead of "bash"), since libmakepkg uses bash-isms that won't parse in POSIX mode. --- lib/common.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/common.sh b/lib/common.sh index a3c2ec2..821f8df 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -4,10 +4,12 @@ # License: Unspecified [[ -z ${_INCLUDE_COMMON_SH:-} ]] || return 0 -_INCLUDE_COMMON_SH=true +_INCLUDE_COMMON_SH="$(set +o|grep nounset)" +set +u +o posix # shellcheck disable=1091 . /usr/share/makepkg/util.sh +$_INCLUDE_COMMON_SH # Avoid any encoding problems export LANG=C -- cgit v1.2.3-54-g00ecf From 75ad2aca572d36c4df1b07153e2403534fbd89ed Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 15 Jan 2018 17:57:00 +0100 Subject: makechrootpkg: Adjust to work properly with `set -e` This worked properly until eab5aba. --- makechrootpkg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index c7fe076..a6c54cc 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -205,7 +205,7 @@ EOF { printf '#!/bin/bash\n' declare -f _chrootbuild - declare -p SOURCE_DATE_EPOCH 2>/dev/null + declare -p SOURCE_DATE_EPOCH 2>/dev/null || true printf '_chrootbuild "$@" || exit\n' if [[ $run_namcap = true ]]; then -- cgit v1.2.3-54-g00ecf From 38c7a391b043547b946a99731a56a233458ba7a2 Mon Sep 17 00:00:00 2001 From: Bartłomiej Piotrowski Date: Sun, 21 Jan 2018 14:18:43 +0100 Subject: makechrootpkg: make sure that makepkg.conf is always parsed as text --- makechrootpkg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index a6c54cc..afcd121 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -69,7 +69,7 @@ load_vars() { [[ -f $makepkg_conf ]] || return 1 for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do - [[ -z ${!var:-} ]] && eval "$(grep "^${var}=" "$makepkg_conf")" + [[ -z ${!var:-} ]] && eval "$(grep -a "^${var}=" "$makepkg_conf")" done return 0 -- cgit v1.2.3-54-g00ecf From ab3368f06182cc3f11f672e63ad18f174ba58e02 Mon Sep 17 00:00:00 2001 From: Bartłomiej Piotrowski Date: Sat, 24 Mar 2018 20:35:09 +0100 Subject: Remove corepkg symlink While still possible with 'commitpkg core', there is a chance it will prevent accidental pushes straight to [core]. --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 1debf53..f69d613 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,6 @@ CONFIGFILES = \ COMMITPKG_LINKS = \ extrapkg \ - corepkg \ testingpkg \ stagingpkg \ communitypkg \ -- cgit v1.2.3-54-g00ecf From ffb5003fdacaece3540ba167f7e965a122133af0 Mon Sep 17 00:00:00 2001 From: Emiel Wiedijk Date: Tue, 27 Feb 2018 11:16:24 -0500 Subject: makechrootpkg: respect GNUPGHOME Previously, makechrootpkg hardcoded ~/.gnupg. Therefore, if a user uses a custom GPG home directory, the siganture checking would fail. Now makechrootpkg uses $GNUPGHOME, with a fallback to ~/.gnupg. Signed-off-by: Emiel Wiedijk --- makechrootpkg.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index afcd121..653847f 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -252,7 +252,8 @@ download_sources() { chmod 1777 "$builddir" # Ensure sources are downloaded - sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ + sudo -u "$makepkg_user" --preserve-env=GNUPGHOME \ + env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || die "Could not download sources." @@ -341,7 +342,7 @@ main() { [[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.' makepkg_user=${makepkg_user:-${SUDO_USER:-$USER}} - check_root SOURCE_DATE_EPOCH + check_root SOURCE_DATE_EPOCH,GNUPGHOME # Canonicalize chrootdir, getting rid of trailing / chrootdir=$(readlink -e "$passeddir") -- cgit v1.2.3-54-g00ecf From 3c7efcfb95f0fe743629552c78ba2a7a513311a9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 3 Jan 2018 00:47:36 -0500 Subject: makechrootpkg: Put "keyserver-options auto-key-retrieve" in gpg.conf This allows signature verification by `makepkg --verifysource`, `git verify-tag`, and such without requiring the user to manually retrieve the keys first. This is based off of devtools32 commit 009695b (2017-06-27) by Erich Eckner . There are 2 differences from that commit: - In this version, gpg.conf is owned by builduser, not by root - In this version, we don't keep appending duplicate lines if we re-use a chroot --- makechrootpkg.in | 1 + 1 file changed, 1 insertion(+) diff --git a/makechrootpkg.in b/makechrootpkg.in index 653847f..54a6c99 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -186,6 +186,7 @@ prepare_chroot() { [[ -r $USER_HOME/$x ]] || continue $install -m 644 "$USER_HOME/$x" "$copydir/build/$x" done + $install -m644 /dev/stdin "$copydir/build/.gnupg/gpg.conf" <<<'keyserver-options auto-key-retrieve' sed -e '/^MAKEFLAGS=/d' -e '/^PACKAGER=/d' -i "$copydir/etc/makepkg.conf" for x in BUILDDIR=/build PKGDEST=/pkgdest SRCPKGDEST=/srcpkgdest SRCDEST=/srcdest LOGDEST=/logdest \ -- cgit v1.2.3-54-g00ecf From 400659c376356794204007ab5665be8559cf4ed0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 9 May 2016 18:37:02 -0400 Subject: arch-nspawn: Message style: two spaces after a period This affects both the usage() text, and the error message if the `/.arch-chroot` version doesn't match. The latter is the one that I really care about, and motivates this change. On Parabola, the `arch-nspawn` program isn't in PATH, it's somewhere under `/usr/lib/`, and gets called as a helper to user-facing programs; and the error message is displayed directly to the user. These programs consistently put two spaces after a period when printing a message to the terminal. --- arch-nspawn.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index 7a7a274..7723241 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -19,7 +19,7 @@ files=() usage() { echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]" - echo "A wrapper around systemd-nspawn. Provides support for pacman." + echo "A wrapper around systemd-nspawn. Provides support for pacman." echo echo ' options:' echo ' -C Location of a pacman config file' @@ -101,7 +101,7 @@ umask 0022 if [[ ! -f "$working_dir/.arch-chroot" ]]; then die "'%s' does not appear to be an Arch chroot." "$working_dir" elif [[ $(cat "$working_dir/.arch-chroot") != "$CHROOT_VERSION" ]]; then - die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$CHROOT_VERSION" + die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$CHROOT_VERSION" fi build_mount_args -- cgit v1.2.3-54-g00ecf From 5e73089e6c1e46f00dea0d5ea808ec19c427ad75 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 15:56:42 -0500 Subject: makechrootpkg: _chrootbuild: Split into _chroot{prepare,build} --- makechrootpkg.in | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 54a6c99..e9859e1 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -203,6 +203,12 @@ EOF # This is a little gross, but this way the script is recreated every time in the # working copy + { + printf '#!/bin/bash\n' + declare -f _chrootprepare + printf '_chrootprepare "$@"\n' + } > "$copydir/chrootprepare" + chmod +x "$copydir/chrootprepare" { printf '#!/bin/bash\n' declare -f _chrootbuild @@ -219,6 +225,20 @@ EOF # These functions aren't run in makechrootpkg, # so no global variables +_chrootprepare() { + # No coredumps + ulimit -c 0 + + # shellcheck source=/dev/null + . /etc/profile + + # Beware, there are some stupid arbitrary rules on how you can + # use "$" in arguments to commands with "sudo -i". ${foo} or + # ${1} is OK, but $foo or $1 isn't. + # https://bugzilla.sudo.ws/show_bug.cgi?id=765 + sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@" --nobuild' -bash "$@" +} + _chrootbuild() { # No coredumps ulimit -c 0 @@ -230,7 +250,7 @@ _chrootbuild() { # use "$" in arguments to commands with "sudo -i". ${foo} or # ${1} is OK, but $foo or $1 isn't. # https://bugzilla.sudo.ws/show_bug.cgi?id=765 - sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@" + sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@" --noextract --noprepare' -bash "$@" } _chrootnamcap() { @@ -414,6 +434,11 @@ main() { prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" "$run_namcap" if arch-nspawn "$copydir" \ + --bind="$PWD:/startdir" \ + --bind="$SRCDEST:/srcdest" \ + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + /chrootprepare "${makepkg_args[@]}" && + arch-nspawn "$copydir" \ --bind="$PWD:/startdir" \ --bind="$SRCDEST:/srcdest" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ -- cgit v1.2.3-54-g00ecf From f2ce2d578e61fdc07c7e41e04eb691a347775c91 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 10 May 2016 13:44:46 -0400 Subject: arch-nspawn: Add a table of CARCH/setarch overrides The table is just armv7h->armv7l for now. --- arch-nspawn.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch-nspawn.in b/arch-nspawn.in index 7723241..028191b 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -108,6 +108,9 @@ build_mount_args copy_hostconf eval "$(grep -a '^CARCH=' "$working_dir/etc/makepkg.conf")" +case "$CARCH" in + armv7h) CARCH=armv7l;; +esac [[ -z $nosetarch ]] || unset CARCH -- cgit v1.2.3-54-g00ecf From bef1b9f35ce6744c2a0bbc32f606e7bef700ffdc Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:40:06 -0500 Subject: makechrootpkg, arch-nspawn: Force-enable local '/repo/' repository The change in arch-nspawn is subtle: This was the source of "infamous" "it fails every other time" bug that took me over a year to solve. By having a repository of local packages (rather than simply running `pacman -U`), we are inviting pacman to cache them in `/var/cache/pacman/pkg`. Besides being needless disk writes, this actually causes a real issue. If the package gets rebuilt, pacman will balk, as the file no longer matches the cached signature. So, how do we prevent pacman from caching these local packages? Simple: include the directory they are already in in the pacman.conf:CacheDir list. This will prevent pacman from copying the files to one of the other cache directories. --- arch-nspawn.in | 1 + makechrootpkg.in | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch-nspawn.in b/arch-nspawn.in index 028191b..c448056 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -105,6 +105,7 @@ elif [[ $(cat "$working_dir/.arch-chroot") != "$CHROOT_VERSION" ]]; then fi build_mount_args +cache_dirs+=('/repo/') copy_hostconf eval "$(grep -a '^CARCH=' "$working_dir/etc/makepkg.conf")" diff --git a/makechrootpkg.in b/makechrootpkg.in index e9859e1..0c21ed5 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -201,6 +201,19 @@ builduser ALL = NOPASSWD: /usr/bin/pacman EOF chmod 440 "$copydir/etc/sudoers.d/builduser-pacman" + if ! grep -q '^\[repo\]' "$copydir/etc/pacman.conf"; then + local line + line=$(grep -n '^\[' "$copydir/etc/pacman.conf" |grep -Fv ':[options]'|sed 's/:.*//;1q') + local ins='[repo] +SigLevel = Optional TrustAll +Server = file:///repo +' + sed -i "${line}i${ins//$'\n'/\\n}" "$copydir/etc/pacman.conf" + fi + # Avoid having to use `pacman -Sy` to update [repo], as + # networking might be disabled inside of the chroot. + cp "$copydir/repo/repo.db" "$copydir/var/lib/pacman/sync/repo.db" + # This is a little gross, but this way the script is recreated every time in the # working copy { -- cgit v1.2.3-54-g00ecf From ce1ff66a37a0420015eefaa8270a3877f662f4d3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 May 2013 15:12:42 -0400 Subject: lib/common.sh: Internationalize 2017-02-15: (070092d) Import from libretools. 2017-02-19: (7c55e79) Tidy formatting (2018-01-02: erroneously removing newlines that had been added to avoid confusing xgettext). 2017-05-05: (c4d5957) Don't say "local var" and "var=$(subshell)" in the same command (shellcheck complains about this). 2017-09-24: Update to work with loading the message functions from /usr/share/makepkg/util.sh 2018-01-02: Avoid confusing xgettext. --- lib/common.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 821f8df..6d6515c 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -11,8 +11,22 @@ set +u +o posix . /usr/share/makepkg/util.sh $_INCLUDE_COMMON_SH -# Avoid any encoding problems -export LANG=C +[[ -n ${TEXTDOMAIN:-} ]] || export TEXTDOMAIN='libretools' +[[ -n ${TEXTDOMAINDIR:-} ]] || export TEXTDOMAINDIR='/usr/share/locale' + +if type gettext &>/dev/null; then + _() { gettext "$@"; } +else + _() { echo "$@"; } +fi + +_l() { + TEXTDOMAIN='librelib' TEXTDOMAINDIR='/usr/share/locale' "$@" +} + +_p() { + TEXTDOMAIN='pacman-scripts' TEXTDOMAINDIR='/usr/share/locale' "$@" +} shopt -s extglob @@ -24,15 +38,36 @@ else declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW='' fi +# makepkg message functions expect gettext to already be called; like +# `msg "$(gettext 'Hello World')"`. Where libretools expects the +# message functions to call gettext. So, we'll do some magic to wrap +# the makepkg versions. +eval "$( + fns=( + plain + msg + msg2 + warning + error + ) + + # declare _makepkg_${fn} as a copy of ${fn} + declare -f "${fns[@]}" | sed 's/^[a-z]/_makepkg_&/' + + # re-declare ${fn} as a wrapper around _makepkg_${fn} + printf '%s() { local mesg; mesg="$(_ "$1")"; _p _makepkg_"${FUNCNAME[0]}" "$mesg" "${@:2}"; }\n' \ + "${fns[@]}" +)" + stat_busy() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2 } stat_done() { # shellcheck disable=2059 - printf "${BOLD}done${ALL_OFF}\n" >&2 + printf "${BOLD}$(_l _ "done")${ALL_OFF}\n" >&2 } _setup_workdir=false @@ -51,7 +86,7 @@ cleanup() { } abort() { - error 'Aborting...' + _l error 'Aborting...' cleanup 255 } @@ -74,7 +109,8 @@ die() { ## # usage : lock( $fd, $file, $message, [ $message_arguments... ] ) ## -lock() { +lock() # newline here to avoid confusing xgettext +{ # Only reopen the FD if it wasn't handed to us if ! [[ "/dev/fd/$1" -ef "$2" ]]; then mkdir -p -- "$(dirname -- "$2")" @@ -91,7 +127,8 @@ lock() { ## # usage : slock( $fd, $file, $message, [ $message_arguments... ] ) ## -slock() { +slock() # newline here to avoid confusing xgettext +{ # Only reopen the FD if it wasn't handed to us if ! [[ "/dev/fd/$1" -ef "$2" ]]; then mkdir -p -- "$(dirname -- "$2")" @@ -179,7 +216,7 @@ find_cached_package() { return 0 ;; *) - error 'Multiple packages found:' + _l error 'Multiple packages found:' printf '\t%s\n' "${results[@]}" >&2 return 1 esac -- cgit v1.2.3-54-g00ecf From bae0e4d364084d8370647c5608bebfff25350726 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:42:06 -0500 Subject: checkpkg, find-libdeps, finddeps, lddd: Use libremessages to add help text --- checkpkg.in | 27 +++++++++++++++++++++++++-- find-libdeps.in | 28 ++++++++++++++++++++++++---- finddeps.in | 18 ++++++++++++------ lddd.in | 18 +++++++++++++++++- 4 files changed, 78 insertions(+), 13 deletions(-) diff --git a/checkpkg.in b/checkpkg.in index e0e1f83..cfec71e 100644 --- a/checkpkg.in +++ b/checkpkg.in @@ -3,7 +3,28 @@ shopt -s extglob -m4_include(lib/common.sh) +. "$(librelib messages)" + +usage() { + print 'Usage: %s [-h]' "${0##*/}" + print 'Compare a locally built a package with the one in the repositories.' + echo + prose 'This should be run from a directory containing a + PKGBUILD. It searches for a locally built package + corresponding to the PKGBUILD, and downloads the last + version of that package from the pacman repositories. + It then compares the list of .so files provided by each + version of the package. It does this for each part of + a split package.' +} + +if [[ $1 = '-h' ]]; then + usage + exit 0 +elif [[ $# -gt 0 ]]; then + usage >&2 + exit 1 +fi # Source makepkg.conf; fail if it is not found if [[ -r '/etc/makepkg.conf' ]]; then @@ -23,7 +44,9 @@ elif [[ -r "$HOME/.makepkg.conf" ]]; then fi if [[ ! -f PKGBUILD ]]; then - die 'This must be run in the directory of a built package.' + error 'This must be run in the directory of a built package.' + usage >&2 + exit 1 fi # shellcheck source=PKGBUILD.proto diff --git a/find-libdeps.in b/find-libdeps.in index 1fb1fdf..cb68237 100644 --- a/find-libdeps.in +++ b/find-libdeps.in @@ -1,7 +1,7 @@ #!/bin/bash # License: Unspecified -m4_include(lib/common.sh) +. "$(librelib messages)" set -e shopt -s extglob @@ -20,12 +20,32 @@ case $script_mode in *) die "Unknown mode %s" "$script_mode" ;; esac +usage() { + print "Usage: find-lib(deps|provides) [options] " + print "Find library dependencies or provides of a package." + echo + prose 'Prints a list of library dependencies in the format:' + echo + print ' =-' + echo + prose "Where is the shared library version, or + repeated if there is no version attached; and + is the architecture of the library (either \`32\` + or \`64\`, based on the ELF Class)." + echo + print "Options:" + flag "--ignore-internal" "Ignore internal libraries; libraries + without a version attached" + flag "-h" "Show this message" +} if [[ -z $1 ]]; then - echo "${0##*/} [options] " - echo "Options:" - echo " --ignore-internal ignore internal libraries" + usage >&2 exit 1 fi +if [[ $1 = '-h' ]]; then + usage + exit 0 +fi if [[ -d $1 ]]; then pushd "$1" >/dev/null diff --git a/finddeps.in b/finddeps.in index 2a085e5..5f89b55 100644 --- a/finddeps.in +++ b/finddeps.in @@ -4,18 +4,24 @@ # # License: Unspecified -m4_include(lib/common.sh) +. "$(librelib messages)" match=$1 +usage() { + print 'Usage: %s ' "${0##*/}" + print 'Find packages that depend on a given depname.' + echo + prose 'Run this script from the top-level directory of your ABS tree.' +} if [[ -z $match ]]; then - echo 'Usage: finddeps ' - echo '' - echo 'Find packages that depend on a given depname.' - echo 'Run this script from the top-level directory of your ABS tree.' - echo '' + usage >&2 exit 1 fi +if [[ $match = '-h' ]]; then + usage + exit 0 +fi find . -type d | while read -r d; do if [[ -f "$d/PKGBUILD" ]]; then diff --git a/lddd.in b/lddd.in index 908923b..4c6871c 100644 --- a/lddd.in +++ b/lddd.in @@ -4,7 +4,23 @@ # # License: Unspecified -m4_include(lib/common.sh) +. "$(librelib messages)" + +usage() { + print "Usage: %s [-h]" "${0##*/}" + print "Find broken library links on your machine." + echo + prose "Scans \$PATH and library directories for ELF files with + references to missing shared libraries." +} + +if [[ $1 = '-h' ]]; then + usage + exit 0 +elif [[ $# -gt 0 ]]; then + usage >&2 + exit 1 +fi ifs=$IFS IFS="${IFS}:" -- cgit v1.2.3-54-g00ecf From 4c66bcbcf6bc2bdd34fdf650ff57af8e5dc58e11 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 18:50:04 -0500 Subject: lib/common.sh: Discourage use in favor of libremessages --- lib/common.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/common.sh b/lib/common.sh index 6d6515c..0b1dc59 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,6 +1,9 @@ #!/hint/bash # This may be included with or without `set -euE` +# This file is included by libremessages. +# You should probably use libremessages instead of this. + # License: Unspecified [[ -z ${_INCLUDE_COMMON_SH:-} ]] || return 0 -- cgit v1.2.3-54-g00ecf From 21295553ad1d110050359b2d20257533d9bb7d44 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 18:50:27 -0500 Subject: mkarchroot: Use librelib rather than PATH to find arch-nspawn --- mkarchroot.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkarchroot.in b/mkarchroot.in index 52e363f..5165960 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -92,7 +92,7 @@ echo "$CHROOT_VERSION" > "$working_dir/.arch-chroot" systemd-machine-id-setup --root="$working_dir" -exec arch-nspawn \ +exec "$(librelib chroot/arch-nspawn)" \ ${nosetarch:+-s} \ ${pac_conf:+-C "$pac_conf"} \ ${makepkg_conf:+-M "$makepkg_conf"} \ -- cgit v1.2.3-54-g00ecf From 4785073727971d575375c193c882f38231849f5e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 20 Apr 2017 13:49:19 -0400 Subject: makechrootpkg: Also build --allsource packages It also sets SRCEXT="-$pkgarch$SRCEXT", so that two runs of makechrootpkg on different architectures don't overwrite eachothers source packages. --- makechrootpkg.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/makechrootpkg.in b/makechrootpkg.in index 0c21ed5..b594de2 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -259,10 +259,25 @@ _chrootbuild() { # shellcheck source=/dev/null . /etc/profile + local srcext + srcext="$( + # shellcheck source=makepkg-x86_64.conf + . /etc/makepkg.conf || exit + # shellcheck source=PKGBUILD.proto + . /startdir/PKGBUILD || exit + if [ "$arch" = any ]; then + pkgarch=any + else + pkgarch=$CARCH + fi + printf '%s\n' "-$pkgarch$SRCEXT" + )" || return + # Beware, there are some stupid arbitrary rules on how you can # use "$" in arguments to commands with "sudo -i". ${foo} or # ${1} is OK, but $foo or $1 isn't. # https://bugzilla.sudo.ws/show_bug.cgi?id=765 + sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; SRCEXT="${1}" makepkg "${@:2}" --allsource' -bash "$srcext" "$@" || return sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@" --noextract --noprepare' -bash "$@" } -- cgit v1.2.3-54-g00ecf From 1ce1c85402a8dab1dfe629628af50438d4054b79 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 5 May 2017 13:12:32 -0400 Subject: common.sh: Add a find_cached_srcpackage counterpart to find_cached_package --- lib/common.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/common.sh b/lib/common.sh index 0b1dc59..ac42b00 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -224,3 +224,60 @@ find_cached_package() { return 1 esac } + +## +# usage: find_cached_srcpackage( $pkgname, $pkgver, $arch ) +# +# $pkgver can be supplied with or without a pkgrel appended. +# If not supplied, any pkgrel will be matched. +## +find_cached_srcpackage() { + local searchdirs=("$PWD" "$SRCPKGDEST") results=() + local targetname=$1 targetver=$2 targetarch=$3 + local dir pkg pkgbasename name ver rel arch r results + + for dir in "${searchdirs[@]}"; do + [[ -d $dir ]] || continue + + for pkg in "$dir"/*.src.tar?(.?z); do + [[ -f $pkg ]] || continue + + # avoid adding duplicates of the same inode + for r in "${results[@]}"; do + [[ $r -ef $pkg ]] && continue 2 + done + + # split apart package filename into parts + pkgbasename=${pkg##*/} + pkgbasename=${pkgbasename%.src.tar?(.?z)} + + arch=${pkgbasename##*-} + pkgbasename=${pkgbasename%-"$arch"} + + rel=${pkgbasename##*-} + pkgbasename=${pkgbasename%-"$rel"} + + ver=${pkgbasename##*-} + name=${pkgbasename%-"$ver"} + + if [[ $targetname = "$name" && $targetarch = "$arch" ]] && + pkgver_equal "$targetver" "$ver-$rel"; then + results+=("$pkg") + fi + done + done + + case ${#results[*]} in + 0) + return 1 + ;; + 1) + printf '%s\n' "${results[0]}" + return 0 + ;; + *) + _l error 'Multiple packages found:' + printf '\t%s\n' "${results[@]}" >&2 + return 1 + esac +} -- cgit v1.2.3-54-g00ecf