Skip to content

Commit

Permalink
s390x: allow cosa build and run without anaconda
Browse files Browse the repository at this point in the history
- add zipl code in create_disk.sh. We need to implement removal of
ignition.firstboot and re-run zipl in ignition-dracut hooks.
See coreos/ignition-dracut#84.

Signed-off-by: Tuan Hoang <[email protected]>
  • Loading branch information
tuan-hoang1 committed Aug 12, 2019
1 parent 3c52b09 commit 1df75db
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ echo '{}' > tmp/vm-iso-checksum.json
if [ -n "${build_qemu}" ]; then
img_qemu=${imageprefix}-qemu.qcow2
case "$arch" in
"x86_64"|"aarch64")
"x86_64"|"aarch64"|"s390x")
build_image "$img_qemu"
;;
*)
Expand Down
43 changes: 35 additions & 8 deletions src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,53 @@ if [ "$arch" == "x86_64" ]; then
--boot-directory rootfs/boot \
$disk
ext="X64"
else
elif [ "$arch" == "aarch64" ]; then
mkdir -p rootfs/boot/grub2
ext="AA64"
fi

# we use pure BLS, so don't need grub2-mkconfig
ostree config --repo rootfs/ostree/repo set sysroot.bootloader none

# install uefi grub
mkdir -p rootfs/boot/efi/EFI/{BOOT,fedora}
cp "/boot/efi/EFI/BOOT/BOOT${ext}.EFI" "rootfs/boot/efi/EFI/BOOT/BOOT${ext}.EFI"
cp "/boot/efi/EFI/fedora/grub${ext,,}.efi" "rootfs/boot/efi/EFI/BOOT/grub${ext,,}.efi"
cat > rootfs/boot/efi/EFI/fedora/grub.cfg << 'EOF'
if [ "$arch" == "s390x" ]; then
# current zipl expects 'title' to be first line, and no blank lines in BLS file
# see https://github.com/ibm-s390-tools/s390-tools/issues/64
blsfile=$(find rootfs/boot/loader/entries/*.conf)
tmpfile=$(mktemp)
for f in title version linux initrd; do
echo $(grep $f $blsfile) >> $tmpfile
done
# we force firstboot in building base image on s390x
# ignition-dracut hook will remove this and update zipl for second boot
options="$(grep options $blsfile | cut -d' ' -f2-) ignition.firstboot rd.neednet=1 ip=dhcp"
echo "options $options" >> $tmpfile
cat $tmpfile > $blsfile

# ideally we want to invoke zipl with bls and zipl.conf but we might need
# to chroot to rootfs/ to do so. We would also do that when FCOS boot on its own.
# without chroot we can use --target option in zipl but it requires kernel + initramfs
# pair instead
echo $options > $tmpfile
zipl --verbose \
--target rootfs/boot \
--image rootfs/boot/"$(grep linux $blsfile | cut -d' ' -f2)" \
--ramdisk rootfs/boot/"$(grep initrd $blsfile | cut -d' ' -f2)" \
--parmfile $tmpfile
else
# install uefi grub
mkdir -p rootfs/boot/efi/EFI/{BOOT,fedora}
cp "/boot/efi/EFI/BOOT/BOOT${ext}.EFI" "rootfs/boot/efi/EFI/BOOT/BOOT${ext}.EFI"
cp "/boot/efi/EFI/fedora/grub${ext,,}.efi" "rootfs/boot/efi/EFI/BOOT/grub${ext,,}.efi"
cat > rootfs/boot/efi/EFI/fedora/grub.cfg << 'EOF'
search --label boot --set prefix
set prefix=($prefix)/grub2
normal
EOF

# copy the grub config and any other files we might need
cp $grub_script rootfs/boot/grub2/grub.cfg
# copy the grub config and any other files we might need
cp $grub_script rootfs/boot/grub2/grub.cfg
fi

touch rootfs/boot/ignition.firstboot

umount -R rootfs

0 comments on commit 1df75db

Please sign in to comment.