Skip to content

Commit 1e2598b

Browse files
committed
flatcar-postinst: Remove old kernel copying and bootloader handling
Flatcar doesn't ship the kernel image on /usr since 2021 and this anyway didn't support dm-verity setups. The old bootloader handling is anyway not needed for a long time now and also doesn't work without the kernel. Remove the broken kernel and bootloader handling.
1 parent 0a13c5e commit 1e2598b

File tree

2 files changed

+0
-89
lines changed

2 files changed

+0
-89
lines changed

flatcar-postinst

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ OEM_MNT="/usr/share/oem"
1010

1111
INSTALL_MNT=$(dirname "$0")
1212
INSTALL_DEV="$1"
13-
INSTALL_KERNEL=""
14-
15-
for arg in "$@"; do
16-
case "${arg}" in
17-
KERNEL=*) INSTALL_KERNEL="${arg#KERNEL=}" ;;
18-
esac
19-
done
2013

2114
# Figure out if the slot id is A or B
2215
INSTALL_LABEL=$(blkid -o value -s PARTLABEL "${INSTALL_DEV}")
@@ -30,71 +23,6 @@ case "${INSTALL_LABEL}" in
3023
exit 1
3124
esac
3225

33-
# Find the ESP partition and mount it if needed
34-
ESP_PARTTYPE="c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
35-
ESP_MNT=
36-
37-
declare -a DEV_LIST
38-
mapfile DEV_LIST < <(lsblk -P -o NAME,PARTTYPE,MOUNTPOINT)
39-
40-
for dev_info in "${DEV_LIST[@]}"; do
41-
eval "$dev_info"
42-
43-
if [[ "${PARTTYPE}" != "${ESP_PARTTYPE}" ]]; then
44-
continue
45-
fi
46-
47-
if [[ -n "${MOUNTPOINT}" ]]; then
48-
ESP_MNT="${MOUNTPOINT}"
49-
else
50-
ESP_MNT="$(mktemp -d /tmp/postinst_esp.XXXXXXXXXX)"
51-
mount "/dev/${NAME}" "${ESP_MNT}"
52-
trap "umount '${ESP_MNT}' && rmdir '${ESP_MNT}'" EXIT
53-
fi
54-
55-
break
56-
done
57-
58-
if [[ -z "${ESP_MNT}" ]]; then
59-
echo "Failed to find ESP partition!" >&2
60-
exit 1
61-
fi
62-
63-
if [[ ! -d "${ESP_MNT}" ]]; then
64-
echo "ESP partition mount point (${ESP_MNT}) is not a directory!" >&2
65-
exit 1
66-
fi
67-
68-
# Update bootloaders from CoreOS <= 522.x.x
69-
if grep -q cros_legacy /proc/cmdline; then
70-
# Update kernel and bootloader configs
71-
mkdir -p "${ESP_MNT}"{/syslinux,/boot/grub}
72-
cp -v "${INSTALL_MNT}/boot/vmlinuz" \
73-
"${ESP_MNT}/syslinux/vmlinuz.${SLOT}"
74-
cp -v "${INSTALL_MNT}/boot/syslinux/root.${SLOT}.cfg" \
75-
"${ESP_MNT}/syslinux/root.${SLOT}.cfg"
76-
77-
# For Xen's pvgrub
78-
cp -v "${INSTALL_MNT}/boot/grub/menu.lst.${SLOT}" \
79-
"${ESP_MNT}/boot/grub/menu.lst"
80-
81-
# For systems that have disabled boot_kernel and kexec
82-
if ! grep -q boot_kernel "${ESP_MNT}/syslinux/default.cfg"; then
83-
cp -v "${INSTALL_MNT}/boot/syslinux/default.cfg.${SLOT}" \
84-
"${ESP_MNT}/syslinux/default.cfg"
85-
fi
86-
elif [[ -z "${INSTALL_KERNEL}" ]]; then
87-
# not a legacy system but update_engine didn't handle the kernel.
88-
# kernel names are in lower case, ${SLOT,,} converts the slot name
89-
if [ -e "${ESP_MNT}/coreos/vmlinuz-a" ] || [ -e "${ESP_MNT}/coreos/vmlinuz-b" ]; then
90-
cp -v "${INSTALL_MNT}/boot/vmlinuz" \
91-
"${ESP_MNT}/coreos/vmlinuz-${SLOT,,}"
92-
else
93-
cp -v "${INSTALL_MNT}/boot/vmlinuz" \
94-
"${ESP_MNT}/flatcar/vmlinuz-${SLOT,,}"
95-
fi
96-
fi
97-
9826
# If the OEM provides a hook, call it
9927
if [[ -x "${OEM_MNT}/bin/oem-postinst" ]]; then
10028
"${OEM_MNT}/bin/oem-postinst" "${SLOT}" "${INSTALL_MNT}"

src/update_engine/omaha_response_handler_action.cc

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,8 @@ bool OmahaResponseHandlerAction::GetInstallDev(const std::string& boot_dev,
112112
return true;
113113
}
114114

115-
namespace {
116-
bool IsCrosLegacySystem() {
117-
string cmdline;
118-
TEST_AND_RETURN_FALSE(
119-
files::ReadFileToString(files::FilePath("/proc/cmdline"), &cmdline));
120-
return cmdline.find("cros_legacy") != string::npos;
121-
}
122-
} // namespace
123-
124115
bool OmahaResponseHandlerAction::GetKernelPath(const std::string& part_path,
125116
std::string* kernel_path) {
126-
// If 'cros_legacy' is in the kernel args we are on an old system
127-
// using SYSLINUX style bootloader configuration. Leave the kernel to
128-
// the post install script on such systems.
129-
if (IsCrosLegacySystem()) {
130-
*kernel_path = "";
131-
return true;
132-
}
133-
134117
files::FilePath coreos_kernel_a = files::FilePath("/boot/coreos/vmlinuz-a");
135118
files::FilePath coreos_kernel_b = files::FilePath("/boot/coreos/vmlinuz-b");
136119

0 commit comments

Comments
 (0)