Forked from
pkg / systemd
131 commits behind the upstream repository.
-
Ritesh Raj Sarraf authored
Refresh patches against the latest bashism changes from Buster. Also, ignore some additional code related to INITRD_OPTIONS Signed-off-by:
Ritesh Raj Sarraf <ritesh.sarraf@collabora.com>
Ritesh Raj Sarraf authoredRefresh patches against the latest bashism changes from Buster. Also, ignore some additional code related to INITRD_OPTIONS Signed-off-by:
Ritesh Raj Sarraf <ritesh.sarraf@collabora.com>
0003-Reworked-kernel-install-script.patch 5.86 KiB
From 846fbb18270c33ebe4c11c32ea65ab0d6a114fbf Mon Sep 17 00:00:00 2001
From: Denis Pynkin <denis.pynkin@collabora.com>
Date: Thu, 14 Feb 2019 00:46:48 +0300
Subject: [PATCH 3/3] Reworked kernel-install script
- Removed bashisms -- script is adapted for running with `/bin/sh`
- Add support of calling the script without passing the kernel image.
- Allow to use name prefix while detecting the action.
If the name of (sym)link to 'kernel-install' script ends with
'installkernel' or 'removekernel' -- the action 'add' or 'remove' is
assumed. This change allow to use file names like `zz_installkernel`
to force it to run last during the kernel installing or removing.
Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
---
src/kernel-install/kernel-install | 77 ++++++++++++++++---------------
1 file changed, 41 insertions(+), 36 deletions(-)
--- a/src/kernel-install/kernel-install
+++ b/src/kernel-install/kernel-install
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# SPDX-License-Identifier: LGPL-2.1+
@@ -31,22 +31,18 @@
dropindirs_sort()
{
local suffix=$1; shift
- local -a files
local f d i
- readarray -t files <<<"$(
- for d in "$@"; do
- for i in "$d/"*"$suffix"; do
- if [[ -e "$i" ]]; then
- echo "${i##*/}"
- fi
- done
- done | sort -Vu
- )"
-
- for f in "${files[@]}"; do
+ for d in "$@"; do
+ for i in "$d/"*"$suffix"; do
+ if [ -e "$i" ]; then
+ echo "${i##*/}"
+ fi
+ done
+ done | sort -u | \
+ while read f; do
for d in "$@"; do
- if [[ -e "$d/$f" ]]; then
+ if [ -e "$d/$f" ]; then
echo "$d/$f"
continue 2
fi
@@ -57,42 +53,46 @@
export LC_COLLATE=C
for i in "$@"; do
- if [ "$i" == "--help" -o "$i" == "-h" ]; then
+ if [ "$i" = "--help" ] || [ "$i" = "-h" ]; then
usage
exit 0
fi
done
-if [[ "${0##*/}" == 'installkernel' ]]; then
++if [ "${0%installkernel}" != "${0}" ]; then
COMMAND='add'
- # make install doesn't pass any parameter wrt initrd handling
- INITRD_OPTIONS=()
++elif [ "${0%removekernel}" != "${0}" ]; then
++ COMMAND='remove'
else
COMMAND="$1"
shift
- INITRD_OPTIONS=( "${@:3}" )
fi
KERNEL_VERSION="$1"
KERNEL_IMAGE="$2"
-if [[ -f /etc/machine-id ]]; then
+if [ -f /etc/machine-id ]; then
read MACHINE_ID < /etc/machine-id
fi
-if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
+if [ -z "$COMMAND" ] || [ -z "$KERNEL_VERSION" ]; then
echo "Not enough arguments" >&2
exit 1
fi
-if ! [[ $MACHINE_ID ]]; then
+# According to man page 2-nd parameter could be skipped
+if [ -z "$KERNEL_IMAGE" ]; then
+ KERNEL_IMAGE="/boot/vmlinuz-$KERNEL_VERSION"
+fi
+
+if [ -z "$MACHINE_ID" ]; then
BOOT_DIR_ABS=$(mktemp -d /tmp/kernel-install.XXXXX) || exit 1
trap "rm -rf '$BOOT_DIR_ABS'" EXIT INT QUIT PIPE
-elif [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
+elif [ -d /efi/loader/entries ] || [ -d /efi/$MACHINE_ID ]; then
BOOT_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
-elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then
+elif [ -d /boot/loader/entries ] || [ -d /boot/$MACHINE_ID ]; then
BOOT_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
-elif [[ -d /boot/efi/loader/entries ]] || [[ -d /boot/efi/$MACHINE_ID ]]; then
+elif [ -d /boot/efi/loader/entries ] || [ -d /boot/efi/$MACHINE_ID ]; then
BOOT_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
elif mountpoint -q /efi; then
BOOT_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
@@ -106,15 +106,16 @@
ret=0
-readarray -t PLUGINS <<<"$(
+
+plugins_list(){
dropindirs_sort ".install" \
"/etc/kernel/install.d" \
"/usr/lib/kernel/install.d"
-)"
+}
case $COMMAND in
add)
- if [[ ! "$KERNEL_IMAGE" ]]; then
+ if [ -z "$KERNEL_IMAGE" ]; then
echo "Command 'add' requires an argument" >&2
exit 1
fi
@@ -124,42 +125,42 @@
exit 1
}
- for f in "${PLUGINS[@]}"; do
- if [[ -x $f ]]; then
+ plugins_list | while read f; do
+ if [ -x "$f" ]; then
"$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE" "${INITRD_OPTIONS[@]}"
x=$?
- if [[ $x == $SKIP_REMAINING ]]; then
+ if [ $x = $SKIP_REMAINING ]; then
ret=0
break
fi
- ((ret+=$x))
+ ret=`expr $ret + $x`
fi
done
- if ! [[ $MACHINE_ID ]] && ! rmdir "$BOOT_DIR_ABS"; then
+ if [ -z "$MACHINE_ID" ] && ! rmdir "$BOOT_DIR_ABS"; then
echo "Warning: In kernel-install plugins, requiring BOOT_DIR_ABS to be preset is deprecated." >&2
echo " All plugins should not put anything in BOOT_DIR_ABS if the environment" >&2
echo " variable KERNEL_INSTALL_MACHINE_ID is empty." >&2
rm -rf "$BOOT_DIR_ABS"
- ((ret+=$?))
+ ret=`expr $ret + $?`
fi
;;
remove)
- for f in "${PLUGINS[@]}"; do
- if [[ -x $f ]]; then
+ plugins_list | while read f; do
+ if [ -x "$f" ]; then
"$f" remove "$KERNEL_VERSION" "$BOOT_DIR_ABS"
x=$?
- if [[ $x == $SKIP_REMAINING ]]; then
+ if [ $x = $SKIP_REMAINING ]; then
ret=0
break
fi
- ((ret+=$x))
+ ret=`expr $ret + $x`
fi
done
rm -rf "$BOOT_DIR_ABS"
- ((ret+=$?))
+ ret=`expr $ret + $?`
;;
*)
@@ -169,3 +170,4 @@
esac
exit $ret
+