Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/makechrootpkg.in
diff options
context:
space:
mode:
author依云 <lilydjwg@gmail.com>2023-01-14 00:44:55 +0800
committerChristian Heusel <christian@heusel.eu>2024-05-18 19:39:18 +0200
commit5f198534144f09d09f9e4c0541d8da15f8c1aed3 (patch)
tree6f0692d5e24bb3ad199b0777d293f80f3ab4152e /src/makechrootpkg.in
parent2b62ac660d258858f7a7795a113a7056d0d2c79d (diff)
feat: support bind mounting a tmpfs
A .cache can be bind mounted into the container to save the caches for reuse, but sometimes we want to exclude specific caches (because they don't work well, e.g. bazel's). Component: makechrootpkg
Diffstat (limited to 'src/makechrootpkg.in')
-rw-r--r--src/makechrootpkg.in44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/makechrootpkg.in b/src/makechrootpkg.in
index 459f7ce..9df14e8 100644
--- a/src/makechrootpkg.in
+++ b/src/makechrootpkg.in
@@ -38,6 +38,7 @@ inspect=never
bindmounts_ro=()
bindmounts_rw=()
+bindmounts_tmpfs=()
copy=$USER
[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
@@ -65,23 +66,24 @@ usage() {
echo "Default makepkg args: ${default_makepkg_args[*]}"
echo ''
echo 'Flags:'
- echo '-h This help'
- echo '-c Clean the chroot before building'
- echo '-d <dir> Bind directory into build chroot as read-write'
- echo '-D <dir> Bind directory into build chroot as read-only'
- echo '-u Update the working copy of the chroot before building'
- echo ' This is useful for rebuilds without dirtying the pristine'
- echo ' chroot'
- echo '-r <dir> The chroot dir to use'
- echo '-I <pkg> Install a package into the working copy of the chroot'
- echo '-l <copy> The directory to use as the working copy of the chroot'
- echo ' Useful for maintaining multiple copies'
- echo " Default: $copy"
- echo '-n Run namcap on the package'
- echo '-C Run checkpkg on the package'
- echo '-T Build in a temporary directory'
- echo '-U Run makepkg as a specified user'
- echo '-x <when> Inspect chroot after build (never, always, failure)'
+ echo '-h This help'
+ echo '-c Clean the chroot before building'
+ echo '-d <dir> Bind directory into build chroot as read-write'
+ echo '-D <dir> Bind directory into build chroot as read-only'
+ echo '-t <dir[:opts]> Mount a tmpfs at directory'
+ echo '-u Update the working copy of the chroot before building'
+ echo ' This is useful for rebuilds without dirtying the pristine'
+ echo ' chroot'
+ echo '-r <dir> The chroot dir to use'
+ echo '-I <pkg> Install a package into the working copy of the chroot'
+ echo '-l <copy> The directory to use as the working copy of the chroot'
+ echo ' Useful for maintaining multiple copies'
+ echo " Default: $copy"
+ echo '-n Run namcap on the package'
+ echo '-C Run checkpkg on the package'
+ echo '-T Build in a temporary directory'
+ echo '-U Run makepkg as a specified user'
+ echo '-x <when> Inspect chroot after build (never, always, failure)'
exit 1
}
@@ -148,7 +150,7 @@ install_packages() {
pkgnames=("${install_pkgs[@]##*/}")
cp -- "${install_pkgs[@]}" "$copydir/root/"
- arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
+ arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" "${bindmounts_tmpfs[@]}" \
pacman -U --noconfirm --ask=4 -- "${pkgnames[@]/#//root/}"
ret=$?
rm -- "${pkgnames[@]/#/$copydir/root/}"
@@ -291,11 +293,12 @@ move_products() {
}
# }}}
-while getopts 'hcur:I:l:nCTD:d:U:x:' arg; do
+while getopts 'hcur:I:l:nCTD:d:U:x:t:' arg; do
case "$arg" in
c) clean_first=1 ;;
D) bindmounts_ro+=("--bind-ro=$OPTARG") ;;
d) bindmounts_rw+=("--bind=$OPTARG") ;;
+ t) bindmounts_tmpfs+=("--tmpfs=$OPTARG") ;;
u) update_first=1 ;;
r) passeddir="$OPTARG" ;;
I) install_pkgs+=("$OPTARG") ;;
@@ -365,7 +368,7 @@ if [[ ! -d $copydir ]] || (( clean_first )); then
fi
(( update_first )) && arch-nspawn "$copydir" \
- "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
+ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" "${bindmounts_tmpfs[@]}" \
pacman -Syuu --noconfirm
if [[ -n ${install_pkgs[*]:-} ]]; then
@@ -390,6 +393,7 @@ nspawn_build_args=(
--tmpfs="/tmp:${tmp_opts}"
"${bindmounts_ro[@]}"
"${bindmounts_rw[@]}"
+ "${bindmounts_tmpfs[@]}"
)
if arch-nspawn "$copydir" \