Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--arch-nspawn.in14
-rw-r--r--archbuild.in6
-rw-r--r--checkpkg.in11
-rw-r--r--lib/common.sh6
-rw-r--r--makechrootpkg.in67
-rw-r--r--mkarchroot.in4
7 files changed, 59 insertions, 51 deletions
diff --git a/Makefile b/Makefile
index 82a7362..244a791 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-V=20140510
+V=20141024
PREFIX = /usr/local
diff --git a/arch-nspawn.in b/arch-nspawn.in
index 6c9a102..10f79f6 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -26,6 +26,8 @@ usage() {
exit 1
}
+orig_argv=("$@")
+
while getopts 'hC:M:c:' arg; do
case "$arg" in
C) pac_conf="$OPTARG" ;;
@@ -38,7 +40,7 @@ done
shift $(($OPTIND - 1))
(( $# < 1 )) && die 'You must specify a directory.'
-check_root "$0" "$@"
+check_root "$0" "${orig_argv[@]}"
working_dir=$(readlink -f "$1")
shift 1
@@ -94,16 +96,8 @@ copy_hostconf
eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf")
-machine_name="${working_dir//[![:alnum:]_-]/-}"
-machine_name="${machine_name#-}"
-HOST_NAME_MAX="$(getconf HOST_NAME_MAX)"
-if [[ ${#machine_name} -gt "$HOST_NAME_MAX" ]]; then
- machine_name="${machine_name:(-${HOST_NAME_MAX})}"
- machine_name="${machine_name#-}"
-fi
-
exec ${CARCH:+setarch "$CARCH"} systemd-nspawn -q \
-D "$working_dir" \
- --machine "$machine_name" \
+ --register=no \
"${mount_args[@]}" \
"$@"
diff --git a/archbuild.in b/archbuild.in
index 64e0904..812db7c 100644
--- a/archbuild.in
+++ b/archbuild.in
@@ -29,6 +29,8 @@ usage() {
exit 1
}
+orig_argv=("$@")
+
while getopts 'hcr:' arg; do
case "${arg}" in
c) clean_first=true ;;
@@ -37,11 +39,11 @@ while getopts 'hcr:' arg; do
esac
done
+check_root "$0" "${orig_argv[@]}"
+
# Pass all arguments after -- right to makepkg
makechrootpkg_args+=("${@:$OPTIND}")
-check_root "$0" "$@"
-
if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
msg "Creating chroot for [%s] (%s)..." "${repo}" "${arch}"
diff --git a/checkpkg.in b/checkpkg.in
index 81e7184..656d010 100644
--- a/checkpkg.in
+++ b/checkpkg.in
@@ -63,12 +63,11 @@ for _pkgname in "${pkgname[@]}"; do
sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname"
- if diff "$TEMPDIR/filelist-$_pkgname"{-old,} | grep '\.so' &>/dev/null; then
- mkdir -p "$TEMPDIR/pkg"
- bsdtar -x -C "$TEMPDIR" -f "$pkgfile" #> /dev/null
- comm -13 <(sort "$TEMPDIR/filelist-$_pkgname-old") <(sort "$TEMPDIR/filelist-$_pkgname") | grep .so$ | while read i; do
- echo "${i}: " "$(objdump -p "$TEMPDIR/$i" | grep SONAME)"
- done
+ find-libprovides "$TEMPDIR/$oldpkg" | sort > "$TEMPDIR/libraries-$_pkgname-old"
+ find-libprovides "$pkgfile" | sort > "$TEMPDIR/libraries-$_pkgname"
+ if ! diff_output="$(sdiff -s "$TEMPDIR/libraries-$_pkgname-old" "$TEMPDIR/libraries-$_pkgname")"; then
+ msg "Sonames differ in $_pkgname!"
+ echo "$diff_output"
else
msg "No soname differences for %s." "$_pkgname"
fi
diff --git a/lib/common.sh b/lib/common.sh
index 6305528..b1e7d6e 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -85,8 +85,9 @@ trap_abort() {
}
trap_exit() {
+ local r=$?
trap - EXIT INT QUIT TERM HUP
- cleanup
+ cleanup $r
}
die() {
@@ -266,7 +267,6 @@ check_root() {
if type -P sudo >/dev/null; then
exec sudo -- "$@"
else
- exec su root -c "$(printf '%q' "$@")"
+ exec su root -c "$(printf ' %q' "$@")"
fi
- die 'This script must be run as root.'
}
diff --git a/makechrootpkg.in b/makechrootpkg.in
index f646117..3f1e1e1 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -67,9 +67,10 @@ usage() {
exit 1
}
+orig_argv=("$@")
+
while getopts 'hcur:I:l:nTD:d:' arg; do
case "$arg" in
- h) usage ;;
c) clean_first=true ;;
D) bindmounts_ro+=(--bind-ro="$OPTARG") ;;
d) bindmounts_rw+=(--bind="$OPTARG") ;;
@@ -77,15 +78,16 @@ while getopts 'hcur:I:l:nTD:d:' arg; do
r) passeddir="$OPTARG" ;;
I) install_pkgs+=("$OPTARG") ;;
l) copy="$OPTARG" ;;
- n) run_namcap=true; makepkg_args+=('-i') ;;
+ n) run_namcap=true; makepkg_args+=(-i) ;;
T) temp_chroot=true; copy+="-$$" ;;
+ h|*) usage ;;
esac
done
-check_root "$0" "$@"
-
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
+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"
@@ -101,7 +103,7 @@ else
fi
# Pass all arguments after -- right to makepkg
-makepkg_args+=("${@:OPTIND}")
+makepkg_args+=("${@:$OPTIND}")
# See if -R was passed to makepkg
for arg in "${@:OPTIND}"; do
@@ -114,7 +116,7 @@ for arg in "${@:OPTIND}"; do
done
if [[ -n $SUDO_USER ]]; then
- USER_HOME=$(eval echo ~$SUDO_USER)
+ eval "USER_HOME=~$SUDO_USER"
else
USER_HOME=$HOME
fi
@@ -235,7 +237,13 @@ prepare_chroot() {
echo 'SRCDEST="/srcdest"' >> "$copydir/etc/makepkg.conf"
fi
- chown -R nobody "$copydir"/{build,pkgdest,srcpkgdest,logdest,srcdest,startdir}
+ builduser_uid=${SUDO_UID:-$UID}
+
+ # We can't use useradd without chrooting, otherwise it invokes PAM modules
+ # which we might not be able to load (i.e. when building i686 packages on
+ # an x86_64 host).
+ printf 'builduser:x:%d:100:builduser:/:/usr/bin/nologin\n' "$builduser_uid" >>"$copydir/etc/passwd"
+ chown -R "$builduser_uid" "$copydir"/{build,pkgdest,srcpkgdest,logdest,srcdest,startdir}
if [[ -n $MAKEFLAGS ]]; then
sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg.conf"
@@ -247,18 +255,33 @@ prepare_chroot() {
echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf"
fi
- if [[ ! -f $copydir/etc/sudoers.d/nobody-pacman ]]; then
- cat > "$copydir/etc/sudoers.d/nobody-pacman" <<EOF
+ if [[ ! -f $copydir/etc/sudoers.d/builduser-pacman ]]; then
+ cat > "$copydir/etc/sudoers.d/builduser-pacman" <<EOF
Defaults env_keep += "HOME"
-nobody ALL = NOPASSWD: /usr/bin/pacman
+builduser ALL = NOPASSWD: /usr/bin/pacman
EOF
- chmod 440 "$copydir/etc/sudoers.d/nobody-pacman"
+ chmod 440 "$copydir/etc/sudoers.d/builduser-pacman"
fi
# This is a little gross, but this way the script is recreated every time in the
# working copy
- printf $'#!/bin/bash\n%s\n_chrootbuild %q "$@"' "$(declare -f _chrootbuild)" \
- "$run_namcap" >"$copydir/chrootbuild"
+ {
+ printf '#!/bin/bash\n'
+ declare -f _chrootbuild
+ printf '_chrootbuild'
+ printf ' %q' "${makepkg_args[@]}"
+ printf ' || exit\n'
+
+ if $run_namcap; then
+ cat <<'EOF'
+pacman -S --needed --noconfirm namcap
+for pkgfile in /startdir/PKGBUILD /pkgdest/*; do
+ echo "Checking ${pkgfile##*/}"
+ sudo -u builduser namcap "$pkgfile" 2>&1 | tee "/logdest/${pkgfile##*/}-namcap.log"
+done
+EOF
+ fi
+ } >"$copydir/chrootbuild"
chmod +x "$copydir/chrootbuild"
}
@@ -284,8 +307,6 @@ download_sources() {
_chrootbuild() {
# This function isn't run in makechrootpkg,
# so no global variables
- local run_namcap="$1"; shift
- local makepkg_args=("$@")
. /etc/profile
export HOME=/build
@@ -303,7 +324,7 @@ _chrootbuild() {
for vcsdir in */.$vcs; do
rm "${vcsdir%/.$vcs}"
cp -a "${dir}_host/${vcsdir%/.$vcs}" .
- chown -R nobody "${vcsdir%/.$vcs}"
+ chown -R builduser "${vcsdir%/.$vcs}"
done
done
done
@@ -313,7 +334,7 @@ _chrootbuild() {
# XXX: Keep PKGBUILD writable for pkgver()
rm PKGBUILD*
cp /startdir_host/PKGBUILD* .
- chown nobody PKGBUILD*
+ chown builduser PKGBUILD*
# Safety check
if [[ ! -w PKGBUILD ]]; then
@@ -321,17 +342,7 @@ _chrootbuild() {
exit 1
fi
- sudo -u nobody makepkg "${makepkg_args[@]}" || exit 1
-
- if $run_namcap; then
- pacman -S --needed --noconfirm namcap
- for pkgfile in /startdir/PKGBUILD /pkgdest/*; do
- echo "Checking ${pkgfile##*/}"
- sudo -u nobody namcap "$pkgfile" 2>&1 | tee "/logdest/${pkgfile##*/}-namcap.log"
- done
- fi
-
- exit 0
+ sudo -u builduser makepkg "$@"
}
move_products() {
diff --git a/mkarchroot.in b/mkarchroot.in
index 09ba64f..3da2144 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -24,6 +24,8 @@ usage() {
exit 1
}
+orig_argv=("$@")
+
while getopts 'hC:M:c:' arg; do
case "$arg" in
C) pac_conf="$OPTARG" ;;
@@ -37,7 +39,7 @@ shift $(($OPTIND - 1))
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
-check_root "$0" "$@"
+check_root "$0" "${orig_argv[@]}"
working_dir="$(readlink -f $1)"
shift 1