Switch to using upstream mk-s390image for s390 cdboot.img creation

mk-s390-cdboot has stopped working because the kernel outgrew the
hard-coded offset it used when creating cdboot.img. IBM now has a script
in s390utils that can do the same thing so use the upstream script
instead.

This drops mk-s390-cdboot script, switches the s390 templates to use
mk-s390image from s390utils.

It adds @ROOT@ to cdboot.prm, and sets inst.stage2 so that the installer
image will be found when booting the iso.

Resolves: rhbz#1891778
This commit is contained in:
Brian C. Lane 2020-10-27 14:03:58 -07:00
parent 0a4afedba8
commit 67d16ebc32
6 changed files with 11 additions and 121 deletions

View File

@ -76,6 +76,7 @@ Requires: grub2-tools
%ifarch s390 s390x %ifarch s390 s390x
Requires: openssh Requires: openssh
Requires: s390utils >= 2.15.0-2
%endif %endif
%ifarch %{arm} %ifarch %{arm}
@ -169,7 +170,6 @@ make DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} install
%{_sbindir}/livemedia-creator %{_sbindir}/livemedia-creator
%{_sbindir}/mkksiso %{_sbindir}/mkksiso
%{_bindir}/image-minimizer %{_bindir}/image-minimizer
%{_bindir}/mk-s390-cdboot
%dir %{_sysconfdir}/lorax %dir %{_sysconfdir}/lorax
%config(noreplace) %{_sysconfdir}/lorax/lorax.conf %config(noreplace) %{_sysconfdir}/lorax/lorax.conf
%dir %{_datadir}/lorax %dir %{_datadir}/lorax

View File

@ -19,7 +19,6 @@ for root, dnames, fnames in os.walk("share"):
data_files.append(("/usr/sbin", ["src/sbin/lorax", "src/sbin/mkefiboot", data_files.append(("/usr/sbin", ["src/sbin/lorax", "src/sbin/mkefiboot",
"src/sbin/livemedia-creator", "src/sbin/mkksiso"])) "src/sbin/livemedia-creator", "src/sbin/mkksiso"]))
data_files.append(("/usr/bin", ["src/bin/image-minimizer", data_files.append(("/usr/bin", ["src/bin/image-minimizer",
"src/bin/mk-s390-cdboot",
"src/bin/composer-cli"])) "src/bin/composer-cli"]))
# get the version # get the version

View File

@ -1 +1 @@
ro ro @ROOT@

View File

@ -6,6 +6,7 @@ KERNELDIR=BOOTDIR
INITRD_ADDRESS="0x02000000" INITRD_ADDRESS="0x02000000"
LIVEDIR="LiveOS" LIVEDIR="LiveOS"
LORAXDIR="usr/share/lorax/" LORAXDIR="usr/share/lorax/"
MKS390IMAGE="/usr/bin/mk-s390image"
# The assumption seems to be that there is only one s390 kernel, ever # The assumption seems to be that there is only one s390 kernel, ever
kernel = kernels[0] kernel = kernels[0]
@ -74,10 +75,10 @@ treeinfo images-${basearch} cdboot.prm ${BOOTDIR}/cdboot.prm
%endfor %endfor
## Make a combined kernel+initrd image for the iso ## Make a combined kernel+initrd image for the iso
runcmd mk-s390-cdboot -i ${outroot}/${KERNELDIR}/kernel.img \ runcmd ${MKS390IMAGE} ${outroot}/${KERNELDIR}/kernel.img \
${outroot}/${BOOTDIR}/cdboot.img \
-r ${outroot}/${KERNELDIR}/initrd.img \ -r ${outroot}/${KERNELDIR}/initrd.img \
-p ${outroot}/${BOOTDIR}/cdboot.prm \ -p ${outroot}/${BOOTDIR}/cdboot.prm
-o ${outroot}/${BOOTDIR}/cdboot.img
## make boot.iso ## make boot.iso
runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \ runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \

View File

@ -5,6 +5,7 @@ BOOTDIR="images"
KERNELDIR=BOOTDIR KERNELDIR=BOOTDIR
INITRD_ADDRESS="0x02000000" INITRD_ADDRESS="0x02000000"
LORAXDIR="usr/share/lorax/" LORAXDIR="usr/share/lorax/"
MKS390IMAGE="/usr/bin/mk-s390image"
# The assumption seems to be that there is only one s390 kernel, ever # The assumption seems to be that there is only one s390 kernel, ever
kernel = kernels[0] kernel = kernels[0]
@ -32,6 +33,7 @@ install ${configdir}/generic.ins .
## configure bootloader ## configure bootloader
replace @INITRD_LOAD_ADDRESS@ ${INITRD_ADDRESS} generic.ins replace @INITRD_LOAD_ADDRESS@ ${INITRD_ADDRESS} generic.ins
replace @ROOT@ 'inst.stage2=hd:LABEL=${isolabel|udev}' ${BOOTDIR}/cdboot.prm
## install kernel ## install kernel
installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/kernel.img installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/kernel.img
@ -70,10 +72,10 @@ treeinfo images-${basearch} redhat.exec ${BOOTDIR}/redhat.exec
%endfor %endfor
## Make a combined kernel+initrd image for the iso ## Make a combined kernel+initrd image for the iso
runcmd mk-s390-cdboot -i ${outroot}/${KERNELDIR}/kernel.img \ runcmd ${MKS390IMAGE} ${outroot}/${KERNELDIR}/kernel.img \
${outroot}/${BOOTDIR}/cdboot.img \
-r ${outroot}/${KERNELDIR}/initrd.img \ -r ${outroot}/${KERNELDIR}/initrd.img \
-p ${outroot}/${BOOTDIR}/cdboot.prm \ -p ${outroot}/${BOOTDIR}/cdboot.prm
-o ${outroot}/${BOOTDIR}/cdboot.img
## make boot.iso ## make boot.iso
runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \ runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \

View File

@ -1,112 +0,0 @@
#!/usr/bin/python3
#
# mk-s390-cdboot
#
# Copyright (C) 2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import argparse
import os
import shutil
from struct import pack
import sys
INITRD_START = 0x0000000000800000
START_PSW_ADDRESS = 0x80010000
KERNEL_PSW_ADDRESS = 0x04
KERNEL_INITRD_START = 0x10408
KERNEL_INITRD_SIZE = 0x10410
KERNEL_CMDLINE = 0x10480
# See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/s390/include/uapi/asm/setup.h
KERNEL_CMDLINE_SIZE = 896
def setup_parser():
""" Setup the cmdline parser"""
parser = argparse.ArgumentParser(description="Create s390 boot image")
parser.add_argument("-i", dest="kernel", required=True, metavar="KERNEL",
help="The kernel.img file")
parser.add_argument("-r", dest="ramdisk", required=True, metavar="RAMDISK",
help="The initrd.img file")
parser.add_argument("-p", dest="parmfile", required=True, metavar="PARMFILE",
help="The parm file")
parser.add_argument("-o", dest="outfile", required=True, metavar="OUTFILE",
help="The output image file")
return parser
def copy_kernel(kernel, outfile):
""" Copy the kernel to the outfile"""
shutil.copy2(kernel, outfile)
def append_ramdisk(ramdisk, outfile):
""" Append the ramdisk to the kernel and return its size"""
with open(ramdisk, "rb") as ram_fd:
with open(outfile, "r+b") as out_fd:
out_fd.seek(INITRD_START)
out_fd.write(ram_fd.read())
return os.stat(ramdisk).st_size
def configure_kernel(outfile, parmfile, size):
""" Configure the kernel with the ramdisk start address and size."""
with open(outfile, "r+b") as out_fd:
# Change the start PSW address
out_fd.seek(KERNEL_PSW_ADDRESS)
out_fd.write(pack(">L", START_PSW_ADDRESS))
# Write the initrd start and size
out_fd.seek(KERNEL_INITRD_START)
out_fd.write(pack(">Q", INITRD_START))
out_fd.seek(KERNEL_INITRD_SIZE)
out_fd.write(pack(">Q", size))
# Erase the previous COMMAND_LINE, write zeros
out_fd.seek(KERNEL_CMDLINE)
out_fd.write(bytes(KERNEL_CMDLINE_SIZE))
# Write the first line of the parmfile
cmdline = open(parmfile, "r").readline().strip()
out_fd.seek(KERNEL_CMDLINE)
out_fd.write(bytes(cmdline, "utf-8"))
def main():
parser = setup_parser()
args = parser.parse_args()
errors = []
for f in [args.kernel, args.ramdisk, args.parmfile]:
if not os.path.exists(f):
errors.append("ERROR: %s is missing" % f)
if errors:
for e in errors:
print(e)
sys.exit(1)
print("Creating bootable CD-ROM image...")
print("kernel is : %s" % args.kernel)
print("ramdisk is : %s" % args.ramdisk)
print("parmfile is: %s" % args.parmfile)
print("outfile is : %s" % args.outfile)
copy_kernel(args.kernel, args.outfile)
size = append_ramdisk(args.ramdisk, args.outfile)
configure_kernel(args.outfile, args.parmfile, size)
if __name__ == '__main__':
main()