From 4dcdbcaf1eff0962522a04710817156ce4d44b9e Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 3 May 2013 14:23:04 +0200 Subject: makechrootpkg: Ensure we have a writable PKGBUILD For pkgver updates. --- makechrootpkg.in | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'makechrootpkg.in') diff --git a/makechrootpkg.in b/makechrootpkg.in index 0d93c2e..862e6bc 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -247,6 +247,11 @@ shopt -s nullglob ln -sft /srcdest /srcdest_host/* ln -sft /startdir /startdir_host/* +# Keep PKGBUILD writable for pkgver() +rm /startdir/PKGBUILD* +cp /startdir_host/PKGBUILD* /startdir +chown nobody /startdir/PKGBUILD* + cd /startdir sudo -u nobody makepkg $makepkg_args || exit 1 -- cgit v1.2.3-54-g00ecf From 4937422fcfd7ad2b3babe7621f201ba4376ed4cd Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 3 May 2013 20:01:32 +0200 Subject: makechrootpkg: Split out chrootbuild into a function Now syntax highlighting works properly! :D --- makechrootpkg.in | 70 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 28 deletions(-) (limited to 'makechrootpkg.in') diff --git a/makechrootpkg.in b/makechrootpkg.in index 862e6bc..c7baf4d 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -237,34 +237,8 @@ EOF # This is a little gross, but this way the script is recreated every time in the # working copy - cat >"$copydir/chrootbuild" <&1 | tee "/logdest/\${pkgfile##*/}-namcap.log" - done -fi - -exit 0 -EOF + printf $'#!/bin/bash\n%s\n_chrootbuild %q %q' "$(declare -f _chrootbuild)" \ + "$makepkg_args" "$run_namcap" >"$copydir/chrootbuild" chmod +x "$copydir/chrootbuild" } @@ -287,6 +261,46 @@ download_sources() { rm -rf $builddir } +_chrootbuild() { + # This function isn't run in makechrootpkg, + # so no global variables + local makepkg_args="$1" + local run_namcap="$2" + + . /etc/profile + export HOME=/build + shopt -s nullglob + + # Workaround makepkg disliking read-only dirs + ln -sft /srcdest /srcdest_host/* + ln -sft /startdir /startdir_host/* + + cd /startdir + + # Keep PKGBUILD writable for pkgver() + rm PKGBUILD* + cp /startdir_host/PKGBUILD* . + chown nobody PKGBUILD* + + # Safety check + if [[ ! -w PKGBUILD ]]; then + echo "Can't write to PKGBUILD!" + 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 +} + move_products() { for pkgfile in "$copydir"/pkgdest/*; do chown "$src_owner" "$pkgfile" -- cgit v1.2.3-54-g00ecf From fc71be3479d4330dfac8641fe0a6d0517964e4be Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 9 May 2013 02:31:35 +0200 Subject: makechrootpkg: Update comments to point out the bad hacks --- makechrootpkg.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'makechrootpkg.in') diff --git a/makechrootpkg.in b/makechrootpkg.in index c7baf4d..dbe705e 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -208,7 +208,8 @@ prepare_chroot() { echo 'LOGDEST="/logdest"' >> "$copydir/etc/makepkg.conf" fi - # These two get bind-mounted + # These two get bind-mounted read-only + # XXX: makepkg dislikes having these dirs read-only, so separate them mkdir -p "$copydir/startdir" "$copydir/startdir_host" mkdir -p "$copydir/srcdest" "$copydir/srcdest_host" if ! grep -q 'SRCDEST="/srcdest"' "$copydir/etc/makepkg.conf"; then @@ -271,13 +272,13 @@ _chrootbuild() { export HOME=/build shopt -s nullglob - # Workaround makepkg disliking read-only dirs + # XXX: Workaround makepkg disliking read-only dirs ln -sft /srcdest /srcdest_host/* ln -sft /startdir /startdir_host/* cd /startdir - # Keep PKGBUILD writable for pkgver() + # XXX: Keep PKGBUILD writable for pkgver() rm PKGBUILD* cp /startdir_host/PKGBUILD* . chown nobody PKGBUILD* -- cgit v1.2.3-54-g00ecf From 7a3f524201f1fe2ec1ba851f595e86aa4a4b8f51 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 9 May 2013 02:29:52 +0200 Subject: makechrootpkg: Add hack for svn sources and makepkg 4.1.1 --- makechrootpkg.in | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'makechrootpkg.in') diff --git a/makechrootpkg.in b/makechrootpkg.in index dbe705e..d7d3ecf 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -276,6 +276,17 @@ _chrootbuild() { ln -sft /srcdest /srcdest_host/* ln -sft /startdir /startdir_host/* + # XXX: Keep svn sources writable + # Since makepkg 4.1.1 they get checked out via cp -a, copying the symlink + for dir in /srcdest /startdir; do + cd $dir + for svndir in */.svn; do + rm ${svndir%/.svn} + cp -a ${dir}_host/${svndir%/.svn} . + chown -R nobody ${svndir%/.svn} + done + done + cd /startdir # XXX: Keep PKGBUILD writable for pkgver() -- cgit v1.2.3-54-g00ecf