systemd-logind to be safe. See
https://cgit.freedesktop.org/xorg/xserver/commit/?id=dc48bd653c7e101.)
- * All kernel install plugins are called with the environment variable
+ * All kernel-install plugins are called with the environment variable
KERNEL_INSTALL_MACHINE_ID which is set to the machine ID given by
- /etc/machine-id. If the file is missing or empty, the variable is
- empty and BOOT_DIR_ABS is the path of a temporary directory which is
- removed after all the plugins exit. So, if KERNEL_INSTALL_MACHINE_ID
- is empty, all plugins should not put anything in BOOT_DIR_ABS.
+ /etc/machine-id. If the machine ID could not be determined,
+ $KERNEL_INSTALL_MACHINE_ID will be empty. Plugins should not put
+ anything in the entry directory (passed as the second argument) if
+ $KERNEL_INSTALL_MACHINE_ID is empty. For backwards compatiblity, a
+ temporary directory is passed as the entry directory and removed
+ after all the plugins exit.
Contributions from: Adrian Heine né Lang, Aggelos Avgerinos, Alexander
Kurtz, Alexandros Frantzis, Alexey Brodkin, Alex Lu, Amir Pakdel, Amir
COMMAND="$1"
KERNEL_VERSION="$2"
-BOOT_DIR_ABS="$3"
+ENTRY_DIR_ABS="$3"
KERNEL_IMAGE="$4"
INITRD_OPTIONS_START="5"
COMMAND="$1"
KERNEL_VERSION="$2"
-BOOT_DIR_ABS="$3"
+ENTRY_DIR_ABS="$3"
KERNEL_IMAGE="$4"
INITRD_OPTIONS_START="5"
exit 0
fi
-if ! [[ -d "$BOOT_DIR_ABS" ]]; then
+if ! [[ -d "$ENTRY_DIR_ABS" ]]; then
exit 0
fi
MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
-BOOT_DIR="/$MACHINE_ID/$KERNEL_VERSION"
-BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
+ENTRY_DIR="/$MACHINE_ID/$KERNEL_VERSION"
+BOOT_ROOT=${ENTRY_DIR_ABS%$ENTRY_DIR}
if [[ $COMMAND == remove ]]; then
rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
fi
-cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS/linux" &&
- chown root:root "$BOOT_DIR_ABS/linux" &&
- chmod 0644 "$BOOT_DIR_ABS/linux" || {
- echo "Could not copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'." >&2
+cp "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" &&
+ chown root:root "$ENTRY_DIR_ABS/linux" &&
+ chmod 0644 "$ENTRY_DIR_ABS/linux" || {
+ echo "Could not copy '$KERNEL_IMAGE to '$ENTRY_DIR_ABS/linux'." >&2
exit 1
}
if [[ -f "${initrd}" ]]; then
initrd_basename="$(basename ${initrd})"
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
- echo "Installing $BOOT_DIR_ABS/${initrd_basename}"
- cp "${initrd}" "$BOOT_DIR_ABS/${initrd_basename}" &&
- chown root:root "$BOOT_DIR_ABS/${initrd_basename}" &&
- chmod 0644 "$BOOT_DIR_ABS/${initrd_basename}" || {
- echo "Could not copy '${initrd}' to '$BOOT_DIR_ABS/${initrd_basename}'." >&2
+ echo "Installing $ENTRY_DIR_ABS/${initrd_basename}"
+ cp "${initrd}" "$ENTRY_DIR_ABS/${initrd_basename}" &&
+ chown root:root "$ENTRY_DIR_ABS/${initrd_basename}" &&
+ chmod 0644 "$ENTRY_DIR_ABS/${initrd_basename}" || {
+ echo "Could not copy '${initrd}' to '$ENTRY_DIR_ABS/${initrd_basename}'." >&2
exit 1
}
fi
echo "version $KERNEL_VERSION"
echo "machine-id $MACHINE_ID"
echo "options ${BOOT_OPTIONS[*]}"
- echo "linux $BOOT_DIR/linux"
+ echo "linux $ENTRY_DIR/linux"
for initrd in "${INITRD_OPTIONS[@]}"; do
- [[ -f $BOOT_DIR_ABS/$(basename ${initrd}) ]] && \
- echo "initrd $BOOT_DIR/$(basename ${initrd})"
+ [[ -f $ENTRY_DIR_ABS/$(basename ${initrd}) ]] && \
+ echo "initrd $ENTRY_DIR/$(basename ${initrd})"
done
:
} > "$LOADER_ENTRY" || {
fi
if ! [[ $MACHINE_ID ]]; then
- BOOT_DIR_ABS=$(mktemp -d /tmp/kernel-install.XXXXX) || exit 1
- trap "rm -rf '$BOOT_DIR_ABS'" EXIT INT QUIT PIPE
+ ENTRY_DIR_ABS=$(mktemp -d /tmp/kernel-install.XXXXX) || exit 1
+ trap "rm -rf '$ENTRY_DIR_ABS'" EXIT INT QUIT PIPE
elif [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
- BOOT_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
+ ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then
- BOOT_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
+ ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
elif [[ -d /boot/efi/loader/entries ]] || [[ -d /boot/efi/$MACHINE_ID ]]; then
- BOOT_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
+ ENTRY_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
elif mountpoint -q /efi; then
- BOOT_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
+ ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
elif mountpoint -q /boot/efi; then
- BOOT_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
+ ENTRY_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
else
- BOOT_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
+ ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
fi
export KERNEL_INSTALL_MACHINE_ID=$MACHINE_ID
exit 1
fi
- mkdir -p "$BOOT_DIR_ABS" || {
- echo "Could not create boot directory '$BOOT_DIR_ABS'." >&2
+ mkdir -p "$ENTRY_DIR_ABS" || {
+ echo "Could not create boot directory '$ENTRY_DIR_ABS'." >&2
exit 1
}
for f in "${PLUGINS[@]}"; do
if [[ -x $f ]]; then
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
- echo "+$f add $KERNEL_VERSION $BOOT_DIR_ABS $KERNEL_IMAGE ${INITRD_OPTIONS[@]}"
- "$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE" "${INITRD_OPTIONS[@]}"
+ echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $KERNEL_IMAGE ${INITRD_OPTIONS[@]}"
+ "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$KERNEL_IMAGE" "${INITRD_OPTIONS[@]}"
x=$?
if [[ $x == $SKIP_REMAINING ]]; then
ret=0
fi
done
- if ! [[ $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
+ if ! [[ $MACHINE_ID ]] && ! rmdir "$ENTRY_DIR_ABS"; then
+ echo "Warning: In kernel-install plugins, requiring ENTRY_DIR_ABS to be preset is deprecated." >&2
+ echo " All plugins should not put anything in ENTRY_DIR_ABS if the environment" >&2
echo " variable KERNEL_INSTALL_MACHINE_ID is empty." >&2
- rm -rf "$BOOT_DIR_ABS"
+ rm -rf "$ENTRY_DIR_ABS"
((ret+=$?))
fi
;;
for f in "${PLUGINS[@]}"; do
if [[ -x $f ]]; then
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
- echo "+$f remove $KERNEL_VERSION $BOOT_DIR_ABS"
- "$f" remove "$KERNEL_VERSION" "$BOOT_DIR_ABS"
+ echo "+$f remove $KERNEL_VERSION $ENTRY_DIR_ABS"
+ "$f" remove "$KERNEL_VERSION" "$ENTRY_DIR_ABS"
x=$?
if [[ $x == $SKIP_REMAINING ]]; then
ret=0
done
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
- echo "Removing $BOOT_DIR_ABS"
+ echo "Removing $ENTRY_DIR_ABS"
- rm -rf "$BOOT_DIR_ABS"
+ rm -rf "$ENTRY_DIR_ABS"
((ret+=$?))
;;