remove pve-kernel-helper

it lives in the proxmox-kernel-helper repository now.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2023-01-10 15:56:53 +01:00
parent 89a23fe1a1
commit 7fc1b2ac61
21 changed files with 1 additions and 1325 deletions

View File

@ -7,17 +7,10 @@ GITVERSION:=$(shell git rev-parse HEAD)
KERNEL_DEB=pve-kernel-${KERNEL_VER}_${DEB_VERSION_UPSTREAM_REVISION}_all.deb
HEADERS_DEB=pve-headers-${KERNEL_VER}_${DEB_VERSION_UPSTREAM_REVISION}_all.deb
HELPER_DEB=pve-kernel-helper_${DEB_VERSION_UPSTREAM_REVISION}_all.deb
BUILD_DIR=build
DEBS=${KERNEL_DEB} ${HEADERS_DEB} ${HELPER_DEB}
SUBDIRS = proxmox-boot bin
.PHONY: all
all: ${SUBDIRS}
set -e && for i in ${SUBDIRS}; do ${MAKE} -C $$i; done
DEBS=${KERNEL_DEB} ${HEADERS_DEB}
.PHONY: deb
deb: ${DEBS}
@ -32,10 +25,6 @@ ${KERNEL_DEB}: debian
cd ${BUILD_DIR}; dpkg-buildpackage -b -uc -us
lintian ${DEBS}
.PHONY: install
install: ${SUBDIRS}
set -e && for i in ${SUBDIRS}; do ${MAKE} -C $$i $@; done
.PHONY: upload
upload: ${DEBS}
tar cf - ${DEBS}|ssh repoman@repo.proxmox.com -- upload --product pve,pmg,pbs --dist bullseye

View File

@ -1,13 +0,0 @@
SBINDIR=${DESTDIR}/usr/sbin
.PHONY: all
all:
install:
install -d ${SBINDIR}
install -m 0755 proxmox-boot-tool ${SBINDIR}/
install -m 0755 grub-install-wrapper ${SBINDIR}/grub-install
.PHONY: clean distclean
distclean:
clean:

View File

@ -1,30 +0,0 @@
#! /bin/sh
set -e
. /usr/share/pve-kernel-helper/scripts/functions
if proxmox-boot-tool status --quiet; then
# detect when being called by dpkg (e.g. grub-pc.postinst
if [ -n "$DPKG_RUNNING_VERSION" ] && echo "$DPKG_MAINTSCRIPT_PACKAGE" | grep -sq "^grub-"; then
if [ -d /sys/firmware/efi ]; then
echo "Promxox's boot-tool is used and booted via EFI, skipping re-sync of GRUB"
exit 0
fi
MARKER_FILE="/tmp/proxmox-boot-tool.dpkg.marker"
if [ ! -e "$MARKER_FILE" ]; then
warn "This system is booted via proxmox-boot-tool, running proxmox-boot-tool init for all configured bootdisks"
proxmox-boot-tool reinit
proxmox-boot-tool refresh
touch "$MARKER_FILE"
exit 0
else
echo "Proxmox's boot-tool marker file found, ignoring grub install call."
exit 0
fi
fi
warn "grub-install is disabled because this system is booted via proxmox-boot-tool, if you really need to run it, run /usr/sbin/grub-install.real"
exit 1
else
grub-install.real "$@"
fi

View File

@ -1,682 +0,0 @@
#!/bin/sh
set -e
. /usr/share/pve-kernel-helper/scripts/functions
_add_entry_to_list_file() {
file="$1"
entry="$2"
if [ -e "$file" ]; then
cp "$file" "$file.new"
fi
echo "$entry" >> "$file.new"
sort -uo "$file.new" "$file.new"
mv "$file.new" "$file"
}
_remove_entry_from_list_file() {
file="$1"
entry="$2"
# guard against removing whole file by accident!
if [ -z "$entry" ]; then
echo "cannot remove empty entry from '$file'."
return
fi
if [ -e "$file" ]; then
grep -vFx "$entry" "$file" > "$file.new" || true
mv "$file.new" "$file"
else
echo "'$file' does not exist.."
fi
}
_get_partition_info() {
if [ ! -e "$1" ]; then
warn "E: '$1' does not exist!"
exit 1
fi
bdev=$(realpath "$1")
if [ ! -b "$bdev" ]; then
warn "E: '$bdev' is not a block device!"
exit 1
fi
bdev_info=$( \
lsblk \
--bytes \
--pairs \
-o 'UUID,SIZE,FSTYPE,PARTTYPE,PKNAME,MOUNTPOINT' \
"$bdev" \
)
if [ -z "$bdev_info" ]; then
warn "E: unable to get information about block device '$1'!"
exit 1
fi
count=$(echo "$bdev_info" | grep -c '^')
if [ "$count" -ne '1' ]; then
echo "$bdev_info"
warn "E: block device '$1' has children!"
exit 1
fi
echo "$bdev_info"
eval "$bdev_info"
if [ -z "$PKNAME" ]; then
warn "E: cannot determine parent device of '$1' - please provide a partition, not a full disk."
exit 1
fi
if [ -n "$SIZE" ] && [ "$SIZE" -lt 268435456 ]; then
warn "E: '$1' is too small (<256M)."
exit 1
fi
if [ -n "$MOUNTPOINT" ]; then
warn "E: '$1' is mounted on '$MOUNTPOINT' - exiting."
exit 1
fi
}
format() {
part="$1"
force="$2"
_get_partition_info "$part"
if [ -n "$FSTYPE" ]; then
if [ -z "$force" ] || [ "$force" != '--force' ]; then
warn "E: '$part' contains a filesystem ('$FSTYPE') - exiting (use --force to override)"
exit 1
fi
fi
part_basename=$(basename "$bdev")
if [ -z "$part_basename" ]; then
if [ "$part" != "$bdev" ]; then
symlinkmsg=" -> '$bdev'"
fi
warn "E: unable to determine basename of '$part'$symlinkmsg"
exit 1
fi
part_num=$(cat /sys/block/"$PKNAME"/"$part_basename"/partition)
if [ -z "$part_num" ]; then
warn "E: unable to determine partition number of '$part'"
exit 1
fi
if [ -z "$PARTTYPE" ] || [ "$PARTTYPE" != "$ESPTYPE" ]; then
echo "Setting partition type of '$part' to '$ESPTYPE'.."
sgdisk "-t$part_num:$ESPTYPE" "/dev/$PKNAME"
echo "Calling 'udevadm settle'.."
udevadm settle --timeout=5
fi
echo "Formatting '$part' as vfat.."
mkfs.vfat -F 32 "$part"
echo "Done."
exit 0
}
init_bootloader() {
part="$1"
_get_partition_info "$part"
if [ -z "$PARTTYPE" ] || [ "$PARTTYPE" != "$ESPTYPE" ]; then
warn "E: '$part' has wrong partition type (!= $ESPTYPE)."
exit 1
fi
if [ -z "$FSTYPE" ] || [ "$FSTYPE" != 'vfat' ]; then
warn "E: '$part' has wrong filesystem (!= vfat)."
exit 1
fi
if [ -z "$UUID" ]; then
warn "E: '$part' has no UUID set, required for mounting."
exit 1
fi
esp_mp="/var/tmp/espmounts/$UUID"
mkdir -p "$esp_mp"
echo "Mounting '$part' on '$esp_mp'."
mount -t vfat "$part" "$esp_mp"
if [ -d /sys/firmware/efi ]; then
echo "Installing systemd-boot.."
mkdir -p "$esp_mp/$PMX_ESP_DIR"
bootctl --graceful --path "$esp_mp" install
echo "Configuring systemd-boot.."
echo "timeout 3" > "$esp_mp/$PMX_LOADER_CONF.tmp"
echo "default proxmox-*" >> "$esp_mp/$PMX_LOADER_CONF.tmp"
mv "$esp_mp/$PMX_LOADER_CONF.tmp" "$esp_mp/$PMX_LOADER_CONF"
else
echo "Installing grub i386-pc target.."
grub-install.real \
--boot-directory "$esp_mp" \
--target i386-pc \
--no-floppy \
--bootloader-id='proxmox' \
"/dev/$PKNAME"
fi
echo "Unmounting '$part'."
umount "$part"
echo "Adding '$part' to list of synced ESPs.."
_add_entry_to_list_file "$ESP_LIST" "$UUID"
}
reinit() {
if ! (echo "${curr_uuid}" | grep -qE '[0-9a-fA-F]{4}-[0-9a-fA-F]{4}'); then
warn "WARN: ${curr_uuid} read from ${ESP_LIST} does not look like a VFAT-UUID - skipping"
return
fi
path="/dev/disk/by-uuid/$curr_uuid"
if [ ! -e "${path}" ]; then
warn "WARN: ${path} does not exist - clean '${ESP_LIST}'! - skipping"
return
fi
init_bootloader "$path"
}
_clean_impl() {
if [ ! -e "/dev/disk/by-uuid/" ]; then
warn 'E: /dev/disk/by-uuid does not exist, aborting!'
exit 1
fi
printf "Checking whether ESP '%s' exists.. " "$curr_uuid" # avoid newline
if [ -e "/dev/disk/by-uuid/$curr_uuid" ]; then
echo "Found!"
else
echo "Not found!"
if [ -z "$dry_run" ] || [ "$dry_run" != '--dry-run' ]; then
_remove_entry_from_list_file "$ESP_LIST" "$curr_uuid"
fi
fi
}
clean() {
dry_run="$1"
rm -f "$ESP_LIST".tmp
loop_esp_list _clean_impl
if [ "$?" -eq 2 ]; then
warn "E: $ESP_LIST does not exist."
exit 1
fi
if [ -e "$ESP_LIST".tmp ]; then
mv "$ESP_LIST".tmp "$ESP_LIST"
fi
echo "Sorting and removing duplicate ESPs.."
sort -uo "$ESP_LIST".tmp "$ESP_LIST"
mv "$ESP_LIST".tmp "$ESP_LIST"
}
refresh() {
hook=$1
hookscripts='proxmox-auto-removal zz-proxmox-boot'
if [ -n "$hook" ]; then
if echo "$hookscripts" | grep -sqE "(^|[[:space:]]+)$hook([[:space:]]+|$)"; then
hookscripts="$hook"
else
warn "E: '$hook' is not a valid hook script name.";
exit 1;
fi
fi
for script in $hookscripts; do
scriptpath="/etc/kernel/postinst.d/$script"
if [ -f "$scriptpath" ] && [ -x "$scriptpath" ]; then
echo "Running hook script '$script'.."
$scriptpath
else
warn "Hook script '$script' not found or not executable, skipping."
fi
done
}
add_kernel() {
ver="$1"
if [ -z "$ver" ]; then
warn "E: <kernel-version> is mandatory"
warn ""
exit 1
fi
if [ ! -e "/boot/vmlinuz-$ver" ]; then
warn "E: no kernel image found in /boot for '$ver', not adding."
exit 1
fi
_add_entry_to_list_file "$MANUAL_KERNEL_LIST" "$ver"
echo "Added kernel '$ver' to manual kernel list. Use the 'refresh' command to update the ESPs."
}
remove_kernel() {
ver="$1"
if [ -z "$ver" ]; then
warn "E: <kernel-version> is mandatory"
warn ""
exit 1
fi
if grep -sqFx "$ver" "$MANUAL_KERNEL_LIST"; then
_remove_entry_from_list_file "$MANUAL_KERNEL_LIST" "$ver"
echo "Removed kernel '$ver' from manual kernel list. Use the 'refresh' command to update the ESPs."
else
echo "Kernel '$ver' not found in manual kernel list."
fi
}
list_kernels() {
boot_kernels="$(boot_kernel_list)"
if [ -e "$MANUAL_KERNEL_LIST" ]; then
manual_kernels="$(cat "$MANUAL_KERNEL_LIST" || true)"
boot_kernels="$(echo "$boot_kernels" | grep -Fxv -f "$MANUAL_KERNEL_LIST" || true)"
fi
if [ -z "$manual_kernels" ]; then
manual_kernels="None."
fi
echo "Manually selected kernels:"
echo "$manual_kernels"
echo ""
echo "Automatically selected kernels:"
echo "$boot_kernels"
pinned_kernel="$(get_first_line "$PINNED_KERNEL_CONF")"
nextboot_kernel="$(get_first_line "$NEXT_BOOT_PIN")"
if [ -n "$pinned_kernel" ]; then
echo ""
echo "Pinned kernel:"
echo "${pinned_kernel}"
fi
if [ -n "$nextboot_kernel" ]; then
echo ""
echo "Kernel pinned on next-boot:"
echo "${nextboot_kernel}"
fi
}
usage() {
subcmd="$1"
if [ -z "$subcmd" ]; then
warn "USAGE: $0 <commands> [ARGS]"
warn ""
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "format" ]; then
warn " $0 format <partition> [--force]"
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "init" ]; then
warn " $0 init <partition>"
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "reinit" ]; then
warn " $0 reinit"
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "clean" ]; then
warn " $0 clean [--dry-run]"
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "refresh" ]; then
warn " $0 refresh [--hook <name>]"
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "kernel" ]; then
warn " $0 kernel <add|remove> <kernel-version>"
warn " $0 kernel pin <kernel-version> [--next-boot]"
warn " $0 kernel unpin [--next-boot]"
warn " $0 kernel list"
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "status" ]; then
warn " $0 status [--quiet]"
fi
if [ -z "$subcmd" ] || [ "$subcmd" = "help" ]; then
warn " $0 help"
fi
}
help() {
echo "USAGE: $0 format <partition> [--force]"
echo ""
echo " format <partition> as EFI system partition. Use --force to format even if <partition> is currently in use."
echo ""
echo "USAGE: $0 init <partition>"
echo ""
echo " initialize EFI system partition at <partition> for automatic synchronization of pve-kernels and their associated initrds."
echo ""
echo "USAGE: $0 reinit"
echo ""
echo " reinitialize all configured EFI system partitions from $ESP_LIST."
echo ""
echo "USAGE: $0 clean [--dry-run]"
echo ""
echo " remove no longer existing EFI system partition UUIDs from $ESP_LIST. Use --dry-run to only print outdated entries instead of removing them."
echo ""
echo "USAGE: $0 refresh [--hook <name>]"
echo ""
echo " refresh all configured EFI system partitions. Use --hook to only run the specified hook, omit to run all."
echo ""
echo "USAGE: $0 kernel <add|remove> <kernel-version>"
echo ""
echo " add/remove pve-kernel with ABI <kernel-version> to list of synced kernels, in addition to automatically selected ones."
echo " NOTE: you need to manually run 'refresh' once you're finished with adding/removing kernels from the list"
echo ""
echo "USAGE: $0 kernel pin <kernel-version> [--next-boot]"
echo ""
echo " pin pve-kernel with ABI <kernel-version> as the default entry to be booted."
echo " with --next-boot sets <kernel-version> only for the next boot."
echo " NOTE: you need to manually run 'refresh' once you're finished with pinning kernels"
echo ""
echo "USAGE: $0 kernel unpin [--next-boot]"
echo ""
echo " unpin removes pinned and next-boot kernel settings."
echo " with --next-boot only removes the pin for the next boot."
echo ""
echo "USAGE: $0 kernel list"
echo ""
echo " list kernel versions currently selected for inclusion on ESPs."
echo ""
echo "USAGE: $0 status [--quiet]"
echo ""
echo " Print details about the ESPs configuration. Exits with 0 if any ESP is configured, else with 2."
echo ""
}
_status_detail() {
if ! (echo "${curr_uuid}" | grep -qE '[0-9a-fA-F]{4}-[0-9a-fA-F]{4}'); then
warn "WARN: ${curr_uuid} read from ${ESP_LIST} does not look like a VFAT-UUID - skipping"
return
fi
path="/dev/disk/by-uuid/$curr_uuid"
if [ ! -e "${path}" ]; then
warn "WARN: ${path} does not exist - clean '${ESP_LIST}'! - skipping"
return
fi
mountpoint="${MOUNTROOT}/${curr_uuid}"
mkdir -p "${mountpoint}" || \
{ warn "creation of mountpoint ${mountpoint} failed - skipping"; return; }
mount "${path}" "${mountpoint}" || \
{ warn "mount of ${path} failed - skipping"; return; }
result=""
if [ -f "${mountpoint}/$PMX_LOADER_CONF" ]; then
if [ ! -d "${mountpoint}/$PMX_ESP_DIR" ]; then
warn "${path}/$PMX_ESP_DIR does not exist"
fi
versions_uefi=$(ls -1 ${mountpoint}/$PMX_ESP_DIR | awk '{printf (NR>1?", ":"") $0}')
result="uefi (versions: ${versions_uefi})"
fi
if [ -d "${mountpoint}/grub" ]; then
versions_grub=$(ls -1 ${mountpoint}/vmlinuz-* | awk '{ gsub(/.*\/vmlinuz-/, ""); printf (NR>1?", ":"") $0 }')
if [ -n "$result" ]; then
result="${result}, grub (versions: ${versions_grub})"
else
result="grub (versions: ${versions_grub})"
fi
fi
echo "$curr_uuid is configured with: $result"
umount "${mountpoint}" || \
{ warn "umount of ${path} failed - failure"; exit 0; }
rmdir "${mountpoint}" || true
}
status() {
quiet="$1"
if [ ! -e "${ESP_LIST}" ]; then
if [ -z "$quiet" ]; then
warn "E: $ESP_LIST does not exist."
fi
exit 2
fi
if [ -z "$quiet" ]; then
if [ -d /sys/firmware/efi ]; then
echo "System currently booted with uefi"
else
echo "System currently booted with legacy bios"
fi
loop_esp_list _status_detail
fi
}
_ask_interactive_refresh() {
msg="$1"
if [ -t 0 ] && [ -t 1 ]; then # check if interactive
echo "$msg."
printf "Refresh the actual boot ESPs now? [yN] "
read -r do_refresh
if [ "$do_refresh" != "${do_refresh#[Yy]}" ] ;then
refresh
else
echo "Skip auto-refresh, you can call it any time to enact boot changes."
fi
else
echo "$msg. Use the 'refresh' command to update the ESPs."
fi
}
pin_kernel() {
ver="$1"
pin_file="$2"
if [ -z "$ver" ]; then
boot_kernels="$(boot_kernel_list)"
warn "E: <kernel-version> is mandatory"
warn ""
warn "Possible Proxmox kernel versions are:"
warn "$boot_kernels"
exit 1
fi
if [ -z "$pin_file" ]; then
pin_file="$PINNED_KERNEL_CONF"
fi
if [ ! -e "/boot/vmlinuz-$ver" ]; then
boot_kernels="$(boot_kernel_list)"
warn "E: no kernel image found in /boot for '$ver', not setting default."
warn ""
warn "Possible Proxmox kernel versions are:"
warn "$boot_kernels"
exit 1
fi
if [ -e "$pin_file" ]; then
old_pin=$(get_first_line "${pin_file}")
if [ "$ver" != "$old_pin" ]; then
echo "Overriding previously pinned version '$old_pin' with '$ver'"
fi
fi
echo "$ver" > "$pin_file"
if [ -f "${ESP_LIST}" ]; then
_ask_interactive_refresh "Set kernel '$ver' in $pin_file"
else
next_boot_ver=$(get_first_line "${NEXT_BOOT_PIN}")
pin_ver="${next_boot_ver:-$ver}"
echo "Setting '$pin_ver' as grub default entry and running update-grub."
set_grub_default "$pin_ver"
update-grub
fi
}
unpin_kernel() {
last_pin=$(get_first_line "${NEXT_BOOT_PIN}")
rm -f "$NEXT_BOOT_PIN"
echo "Removed $NEXT_BOOT_PIN."
if [ -z "$1" ]; then
old_pin=$(get_first_line "${PINNED_KERNEL_CONF}")
last_pin=${old_pin:-$last_pin}
rm -f "$PINNED_KERNEL_CONF"
echo "Removed $PINNED_KERNEL_CONF."
fi
if [ -f "${ESP_LIST}" ]; then
if [ -n "$last_pin" ]; then
_ask_interactive_refresh "Unpinned kernel '$last_pin'"
fi
else
echo "Reset default grub entry and running update-grub."
pinned_kernel=$(get_first_line "${PINNED_KERNEL_CONF}")
set_grub_default "$pinned_kernel"
update-grub
fi
}
if [ -z "$1" ]; then
usage
exit 0
fi
case "$1" in
'format')
shift
if [ -z "$1" ]; then
warn "E: <partition> is mandatory."
warn ""
usage "format"
exit 1
fi
format "$@"
exit 0
;;
'init')
reexec_in_mountns "$@"
shift
if [ -z "$1" ]; then
warn "E: <partition> is mandatory."
warn ""
usage "init"
exit 1
fi
init_bootloader "$@"
echo "Refreshing kernels and initrds.."
refresh
exit 0
;;
'reinit')
reexec_in_mountns "$@"
shift
if [ "$#" -eq 1 ]; then
warn "E: no arguments allowed."
warn ""
usage "reinit"
exit 1
fi
loop_esp_list reinit "$@"
exit 0
;;
'clean')
shift
clean "$@"
exit 0
;;
'refresh')
shift
if [ "$#" -eq 0 ]; then
refresh
elif [ "$#" -eq 2 ] && [ "$1" = "--hook" ]; then
refresh "$2"
else
usage "refresh"
exit 1
fi
exit 0
;;
'kernel'|'kernels')
shift
if [ -z "$1" ]; then
warn "E: subcommand is mandatory for 'kernel'."
warn ""
usage "kernel"
exit 1
fi
cmd="$1"
case "$cmd" in
'add')
add_kernel "$2"
exit 0
;;
'remove')
remove_kernel "$2"
exit 0
;;
'list')
list_kernels
exit 0
;;
'pin')
if [ "$#" -eq 3 ] && [ "$3" = '--next-boot' ]; then
pin_kernel "$2" "${NEXT_BOOT_PIN}"
echo "Pinned for next boot only."
elif [ "$#" -eq 2 ]; then
pin_kernel "$2"
else
usage "kernel"
exit 1
fi
exit 0
;;
'unpin')
if [ "$#" -eq 2 ] && [ "$2" = '--next-boot' ]; then
unpin_kernel "$2"
elif [ "$#" -eq 1 ]; then
unpin_kernel
else
usage "kernel"
exit 1
fi
exit 0
;;
*)
warn "E: invalid 'kernel' subcommand '$cmd'."
warn ""
usage "kernel"
exit 1
;;
esac
;;
'status')
if [ "$#" -eq 2 ] && [ "$2" = '--quiet' ]; then
shift
status "$1"
elif [ "$#" -eq 1 ]; then
reexec_in_mountns "$@"
shift
status
else
usage "status"
exit 1
fi
exit 0
;;
'help')
shift
help
exit 0
;;
*)
warn "Invalid/unknown command '$1'."
warn ""
usage
exit 1
;;
esac
exit 1

15
debian/control.in vendored
View File

@ -27,18 +27,3 @@ Depends: pve-firmware,
Description: Latest Proxmox VE Kernel Image
This is a metapackage which will install the latest available
proxmox kernel from the @KERNEL_VER@ series.
Package: pve-kernel-helper
Architecture: all
Section: admin
Priority: optional
Depends: dosfstools,
gdisk,
systemd,
udev,
${misc:Depends},
Breaks: proxmox-ve (<< 6.0-2~)
Replaces: proxmox-ve (<< 6.0-2~)
Description: Function for various kernel maintenance tasks.
This package includes kernel-hooks for marking certain kernels as
NeverAutoRemove and helpers for systemd-boot

View File

@ -1,2 +0,0 @@
# ensure the SYS_FB marked framebuffer can actually be used by the fbcon(sole)
simplefb

View File

@ -1,9 +0,0 @@
etc/grub.d/000_proxmox_boot_header
etc/kernel/postinst.d/*
etc/kernel/postrm.d/*
etc/initramfs/post-update.d/proxmox-boot-sync
lib/systemd/system/proxmox-boot-cleanup.service
usr/sbin/proxmox-boot-tool
usr/sbin/grub-install
usr/share/pve-kernel-helper/scripts/functions
debian/proxmox-simpledrm /usr/share/initramfs-tools/modules.d

View File

@ -1 +0,0 @@
/usr/sbin/proxmox-boot-tool /usr/sbin/pve-efiboot-tool

View File

@ -1,2 +0,0 @@
pve-kernel-helper: no-manual-page [usr/sbin/grub-install]
pve-kernel-helper: no-manual-page [usr/sbin/pve-efiboot-tool]

View File

@ -1,6 +0,0 @@
mv_conffile /etc/initramfs/post-update.d/pve-efiboot-sync /etc/initramfs/post-update.d/proxmox-boot-sync 6.4-1~ pve-kernel-helper
mv_conffile /etc/kernel/postinst.d/pve-auto-removal /etc/kernel/postinst.d/proxmox-auto-removal 6.4-1~ pve-kernel-helper
mv_conffile /etc/kernel/postinst.d/zz-pve-efiboot /etc/kernel/postinst.d/zz-proxmox-boot 6.4-1~ pve-kernel-helper
mv_conffile /etc/kernel/postrm.d/pve-auto-removal /etc/kernel/postrm.d/proxmox-auto-removal 6.4-1~ pve-kernel-helper
mv_conffile /etc/kernel/postrm.d/zz-pve-efiboot /etc/kernel/postrm.d/zz-proxmox-boot 6.4-1~ pve-kernel-helper

View File

@ -1,20 +0,0 @@
#! /bin/sh
set -e
case "$1" in
configure)
if [ -e /etc/kernel/pve-efiboot-uuids ]; then
echo "$0: legacy ESP list /etc/kernel/pve-efiboot-uuids found moving to /etc/kernel/proxmox-boot-uuids" 1>&2
mv /etc/kernel/pve-efiboot-uuids /etc/kernel/proxmox-boot-uuids
fi
if [ -e /etc/kernel/pve-efiboot-manual-kernels ] && [ ! -e /etc/kernel/proxmox-boot-manual-kernels ]; then
echo "$0: legacy manual kernel list /etc/kernel/pve-efiboot-manual-kernels found moving to /etc/kernel/proxmox-boot-manual-kernels" 1>&2
mv /etc/kernel/pve-efiboot-manual-kernels /etc/kernel/proxmox-boot-manual-kernels
fi
;;
esac
#DEBHELPER#
exit 0

View File

@ -1,22 +0,0 @@
#! /bin/sh
set -e
case "$1" in
remove|abort-install|disappear)
dpkg-divert --package pve-kernel-helper --remove --rename \
--divert /usr/sbin/grub-install.real /usr/sbin/grub-install
;;
abort-upgrade)
if [ -n "$2" ]; then
if dpkg --compare-versions "$2" lt "6.4-1~"; then
dpkg-divert --package pve-kernel-helper --remove --rename \
--divert /usr/sbin/grub-install.real /usr/sbin/grub-install
fi
fi
;;
esac
#DEBHELPER#
exit 0

View File

@ -1,19 +0,0 @@
#! /bin/sh
set -e
case "$1" in
install|upgrade)
if ! dpkg -S /usr/sbin/grub-install|grep -q 'diversion by pve-kernel-helper'; then
dpkg-divert --package pve-kernel-helper --add --rename \
--divert /usr/sbin/grub-install.real /usr/sbin/grub-install
fi
;;
*)
echo "ignoring unknown preinst command '$1'"
;;
esac
#DEBHELPER#
exit 0

View File

@ -1 +0,0 @@
activate-noawait update-initramfs

View File

@ -1,24 +0,0 @@
#! /bin/sh
set -e
. /usr/share/pve-kernel-helper/scripts/functions
if proxmox-boot-tool status --quiet; then
cat <<- EOF
#
# This system is booted via proxmox-boot-tool! The grub-config used when
# booting from the disks configured with proxmox-boot-tool resides on the vfat
# partitions with UUIDs listed in ${ESP_LIST}.
# /boot/grub/grub.cfg is NOT read when booting from those disk!
EOF
if [ -z "$DPKG_RUNNING_VERSION" ] && [ -z "$PVE_EFIBOOT_UNSHARED" ]; then
warn "W: This system is booted via proxmox-boot-tool:"
warn "W: Executing 'update-grub' directly does not update the correct configs!"
warn "W: Running: 'proxmox-boot-tool refresh'"
warn ""
proxmox-boot-tool refresh > /dev/null
fi
fi

View File

@ -1,33 +0,0 @@
KERNEL_HOOKSCRIPTS = proxmox-auto-removal zz-proxmox-boot
INITRAMFS_HOOKSCRIPTS = proxmox-boot-sync
SHARE_FILES = functions
GRUB_CFG_SNIPPET = 000_proxmox_boot_header
SYSTEMD_SERVICES = proxmox-boot-cleanup.service
POSTINSTHOOKDIR = ${DESTDIR}/etc/kernel/postinst.d
POSTRMHOOKDIR = ${DESTDIR}/etc/kernel/postrm.d
POSTINITRAMFSHOOKDIR = ${DESTDIR}/etc/initramfs/post-update.d
SHARE_SCRIPTDIR = ${DESTDIR}/usr/share/pve-kernel-helper/scripts
GRUB_CFG_DIR = ${DESTDIR}/etc/grub.d
SERVICE_DIR = ${DESTDIR}/lib/systemd/system
.PHONY: all
all:
install:
install -d ${POSTINSTHOOKDIR}
install -m 0755 ${KERNEL_HOOKSCRIPTS} ${POSTINSTHOOKDIR}
install -d ${POSTRMHOOKDIR}
install -m 0755 ${KERNEL_HOOKSCRIPTS} ${POSTRMHOOKDIR}
install -d ${POSTINITRAMFSHOOKDIR}
install -m 0755 ${INITRAMFS_HOOKSCRIPTS} ${POSTINITRAMFSHOOKDIR}
install -d ${SHARE_SCRIPTDIR}
install -m 0755 ${SHARE_FILES} ${SHARE_SCRIPTDIR}
install -d ${GRUB_CFG_DIR}
install -m 0755 ${GRUB_CFG_SNIPPET} ${GRUB_CFG_DIR}
install -d ${SERVICE_DIR}
install -m 0644 ${SYSTEMD_SERVICES} ${SERVICE_DIR}
.PHONY: clean distclean
distclean:
clean:

View File

@ -1,156 +0,0 @@
#! /bin/sh
set -e
ESP_LIST="/etc/kernel/proxmox-boot-uuids"
ESPTYPE='c12a7328-f81f-11d2-ba4b-00a0c93ec93b'
MANUAL_KERNEL_LIST="/etc/kernel/proxmox-boot-manual-kernels"
PINNED_KERNEL_CONF="/etc/kernel/proxmox-boot-pin"
NEXT_BOOT_PIN="/etc/kernel/next-boot-pin"
MOUNTROOT="${TMPDIR:-/var/tmp}/espmounts"
# relative to the ESP mountpoint
PMX_ESP_DIR="EFI/proxmox"
PMX_LOADER_CONF="loader/loader.conf"
GRUB_PIN_SNIPPET="/etc/default/grub.d/proxmox-kernel-pin.cfg"
# adapted from /etc/kernel/postinst.d/apt-auto-removal as present in
# debian's apt package:
#
# Mark as not-for-autoremoval those kernel packages that are:
# - the currently booted version, if still installed
# - the kernel version we've been called for
# - the latest kernel version (as determined by debian version number)
# - the second-latest kernel version
# - the latest kernel version of each series (e.g. 4.13, 4.15, 5.0) by
# marking the meta-packages
# - the currently pinned kernel if any
kernel_keep_versions() {
eval "$(apt-config shell DPKG Dir::bin::dpkg/f)"
test -n "$DPKG" || DPKG="/usr/bin/dpkg"
list="$("${DPKG}" -l | awk '/^[ih][^nc][ ]+pve-kernel-[0-9]+\./ && $2 !~ /-dbg(:.*)?$/ && $2 !~ /-dbgsym(:.*)?$/ { print $2; }' \
| sed -e 's#^pve-kernel-##' -e 's#:[^:]\+ # #')"
sorted_list="$(echo "$list" | sort --unique --reverse --version-sort)"
[ -n "$1" ] && install_version="$1"
running_version="$(uname -r | tr 'A-Z' 'a-z')"
# ignore the currently running version if attempting a reproducible build
if [ -n "${SOURCE_DATE_EPOCH}" ]; then
running_version=""
elif [ ! -e "/boot/vmlinuz-$running_version" ]; then
# ignore the current version if it got removed, the "auto-remove" logic
# will not be affected, because either it is installed and thus we keep
# it in the list, or it's already removed anyway
running_version=""
fi
latest_2_versions="$(echo "$sorted_list" | grep -E '^[^ ]+-pve' | head -n2 )"
series_metapackages="$(echo "$sorted_list" | grep -Ev '^[^ ]+-pve' | head -n2)"
oldseries="$(echo "$series_metapackages" | tail -n1)"
oldseries_latest_kernel="$(echo "$sorted_list" | grep -E "^${oldseries}\.[^ ]+-pve" | head -n1 )"
if [ -e "$MANUAL_KERNEL_LIST" ]; then
manual_kernels="$(cat "$MANUAL_KERNEL_LIST")"
fi
pinned_kernel="$(get_first_line "$PINNED_KERNEL_CONF")"
nextboot_kernel="$(get_first_line "$NEXT_BOOT_PIN")"
kernels="$(cat <<-EOF
$running_version
$install_version
$manual_kernels
$latest_2_versions
$series_metapackages
$oldseries_latest_kernel
$pinned_kernel
$nextboot_kernel
EOF
)"
echo "$kernels" | sort -u | sed -e '/^$/ d'
}
#bootable kernels are the same as the no_autoremove ones without the meta-package
boot_kernel_list() {
list="$(kernel_keep_versions "$@")"
echo "$list" | grep -vE '^[0-9]+\.[0-9]+$' || true
}
warn() {
echo "$@" 1>&2
}
reexec_in_mountns() {
if [ -z "$PVE_EFIBOOT_UNSHARED" ]; then
export PVE_EFIBOOT_UNSHARED=1
echo "Re-executing '$0' in new private mount namespace.."
unshare --mount --propagation private "$0" "$@"
exit 0
fi
}
loop_esp_list() {
if [ ! -e ${ESP_LIST} ]; then
return 2
fi
cat "${ESP_LIST}" | while IFS= read -r curr_uuid; do
if [ -z "$curr_uuid" ]; then
continue
fi
"$@"
done
}
get_first_line() {
file="$1"
if [ ! -e "$file" ]; then
echo ""
return
fi
while IFS= read -r line || [ -n "$line" ]; do
break
done < "${file}"
echo "$line"
}
set_grub_default() {
kver="$1"
if [ -z "${kver}" ]; then
rm -f "${GRUB_PIN_SNIPPET}"
else
# grub menu entry ids contain the internal root-device id (e.g. for zfs the GUID of
# the pool printed in hex) as this is independent of the ESP (or grub location)
# take it from /boot/grub/grub.cfg
root_devid=$(sed -rn "s/.*gnulinux-advanced-(.+)['] \{$/\1/p" \
/boot/grub/grub.cfg)
entry="gnulinux-advanced-${root_devid}>gnulinux-${kver}-advanced-${root_devid}"
echo "GRUB_DEFAULT=\"${entry}\"" > "${GRUB_PIN_SNIPPET}"
fi
}
set_systemd_boot_default() {
mountpoint="$1"
kver="$2"
if [ -z "${kver}" ]; then
entry="proxmox-*"
else
entry="proxmox-${kver}.conf"
fi
# replaces the current default entry, if one exists else append it at the end of the file
sed -ri "/^default /{h;s/ .*\$/ ${entry}/};\${x;/^$/{s//default ${entry}/;H};x}" \
"${mountpoint}/$PMX_LOADER_CONF"
}

View File

@ -1,39 +0,0 @@
#! /bin/sh
set -e
. /usr/share/pve-kernel-helper/scripts/functions
eval "$(apt-config shell APT_CONF_D Dir::Etc::parts/d)"
test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d"
config_file="${APT_CONF_D}/76pveconf"
generate_apt_config() {
kernels="$(kernel_keep_versions "$@")"
cat <<- EOF
// DO NOT EDIT! File autogenerated by $0
APT::NeverAutoRemove
{
EOF
for kernel in $kernels; do
escaped_kver="$(echo "$kernel" | sed -e 's#\([\.\+]\)#\\\1#g')"
echo " \"^pve-kernel-${escaped_kver}$\";"
done
echo '};'
if [ "${APT_AUTO_REMOVAL_KERNELS_DEBUG:-false}" = 'true' ]; then
cat <<-EOF
/* Debug information:
# dpkg list:
$(dpkg -l | grep -F 'pve-kernel' || true)
# list of installed kernel packages:
$kernels
*/
EOF
fi
}
generate_apt_config "$@" > "${config_file}.dpkg-new"
mv -f "${config_file}.dpkg-new" "$config_file"
chmod 444 "$config_file"

View File

@ -1,13 +0,0 @@
[Unit]
Description=Clean up bootloader next-boot setting
After=systemd-remount-fs.service
ConditionPathExists=/etc/kernel/next-boot-pin
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/proxmox-boot-tool kernel unpin --next-boot
ExecStart=/usr/sbin/proxmox-boot-tool refresh
[Install]
WantedBy=multi-user.target

View File

@ -1,11 +0,0 @@
#! /bin/sh
set -e
# Only run the refresh if update-initramfs has been called manually.
# If this script is being run as part of a post-kernel-install hook,
# this variable will be set to 1 and we do nothing, since our pve-kernel
# hooks will update the ESPs all at once anyway.
if [ -z "$INITRAMFS_TOOLS_KERNEL_HOOK" ]; then
/usr/sbin/proxmox-boot-tool refresh --hook 'zz-proxmox-boot'
fi

View File

@ -1,215 +0,0 @@
#! /bin/sh
set -e
# adapted from '/etc/kernel/postinst.d/zz-update-grub and
# /usr/lib/kernel/install.d/90-loaderentry.install, see also
# https://kernel-team.pages.debian.net/kernel-handbook/ch-update-hooks.html
# - cleanup - gently delete all kernels not in kernel-keep-list
if command -V systemd-detect-virt >/dev/null 2>&1 &&
systemd-detect-virt --quiet --container; then
exit 0
fi
cleanup() {
for mount in "${MOUNTROOT}"/* ; do
if echo "${mount}" | grep -qE '[0-9a-fA-F]{4}-[0-9a-fA-F]{4}' && \
mountpoint -q "${mount}"; then
umount "${mount}" || \
{ warn "umount of ${mount} failed - failure"; exit 0; }
fi
done
}
trap cleanup EXIT INT TERM QUIT
. /usr/share/pve-kernel-helper/scripts/functions
LOADER_TITLE="Proxmox Virtual Environment"
if [ -d /etc/pve/ ]; then
LOADER_TITLE="Proxmox Virtual Environment"
elif [ -d /usr/share/doc/proxmox-mailgateway/ ]; then
LOADER_TITLE="Proxmox Mailgateway"
elif [ -d /usr/share/doc/proxmox-backup/ ]; then
LOADER_TITLE="Proxmox Backup Server"
fi
update_esps() {
if [ ! -f "${ESP_LIST}" ]; then
warn "No ${ESP_LIST} found, skipping ESP sync."
exit 0
fi
if [ -f /etc/kernel/cmdline ]; then
# we can have cmdline files with multiple or no new line at all, handle both!
CMDLINE=$(get_first_line /etc/kernel/cmdline)
echo ${CMDLINE} | grep -q 'root=' || \
{ warn "No root= parameter in /etc/kernel/cmdline found!"; exit 1; }
else
warn "No /etc/kernel/cmdline found - falling back to /proc/cmdline"
# remove initrd entries
CMDLINE="$(perl -pe 's/\binitrd=([0-9a-zA-Z\\\/.-])*\s*//g;' /proc/cmdline)"
fi
loop_esp_list update_esp_func
}
update_esp_func() {
if ! (echo "${curr_uuid}" | grep -qE '[0-9a-fA-F]{4}-[0-9a-fA-F]{4}'); then
warn "WARN: ${curr_uuid} read from ${ESP_LIST} does not look like a VFAT-UUID - skipping"
return
fi
path="/dev/disk/by-uuid/$curr_uuid"
if [ ! -e "${path}" ]; then
warn "WARN: ${path} does not exist - clean '${ESP_LIST}'! - skipping"
return
fi
mountpoint="${MOUNTROOT}/${curr_uuid}"
mkdir -p "${mountpoint}" || \
{ warn "creation of mountpoint ${mountpoint} failed - skipping"; return; }
mount "${path}" "${mountpoint}" || \
{ warn "mount of ${path} failed - skipping"; return; }
if [ -d /sys/firmware/efi ]; then
if [ ! -f "${mountpoint}/$PMX_LOADER_CONF" ]; then
warn "${path} contains no loader.conf - skipping"
return
fi
if [ ! -d "${mountpoint}/$PMX_ESP_DIR" ]; then
warn "${path}/$PMX_ESP_DIR does not exist- skipping"
return
fi
elif [ ! -d "${mountpoint}/grub" ]; then
warn "${path} contains no grub directory - skipping"
return
fi
warn "Copying and configuring kernels on ${path}"
copy_and_config_kernels "${mountpoint}"
pinned_kernel=$(get_first_line "${PINNED_KERNEL_CONF}")
if [ -e "${NEXT_BOOT_PIN}" ]; then
pinned_kernel=$(get_first_line "${NEXT_BOOT_PIN}")
fi
if [ -d /sys/firmware/efi ]; then
set_systemd_boot_default "${mountpoint}" "${pinned_kernel}"
remove_old_kernels_efi "${mountpoint}"
else
set_grub_default "${pinned_kernel}"
remove_old_kernels_legacy "${mountpoint}"
mount --bind "${mountpoint}" "/boot"
update-grub
umount /boot
fi
umount "${mountpoint}" || \
{ warn "umount of ${path} failed - failure"; exit 0; }
rmdir "${mountpoint}" || true
}
copy_and_config_kernels() {
esp="$1"
for kver in ${BOOT_KVERS}; do
linux_image="/boot/vmlinuz-${kver}"
initrd="/boot/initrd.img-${kver}"
if [ ! -f "${linux_image}" ]; then
warn "No linux-image ${linux_image} found - skipping"
continue
fi
if [ ! -f "${initrd}" ]; then
warn "No initrd-image ${initrd} found - skipping"
continue
fi
if [ -d /sys/firmware/efi ]; then
warn " Copying kernel and creating boot-entry for ${kver}"
KERNEL_ESP_DIR="${PMX_ESP_DIR}/${kver}"
KERNEL_LIVE_DIR="${esp}/${KERNEL_ESP_DIR}"
mkdir -p "${KERNEL_LIVE_DIR}"
cp --preserve=timestamps "${linux_image}" "${KERNEL_LIVE_DIR}/"
cp --preserve=timestamps "${initrd}" "${KERNEL_LIVE_DIR}/"
# create loader entry
cat > "${esp}/loader/entries/proxmox-${kver}.conf" <<- EOF
title ${LOADER_TITLE}
version ${kver}
options ${CMDLINE}
linux /${KERNEL_ESP_DIR}/vmlinuz-${kver}
initrd /${KERNEL_ESP_DIR}/initrd.img-${kver}
EOF
else
warn " Copying kernel ${kver}"
cp --preserve=timestamps "${linux_image}" "${esp}/"
cp --preserve=timestamps "${initrd}" "${esp}/"
fi
done
}
remove_old_kernels_efi() {
esp="$1"
for kerneldir in "${esp}/${PMX_ESP_DIR}"/*; do
if [ ! -d "${kerneldir}" ]; then
warn " ${kerneldir} is not a directory - skipping"
continue
fi
kver="$(echo "${kerneldir}" | sed -r "s#^${esp}/${PMX_ESP_DIR}/(.+)\$#\\1#")"
echo "${BOOT_KVERS}" | grep -q "${kver}" && continue;
warn " Removing old version ${kver}"
rm -rf "${kerneldir}"
rm -f "${esp}/loader/entries/proxmox-${kver}.conf"
done
}
remove_old_kernels_legacy() {
esp="$1"
for kernel in "${esp}/"vmlinuz-*; do
kver="$(echo "${kernel}" | sed -r "s#^${esp}/vmlinuz-(.+)\$#\\1#")"
echo "${BOOT_KVERS}" | grep -q "${kver}" && continue;
warn " Removing old version ${kver}"
rm -rf "${esp}/vmlinuz-${kver}"
rm -rf "${esp}/initrd.img-${kver}"
done
}
set -- $DEB_MAINT_PARAMS
mode="${1#\'}"
mode="${mode%\'}"
case $0:$mode in
# Only run on postinst configure and postrm remove, to avoid wasting
# time by calling update-grub multiple times on upgrade and removal.
# Also run if we have no DEB_MAINT_PARAMS, in order to work with old
# kernel packages.
*/postinst.d/*:|*/postinst.d/*:configure)
reexec_in_mountns "$@"
BOOT_KVERS="$(boot_kernel_list "$@")"
update_esps
;;
*/postrm.d/*:|*/postrm.d/*:remove)
reexec_in_mountns "$@"
# no newly installed kernel
BOOT_KVERS="$(boot_kernel_list)"
update_esps
;;
esac
exit 0