V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m15s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m15s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -53,107 +53,6 @@ prepare_mounts() {
|
||||
|
||||
declare var_path="" var_fs="" var_src="" var_opts=""
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
declare -g VAR_CHROOT_SYS_MASK_HELPER=""
|
||||
# shellcheck disable=SC2034
|
||||
VAR_CHROOT_SYS_MASK_HELPER=$(cat <<'EOF'
|
||||
#-------------------------------------------------------------------------------
|
||||
# Quick sys mask for initramfs build (minimalistic, idempotent)
|
||||
# - No strict mountpoint probing; we just try and remember what worked.
|
||||
# - Safe with 'set -e' because we branch on command success/failure.
|
||||
|
||||
cdi_sys_quick_enter() {
|
||||
declare state="/run/.ciss_sysmask"
|
||||
declare did_unmount_cg="0"
|
||||
declare did_mask_sys="0"
|
||||
|
||||
echo "Inside chroot: cdi_sys_quick_enter() @ Start."
|
||||
|
||||
mkdir -p /run
|
||||
mkdir -p /sys
|
||||
|
||||
# 1) Try to unmount 'cgroup2' (ok if it wasn't mounted).
|
||||
if umount -l /sys/fs/cgroup 2>/dev/null; then
|
||||
|
||||
did_unmount_cg="1"
|
||||
|
||||
else
|
||||
|
||||
did_unmount_cg="0"
|
||||
|
||||
fi
|
||||
|
||||
# 2) Try to overlay '/sys' with a tiny read-only 'tmpfs' (mask host sysfs view).
|
||||
if mount -t tmpfs -o ro,nosuid,nodev,noexec,mode=0555,size=1M tmpfs /sys 2>/dev/null; then
|
||||
|
||||
did_mask_sys="1"
|
||||
|
||||
else
|
||||
|
||||
did_mask_sys="0"
|
||||
|
||||
fi
|
||||
|
||||
printf 'MASK_SYS=%s\nUNMOUNTED_CG=%s\n' "${did_mask_sys}" "${did_unmount_cg}" >| "${state}"
|
||||
|
||||
echo "${state}"
|
||||
|
||||
echo "Inside chroot: cdi_sys_quick_enter() @ End."
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
cdi_sys_quick_leave() {
|
||||
declare state="/run/.ciss_sysmask"
|
||||
declare did_mask_sys="0"
|
||||
declare did_unmount_cg="0"
|
||||
|
||||
echo "Inside chroot: cdi_sys_quick_leave() @ Start."
|
||||
|
||||
if [[ -f "${state}" ]]; then
|
||||
|
||||
# shellcheck disable=SC2155
|
||||
declare did_mask_sys="$(grep -Eo '^MASK_SYS=[01]' "${state}" 2>/dev/null | cut -d= -f2 || printf '0')"
|
||||
|
||||
# shellcheck disable=SC2155
|
||||
declare did_unmount_cg="$(grep -Eo '^UNMOUNTED_CG=[01]' "${state}" 2>/dev/null | cut -d= -f2 || printf '0')"
|
||||
|
||||
fi
|
||||
|
||||
# 1) Drop '/sys' mask only if we actually overlaid it.
|
||||
if [[ "${did_mask_sys}" == "1" ]]; then
|
||||
|
||||
if ! umount -l /sys 2>/dev/null; then
|
||||
|
||||
printf 'WARN: could not unmount masked /sys (continuing)\n' >&2
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# 2) Restore 'cgroup2' only if we unmounted it before.
|
||||
if [[ "${did_unmount_cg}" == "1" ]]; then
|
||||
|
||||
mkdir -p /sys/fs/cgroup
|
||||
|
||||
if ! mount -t cgroup2 -o rw,nosuid,nodev,noexec,relatime cgroup2 /sys/fs/cgroup 2>/dev/null; then
|
||||
|
||||
printf 'WARN: could not remount cgroup2 (continuing)\n' >&2
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
rm -f -- "${state}"
|
||||
|
||||
echo "Inside chroot: cdi_sys_quick_leave() @ End."
|
||||
|
||||
return 0
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
EOF
|
||||
)
|
||||
|
||||
for var_path in "${!HMP_SPECIAL_MOUNTS[@]}"; do
|
||||
|
||||
mkdir -p "${TARGET}${var_path}"
|
||||
|
||||
@@ -36,23 +36,9 @@ update_initramfs() {
|
||||
"
|
||||
|
||||
chroot_script "${TARGET}" "
|
||||
### Write the helper verbatim (no host-side expansion).
|
||||
cat >| /tmp/.ciss_sysmask_helper.sh << 'EOS_ENTER'
|
||||
${VAR_CHROOT_SYS_MASK_HELPER}
|
||||
EOS_ENTER
|
||||
|
||||
source /tmp/.ciss_sysmask_helper.sh
|
||||
|
||||
### run: mask sys, build, unmask.
|
||||
cdi_sys_quick_enter
|
||||
|
||||
depmod -a ${var_kernel} 2>&1 | tee -a ${var_logfile}
|
||||
|
||||
update-initramfs -c -v -k all 2>&1 | tee -a ${var_logfile}
|
||||
echo ExitCode: \$? >> ${var_logfile}
|
||||
|
||||
cdi_sys_quick_leave
|
||||
rm -f /tmp/.ciss_sysmask_helper.sh
|
||||
"
|
||||
|
||||
chroot_script "${TARGET}" "
|
||||
|
||||
Reference in New Issue
Block a user