summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch-nspawn.in10
-rw-r--r--checkpkg.in27
-rw-r--r--find-libdeps.in28
-rw-r--r--finddeps.in18
-rw-r--r--lddd.in18
-rw-r--r--lib/common.sh82
-rw-r--r--makechrootpkg.in55
-rw-r--r--mkarchroot.in2
8 files changed, 216 insertions, 24 deletions
diff --git a/arch-nspawn.in b/arch-nspawn.in
index c55f498..7f778be 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 <file> Location of a pacman config file'
@@ -101,13 +101,17 @@ 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
+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
[[ -z $nosetarch ]] || unset CARCH
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] <package file|extracted package dir>"
+ print "Find library dependencies or provides of a package."
+ echo
+ prose 'Prints a list of library dependencies in the format:'
+ echo
+ print ' <soname>=<soversion>-<soarch>'
+ echo
+ prose "Where <soversion> is the shared library version, or
+ <soname> repeated if there is no version attached; and
+ <soarch> 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] <package file|extracted package dir>"
- 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 <depname>' "${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 <depname>'
- 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}:"
diff --git a/lib/common.sh b/lib/common.sh
index a3c2ec2..a0796bb 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
@@ -9,8 +12,18 @@ _INCLUDE_COMMON_SH=true
# shellcheck disable=1091
. /usr/share/makepkg/util.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' "$@"
+}
shopt -s extglob
@@ -23,14 +36,14 @@ else
fi
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
@@ -49,7 +62,7 @@ cleanup() {
}
abort() {
- error 'Aborting...'
+ _l error 'Aborting...'
cleanup 255
}
@@ -177,7 +190,64 @@ find_cached_package() {
return 0
;;
*)
- error 'Multiple packages found:'
+ _l error 'Multiple packages found:'
+ printf '\t%s\n' "${results[@]}" >&2
+ 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
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 511e519..ccdcebc 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -200,10 +200,29 @@ 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
{
printf '#!/bin/bash\n'
+ declare -f _chrootprepare
+ printf '_chrootprepare "$@"\n'
+ } > "$copydir/chrootprepare"
+ chmod +x "$copydir/chrootprepare"
+ {
+ printf '#!/bin/bash\n'
declare -f _chrootbuild
declare -p SOURCE_DATE_EPOCH 2>/dev/null
printf '_chrootbuild "$@" || exit\n'
@@ -218,6 +237,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
@@ -225,11 +258,26 @@ _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; makepkg "$@"' -bash "$@"
+ 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 "$@"
}
_chrootnamcap() {
@@ -415,6 +463,11 @@ main() {
--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[@]}" \
/chrootbuild "${makepkg_args[@]}"
then
move_products "$copydir" "$src_owner"
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"} \