Skip to content

Commit

Permalink
installkernel: don't use local
Browse files Browse the repository at this point in the history
cause that aint POSIX according to shellcheck

Signed-off-by: Nowa Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed Mar 1, 2025
1 parent bcda852 commit 47ce7fb
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions installkernel
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ dropindirs_sort() {

# Create backups of older versions before installing
updatever() {
local oldsuffix="${3}.old"
oldsuffix="${3}.old"
if [ "${3%.efi}" != "${3}" ]; then
# Some UEFIs enforce .efi suffix, so if using efi files retain suffix
oldsuffix="-old${3}"
Expand Down Expand Up @@ -183,10 +183,10 @@ trap cleanup EXIT

# Main installation script that we will call later
main() {
local ver=${1:?}
local img=${2:?}
local map=${3:?}
local dir=${4:-/boot}
ver=${1:?}
img=${2:?}
map=${3:?}
dir=${4:-/boot}
if [ ${#} -gt 4 ]; then
echo "Too many arguments."
return 1
Expand All @@ -195,7 +195,7 @@ main() {
INSTALLKERNEL_STAGING_AREA="$(mktemp -d -t installkernel.staging.XXXXXXX)"
export INSTALLKERNEL_STAGING_AREA

local suffix= candidate=
suffix=
if [ "${INSTALLKERNEL_LAYOUT}" = "efistub" ]; then
if [ ${#} -le 3 ] || [ "${4%/boot}" != "${4}" ]
then
Expand Down Expand Up @@ -254,12 +254,12 @@ main() {
fi
fi

local base_dir=$(dirname "${img}")
local prebuilt_initrd=${base_dir}/initrd
local prebuilt_uki=${base_dir}/uki.efi
base_dir=$(dirname "${img}")
prebuilt_initrd=${base_dir}/initrd
prebuilt_uki=${base_dir}/uki.efi

local initrd=${INSTALLKERNEL_STAGING_AREA}/initrd
local uki=${INSTALLKERNEL_STAGING_AREA}/uki.efi
initrd=${INSTALLKERNEL_STAGING_AREA}/initrd
uki=${INSTALLKERNEL_STAGING_AREA}/uki.efi

# Copy prebuilt initrd, uki.efi at kernel location
if [ -f "${prebuilt_initrd}" ]; then
Expand All @@ -274,7 +274,7 @@ main() {
# /usr/sbin and /sbin, just as dpkg would.
if [ ${#} -le 3 ] || [ "${4}" = "/boot" ]
then
local err=0
err=0
(
#shellcheck disable=SC2030
export LC_ALL=C PATH="${PATH}:/usr/sbin:/sbin"
Expand Down Expand Up @@ -309,7 +309,6 @@ main() {
echo "WARNING: All pre-installation hooks are ignored."
fi

local img_dest
if [ "${img%vmlinux*}" != "${img}" ]; then
img_dest=vmlinux
else
Expand Down Expand Up @@ -381,7 +380,7 @@ main() {
fi
updatever System.map "${map}"

local basedir=$(dirname "${map}")
basedir=$(dirname "${map}")
if [ -f "${basedir}/.config" ]; then
if [ "${INSTALLKERNEL_VERBOSE}" -gt 0 ]; then
echo "Installing config for ${ver}..."
Expand All @@ -400,7 +399,7 @@ main() {
# /usr/sbin and /sbin, just as dpkg would.
if [ ${#} -le 3 ] || [ "${4}" = "/boot" ]
then
local err=0
err=0
(
#shellcheck disable=SC2031
export LC_ALL=C PATH="${PATH}:/usr/sbin:/sbin"
Expand Down Expand Up @@ -505,15 +504,15 @@ export ID="${ID:=linux}"
export PRETTY_NAME="${PRETTY_NAME:=Linux}"

# Now we actually run the install
err=0
main_err=0
if [ ${_ik_install_all} -eq 1 ]; then
for ver in /lib/modules/*; do
ver=$(basename "${ver}")
img=/lib/modules/${ver}/vmlinuz
map=/lib/modules/${ver}/System.map
if [ -f "${img}" ] && [ -f "${map}" ]; then
main "${ver}" "${img}" "${map}" "${_ik_arg_4}" ||
{ err=${?}; echo "WARNING: Installing ${ver} failed"; }
{ main_err=${?}; echo "WARNING: Installing ${ver} failed"; }
cleanup
else
if [ "${INSTALLKERNEL_VERBOSE}" -gt 0 ]; then
Expand All @@ -524,12 +523,12 @@ if [ ${_ik_install_all} -eq 1 ]; then
else
if [ -f "${_ik_arg_2}" ] && [ -f "${_ik_arg_3}" ]; then
main "${_ik_arg_1}" "${_ik_arg_2}" "${_ik_arg_3}" "${_ik_arg_4}" ||
{ err=${?}; echo "ERROR: Installing ${_ik_arg_1} failed"; }
{ main_err=${?}; echo "ERROR: Installing ${_ik_arg_1} failed"; }
cleanup
else
echo "ERROR: No such kernel image or system map."
exit 1
fi
fi

exit ${err}
exit ${main_err}

0 comments on commit 47ce7fb

Please sign in to comment.