build-vm, kernel, tar2fs: make-initrd happens now in build-vm

NB: 07-kernel change breaks multi-kernel setup!

Breaks: 650e92bf7f
This commit is contained in:
Anton Midyukov 2019-05-07 23:17:55 +07:00 committed by Michael Shigorin
parent 1895147905
commit 27674e297b
5 changed files with 47 additions and 22 deletions

View File

@ -27,10 +27,11 @@ BOOT_SIZE_FACTOR=2 # multiply /boot size by this value additionally
CUR_BOUNDARY=0 # align first partition at 1MB for performance (+1)
INITRD_MODULES=
BOOTFSTYPE=
BOOTPART=
BOOTLOADER="$5"
ARCH="$(arch)" # NB: sudo => no GLOBAL_ will do either; mind qemu-*
case "$ARCH" in
@ -209,24 +210,6 @@ fi
# Query ARCH in chroot and redefine arch-dependent variable
ARCH="$(chroot "$ROOTFS" rpm --eval '%_host_cpu')"
if [[ $ARCH = *86* ]]
then # NB: different storage modules might be needed for non-kvm
INITRD_MODULES="sd_mod ata_piix ahci virtio-scsi virtio-blk"
else
INITRD_MODULES=
fi
echo "MODULES_PRELOAD += $INITRD_MODULES $ROOTFSTYPE" >> "$ROOTFS/etc/initrd.mk"
case "$ARCH" in
*86*)
echo "FEATURES += qemu" >> "$ROOTFS/etc/initrd.mk"
;;
e2k)
echo "FEATURES += usb" >> "$ROOTFS/etc/initrd.mk"
;;
esac
# NB: don't stick BOOTFS here, it has slightly different semantics
pushd $ROOTFS/boot
@ -236,7 +219,6 @@ get_label() { echo "${1# *}" | sed -r 's,.*elbrus-([0-9a-z]+)-.*$,\1,'; }
KVERSIONS=
if [ -s .origver ]; then
while read kver; do
chroot "$ROOTFS" make-initrd -k "$kver"
KVERSIONS="$KVERSIONS $kver"
done < .origver
fi

View File

@ -1,3 +1,3 @@
# hooked from lib/sugar.mk
use/build-vm: sub/rootfs@/ use/kernel
use/build-vm: sub/rootfs@/ use/kernel/initrd-setup
@$(call add_feature)

View File

@ -13,6 +13,10 @@ kver="$(rpm -qa 'kernel-image*' \
cd /boot
echo "$kver" > .origver # for tar2fs
make-initrd -N -k "$kver" AUTODETECT= \
FEATURES+="$GLOBAL_VM_INITRDFEATURES" \
MODULES_ADD+="$GLOBAL_VM_INITRDMODULES"
# NB: e2k kernel builds "image" instead of "vmlinuz"
[ -f vmlinuz-$kver ] && ln -s vmlinuz-$kver vmlinuz ||:
ln -s initrd-$kver.img initrd.img # missing at this stage

View File

@ -10,6 +10,12 @@ IMAGE_PACKAGES = $(DOT_BASE) \
IMAGE_PACKAGES_REGEXP = $(THE_PACKAGES_REGEXP) \
$(BASE_PACKAGES_REGEXP)
ifdef EFI_BOOTLOADER
VM_BOOTLOADER=$(EFI_BOOTLOADER)
else
VM_BOOTLOADER=$(BASE_BOOTLOADER)
endif
# intermediate chroot archive
VM_TARBALL := $(IMAGE_OUTDIR)/$(IMAGE_NAME).tar
VM_RAWDISK := $(IMAGE_OUTDIR)/$(IMAGE_NAME).raw
@ -31,7 +37,8 @@ prepare-image: check-sudo
TOPDIR=/usr/share/mkimage-profiles; \
fi; \
if ! sudo $$TOPDIR/bin/tar2fs \
"$(VM_TARBALL)" "$(VM_RAWDISK)" $(VM_SIZE) $(VM_FSTYPE); then \
"$(VM_TARBALL)" "$(VM_RAWDISK)" "$(VM_SIZE)" "$(VM_FSTYPE)" \
"$(VM_BOOTLOADER)"; then \
echo "** error: sudo tar2fs failed, see build log" >&2; \
exit 1; \
fi

View File

@ -37,3 +37,35 @@ use/kernel/desktop:
use/kernel/server:
@$(call add,THE_KMODULES,ipset kvm)
# for vm targets
use/kernel/initrd-setup: use/kernel
@$(call add,VM_INITRDFEATURES,add-modules compress cleanup)
@$(call try,VM_FSTYPE,ext4)
@$(call add,VM_INITRDMODULES,$$(VM_FSTYPE))
ifeq (,$(filter-out i586 x86_64,$(ARCH)))
@$(call add,VM_INITRDFEATURES,qemu)
@$(call add,VM_INITRDMODULES,ata_piix)
endif
ifeq (,$(filter-out e2k%,$(ARCH)))
@$(call add,VM_INITRDFEATURES,usb)
endif
ifeq (,$(filter-out i586 x86_64 aarch64 armh,$(ARCH)))
@$(call add,VM_INITRDMODULES,ahci sd_mod)
@$(call add,VM_INITRDMODULES,nvme nvme-core)
@$(call add,VM_INITRDMODULES,virtio-scsi virtio-blk virtio-rng)
endif
ifeq (,$(filter-out aarch64 armh,$(ARCH)))
@$(call add,VM_INITRDMODULES,bcm2835 sunxi-mmc)
@$(call add,VM_INITRDMODULES,nvmem_rockchip_efuse)
@$(call add,VM_INITRDMODULES,virtio-mmio)
endif
ifeq (,$(filter-out aarch64,$(ARCH)))
@$(call add,VM_INITRDMODULES,meson-gx-mmc)
@$(call add,VM_INITRDMODULES,nvmem_meson_efuse)
endif
ifeq (,$(filter-out armh,$(ARCH)))
@$(call add,VM_INITRDMODULES,sdhci_dove sdhci_esdhc_imx)
endif
@$(call xport,VM_INITRDMODULES)
@$(call xport,VM_INITRDFEATURES)