# HG changeset patch # User Franz Glasner # Date 1717517449 -7200 # Node ID 263b4d382155a7204a1ca31345f5951b2b79d5bc # Parent 5194d87e0b4b40c792f1689f135304d9179080a6 "ftjail populate-tmpl" got a new "-b" flag and an optional parameter to preserver /boot and extract a kernel image also diff -r 5194d87e0b4b -r 263b4d382155 sbin/ftjail --- a/sbin/ftjail Tue May 14 09:46:54 2024 +0200 +++ b/sbin/ftjail Tue Jun 04 18:10:49 2024 +0200 @@ -281,13 +281,14 @@ command_populate_tmpl() { # MOUNTPOINT -- base.txz local _mp _basetxz - local _opt_symlink + local _opt_symlink _opt_preserve_boot local _opt _dir _opt_symlink="" + _opt_preserve_boot="" - while getopts "LP" _opt ; do + while getopts "LPb" _opt ; do case ${_opt} in L) _opt_symlink="yes" @@ -295,6 +296,9 @@ P) _opt_symlink="no" ;; + b) + _opt_preserve_boot="yes" + ;; \?) return 2; ;; @@ -307,6 +311,7 @@ _mp="${1-}" _basetxz="${2-}" + _kerneltxz="${3-}" if [ -z "${_mp}" ]; then echo "ERROR: no mountpoint given" >&2 @@ -344,7 +349,21 @@ (cd "${_mp}/root" && ln -s ../.cshrc .cshrc) || return fi - find "${_mp}/boot" -type f -delete || true + if [ \( "${_opt_preserve_boot}" = "yes" \) -o \( -n "${_kerneltxz}" \) ]; then + if [ "${_opt_symlink}" = "yes" ]; then + echo "ERROR: preserving boot or extracting a kernel not supported when using symlinks" >&2 + return 1 + fi + + if [ -n "${_kerneltxz}" ]; then + echo "Extracting kernel ..." + tar -C "${_mp}" -xJp -f "${_kerneltxz}" || return + else + echo "Preserved \"boot\"" + fi + else + find "${_mp}/boot" -type f -delete || true + fi }