Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
06.makechrootpkg.patch
--- makechrootpkg-optimize 2016-04-01 08:33:23.699505125 +0200
+++ makechrootpkg-optimize 2016-04-01 08:33:39.022755445 +0200
@@ -315,7 +315,7 @@ load_vars() {
[[ -f $makepkg_conf ]] || return 1
- for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do
+ for var in {SRC,SRCPKG,PKG,PROF,LOG}DEST MAKEFLAGS PACKAGER; do
[[ -z ${!var} ]] && eval $(grep "^${var}=" "$makepkg_conf")
done
@@ -392,11 +392,11 @@ prepare_chroot() {
$repack || rm -rf "$copydir/build"
mkdir -p "$copydir/build"
- if ! grep -q 'BUILDDIR="/build"' "$copydir/etc/makepkg.conf"; then
- echo 'BUILDDIR="/build"' >> "$copydir/etc/makepkg.conf"
+ if ! grep -q 'BUILDDIR="/build"' "$copydir/etc/makepkg-optimize.conf"; then
+ echo 'BUILDDIR="/build"' >> "$copydir/etc/makepkg-optimize.conf"
fi
- # Read .makepkg.conf and gnupg pubring
+ # Read .makepkg-optimize.conf and gnupg pubring
if [[ -r $USER_HOME/.gnupg/pubring.kbx ]]; then
install -D "$USER_HOME/.gnupg/pubring.kbx" "$copydir/build/.gnupg/pubring.kbx"
fi
@@ -405,26 +405,32 @@ prepare_chroot() {
fi
mkdir -p "$copydir/pkgdest"
- if ! grep -q 'PKGDEST="/pkgdest"' "$copydir/etc/makepkg.conf"; then
- echo 'PKGDEST="/pkgdest"' >> "$copydir/etc/makepkg.conf"
+ if ! grep -q 'PKGDEST="/pkgdest"' "$copydir/etc/makepkg-optimize.conf"; then
+ echo 'PKGDEST="/pkgdest"' >> "$copydir/etc/makepkg-optimize.conf"
fi
+ mkdir -p "$copydir/${PROFDEST#/}"
+ for dir in $(find "$PROFDEST" -maxdepth 1 -type d -regex '.*.gen$'); do
+ cp -rp "$dir" "$copydir/${PROFDEST#/}"
+ done
+ echo 'PROFDEST="'$PROFDEST'"' >> "$copydir/etc/makepkg-optimize.conf"
+
mkdir -p "$copydir/srcpkgdest"
- if ! grep -q 'SRCPKGDEST="/srcpkgdest"' "$copydir/etc/makepkg.conf"; then
- echo 'SRCPKGDEST="/srcpkgdest"' >> "$copydir/etc/makepkg.conf"
+ if ! grep -q 'SRCPKGDEST="/srcpkgdest"' "$copydir/etc/makepkg-optimize.conf"; then
+ echo 'SRCPKGDEST="/srcpkgdest"' >> "$copydir/etc/makepkg-optimize.conf"
fi
mkdir -p "$copydir/logdest"
- if ! grep -q 'LOGDEST="/logdest"' "$copydir/etc/makepkg.conf"; then
- echo 'LOGDEST="/logdest"' >> "$copydir/etc/makepkg.conf"
+ if ! grep -q 'LOGDEST="/logdest"' "$copydir/etc/makepkg-optimize.conf"; then
+ echo 'LOGDEST="/logdest"' >> "$copydir/etc/makepkg-optimize.conf"
fi
# 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
- echo 'SRCDEST="/srcdest"' >> "$copydir/etc/makepkg.conf"
+ if ! grep -q 'SRCDEST="/srcdest"' "$copydir/etc/makepkg-optimize.conf"; then
+ echo 'SRCDEST="/srcdest"' >> "$copydir/etc/makepkg-optimize.conf"
fi
builduser_uid=${SUDO_UID:-$UID}
@@ -433,16 +439,16 @@ prepare_chroot() {
# 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}
+ chown -R "$builduser_uid" "$copydir"/{build,pkgdest,"${PROFDEST#/}",srcpkgdest,logdest,srcdest,startdir}
if [[ -n $MAKEFLAGS ]]; then
- sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg.conf"
- echo "MAKEFLAGS='${MAKEFLAGS}'" >> "$copydir/etc/makepkg.conf"
+ sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg-optimize.conf"
+ echo "MAKEFLAGS='${MAKEFLAGS}'" >> "$copydir/etc/makepkg-optimize.conf"
fi
if [[ -n $PACKAGER ]]; then
- sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf"
- echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf"
+ sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg-optimize.conf"
+ echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg-optimize.conf"
fi
if [[ ! -f $copydir/etc/sudoers.d/builduser-pacman ]]; then
@@ -482,10 +488,10 @@ download_sources() {
# Ensure sources are downloaded
if [[ -n $SUDO_USER ]]; then
sudo -u $SUDO_USER env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
- makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o
+ makepkg --config="$copydir/etc/makepkg-optimize.conf" --verifysource -o
else
( export SRCDEST BUILDDIR="$builddir"
- makepkg --asroot --config="$copydir/etc/makepkg.conf" --verifysource -o
+ makepkg --asroot --config="$copydir/etc/makepkg-optimize.conf" --verifysource -o
)
fi
(( $? != 0 )) && die "Could not download sources."
@@ -532,7 +538,7 @@ _chrootbuild() {
exit 1
fi
- sudo -u builduser makepkg "$@"
+ sudo -u builduser makepkg-optimize "$@"
}
move_products() {
@@ -541,6 +547,16 @@ move_products() {
mv "$pkgfile" "$PKGDEST"
done
+ for dir in $(find "$PROFDEST" -maxdepth 1 -type d -regex '.*.gen$'); do
+ mv "$dir" "${dir%.gen}.used"
+ done
+
+ for dir in $(find "$copydir/${PROFDEST#/}" -maxdepth 1 -type d -regex '.*.gen$\|.*.used$'); do
+ chown -R "$src_owner" "$dir"
+ cp -rp "$dir" "$PROFDEST"
+ rm -rf "$dir"
+ done
+
for l in "$copydir"/logdest/*; do
[[ $l == */logpipe.* ]] && continue
chown "$src_owner" "$l"
@@ -610,14 +626,15 @@ fi
umask 0022
-load_vars "$USER_HOME/.makepkg.conf"
-load_vars /etc/makepkg.conf
+load_vars "$USER_HOME/.makepkg-optimize.conf"
+load_vars /etc/makepkg-optimize.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
+[[ -d $PROFDEST ]] || PROFDEST=$PWD
create_chroot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.