From a8f512a665f294657279c6823ff23887dd41a8d5 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 13 Jul 2017 19:37:15 +0200 Subject: makechrootpkg: Move makepkg-as-root check to main() download_sources(), while the first invocation of makepkg, is a rather odd place for this kind of guard. --- makechrootpkg.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 246774a..23314c6 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -271,14 +271,9 @@ download_sources() { chmod 1777 "$builddir" # Ensure sources are downloaded - if [[ "$(id -u "$makepkg_user")" != 0 ]]; then - sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ - makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || - die "Could not download sources." - else - error "Running makepkg as root is not allowed." - exit 1 - fi + sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ + makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o || + die "Could not download sources." # Clean up garbage from verifysource rm -rf "$builddir" @@ -406,6 +401,11 @@ main() { [[ -f PKGBUILD ]] || return $ret fi + if [[ "$(id -u "$makepkg_user")" == 0 ]]; then + error "Running makepkg as root is not allowed." + exit 1 + fi + download_sources "$copydir" "$makepkg_user" prepare_chroot "$copydir" "$USER_HOME" "$repack" -- cgit v1.2.3-54-g00ecf From 0cbc179d212d7a26f8c6c2dcd589726cc20d1022 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 13 Jul 2017 19:42:01 +0200 Subject: makechrootpkg: Use long args for makepkg Slightly more verbose, but also more understandable. --- makechrootpkg.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 23314c6..63e6b10 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -16,7 +16,7 @@ m4_include(lib/archroot.sh) shopt -s nullglob init_variables() { - default_makepkg_args=(-s --noconfirm -L --holdver) + default_makepkg_args=(--syncdeps --noconfirm --log --holdver) makepkg_args=("${default_makepkg_args[@]}") repack=false update_first=false @@ -329,7 +329,7 @@ main() { r) passeddir="$OPTARG" ;; I) install_pkgs+=("$OPTARG") ;; l) copy="$OPTARG" ;; - n) run_namcap=true; makepkg_args+=(-i) ;; + n) run_namcap=true; makepkg_args+=(--install) ;; T) temp_chroot=true; copy+="-$$" ;; U) makepkg_user="$OPTARG" ;; h|*) usage ;; -- cgit v1.2.3-54-g00ecf From 75fdff1811a0487f82c75b2e260da905102b4eea Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 13 Jul 2017 19:43:52 +0200 Subject: makechrootpkg: Skip integrity checks inside the chroot We've already done these during download_sources(). --- makechrootpkg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 63e6b10..8d8fd05 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -16,7 +16,7 @@ m4_include(lib/archroot.sh) shopt -s nullglob init_variables() { - default_makepkg_args=(--syncdeps --noconfirm --log --holdver) + default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg) makepkg_args=("${default_makepkg_args[@]}") repack=false update_first=false -- cgit v1.2.3-54-g00ecf From 57151348843446141b90a4af365416d39bdcbbc2 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Sun, 13 Aug 2017 01:24:11 +0200 Subject: Version 20170813 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9549569..753400f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -V=20170320 +V=20170813 PREFIX = /usr/local -- cgit v1.2.3-54-g00ecf From 000ea6c7bbf6191bd284468dde4eb352757e84df Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 24 Aug 2017 17:03:32 +0200 Subject: arch-nspawn: Add --keep-unit to prevent scope conflicts --- arch-nspawn.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index c21b2ce..0cdaf6b 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -113,6 +113,6 @@ eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")" exec ${CARCH:+setarch "$CARCH"} systemd-nspawn -q \ -D "$working_dir" \ - --register=no \ + --register=no --keep-unit \ "${mount_args[@]}" \ "$@" -- cgit v1.2.3-54-g00ecf From d0e684d2e998a9e7f241dc641c1f5273dba71036 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 22 Aug 2017 00:30:17 +0200 Subject: makechrootpkg: Prevent removing build dir when --noextract specified --- makechrootpkg.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 8d8fd05..f8815d8 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -18,7 +18,7 @@ shopt -s nullglob init_variables() { default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg) makepkg_args=("${default_makepkg_args[@]}") - repack=false + keepbuilddir=false update_first=false clean_first=false run_namcap=false @@ -178,17 +178,17 @@ install_packages() { return $ret } -# Usage: prepare_chroot $copydir $HOME $repack $run_namcap +# Usage: prepare_chroot $copydir $HOME $keepbuilddir $run_namcap # Globals: # - MAKEFLAGS # - PACKAGER prepare_chroot() { local copydir=$1 local USER_HOME=$2 - local repack=$3 + local keepbuilddir=$3 local run_namcap=$4 - $repack || rm -rf "$copydir/build" + $keepbuilddir || rm -rf "$copydir/build" local builduser_uid builduser_gid builduser_uid="${SUDO_UID:-$UID}" @@ -359,8 +359,8 @@ main() { # See if -R was passed to makepkg for arg in "${@:OPTIND}"; do case ${arg%%=*} in - -*R*|--repackage) - repack=true + -*R*|--repackage|--noextract) + keepbuilddir=true break 2 ;; esac @@ -408,7 +408,7 @@ main() { download_sources "$copydir" "$makepkg_user" - prepare_chroot "$copydir" "$USER_HOME" "$repack" + prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" if arch-nspawn "$copydir" \ --bind="$PWD:/startdir" \ -- cgit v1.2.3-54-g00ecf From bd826752c9dc8f01917ee831302b6220ad09603a Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 24 Aug 2017 17:07:23 +0200 Subject: makechrootpkg: Also look for -e as --noextract --- makechrootpkg.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index f8815d8..ef3f2ec 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -356,13 +356,13 @@ main() { # Pass all arguments after -- right to makepkg makepkg_args+=("${@:$OPTIND}") - # See if -R was passed to makepkg - for arg in "${@:OPTIND}"; do + # See if -R or -e was passed to makepkg + for arg in "${makepkg_args[@]}"; do case ${arg%%=*} in - -*R*|--repackage|--noextract) - keepbuilddir=true - break 2 - ;; + --repackage|--noextract) keepbuilddir=true; break ;; + --repackage|--noextract) keepbuilddir=true; break ;; + --*) ;; + -*R*|-*e*) keepbuilddir=true; break ;; esac done -- cgit v1.2.3-54-g00ecf From fecf107c37062323cf77e08be7d2192e05cb6255 Mon Sep 17 00:00:00 2001 From: Sébastien Luttringer Date: Wed, 6 Sep 2017 23:27:50 +0200 Subject: arch-nspawn: Force PATH to be the Arch default systemd-nspawn use a default environ PATH value of: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Since filesystem 2017.08, this is no more overrided by /etc/profile to the Arch default: PATH=/usr/local/sbin:/usr/local/bin:/usr/bin --- arch-nspawn.in | 1 + 1 file changed, 1 insertion(+) diff --git a/arch-nspawn.in b/arch-nspawn.in index 0cdaf6b..5205bf4 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -113,6 +113,7 @@ eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")" exec ${CARCH:+setarch "$CARCH"} systemd-nspawn -q \ -D "$working_dir" \ + -E "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin" \ --register=no --keep-unit \ "${mount_args[@]}" \ "$@" -- cgit v1.2.3-54-g00ecf From 5ebb9c16c055747e0501ac58b4cb05c20b8f7439 Mon Sep 17 00:00:00 2001 From: Sébastien Luttringer Date: Mon, 11 Sep 2017 21:26:07 +0200 Subject: Version 20170911 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 753400f..4846aec 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -V=20170813 +V=20170911 PREFIX = /usr/local -- cgit v1.2.3-54-g00ecf From 567cbc89da1f056d0cf77b3c967d649359666524 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 5205bf4..bca969c 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 d64d8a2c5be00eae82e1b7a1662be10ff7f0e2ee 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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index ef3f2ec..57de79e 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -225,6 +225,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 @@ -240,6 +246,16 @@ EOF # These functions aren't run in makechrootpkg, # so no global variables +_chrootprepare() { + # 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 -iu builduser bash -c 'cd /startdir; makepkg "$@" --nobuild' -bash "$@" +} + _chrootbuild() { # shellcheck source=/dev/null . /etc/profile @@ -247,7 +263,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 -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@" + sudo -iu builduser bash -c 'cd /startdir; makepkg "$@" --noextract --noprepare' -bash "$@" } _chrootnamcap() { @@ -411,6 +427,11 @@ main() { prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" 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 a3fa0dbe24f362fe38b1016a9f44bf83c6a11071 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 bca969c..92ca07c 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -108,6 +108,9 @@ build_mount_args copy_hostconf eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")" +case "$CARCH" in + armv7h) CARCH=armv7l;; +esac [[ -z $nosetarch ]] || unset CARCH -- cgit v1.2.3-54-g00ecf From 054f53ceb65c28adc75f84494e5204b78413d63a 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 92ca07c..ebb9f4d 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 '^CARCH=' "$working_dir/etc/makepkg.conf")" diff --git a/makechrootpkg.in b/makechrootpkg.in index 57de79e..41c0c62 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -223,6 +223,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 332a91b8f623f07c002dedb1da3645903d4c1ab7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 2 May 2013 15:12:42 -0400 Subject: lib/common.sh: Internationalize. --- lib/common.sh | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 0fb93d9..c3c3454 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -6,8 +6,18 @@ [[ -z ${_INCLUDE_COMMON_SH:-} ]] || return 0 _INCLUDE_COMMON_SH=true -# 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' "$@" +} shopt -s extglob @@ -34,44 +44,44 @@ fi readonly ALL_OFF BOLD BLUE GREEN RED YELLOW plain() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg2() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } warning() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } error() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 @@ -90,7 +100,7 @@ cleanup() { } abort() { - error 'Aborting...' + _l error 'Aborting...' cleanup 255 } @@ -263,7 +273,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 c190fb59fa14af1baf7313b67f37202951fabf64 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 7f80af82f052cd3ddc79bc519b2e7f5d6a0fc593 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 c3c3454..ed98449 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 baecea05d676ca5b2964b031c37de5414a26ae29 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 14984ae4cc613f63c69f2437a2d915b5a7d818c5 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/makechrootpkg.in b/makechrootpkg.in index 41c0c62..5511002 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -272,10 +272,24 @@ _chrootprepare() { _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 -iu builduser bash -c 'cd /startdir; SRCEXT="${1}" makepkg "${@:2}" --allsource' -bash "$srcext" "$@" || return sudo -iu builduser bash -c 'cd /startdir; makepkg "$@" --noextract --noprepare' -bash "$@" } -- cgit v1.2.3-54-g00ecf From cbfe74c814437f93b0d9b983f740104a7e303049 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 ed98449..118a06c 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -281,3 +281,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 From 2277bec07b9f4aff10d918b3c054adf74a16005f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Jul 2017 11:43:26 -0400 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 ebb9f4d..a225c1a 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -108,7 +108,7 @@ build_mount_args cache_dirs+=('/repo/') copy_hostconf -eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")" +eval "$(grep -a '^CARCH=' "$working_dir/etc/makepkg.conf")" case "$CARCH" in armv7h) CARCH=armv7l;; esac -- cgit v1.2.3-54-g00ecf