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
This commit is contained in:
parent
729d16b48c
commit
f3af569205
24
README.profile.rst
Normal file
24
README.profile.rst
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
=======
|
||||||
|
profile
|
||||||
|
=======
|
||||||
|
|
||||||
|
An archiso profile consists of several configuration files and a directory for files to be added to the resulting image.
|
||||||
|
|
||||||
|
pacman.conf
|
||||||
|
===========
|
||||||
|
|
||||||
|
A configuration for pacman is required per profile.
|
||||||
|
|
||||||
|
Some configuration options will not be used or will be modified:
|
||||||
|
|
||||||
|
* `CacheDir`: the profile's option is **only** used if it is not the default (i.e. `/var/cache/pacman/pkg`) and if it is
|
||||||
|
not the same as the system's option. In all other cases the system's pacman cache is used.
|
||||||
|
* `HookDir`: it is **always** set to the `/etc/pacman.d/hooks` airootfs directory in the work directories airootfs to
|
||||||
|
allow modification via the profile and ensure interoparability with hosts using dracut (see #73 for further
|
||||||
|
information)
|
||||||
|
* `RootDir`: it is **always** removed, as setting it explicitely otherwise refers to the host's root filesystem (see
|
||||||
|
`man 8 pacman` for further information on the `-r` option used by `pacstrap`)
|
||||||
|
* `LogFile`: it is **always** removed, as setting it explicitely otherwise refers to the host's pacman log file (see
|
||||||
|
`man 8 pacman` for further information on the `-r` option used by `pacstrap`)
|
||||||
|
* `DBPath`: it is **always** removed, as setting it explicitely otherwise refers to the host's pacman database (see
|
||||||
|
`man 8 pacman` for further information on the `-r` option used by `pacstrap`)
|
@ -202,9 +202,9 @@ _pacman() {
|
|||||||
_msg_info "Installing packages to '${airootfs_dir}/'..."
|
_msg_info "Installing packages to '${airootfs_dir}/'..."
|
||||||
|
|
||||||
if [[ "${quiet}" = "y" ]]; then
|
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
|
else
|
||||||
pacstrap -C "${pacman_conf}" -c -G -M -- "${airootfs_dir}" "$@"
|
pacstrap -C "${work_dir}/pacman.conf" -c -G -M -- "${airootfs_dir}" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_msg_info "Done! Packages installed successfully."
|
_msg_info "Done! Packages installed successfully."
|
||||||
@ -321,12 +321,32 @@ _run_once() {
|
|||||||
fi
|
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() {
|
_make_pacman_conf() {
|
||||||
local _cache_dirs
|
local _cache_dirs _system_cache_dirs _profile_cache_dirs
|
||||||
_cache_dirs="$(pacman-conf CacheDir)"
|
_system_cache_dirs="$(pacman-conf CacheDir| tr '\n' ' ')"
|
||||||
sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${_cache_dirs[*]//$'\n'/ }|g" \
|
_profile_cache_dirs="$(pacman-conf --config "${pacman_conf}" CacheDir| tr '\n' ' ')"
|
||||||
"${pacman_conf}" > "${work_dir}/pacman.conf"
|
|
||||||
|
# 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)
|
# 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}"
|
install -d -m 0755 -o 0 -g 0 -- "${airootfs_dir}"
|
||||||
|
|
||||||
if [[ -d "${profile}/airootfs" ]]; then
|
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}"
|
cp -af --no-preserve=ownership -- "${profile}/airootfs/." "${airootfs_dir}"
|
||||||
|
|
||||||
[[ -e "${airootfs_dir}/etc/shadow" ]] && chmod -f 0400 -- "${airootfs_dir}/etc/shadow"
|
[[ -e "${airootfs_dir}/etc/shadow" ]] && chmod -f 0400 -- "${airootfs_dir}/etc/shadow"
|
||||||
|
Loading…
Reference in New Issue
Block a user