From f1ed4b1d81dcaa04bfdf49e36f3b5e3cc5dfa338 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:29:19 -0500 Subject: lib/common.sh: Make it safe to include multiple times. This is similar to common C #ifdef guards. I was tempted to wrap the entire thing in the if/fi (rather than use 'return' to bail early. However, that means it won't execute anything until after it reaches 'fi'. And if `shopt -s extglob` isn't executed before parsing, then it will syntax-error on the extended globs. One solution would have been to move `shopt -s extglob` up above the include-guard. But the committed solution is all-around simpler. --- lib/common.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/common.sh b/lib/common.sh index 62f4e72..33f9552 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,5 +1,11 @@ +#!/hint/bash +# This may be included with or without `set -euE` + # License: Unspecified +[[ -z ${_INCLUDE_COMMON_SH:-} ]] || return 0 +_INCLUDE_COMMON_SH=true + # Avoid any encoding problems export LANG=C -- cgit v1.2.3-54-g00ecf From e1ca5a0bc28697c545b619fe1f07bc6145ef5c38 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:37:10 -0500 Subject: mkarchroot, arch-nspawn: Add an `-f` flag to add files to copy. This allows us to copy in files like `qemu-arm-static`, which is necessary for running an ARM chroot on an x86 box. --- arch-nspawn.in | 12 +++++++++++- mkarchroot.in | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index fd4c583..19a1a89 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -16,6 +16,8 @@ CHROOT_VERSION='v3' working_dir='' +files=() + usage() { echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]" echo "A wrapper around systemd-nspawn. Provides support for pacman." @@ -24,17 +26,19 @@ usage() { echo ' -C Location of a pacman config file' echo ' -M Location of a makepkg config file' echo ' -c Set pacman cache' + echo ' -f Copy file from the host to the chroot' echo ' -h This message' exit 1 } orig_argv=("$@") -while getopts 'hC:M:c:' arg; do +while getopts 'hC:M:c:f:' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; + f) files+=("$OPTARG") ;; h|?) usage ;; *) error "invalid argument '%s'" "$arg"; usage ;; esac @@ -80,6 +84,12 @@ copy_hostconf () { [[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf" [[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf" + local file + for file in "${files[@]}"; do + mkdir -p "$(dirname "$working_dir$file")" + cp -T "$file" "$working_dir$file" + done + sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf" } # }}} diff --git a/mkarchroot.in b/mkarchroot.in index 656c74e..8499ed1 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -16,23 +16,27 @@ CHROOT_VERSION='v3' working_dir='' +files=() + usage() { echo "Usage: ${0##*/} [options] working-dir package-list..." echo ' options:' echo ' -C Location of a pacman config file' echo ' -M Location of a makepkg config file' echo ' -c Set pacman cache' + echo ' -f Copy file from the host to the chroot' echo ' -h This message' exit 1 } orig_argv=("$@") -while getopts 'hC:M:c:' arg; do +while getopts 'hC:M:c:f:' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; + f) files+=("$OPTARG") ;; h|?) usage ;; *) error "invalid argument '%s'" "$arg"; usage ;; esac @@ -70,6 +74,11 @@ if [[ $(stat -f -c %T "$working_dir") == btrfs ]]; then chmod 0755 "$working_dir" fi +for file in "${files[@]}"; do + mkdir -p "$(dirname "$working_dir$file")" + cp "$file" "$working_dir$file" +done + pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \ "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages' -- cgit v1.2.3-54-g00ecf From df3eee40d3ff0a6c8532a1d19bad25d057330cd2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:39:25 -0500 Subject: mkarchroot, arch-nspawn: Add an `-s` flag to inhibit `setarch`. This allows us to run an ARM chroot on an x86 box; as the binfmt runner will set the architecture for us, and the x86 `/usr/bin/setarch` program won't know about the ARM architecture string. --- arch-nspawn.in | 6 +++++- mkarchroot.in | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index 19a1a89..ea6e5ea 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -27,18 +27,20 @@ usage() { echo ' -M Location of a makepkg config file' echo ' -c Set pacman cache' echo ' -f Copy file from the host to the chroot' + echo ' -s Do not run setarch' echo ' -h This message' exit 1 } orig_argv=("$@") -while getopts 'hC:M:c:f:' arg; do +while getopts 'hC:M:c:f:s' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; f) files+=("$OPTARG") ;; + s) nosetarch=1 ;; h|?) usage ;; *) error "invalid argument '%s'" "$arg"; usage ;; esac @@ -111,6 +113,8 @@ case "$CARCH" in armv7h) CARCH=armv7l;; esac +[[ -z $nosetarch ]] || unset CARCH + exec ${CARCH:+setarch "$CARCH"} systemd-nspawn -q \ -D "$working_dir" \ --register=no \ diff --git a/mkarchroot.in b/mkarchroot.in index 8499ed1..4cf8e56 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -25,18 +25,20 @@ usage() { echo ' -M Location of a makepkg config file' echo ' -c Set pacman cache' echo ' -f Copy file from the host to the chroot' + echo ' -s Do not run setarch' echo ' -h This message' exit 1 } orig_argv=("$@") -while getopts 'hC:M:c:f:' arg; do +while getopts 'hC:M:c:f:s' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; f) files+=("$OPTARG") ;; + s) nosetarch=1 ;; h|?) usage ;; *) error "invalid argument '%s'" "$arg"; usage ;; esac @@ -89,6 +91,7 @@ echo "$CHROOT_VERSION" > "$working_dir/.arch-chroot" systemd-machine-id-setup --root="$working_dir" exec arch-nspawn \ + ${nosetarch:+-s} \ ${pac_conf:+-C "$pac_conf"} \ ${makepkg_conf:+-M "$makepkg_conf"} \ ${cache_dir:+-c "$cache_dir"} \ -- cgit v1.2.3-54-g00ecf From 2c504b8edc4f5ffde99323a65442675402cbd83b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 15:00:12 -0500 Subject: mkarchroot: Don't let the environment affect pacstrap (sans proxy settings). A previous iteration of this change (libretools commit d7dcce53396d) simply inserted `env -i` to clear the environment. However, that lead to it ignoring proxy settings, which some users had problems with: https://labs.parabola.nu/issues/487: > To fix other bugs, the pacstrap environment is blank, which also > means that the proxy settings are blank. So (in libretools commit d17d1d82349f), I changed it to use `declare -x` to inspect the environment, and create a version of it only consisting of variables ending with "_proxy" (case-insensitive). I honestly don't remember what "other bugs" prompted me to clear the environment in the first place. --- mkarchroot.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mkarchroot.in b/mkarchroot.in index 4cf8e56..4ebafa6 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -81,6 +81,11 @@ for file in "${files[@]}"; do cp "$file" "$working_dir$file" done +_env=() +while read -r varname; do + _env+=("$varname=${!varname}") +done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$') +env -i "${_env[@]}" \ pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \ "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages' -- cgit v1.2.3-54-g00ecf From 54749b7fce6d95c1653ca1e2cf0936d1cecc688e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 17:05:37 -0500 Subject: makechrootpkg: Quote directory passed to `rm -rf`. --- makechrootpkg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index fe6cdbe..871537c 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -304,7 +304,7 @@ download_sources() { (( $? != 0 )) && die "Could not download sources." # Clean up garbage from verifysource - rm -rf $builddir + rm -rf "$builddir" } _chrootbuild() { -- cgit v1.2.3-54-g00ecf From 914cf4f45d3dfc3a566e77397a0ef8ed97ad41cc Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 17:06:32 -0500 Subject: makechrootpkg: Improve status messages. --- makechrootpkg.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 871537c..ee4a933 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -144,9 +144,10 @@ create_chroot() { if [[ ! -d $copydir ]] || $clean_first; then # Get a read lock on the root chroot to make # sure we don't clone a half-updated chroot - slock 8 "$chrootdir/root.lock" "Locking clean chroot" + slock 8 "$chrootdir/root.lock" \ + "Locking clean chroot [%s]" "$chrootdir/root" - stat_busy "Creating clean working copy [%s]" "$copy" + stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir" if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then if [[ -d $copydir ]]; then btrfs_subvolume_delete "$copydir" >/dev/null || @@ -169,7 +170,7 @@ create_chroot() { } clean_temporary() { - stat_busy "Removing temporary copy [%s]" "$copy" + stat_busy "Removing chroot copy [%s]" "$copydir" if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then btrfs_subvolume_delete "$copydir" >/dev/null || die "Unable to delete subvolume %s" "$copydir" -- cgit v1.2.3-54-g00ecf From 37eec3ff31c4a709fcd8e21dbf4e53624f0fc2f1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 15:36:21 -0500 Subject: makechrootpkg: Have functions be more function-y. Rather than them simply being named blocks of code with braces around them. That is: have them take things via arguments rather than global variables. Specific notes: - download_sources: Observation: if $SUDO_USER is set, then src_owner=$SUDO_USER. So (for clarity), rather than checking if $SUDO_USER is set, check if $src_owner is different than $USER. This reduces how much we have to worry about global state. - install_packages: 1. Receive the list of packages as arguments, rather than a global variable. 2. Make the caller responsible for looking at PKGBUILD. From the name and arguments, one would never expect it to look at PKGBUILD. - create_chroot->sync_chroot: I pulled the `if [[ ! -d $copydir ]] || $clean_first;` check out; it is now the caller's responsibility to use that check when deciding if to call sync_chroot. --- makechrootpkg.in | 136 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 100 insertions(+), 36 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index ee4a933..970d3e9 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -70,6 +70,14 @@ usage() { } # {{{ functions +# Usage: load_vars $makepkg_conf +# Globals: +# - SRCDEST +# - SRCPKGDEST +# - PKGDEST +# - LOGDEST +# - MAKEFLAGS +# - PACKAGER load_vars() { local makepkg_conf="$1" var @@ -137,39 +145,56 @@ btrfs_subvolume_delete() { btrfs subvolume delete "$dir" } -create_chroot() { - # Lock the chroot we want to use. We'll keep this lock until we exit. - lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" - - if [[ ! -d $copydir ]] || $clean_first; then - # Get a read lock on the root chroot to make - # sure we don't clone a half-updated chroot - slock 8 "$chrootdir/root.lock" \ - "Locking clean chroot [%s]" "$chrootdir/root" - - stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir" - if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then - if [[ -d $copydir ]]; then - btrfs_subvolume_delete "$copydir" >/dev/null || - die "Unable to delete subvolume %s" "$copydir" - fi - btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null || - die "Unable to create subvolume %s" "$copydir" - else - mkdir -p "$copydir" - rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir" - fi - stat_done +# Usage: sync_chroot $CHROOTDIR/$CHROOT <$CHROOTCOPY|$copydir> +# Globals: +# - chroottype +sync_chroot() { + local chrootdir=$1 + local copy=$2 + local copydir='' + if [[ ${copy:0:1} = / ]]; then + copydir=$copy + else + copydir="$chrootdir/$copy" + fi + + if [[ "$chrootdir/root" -ef "$copydir" ]]; then + error 'Cannot sync copy with itself: %s' "$copydir" + return 1 + fi - # Drop the read lock again - lock_close 8 + # Get a read lock on the root chroot to make + # sure we don't clone a half-updated chroot + slock 8 "$chrootdir/root.lock" \ + "Locking clean chroot [%s]" "$chrootdir/root" + + stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir" + if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then + if [[ -d $copydir ]]; then + btrfs_subvolume_delete "$copydir" >/dev/null || + die "Unable to delete subvolume %s" "$copydir" + fi + btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null || + die "Unable to create subvolume %s" "$copydir" + else + mkdir -p "$copydir" + rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir" fi + stat_done + + # Drop the read lock again + lock_close 8 # Update mtime touch "$copydir" } -clean_temporary() { +# Usage: delete_chroot $copydir +# Globals: +# - chroottype +delete_chroot() { + local copydir=$1 + stat_busy "Removing chroot copy [%s]" "$copydir" if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then btrfs_subvolume_delete "$copydir" >/dev/null || @@ -185,9 +210,14 @@ clean_temporary() { stat_done } +# Usage: install_packages $copydir $pkgs... install_packages() { + local copydir=$1 + local install_pkgs=("${@:2}") + declare -i ret=0 local pkgname + local install_pkg for install_pkg in "${install_pkgs[@]}"; do pkgname="${install_pkg##*/}" cp "$install_pkg" "$copydir/$pkgname" @@ -200,11 +230,19 @@ install_packages() { rm "$copydir/$pkgname" done - # If there is no PKGBUILD we are done - [[ -f PKGBUILD ]] || exit $ret + return $ret } +# Usage: prepare_chroot $copydir $HOME $repack $run_namcap +# Globals: +# - MAKEFLAGS +# - PACKAGER prepare_chroot() { + local copydir=$1 + local USER_HOME=$2 + local repack=$3 + local run_namcap=$4 + $repack || rm -rf "$copydir/build" mkdir -p "$copydir/build" @@ -289,13 +327,20 @@ EOF chmod +x "$copydir/chrootbuild" } +# Usage: download_sources $copydir $src_owner +# Globals: +# - SRCDEST +# - USER download_sources() { + local copydir=$1 + local src_owner=$2 + local builddir="$(mktemp -d)" chmod 1777 "$builddir" # Ensure sources are downloaded - if [[ -n $SUDO_USER ]]; then - sudo -u $SUDO_USER env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ + if [[ $USER != $src_owner ]]; then + sudo -u $src_owner env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \ makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o else ( export SRCDEST BUILDDIR="$builddir" @@ -349,12 +394,21 @@ _chrootbuild() { sudo -u builduser makepkg "$@" } +# Usage: move_products $copydir $owner +# Globals: +# - PKGDEST +# - LOGDEST move_products() { + local copydir=$1 + local src_owner=$2 + + local pkgfile for pkgfile in "$copydir"/pkgdest/*; do chown "$src_owner" "$pkgfile" mv "$pkgfile" "$PKGDEST" done + local l for l in "$copydir"/logdest/*; do [[ $l == */logpipe.* ]] && continue chown "$src_owner" "$l" @@ -433,17 +487,27 @@ load_vars /etc/makepkg.conf [[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD [[ -d $LOGDEST ]] || LOGDEST=$PWD -create_chroot +# Lock the chroot we want to use. We'll keep this lock until we exit. +lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" + +if [[ ! -d $copydir ]] || $clean_first; then + sync_chroot "$chrootdir" "$copy" +fi $update_first && arch-nspawn "$copydir" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ pacman -Syu --noconfirm -[[ -n ${install_pkgs[*]} ]] && install_packages +if [[ -n ${install_pkgs[*]} ]]; then + install_packages "$copydir" "${install_pkgs[@]}" + ret=$? + # If there is no PKGBUILD we have done + [[ -f PKGBUILD ]] || return $ret +fi -download_sources +download_sources "$copydir" "$src_owner" -prepare_chroot +prepare_chroot "$copydir" "$USER_HOME" "$repack" if arch-nspawn "$copydir" \ --bind-ro="$PWD:/startdir_host" \ @@ -451,12 +515,12 @@ if arch-nspawn "$copydir" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ /chrootbuild "${makepkg_args[@]}" then - move_products + move_products "$copydir" "$src_owner" else (( ret += 1 )) fi -$temp_chroot && clean_temporary +$temp_chroot && delete_chroot "$copydir" if (( ret != 0 )); then if $temp_chroot; then -- cgit v1.2.3-54-g00ecf From 05a65ee16dce078e87f5dba576d0d087e22c34d7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 18:41:58 -0500 Subject: makechrootpkg: Detect the chroottype in individual functions, not globally. --- makechrootpkg.in | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 970d3e9..8e1fd95 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -146,8 +146,6 @@ btrfs_subvolume_delete() { } # Usage: sync_chroot $CHROOTDIR/$CHROOT <$CHROOTCOPY|$copydir> -# Globals: -# - chroottype sync_chroot() { local chrootdir=$1 local copy=$2 @@ -163,6 +161,9 @@ sync_chroot() { return 1 fi + # Detect chrootdir filesystem type + local chroottype=$(stat -f -c %T "$chrootdir") + # Get a read lock on the root chroot to make # sure we don't clone a half-updated chroot slock 8 "$chrootdir/root.lock" \ @@ -190,10 +191,10 @@ sync_chroot() { } # Usage: delete_chroot $copydir -# Globals: -# - chroottype delete_chroot() { local copydir=$1 + # Detect chrootdir filesystem type + local chroottype=$(stat -f -c %T "$copydir") stat_busy "Removing chroot copy [%s]" "$copydir" if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then @@ -448,9 +449,6 @@ chrootdir=$(readlink -e "$passeddir") [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir" -# Detect chrootdir filesystem type -chroottype=$(stat -f -c %T "$chrootdir") - if [[ ${copy:0:1} = / ]]; then copydir=$copy else -- cgit v1.2.3-54-g00ecf From 5f3b9de5178b6be3bb12390d5fb299594a757844 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 | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 8e1fd95..67d2cf8 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -310,6 +310,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 @@ -354,7 +360,7 @@ download_sources() { rm -rf "$builddir" } -_chrootbuild() { +_chrootprepare() { # This function isn't run in makechrootpkg, # so no global variables @@ -392,7 +398,20 @@ _chrootbuild() { exit 1 fi - sudo -u builduser makepkg "$@" + sudo -u builduser makepkg "$@" --nobuild +} + +_chrootbuild() { + # This function isn't run in makechrootpkg, + # so no global variables + + . /etc/profile + export HOME=/build + shopt -s nullglob + + cd /startdir + + sudo -u builduser makepkg "$@" --noextract --noprepare } # Usage: move_products $copydir $owner @@ -508,6 +527,11 @@ download_sources "$copydir" "$src_owner" prepare_chroot "$copydir" "$USER_HOME" "$repack" if arch-nspawn "$copydir" \ + --bind-ro="$PWD:/startdir_host" \ + --bind-ro="$SRCDEST:/srcdest_host" \ + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + /chrootprepare "${makepkg_args[@]}" && + arch-nspawn "$copydir" \ --bind-ro="$PWD:/startdir_host" \ --bind-ro="$SRCDEST:/srcdest_host" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ -- cgit v1.2.3-54-g00ecf From 428cf5f1f8718f0abc2a9410677222889b9c8470 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 17:34:31 -0500 Subject: makechrootpkg: _chrootprepare: Clean srcdest and startdir. --- makechrootpkg.in | 1 + 1 file changed, 1 insertion(+) diff --git a/makechrootpkg.in b/makechrootpkg.in index 67d2cf8..d40bb88 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -369,6 +369,7 @@ _chrootprepare() { shopt -s nullglob # XXX: Workaround makepkg disliking read-only dirs + rm -rf -- /srcdest/* /startdir/* ln -sft /srcdest /srcdest_host/* ln -sft /startdir /startdir_host/* -- cgit v1.2.3-54-g00ecf From c8300c3ff1afc667aa53f1782846902752687357 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 18:39:40 -0500 Subject: makechrootpkg: move_products: Mimic `makepkg` and symlink products into PWD. --- makechrootpkg.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/makechrootpkg.in b/makechrootpkg.in index d40bb88..878c663 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -427,6 +427,9 @@ move_products() { for pkgfile in "$copydir"/pkgdest/*; do chown "$src_owner" "$pkgfile" mv "$pkgfile" "$PKGDEST" + if [[ $PKGDEST != $PWD ]]; then + ln -sf "$PKGDEST/${pkgfile##*/}" . + fi done local l -- cgit v1.2.3-54-g00ecf From 22da1ef5087e7065439e23187f0984148a905fff 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 | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/arch-nspawn.in b/arch-nspawn.in index ea6e5ea..85af8c5 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -106,6 +106,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 878c663..3f4e009 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -308,6 +308,15 @@ EOF chmod 440 "$copydir/etc/sudoers.d/builduser-pacman" fi + if ! grep -q '^\[repo\]' "$copydir/etc/pacman.conf"; then + local 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 + # This is a little gross, but this way the script is recreated every time in the # working copy { @@ -399,6 +408,8 @@ _chrootprepare() { exit 1 fi + # Sync deps now, as networking may be disabled during _chrootbuild + cp /repo/repo.db /var/lib/pacman/sync/repo.db sudo -u builduser makepkg "$@" --nobuild } -- cgit v1.2.3-54-g00ecf From 90fe539365baf28be143e3ab500bf654ef3b98d5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 15:25:22 -0500 Subject: makechrootpkg: Adjust to have the functions work with `set -u`. Even though main() doesn't call `set -u`; this way the functions will continue to work if copied into an environment with `set -u`, or so that we are ready if we ever want to start using `set -u`. --- makechrootpkg.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 3f4e009..afd14f6 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -31,7 +31,7 @@ bindmounts_ro=() bindmounts_rw=() copy=$USER -[[ -n $SUDO_USER ]] && copy=$SUDO_USER +[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER [[ -z "$copy" || $copy = root ]] && copy=copy src_owner=${SUDO_USER:-$USER} @@ -84,7 +84,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 "^${var}=" "$makepkg_conf") done return 0 @@ -290,12 +290,12 @@ prepare_chroot() { printf 'builduser:x:%d:100:builduser:/build:/bin/bash\n' "$builduser_uid" >>"$copydir/etc/passwd" chown -R "$builduser_uid" "$copydir"/{build,pkgdest,srcpkgdest,logdest,srcdest,startdir} - if [[ -n $MAKEFLAGS ]]; then + if [[ -n ${MAKEFLAGS:-} ]]; then sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg.conf" echo "MAKEFLAGS='${MAKEFLAGS}'" >> "$copydir/etc/makepkg.conf" fi - if [[ -n $PACKAGER ]]; then + if [[ -n ${PACKAGER:-} ]]; then sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf" echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf" fi @@ -530,7 +530,7 @@ $update_first && arch-nspawn "$copydir" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ pacman -Syu --noconfirm -if [[ -n ${install_pkgs[*]} ]]; then +if [[ -n ${install_pkgs[*]:-} ]]; then install_packages "$copydir" "${install_pkgs[@]}" ret=$? # If there is no PKGBUILD we have done -- cgit v1.2.3-54-g00ecf From 880ae81d3c485a54c744cb75f3faa4adf8cea802 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 15:27:51 -0500 Subject: makechrootpkg: Avoid having code floating around outside of a function. This means wrapping variable initialization in init_variables(), and the main program routine in main(). I did NOT put `shopt -s nullglob` in to a function. --- makechrootpkg.in | 238 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 123 insertions(+), 115 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index afd14f6..7ff2fd7 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -14,26 +14,28 @@ m4_include(lib/common.sh) shopt -s nullglob -default_makepkg_args=(-s --noconfirm -L --holdver) -makepkg_args=("${default_makepkg_args[@]}") -repack=false -update_first=false -clean_first=false -install_pkg= -run_namcap=false -temp_chroot=false -chrootdir= -passeddir= -declare -a install_pkgs -declare -i ret=0 - -bindmounts_ro=() -bindmounts_rw=() - -copy=$USER -[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER -[[ -z "$copy" || $copy = root ]] && copy=copy -src_owner=${SUDO_USER:-$USER} +init_variables() { + default_makepkg_args=(-s --noconfirm -L --holdver) + makepkg_args=("${default_makepkg_args[@]}") + repack=false + update_first=false + clean_first=false + install_pkg= + run_namcap=false + temp_chroot=false + chrootdir= + passeddir= + declare -a install_pkgs + declare -i ret=0 + + bindmounts_ro=() + bindmounts_rw=() + + copy=$USER + [[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER + [[ -z "$copy" || $copy = root ]] && copy=copy + src_owner=${SUDO_USER:-$USER} +} usage() { echo "Usage: ${0##*/} [options] -r [--] [makepkg args]" @@ -457,114 +459,120 @@ move_products() { } # }}} -orig_argv=("$@") - -while getopts 'hcur:I:l:nTD:d:' arg; do - case "$arg" in - c) clean_first=true ;; - D) bindmounts_ro+=(--bind-ro="$OPTARG") ;; - d) bindmounts_rw+=(--bind="$OPTARG") ;; - u) update_first=true ;; - r) passeddir="$OPTARG" ;; - I) install_pkgs+=("$OPTARG") ;; - l) copy="$OPTARG" ;; - n) run_namcap=true; makepkg_args+=(-i) ;; - T) temp_chroot=true; copy+="-$$" ;; - h|*) usage ;; - esac -done +main() { + init_variables + + orig_argv=("$@") + + while getopts 'hcur:I:l:nTD:d:' arg; do + case "$arg" in + c) clean_first=true ;; + D) bindmounts_ro+=(--bind-ro="$OPTARG") ;; + d) bindmounts_rw+=(--bind="$OPTARG") ;; + u) update_first=true ;; + r) passeddir="$OPTARG" ;; + I) install_pkgs+=("$OPTARG") ;; + l) copy="$OPTARG" ;; + n) run_namcap=true; makepkg_args+=(-i) ;; + T) temp_chroot=true; copy+="-$$" ;; + h|*) usage ;; + esac + done -[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.' + [[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.' -check_root "$0" "${orig_argv[@]}" + check_root "$0" "${orig_argv[@]}" -# Canonicalize chrootdir, getting rid of trailing / -chrootdir=$(readlink -e "$passeddir") -[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" -[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir" + # Canonicalize chrootdir, getting rid of trailing / + chrootdir=$(readlink -e "$passeddir") + [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" + [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir" -if [[ ${copy:0:1} = / ]]; then - copydir=$copy -else - copydir="$chrootdir/$copy" -fi + if [[ ${copy:0:1} = / ]]; then + copydir=$copy + else + copydir="$chrootdir/$copy" + fi -# Pass all arguments after -- right to makepkg -makepkg_args+=("${@:$OPTIND}") + # Pass all arguments after -- right to makepkg + makepkg_args+=("${@:$OPTIND}") + + # See if -R was passed to makepkg + for arg in "${@:OPTIND}"; do + case ${arg%%=*} in + -*R*|--repackage) + repack=true + break 2 + ;; + esac + done -# See if -R was passed to makepkg -for arg in "${@:OPTIND}"; do - case ${arg%%=*} in - -*R*|--repackage) - repack=true - break 2 - ;; - esac -done + if [[ -n $SUDO_USER ]]; then + eval "USER_HOME=~$SUDO_USER" + else + USER_HOME=$HOME + fi -if [[ -n $SUDO_USER ]]; then - eval "USER_HOME=~$SUDO_USER" -else - USER_HOME=$HOME -fi + umask 0022 -umask 0022 + load_vars "$USER_HOME/.makepkg.conf" + load_vars /etc/makepkg.conf -load_vars "$USER_HOME/.makepkg.conf" -load_vars /etc/makepkg.conf + # Use PKGBUILD directory if these don't exist + [[ -d $PKGDEST ]] || PKGDEST=$PWD + [[ -d $SRCDEST ]] || SRCDEST=$PWD + [[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD + [[ -d $LOGDEST ]] || LOGDEST=$PWD -# Use PKGBUILD directory if these don't exist -[[ -d $PKGDEST ]] || PKGDEST=$PWD -[[ -d $SRCDEST ]] || SRCDEST=$PWD -[[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD -[[ -d $LOGDEST ]] || LOGDEST=$PWD + # Lock the chroot we want to use. We'll keep this lock until we exit. + lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" -# Lock the chroot we want to use. We'll keep this lock until we exit. -lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" + if [[ ! -d $copydir ]] || $clean_first; then + sync_chroot "$chrootdir" "$copy" + fi + + $update_first && arch-nspawn "$copydir" \ + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + pacman -Syu --noconfirm -if [[ ! -d $copydir ]] || $clean_first; then - sync_chroot "$chrootdir" "$copy" -fi + if [[ -n ${install_pkgs[*]:-} ]]; then + install_packages "$copydir" "${install_pkgs[@]}" + ret=$? + # If there is no PKGBUILD we have done + [[ -f PKGBUILD ]] || return $ret + fi -$update_first && arch-nspawn "$copydir" \ + download_sources "$copydir" "$src_owner" + + prepare_chroot "$copydir" "$USER_HOME" "$repack" + + if arch-nspawn "$copydir" \ + --bind-ro="$PWD:/startdir_host" \ + --bind-ro="$SRCDEST:/srcdest_host" \ + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + /chrootprepare "${makepkg_args[@]}" && + arch-nspawn "$copydir" \ + --bind-ro="$PWD:/startdir_host" \ + --bind-ro="$SRCDEST:/srcdest_host" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ - pacman -Syu --noconfirm - -if [[ -n ${install_pkgs[*]:-} ]]; then - install_packages "$copydir" "${install_pkgs[@]}" - ret=$? - # If there is no PKGBUILD we have done - [[ -f PKGBUILD ]] || return $ret -fi - -download_sources "$copydir" "$src_owner" - -prepare_chroot "$copydir" "$USER_HOME" "$repack" - -if arch-nspawn "$copydir" \ - --bind-ro="$PWD:/startdir_host" \ - --bind-ro="$SRCDEST:/srcdest_host" \ - "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ - /chrootprepare "${makepkg_args[@]}" && - arch-nspawn "$copydir" \ - --bind-ro="$PWD:/startdir_host" \ - --bind-ro="$SRCDEST:/srcdest_host" \ - "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ - /chrootbuild "${makepkg_args[@]}" -then - move_products "$copydir" "$src_owner" -else - (( ret += 1 )) -fi - -$temp_chroot && delete_chroot "$copydir" - -if (( ret != 0 )); then - if $temp_chroot; then - die "Build failed" + /chrootbuild "${makepkg_args[@]}" + then + move_products "$copydir" "$src_owner" else - die "Build failed, check %s/build" "$copydir" + (( ret += 1 )) fi -else - true -fi + + $temp_chroot && delete_chroot "$copydir" + + if (( ret != 0 )); then + if $temp_chroot; then + die "Build failed" + else + die "Build failed, check %s/build" "$copydir" + fi + else + true + fi +} + +main "$@" -- cgit v1.2.3-54-g00ecf From 10820f2701f1fe43ea32d72c88b6a70dace09b76 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:03:57 -0500 Subject: lib/common.sh: Internationalize. --- lib/common.sh | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 33f9552..89cd257 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,37 +44,37 @@ fi readonly ALL_OFF BOLD BLUE GREEN RED YELLOW plain() { - local mesg=$1; shift + local mesg="$(_ "$1")"; shift printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg() { - local mesg=$1; shift + local mesg="$(_ "$1")"; shift printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg2() { - local mesg=$1; shift + local mesg="$(_ "$1")"; shift printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } warning() { - local mesg=$1; shift - printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 + local mesg="$(_ "$1")"; shift + printf "${YELLOW}==> $(_l _ "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } error() { - local mesg=$1; shift - printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 + local mesg="$(_ "$1")"; shift + printf "${RED}==> $(_l _ "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } stat_busy() { - local mesg=$1; shift + local mesg="$(_ "$1")"; shift printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2 } stat_done() { - printf "${BOLD}$(gettext "done")${ALL_OFF}\n" >&2 + printf "${BOLD}$(_l _ "done")${ALL_OFF}\n" >&2 } _setup_workdir=false @@ -83,7 +93,7 @@ cleanup() { } abort() { - error 'Aborting...' + _l error 'Aborting...' cleanup 255 } @@ -261,7 +271,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 e5d65f09ed2421c5e68e3a6fa91bb51773734e26 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 fbd30d3..6904e32 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 @@ -18,7 +39,9 @@ if [[ -r ~/.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 . ./PKGBUILD diff --git a/find-libdeps.in b/find-libdeps.in index 5c350a9..794a2cd 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 89ccc41..cc1ffab 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 d; do if [[ -f "$d/PKGBUILD" ]]; then diff --git a/lddd.in b/lddd.in index f01ebf9..09e0d07 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 2e2bebf2e674b8ab0003aafa0c27477fbadcd96e 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 89cd257..b8bab9b 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 f7a12367bf457ec3591fab1927e41de07d7c2d84 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 4ebafa6..f86ae35 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -95,7 +95,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