OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:Agama:Release/agama-installer?expand=0&rev=34
137 lines
4.0 KiB
Bash
137 lines
4.0 KiB
Bash
#! /bin/bash
|
|
|
|
# This script uses the KIWI 'editbootconfig' hook to modify the Live layout
|
|
# and ISO generation.
|
|
#
|
|
# Note that the 'editbootconfig' hook runs before the initrd is generated -
|
|
# this is too early for our purposes. So we have to do some gray area
|
|
# trickery:
|
|
#
|
|
# 1. Inject our modification scripts via config-cdroot.tar.xz into the Live tree.
|
|
# 2. Inject a 'xorriso' wrapper script into /usr/local/bin to hook into the ISO
|
|
# creation directly.
|
|
# This script (a) adjusts the boot config, (b) runs xorriso, and (c) makes
|
|
# it zIPL bootable on s390x.
|
|
#
|
|
set -ex
|
|
|
|
dst=${1#iso:}
|
|
|
|
# KIWI config
|
|
# Copy it to $dst from where it can be later read by xorriso
|
|
if [ -f .profile ]; then
|
|
source .profile
|
|
cp .profile "$dst"
|
|
fi
|
|
|
|
arch=`uname -m`
|
|
|
|
bootfix=$dst/fix_bootconfig.$arch
|
|
if [ -f $bootfix ] ; then
|
|
echo "bootconfig script found: \"$bootfix\""
|
|
fi
|
|
|
|
if [ $arch = ppc64le ] ; then
|
|
mkdir -p $dst/boot/grub2
|
|
cp -r usr/share/grub2/powerpc-ieee1275 $dst/boot/grub2
|
|
mv $dst/boot/grub2/powerpc-ieee1275/grub.elf $dst/boot/grub2
|
|
fi
|
|
|
|
cat <<XXX >/usr/local/bin/xorriso
|
|
#! /bin/bash
|
|
|
|
set -x
|
|
|
|
# get the output ISO file name and the input directory from the xorriso parameters
|
|
for i in "\$@" ; do
|
|
if [ -n "\$iso_opt" ] ; then
|
|
iso_opt=
|
|
export iso="\$i"
|
|
continue
|
|
fi
|
|
if [ "\$i" = "-outdev" ] ; then
|
|
iso_opt=1
|
|
continue
|
|
fi
|
|
if [ -n "\$map_opt" ] ; then
|
|
map_opt=
|
|
target_dir="\$i"
|
|
continue
|
|
fi
|
|
if [ "\$i" = "-map" ] ; then
|
|
map_opt=1
|
|
continue
|
|
fi
|
|
done
|
|
|
|
# dump or copy some data from the Live system root image directly to the ISO image to avoid
|
|
# complicated processing (the ISO image contains a squashfs image which contains ext4 image which
|
|
# finally contains the needed files)
|
|
if [ -n "\$target_dir" ]; then
|
|
mount_dir1=\$(mktemp -d)
|
|
mount_dir2=\$(mktemp -d)
|
|
|
|
mount -o loop "\$target_dir"/LiveOS/squashfs.img "\$mount_dir1"
|
|
mount -o loop "\$mount_dir1"/LiveOS/rootfs.img "\$mount_dir2"
|
|
|
|
# dump the list of the installed packages
|
|
rpm --root "\$mount_dir2" -qa | sort | gzip > "\$target_dir/LiveOS/.packages.gz"
|
|
|
|
# dump the same list also in JSON format for easier processing,
|
|
# use jq for sorting the array (case insensitive), for merging to a single
|
|
# array and also for formatting the final JSON output
|
|
rpm --root "\$mount_dir2" -qa --queryformat \\
|
|
'\\{"name":"%{NAME}","version":"%{VERSION}","release":"%{RELEASE}","arch":"%{ARCH}"\\}' \\
|
|
| chroot "\$mount_dir2" /usr/bin/jq -s 'sort_by(.name|ascii_downcase)' \\
|
|
| gzip > "\$target_dir/LiveOS/.packages.json.gz"
|
|
|
|
# copy the build info file if present
|
|
if [ -f "\$mount_dir2"/var/log/build/info ]; then
|
|
cp -a "\$mount_dir2"/var/log/build/info "\$target_dir/LiveOS/.info"
|
|
fi
|
|
|
|
# unmount in reverse(!) order
|
|
umount "\$mount_dir2"
|
|
umount "\$mount_dir1"
|
|
|
|
rmdir "\$mount_dir1"
|
|
rmdir "\$mount_dir2"
|
|
fi
|
|
|
|
profile=$(echo "$kiwi_profiles" | tr "_" "-")
|
|
# keep in sync with ISO Volume ID set in the config.sh script
|
|
volid="Install-\$profile-$arch"
|
|
|
|
# the simple rescue system reuses the installation live media
|
|
# but boots to the text-mode only and disables the Agama server
|
|
export RESCUE_SYSTEM_BOOT_SETTINGS="systemd.unit=multi-user.target \
|
|
systemd.mask=agama.service systemd.mask=agama-dbus-monitor.service \
|
|
systemd.mask=agama-ssh-issue.service systemd.mask=agama-avahi-issue.service \
|
|
systemd.mask=agama-welcome-issue.service systemd.mask=agama-url-issue.service \
|
|
systemd.mask=agama-certificate-issue.service \
|
|
systemd.mask=agama-certificate-issue.path \
|
|
systemd.mask=agama-certificate-wait.service"
|
|
|
|
[ -x $bootfix ] && $bootfix $dst
|
|
rm -f $dst/fix_bootconfig.* $dst/.profile
|
|
|
|
case $arch in
|
|
s390x)
|
|
/usr/bin/xorriso "\$@" -volid "\$volid" -boot_image any bin_path=boot/s390x/cd.ikr -boot_image any boot_info_table=off -boot_image any load_size=512
|
|
err=\$?
|
|
[ -x /usr/bin/isozipl ] && isozipl "\$iso"
|
|
;;
|
|
ppc64le)
|
|
/usr/bin/xorriso "\$@" -volid "\$volid" -boot_image any chrp_boot_part=on
|
|
err=\$?
|
|
;;
|
|
*)
|
|
/usr/bin/xorriso "\$@" -volid "\$volid"
|
|
err=\$?
|
|
esac
|
|
|
|
exit \$err
|
|
XXX
|
|
|
|
chmod +x /usr/local/bin/xorriso
|