rename VMLINUZ to _VMLINUZ

This commit is contained in:
Tobias Powalowski 2023-02-15 17:05:40 +01:00
parent 4c7337b7ff
commit 0530f38947

View file

@ -17,8 +17,8 @@ _INST="/${_LIB}/installer"
_HELP="/${_LIB}/installer/help" _HELP="/${_LIB}/installer/help"
_RUN="/${_LIB}/run" _RUN="/${_LIB}/run"
_UPDATE="/${_LIB}/update-installer" _UPDATE="/${_LIB}/update-installer"
[[ "${_RUNNING_ARCH}" == "x86_64" || "${_RUNNING_ARCH}" == "riscv64" ]] && VMLINUZ="vmlinuz-linux" [[ "${_RUNNING_ARCH}" == "x86_64" || "${_RUNNING_ARCH}" == "riscv64" ]] && _VMLINUZ="vmlinuz-linux"
[[ "${_RUNNING_ARCH}" == "aarch64" ]] && VMLINUZ="Image" [[ "${_RUNNING_ARCH}" == "aarch64" ]] && _VMLINUZ="Image"
_graphic_options() { _graphic_options() {
if ! [[ "${_RUNNING_ARCH}" == "riscv64" ]]; then if ! [[ "${_RUNNING_ARCH}" == "riscv64" ]]; then
@ -219,20 +219,20 @@ _create_container() {
_kver_x86() { _kver_x86() {
# get kernel version from installed kernel # get kernel version from installed kernel
if [[ -f "${_RAM}/${VMLINUZ}" ]]; then if [[ -f "${_RAM}/${_VMLINUZ}" ]]; then
offset="$(od -An -j0x20E -dN2 "${_RAM}/${VMLINUZ}")" offset="$(od -An -j0x20E -dN2 "${_RAM}/${_VMLINUZ}")"
read -r _HWKVER _ < <(dd if="${_RAM}/${VMLINUZ}" bs=1 count=127 skip=$((offset + 0x200)) 2>/dev/null) read -r _HWKVER _ < <(dd if="${_RAM}/${_VMLINUZ}" bs=1 count=127 skip=$((offset + 0x200)) 2>/dev/null)
fi fi
} }
_kver_generic() { _kver_generic() {
# get kernel version from installed kernel # get kernel version from installed kernel
if [[ -f "${_RAM}/${VMLINUZ}" ]]; then if [[ -f "${_RAM}/${_VMLINUZ}" ]]; then
reader="cat" reader="cat"
# try if the image is gzip compressed # try if the image is gzip compressed
bytes="$(od -An -t x2 -N2 "${_RAM}/${VMLINUZ}" | tr -dc '[:alnum:]')" bytes="$(od -An -t x2 -N2 "${_RAM}/${_VMLINUZ}" | tr -dc '[:alnum:]')"
[[ $bytes == '8b1f' ]] && reader="zcat" [[ $bytes == '8b1f' ]] && reader="zcat"
read -r _ _ _HWKVER _ < <($reader "${_RAM}/${VMLINUZ}" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+') read -r _ _ _HWKVER _ < <($reader "${_RAM}/${_VMLINUZ}" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+')
fi fi
} }
@ -340,11 +340,11 @@ _new_environment() {
_create_container || exit 1 _create_container || exit 1
_clean_kernel_cache _clean_kernel_cache
_ram_check _ram_check
echo -e "\e[1mStep 04/10:\e[m Copying kernel ${VMLINUZ} to ${_RAM}/${VMLINUZ}..." echo -e "\e[1mStep 04/10:\e[m Copying kernel ${_VMLINUZ} to ${_RAM}/${_VMLINUZ}..."
# use ramfs to get immediate free space on file deletion # use ramfs to get immediate free space on file deletion
mkdir ${_RAM} mkdir ${_RAM}
mount -t ramfs none ${_RAM} mount -t ramfs none ${_RAM}
cp "${_W_DIR}/boot/${VMLINUZ}" ${_RAM}/ || exit 1 cp "${_W_DIR}/boot/${_VMLINUZ}" ${_RAM}/ || exit 1
[[ ${_RUNNING_ARCH} == "x86_64" ]] && _kver_x86 [[ ${_RUNNING_ARCH} == "x86_64" ]] && _kver_x86
[[ ${_RUNNING_ARCH} == "aarch64" || ${_RUNNING_ARCH} == "riscv64" ]] && _kver_generic [[ ${_RUNNING_ARCH} == "aarch64" || ${_RUNNING_ARCH} == "riscv64" ]] && _kver_generic
# fallback if no detectable kernel is installed # fallback if no detectable kernel is installed
@ -354,7 +354,7 @@ _new_environment() {
# write initramfs to "${_W_DIR}"/tmp # write initramfs to "${_W_DIR}"/tmp
${_NSPAWN} "${_W_DIR}" /bin/bash -c "umount tmp;mkinitcpio -k ${_HWKVER} -c ${_CONFIG} -d /tmp" >/dev/tty7 2>&1 || exit 1 ${_NSPAWN} "${_W_DIR}" /bin/bash -c "umount tmp;mkinitcpio -k ${_HWKVER} -c ${_CONFIG} -d /tmp" >/dev/tty7 2>&1 || exit 1
echo -e "\e[1mStep 06/10:\e[m Cleanup ${_W_DIR}..." echo -e "\e[1mStep 06/10:\e[m Cleanup ${_W_DIR}..."
find "${_W_DIR}"/. -mindepth 1 -maxdepth 1 ! -name 'tmp' ! -name "${VMLINUZ}" -exec rm -rf {} \; find "${_W_DIR}"/. -mindepth 1 -maxdepth 1 ! -name 'tmp' ! -name "${_VMLINUZ}" -exec rm -rf {} \;
_clean_kernel_cache _clean_kernel_cache
_ram_check _ram_check
echo -e "\e[1mStep 07/10:\e[m Creating initramfs ${_RAM}/${_INITRD}..." echo -e "\e[1mStep 07/10:\e[m Creating initramfs ${_RAM}/${_INITRD}..."
@ -380,14 +380,14 @@ _new_environment() {
done done
if [[ "$(($(stat -c %s ${_RAM}/${_INITRD})*339/100000))" -lt "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" ]]; then if [[ "$(($(stat -c %s ${_RAM}/${_INITRD})*339/100000))" -lt "$(grep -w MemTotal /proc/meminfo | cut -d ':' -f2 | sed -e 's# ##g' -e 's#kB$##g')" ]]; then
echo -e "\e[1mStep 10/10:\e[m Running \e[1;92mkexec\e[m with \e[1mnew\e[m KEXEC_FILE_LOAD..." echo -e "\e[1mStep 10/10:\e[m Running \e[1;92mkexec\e[m with \e[1mnew\e[m KEXEC_FILE_LOAD..."
kexec -s -f ${_RAM}/"${VMLINUZ}" --initrd="${_RAM}/${_INITRD}" --reuse-cmdline & kexec -s -f ${_RAM}/"${_VMLINUZ}" --initrd="${_RAM}/${_INITRD}" --reuse-cmdline &
else else
echo -e "\e[1mStep 10/10:\e[m Running \e[1;92mkexec\e[m with \e[1mold\e[m KEXEC_LOAD..." echo -e "\e[1mStep 10/10:\e[m Running \e[1;92mkexec\e[m with \e[1mold\e[m KEXEC_LOAD..."
kexec -c -f --mem-max=0xA0000000 ${_RAM}/"${VMLINUZ}" --initrd="${_RAM}/${_INITRD}" --reuse-cmdline & kexec -c -f --mem-max=0xA0000000 ${_RAM}/"${_VMLINUZ}" --initrd="${_RAM}/${_INITRD}" --reuse-cmdline &
fi fi
sleep 2 sleep 2
_clean_kernel_cache _clean_kernel_cache
rm ${_RAM}/{"${VMLINUZ}","${_INITRD}"} rm ${_RAM}/{"${_VMLINUZ}","${_INITRD}"}
umount ${_RAM} &>/dev/null umount ${_RAM} &>/dev/null
rm -r ${_RAM} &>/dev/null rm -r ${_RAM} &>/dev/null
#shellcheck disable=SC2115 #shellcheck disable=SC2115