Commit d9dca6cb authored by Anton Midyukov's avatar Anton Midyukov

doc, grub, stage1, stage2: Add support multiple kernels for grub only

At the moment, the ability to select the kernel with which to boot is implemented only for grub (grub-pc, grub-efi, ieee1275boot). note that renamed STAGE1_KFLAVOUR to STAGE1_KFLAVOURS, as multiple kernels can now be added.
parent f7043b4a
......@@ -32,9 +32,8 @@ NB: пути приводятся от верхнего уровня; проек
* features.in/kernel/stage1/scripts.d/80-make-initrd
* features.in/stage2/stage1/scripts.d/03-test-kernel
* sub.in/stage1/Makefile
** ожидают, что в stage1 попадёт строго одно ядро сообразно
явному указанию в STAGE1_KFLAVOUR (либо последнее указанное
в KFLAVOURS)
** если используется загрузчик отличный от grub, то в stage1 попадёт
последнее ядро, указанное в STAGE1_KFLAVOURS или KFLAVOURS
** если добавить какой-либо kernel-image в STAGE1_PACKAGES*,
результат может быть неожиданным
** обратите внимание: bin/tar2fs умеет несколько ядер
......
......@@ -18,7 +18,8 @@
** SYSTEM_PACKAGES, STAGE2_PACKAGES
** STAGE1_KMODULES, STAGE1_KMODULES_REGEXP,
STAGE2_KMODULES, STAGE2_KMODULES_REGEXP
*** STAGE1_KFLAVOUR или последний из KFLAVOURS
*** STAGE1_KFLAVOURS или KFLAVOURS для grub, для других загрузчиков
последний из STAGE1_KFLAVOURS или KFLAVOURS
* install2: компактная "живая" система, содержащая только инсталятор
** см. stage2
......@@ -47,4 +48,5 @@
** STAGE1_PACKAGES, SYSTEM_PACKAGES
** STAGE1_PACKAGES_REGEXP
** STAGE1_KMODULES_REGEXP
*** STAGE1_KFLAVOUR или последний из KFLAVOURS
*** STAGE1_KFLAVOURS или KFLAVOURS для grub, для других загрузчиков
последний из STAGE1_KFLAVOURS или KFLAVOURS
......@@ -3,7 +3,7 @@ default='linux'
menuentry $"Install "'@distro@' --hotkey 'i' --id 'linux' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"VNC install "'@distro@'$" (edit to set server IP address)" --id 'vncconnect' {
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ $EFI_BOOTARGS headless no_alt_virt_keyboard vncconnect=IP lang=$lang
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ $EFI_BOOTARGS headless no_alt_virt_keyboard vncconnect=IP lang=$lang
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"VNC install "'@distro@'$" (edit to set password and connect here)" --id 'vncpasswd' {
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ $EFI_BOOTARGS headless no_alt_virt_keyboard vncpassword=VNCPWD lang=$lang
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ $EFI_BOOTARGS headless no_alt_virt_keyboard vncpassword=VNCPWD lang=$lang
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"LiveCD (no hard disk needed)" --id 'live' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"LiveCD with sessions support" --id 'session' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"Rescue LiveCD" --id 'rescue' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ $EFI_BOOTARGS
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ $EFI_BOOTARGS
echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"Rescue with sessions support" --id 'rescue_session' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom,label:ALT* ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ $EFI_BOOTARGS live_rw
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom,label:ALT* ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ $EFI_BOOTARGS live_rw
echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"Forensic mode (leave disks alone)" --id 'rescue_forensic' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ $EFI_BOOTARGS max_loop=16 forensic hash=@rescue_hash@
linux$linux_suffix /boot/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ $EFI_BOOTARGS max_loop=16 forensic hash=@rescue_hash@
echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full.cz
initrd$linux_suffix /boot/full.cz
}
menuentry $"Rescue with remote SSH access (DHCP)" --id 'rescue_remote' {
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ $EFI_BOOTARGS max_loop=16 ip=dhcp port=22 rootpw=AUTO hash=@rescue_hash@
linux$linux_suffix /boot/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ $EFI_BOOTARGS max_loop=16 ip=dhcp port=22 rootpw=AUTO hash=@rescue_hash@
echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
initrd$linux_suffix /boot/full$KFLAVOUR.cz
}
menuentry $"Check this media for defects" --id 'mediachk' {
linux$linux_suffix @boot_path@/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@ $EFI_BOOTARGS
initrd$linux_suffix @boot_path@/full.cz
linux$linux_suffix /boot/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@ $EFI_BOOTARGS
initrd$linux_suffix /boot/full.cz
}
......@@ -99,9 +99,6 @@ bootargs: clean
sed -i "s, lang=.lang,,g" $(DSTCFGS); \
fi; \
sed -i "/lang=@LOCALE@/d" $(DSTCFGS)
@if [ $$(echo $(KFLAVOURS) | wc -w) -gt 1 ]; then \
sed -i "s,@KFLAVOUR@,$(KFLAVOURS),g" $(DSTCFGS); \
fi
GRUBTHEME=$(GRUBTHEME); \
[ -n "$$GRUBTHEME" ] || GRUBTHEME=$$(cut -d "-" -f2 <<< $(BRANDING)); \
sed -i "s,@grubtheme@,$$GRUBTHEME,g" $(DSTCFGS)
......
......@@ -49,20 +49,25 @@ fi
default_change "$CFG"
case "$GLOBAL_BOOTLOADER" in
ieee1275boot|grubpcboot)
BOOT_PATH=/boot;;
*)
BOOT_PATH=/EFI/BOOT;;
esac
sed -i "s,@boot_path@,$BOOT_PATH,g" "$CFG"
# snippets are not going into the actual image
if [ "$DEBUG" != 2 ]; then
rm -r .in/
fi
# change kernels version for multiple kernels only
if [ $(echo "$GLOBAL_KFLAVOURS" | wc -w) -gt 1 ]; then
kver=
echo $GLOBAL_KFLAVOURS
for KFLAVOUR in $GLOBAL_KFLAVOURS; do
kver+=" $(rpm -qa 'kernel-image*' \
--qf '%{version}-%{name}-%{release}\n' \
| grep "$KFLAVOUR" \
| sed 's/kernel-image-//')"
done
sed -i "s,@KFLAVOUR@,$kver,g" $CFG
fi
# copy grub theme
mkdir -p themes
GRUBTHEME="$(grep -m1 '/theme.txt;' "$CFG" |rev | cut -f2 -d '/' |rev)"
......
......@@ -11,23 +11,20 @@ case "`arch`" in
;;
esac
if [ -L /boot/$kname ]; then
kimage="$(readlink -mv /boot/$kname)"
else
kimage="$(find /boot -type f -name "$kname-*" -print -quit)"
fi
kver="${kimage#/boot/$kname-}"
kimage="$(find /boot -type f -name "$kname-*")"
mkmodpack -p /.in/modules -o /tmp/modules -k "$kver"
rm -f /boot/full*.cz
rm -f /boot/full.cz
for kver in $kimage; do
kver="${kver#/boot/$kname-}"
mkmodpack -p /.in/modules -o /tmp/modules-"$kver" -k "$kver"
cat "$libdir/propagator/initfs" /tmp/modules-"$kver" > /boot/full-"$kver".cz
[ ! -f /tmp/modules ] ||
cat "$libdir/propagator/initfs" /tmp/modules > /boot/full.cz
sed \
-e "s,@LIBDIR@,$libdir," \
-e "s,@TMPDIR@,/tmp,g" \
< "$WORKDIR/initfs" |
gencpio - |
gzip -c >> /boot/full-"$kver".cz
sed \
-e "s,@LIBDIR@,$libdir," \
-e "s,@TMPDIR@,/tmp,g" \
< "$WORKDIR/initfs" |
gencpio - |
gzip -c >> /boot/full.cz
done
......@@ -14,15 +14,16 @@ esac
if [ -L "/boot/$kname" ]; then
kimage="$(readlink -ev /boot/$kname)"
else
kimage="$(find /boot -type f -name "$kname-*" -print -quit)"
kverdef="${kimage#/boot/$kname-}"
fi
if [ -n "$kimage" ]; then
cp -af "$kimage" boot/$kname
[ ! -f /boot/full.cz ] ||
cp -af /boot/full.cz boot/full.cz
fi
kimage="$(find /boot -type f -name "$kname-*")"
propagator="$(find /boot -type f -name 'full-*.cz')"
cp $verbose -af $kimage boot/
mv boot/$kname-$kverdef boot/$kname
cp $verbose -af $propagator boot/
mv boot/full-$kverdef.cz boot/full.cz
# config is generated in mkimage
case "$GLOBAL_EFI_BOOTLOADER" in
......
......@@ -19,16 +19,25 @@ COPY_TREE = ./files
include $(MKIMAGE_PREFIX)/targets.mk
# here we try and come up with the installer kernel/modules, if any;
# only a single kernel might be needed (STAGE1_KFLAVOUR sets explicitly);
# kernel image copied from instrumental chroot into .work/syslinux/alt0/
STAGE1_KFLAVOUR ?= $(lastword $(KFLAVOURS))
# only for grub allowed multiple kernels, for other a single kernel
# might be needed (STAGE1_KFLAVOURS sets explicitly);
# kernel image copied from instrumental chroot into .work/boot/
ifeq (grubpcboot,$(BOOTLOADER))
STAGE1_KFLAVOURS ?= $(KFLAVOURS)
endif
ifeq (grub-efi,$(EFI_BOOTLOADER))
STAGE1_KFLAVOURS ?= $(KFLAVOURS)
endif
ifeq (ieee1275boot,$(BOOTLOADER))
STAGE1_KFLAVOURS ?= $(KFLAVOURS)
endif
STAGE1_KFLAVOURS ?= $(lastword $(KFLAVOURS))
# propagator needed iff stage1 kernel installed (not for e.g. syslinux.iso)
ifneq "$(STAGE1_KFLAVOUR)" ""
GLOBAL_STAGE1_KFLAVOUR := $(STAGE1_KFLAVOUR)
ifneq "$(STAGE1_KFLAVOURS)" ""
GLOBAL_STAGE1_KFLAVOURS := $(STAGE1_KFLAVOURS)
CHROOT_PACKAGES_REGEXP := $(call kpackages, \
$(STAGE1_KFLAVOUR),$(STAGE1_KMODULES),$(STAGE1_KMODULES_REGEXP))
$(STAGE1_KFLAVOURS),$(STAGE1_KMODULES),$(STAGE1_KMODULES_REGEXP))
ifneq "$(findstring stage2,$(SUBPROFILES))" "" ### assumes stage2 ~ propagator
LIST_MODULES = .work/chroot/.in/modules
PREPARE_MODULES = prepare-modules
......@@ -45,7 +54,7 @@ GLOBAL_SQUASHFS := $(SQUASHFS)
prepare-modules:
@echo $(foreach V,$(STAGE1_MODLISTS),$(wildcard modules.d/??-$(V))) \
| xargs -r -- cat >> $(PROPAGATOR_MAR_MODULES)
| xargs -r -- cat >> $(LIST_MODULES)
# scripts prepare bootloader configuration, too
# NB: we pass tested squashfs options for sub.in/stage2/Makefile to include
......
......@@ -8,11 +8,12 @@
следует крайне бережно относиться к объёму этой стадии.
Обратите внимание: если не указать явно требуемый вариант
ядра посредством STAGE1_KFLAVOUR, будет взят последний
из перечисленных в KFLAVOURS; если не указать явно регэкс,
описывающий требуемые в инсталяторе kernel-modules-*,
посредством STAGE1_KMODULES_REGEXP -- будут доступны модули
из kernel-image (упаковываются в syslinux/alt0/full.cz).
ядер посредством STAGE1_KFLAVOURS, то будет взят из KFLAVOURS;
если используется загрузчик отличный от grub, то будет взят
последний указанный в STAGE1_KFLAVOURS или KFLAVOURS;
если не указать явно регэкс, описывающий требуемые в инсталяторе
kernel-modules-*, посредством STAGE1_KMODULES_REGEXP -- будут
доступны модули из kernel-image (упаковываются в boot/full*.cz).
Сам список модулей, попадающих в full.cz, определяется
в файле modules (наиболее базовые!) и дополняется указанным
......
......@@ -25,18 +25,29 @@ include stage2cfg.mk
# requisite stuff
IMAGE_PACKAGES += $(SYSTEM_PACKAGES) $(STAGE2_PACKAGES)
# here we also try and come up with the stage1 kernel/modules, if any;
# no kernel flavour specified will result in no modules for stage1 vmlinuz
STAGE1_KFLAVOUR ?= $(lastword $(KFLAVOURS))
# here we try and come up with the installer kernel/modules, if any;
# only for grub allowed multiple kernels, for other a single kernel
# might be needed (STAGE1_KFLAVOURS sets explicitly);
# kernel image copied from instrumental chroot into .work/boot/
ifeq (grubpcboot,$(BOOTLOADER))
STAGE1_KFLAVOURS ?= $(KFLAVOURS)
endif
ifeq (grub-efi,$(EFI_BOOTLOADER))
STAGE1_KFLAVOURS ?= $(KFLAVOURS)
endif
ifeq (ieee1275boot,$(BOOTLOADER))
STAGE1_KFLAVOURS ?= $(KFLAVOURS)
endif
STAGE1_KFLAVOURS ?= $(lastword $(KFLAVOURS))
ifeq (,$(STAGE1_KFLAVOUR))
$(error STAGE1_KFLAVOUR is utterly empty; cannot guess either)
ifeq (,$(STAGE1_KFLAVOURS))
$(error STAGE1_KFLAVOURS is utterly empty; cannot guess either)
endif
# need kernel modules only (which require corresponding kernel-image);
# these go into work chroot; NB: no vmlinuz there (unless live-install)
IMAGE_PACKAGES_REGEXP += $(call kpackages, \
$(STAGE1_KFLAVOUR), \
$(STAGE1_KFLAVOURS), \
$(STAGE1_KMODULES) $(STAGE1_KMODULES_REGEXP) \
$(STAGE2_KMODULES) $(STAGE2_KMODULES_REGEXP))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment