Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archiso/mkarchiso
diff options
context:
space:
mode:
authorDavid Runge <dvzrv@archlinux.org>2020-10-23 22:13:52 +0200
committerDavid Runge <dvzrv@archlinux.org>2020-10-24 17:00:59 +0200
commitf3af5692059067cf8692b5cd1e0d7395c41fec06 (patch)
treef1b09537114dd50c9e641b0a028886c4b9ce4a02 /archiso/mkarchiso
parent729d16b48c99c5d9b23a89123ecde4ecacfa8705 (diff)
Set CacheDir and HookDir for profile more sanely
archiso/mkarchiso: Change `_pacman()` to use the *modified* pacman.conf from the work_dir, instead of using the *unmodified* pacman.conf from the profile. Change `_make_pacman_conf()` to compare the system's and the profile's CacheDir setting and use the profile's CacheDir setting only if it's not the default and not the same as the system's. Always set the HookDir to the airootfs' override directory, so that no hooks from the host system are being run. Remove DBPath, LogFile and RootDir settings from the work_dir pacman.conf as they are otherwise referring to the host system, **even if** pacman is being called with the `-r` flag. Fix a typo in _make_custom_airootfs(). README.profile.rst: Add information about the pacman.conf in a profile and how configuration options behave, when used by mkarchiso. Fixes #73 Fixes #74
Diffstat (limited to 'archiso/mkarchiso')
-rwxr-xr-xarchiso/mkarchiso36
1 files changed, 28 insertions, 8 deletions
diff --git a/archiso/mkarchiso b/archiso/mkarchiso
index b5c5150..9eca18b 100755
--- a/archiso/mkarchiso
+++ b/archiso/mkarchiso
@@ -202,9 +202,9 @@ _pacman() {
_msg_info "Installing packages to '${airootfs_dir}/'..."
if [[ "${quiet}" = "y" ]]; then
- pacstrap -C "${pacman_conf}" -c -G -M -- "${airootfs_dir}" "$@" &> /dev/null
+ pacstrap -C "${work_dir}/pacman.conf" -c -G -M -- "${airootfs_dir}" "$@" &> /dev/null
else
- pacstrap -C "${pacman_conf}" -c -G -M -- "${airootfs_dir}" "$@"
+ pacstrap -C "${work_dir}/pacman.conf" -c -G -M -- "${airootfs_dir}" "$@"
fi
_msg_info "Done! Packages installed successfully."
@@ -321,12 +321,32 @@ _run_once() {
fi
}
-# Set up custom pacman.conf with current cache directories.
+# Set up custom pacman.conf with custom cache and pacman hook directories
_make_pacman_conf() {
- local _cache_dirs
- _cache_dirs="$(pacman-conf CacheDir)"
- sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${_cache_dirs[*]//$'\n'/ }|g" \
- "${pacman_conf}" > "${work_dir}/pacman.conf"
+ local _cache_dirs _system_cache_dirs _profile_cache_dirs
+ _system_cache_dirs="$(pacman-conf CacheDir| tr '\n' ' ')"
+ _profile_cache_dirs="$(pacman-conf --config "${pacman_conf}" CacheDir| tr '\n' ' ')"
+
+ # only use the profile's CacheDir, if it is not the default and not the same as the system cache dir
+ if [[ "${_profile_cache_dirs}" != "/var/cache/pacman/pkg" ]] && \
+ [[ "${_system_cache_dirs}" != "${_profile_cache_dirs}" ]]; then
+ _cache_dirs="${_profile_cache_dirs}"
+ else
+ _cache_dirs="${_system_cache_dirs}"
+ fi
+
+ _msg_info "Copying custom pacman.conf to work directory..."
+ # take the profile pacman.conf and strip all settings that would break in chroot when using pacman -r
+ # see `man 8 pacman` for further info
+ pacman-conf --config "${pacman_conf}" | \
+ sed '/CacheDir/d;/DBPath/d;/HookDir/d;/LogFile/d;/RootDir/d' > "${work_dir}/pacman.conf"
+
+ _msg_info "Using pacman CacheDir: ${_cache_dirs}"
+ # append CacheDir and HookDir to [options] section
+ # HookDir is *always* set to the airootfs' override directory
+ sed "/\[options\]/a CacheDir = ${_cache_dirs}
+ /\[options\]/a HookDir = ${airootfs_dir}/etc/pacman.d/hooks/" \
+ -i "${work_dir}/pacman.conf"
}
# Prepare working directory and copy custom airootfs files (airootfs)
@@ -336,7 +356,7 @@ _make_custom_airootfs() {
install -d -m 0755 -o 0 -g 0 -- "${airootfs_dir}"
if [[ -d "${profile}/airootfs" ]]; then
- _msg_info "Copying custom custom airootfs files and setting up user home directories..."
+ _msg_info "Copying custom airootfs files and setting up user home directories..."
cp -af --no-preserve=ownership -- "${profile}/airootfs/." "${airootfs_dir}"
[[ -e "${airootfs_dir}/etc/shadow" ]] && chmod -f 0400 -- "${airootfs_dir}/etc/shadow"