From f00e882a96201eddf8bf1f326a45e8efc5099dfa Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 5 Oct 2021 10:44:18 -0400 Subject: [PATCH] import coreos-installer-0.9.1-17.el8 --- .coreos-installer.metadata | 2 + .gitignore | 2 + SOURCES/coidracut.patch | 114 ++++++++ SOURCES/coidracut2.patch | 27 ++ SOURCES/coidracut3.patch | 246 ++++++++++++++++++ SOURCES/coidracut4.patch | 80 ++++++ SOURCES/coidracut5.patch | 16 ++ SOURCES/disable-lto-0.6.0.patch | 11 + SOURCES/enable-rdcore.patch | 10 + SOURCES/force_persist_ip-0.9.1.patch | 26 ++ SOURCES/s390x-support-virtio-dasd-0.9.1.patch | 166 ++++++++++++ SPECS/coreos-installer.spec | 223 ++++++++++++++++ 12 files changed, 923 insertions(+) create mode 100644 .coreos-installer.metadata create mode 100644 .gitignore create mode 100644 SOURCES/coidracut.patch create mode 100644 SOURCES/coidracut2.patch create mode 100644 SOURCES/coidracut3.patch create mode 100644 SOURCES/coidracut4.patch create mode 100644 SOURCES/coidracut5.patch create mode 100644 SOURCES/disable-lto-0.6.0.patch create mode 100644 SOURCES/enable-rdcore.patch create mode 100644 SOURCES/force_persist_ip-0.9.1.patch create mode 100644 SOURCES/s390x-support-virtio-dasd-0.9.1.patch create mode 100644 SPECS/coreos-installer.spec diff --git a/.coreos-installer.metadata b/.coreos-installer.metadata new file mode 100644 index 0000000..2b51770 --- /dev/null +++ b/.coreos-installer.metadata @@ -0,0 +1,2 @@ +9ad623e572641316d7bdb51e11e136713b019bfa SOURCES/coreos-installer-0.9.1-vendor.tar.gz +147efc72c044194209d686b78d62e3acbc761763 SOURCES/coreos-installer-0.9.1.crate diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b1e12c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/coreos-installer-0.9.1-vendor.tar.gz +SOURCES/coreos-installer-0.9.1.crate diff --git a/SOURCES/coidracut.patch b/SOURCES/coidracut.patch new file mode 100644 index 0000000..1399a79 --- /dev/null +++ b/SOURCES/coidracut.patch @@ -0,0 +1,114 @@ +diff --git a/dracut/50rdcore/module-setup.sh b/dracut/50rdcore/module-setup.sh +index 27a2ac3..443b5cf 100755 +--- a/dracut/50rdcore/module-setup.sh ++++ b/dracut/50rdcore/module-setup.sh +@@ -1,5 +1,47 @@ + #!/bin/bash + ++install_and_enable_unit() { ++ unit="$1"; shift ++ target="$1"; shift ++ inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit" ++ # note we `|| exit 1` here so we error out if e.g. the units are missing ++ # see https://github.com/coreos/fedora-coreos-config/issues/799 ++ systemctl -q --root="$initdir" add-requires "$target" "$unit" || exit 1 ++} ++ + install() { + inst_simple "$moddir/rdcore" "/usr/bin/rdcore" ++ ++ inst_simple "$moddir/coreos-installer" "/usr/bin/coreos-installer" ++ ++ inst_simple "$moddir/coreos-installer-generator" \ ++ "$systemdutildir/system-generators/coreos-installer-generator" ++ ++ inst_script "$moddir/coreos-installer-service" \ ++ "/usr/libexec/coreos-installer-service" ++ ++ inst_script "$moddir/coreos-installer-disable-device-auto-activation" \ ++ "/usr/libexec/coreos-installer-disable-device-auto-activation" ++ ++ install_and_enable_unit "coreos-installer.service" \ ++ "default.target" ++ ++ install_and_enable_unit "coreos-installer-reboot.service" \ ++ "default.target" ++ ++# install_and_enable_unit "coreos-installer-noreboot.service" \ ++# "basic.target" ++# inst_simple "$moddir/coreos-installer-reboot.service" \ ++# "$systemdsystemunitdir/coreos-installer-reboot.service" ++# inst_simple "$moddir/coreos-installer-noreboot.service" \ ++# "$systemdsystemunitdir/coreos-installer-noreboot.service" ++# ++# inst_simple "$moddir/coreos-installer.target" \ ++# "$systemdsystemunitdir/coreos-installer.target" ++# ++# inst_simple "$moddir/coreos-installer-pre.target" \ ++# "$systemdsystemunitdir/coreos-installer-pre.target" ++# ++# inst_simple "$moddir/coreos-installer-post.target" \ ++# "$systemdsystemunitdir/coreos-installer-post.target" + } +diff --git a/systemd/coreos-installer-generator b/systemd/coreos-installer-generator +index 804d045..b2bcaec 100755 +--- a/systemd/coreos-installer-generator ++++ b/systemd/coreos-installer-generator +@@ -30,11 +30,11 @@ karg_bool() { + } + + if [ -n "$(karg coreos.inst.install_dev)" ]; then +- ln -sf "/usr/lib/systemd/system/coreos-installer-post.target" \ +- "${UNIT_DIR}/default.target" ++# ln -sf "/usr/lib/systemd/system/coreos-installer-post.target" \ ++# "${UNIT_DIR}/basic.target" + + # Create precondition for coreos-installer-reboot.service if requested + if ! karg_bool coreos.inst.skip_reboot; then +- touch /run/coreos-installer-reboot ++ > /run/coreos-installer-reboot + fi + fi +diff --git a/systemd/coreos-installer-reboot.service b/systemd/coreos-installer-reboot.service +index 18fdb4b..ad79614 100644 +--- a/systemd/coreos-installer-reboot.service ++++ b/systemd/coreos-installer-reboot.service +@@ -1,7 +1,7 @@ + [Unit] + Description=Reboot after CoreOS Installer +-Requires=coreos-installer.target +-After=coreos-installer.target ++#Requires=coreos-installer.target ++After=coreos-installer.service + OnFailure=emergency.target + OnFailureJobMode=replace-irreversibly + ConditionPathExists=/run/coreos-installer-reboot +diff --git a/systemd/coreos-installer.service b/systemd/coreos-installer.service +index 5e222f2..716b783 100644 +--- a/systemd/coreos-installer.service ++++ b/systemd/coreos-installer.service +@@ -1,12 +1,20 @@ + [Unit] + Description=CoreOS Installer +-Before=coreos-installer.target +-After=network-online.target +-Wants=network-online.target ++#Before=coreos-installer.target ++#After=nm-run.service ++#After=network-online.target ++#Wants=network-online.target + # Until we retry HTTP requests let's wait here until + # systemd-resolved comes up if enabled. + # https://github.com/coreos/coreos-installer/issues/283 +-After=systemd-resolved.service ++#After=systemd-resolved.service ++ ++After=basic.target ++# Network is enabled here ++After=nm-run.service ++# compat: remove when everyone is on dracut 053+ ++After=dracut-initqueue.service ++ + ConditionKernelCommandLine=coreos.inst.install_dev + OnFailure=emergency.target + OnFailureJobMode=replace-irreversibly diff --git a/SOURCES/coidracut2.patch b/SOURCES/coidracut2.patch new file mode 100644 index 0000000..e5e33c8 --- /dev/null +++ b/SOURCES/coidracut2.patch @@ -0,0 +1,27 @@ +diff --git a/dracut/50rdcore/module-setup.sh b/dracut/50rdcore/module-setup.sh +index 443b5cf..c065851 100755 +--- a/dracut/50rdcore/module-setup.sh ++++ b/dracut/50rdcore/module-setup.sh +@@ -10,6 +10,10 @@ install_and_enable_unit() { + } + + install() { ++ inst_multiple gpg ++ inst_multiple gpg-agent ++ inst_multiple gpg-connect-agent ++ + inst_simple "$moddir/rdcore" "/usr/bin/rdcore" + + inst_simple "$moddir/coreos-installer" "/usr/bin/coreos-installer" +diff --git a/scripts/coreos-installer-service b/scripts/coreos-installer-service +index 347b5f5..239de3a 100755 +--- a/scripts/coreos-installer-service ++++ b/scripts/coreos-installer-service +@@ -87,6 +87,7 @@ fi + + # Other args that should just be copied over + copy_arg coreos.inst.image_url --image-url ++copy_arg coreos.inst.image_file --image-file + copy_arg coreos.inst.platform_id --platform + copy_arg coreos.inst.stream --stream + copy_arg coreos.inst.save_partlabel --save-partlabel diff --git a/SOURCES/coidracut3.patch b/SOURCES/coidracut3.patch new file mode 100644 index 0000000..c03bd2f --- /dev/null +++ b/SOURCES/coidracut3.patch @@ -0,0 +1,246 @@ +diff --git a/dracut/50rdcore/module-setup.sh b/dracut/50rdcore/module-setup.sh +index c065851..2d689d9 100755 +--- a/dracut/50rdcore/module-setup.sh ++++ b/dracut/50rdcore/module-setup.sh +@@ -14,6 +14,48 @@ install() { + inst_multiple gpg-agent + inst_multiple gpg-connect-agent + ++ inst_multiple \ ++ realpath \ ++ basename \ ++ blkid \ ++ cat \ ++ dirname \ ++ findmnt \ ++ growpart \ ++ realpath \ ++ resize2fs \ ++ tail \ ++ tune2fs \ ++ touch \ ++ xfs_admin \ ++ xfs_growfs \ ++ wc \ ++ lsblk \ ++ wipefs ++ ++ inst_multiple \ ++ awk \ ++ cat \ ++ dd \ ++ grep \ ++ mktemp \ ++ partx \ ++ rm \ ++ sed \ ++ sfdisk \ ++ sgdisk \ ++ find ++ ++ inst_multiple -o \ ++ clevis-encrypt-sss \ ++ clevis-encrypt-tang \ ++ clevis-encrypt-tpm2 \ ++ clevis-luks-bind \ ++ clevis-luks-common-functions \ ++ clevis-luks-unlock \ ++ pwmake \ ++ tpm2_create ++ + inst_simple "$moddir/rdcore" "/usr/bin/rdcore" + + inst_simple "$moddir/coreos-installer" "/usr/bin/coreos-installer" +@@ -33,19 +75,8 @@ install() { + install_and_enable_unit "coreos-installer-reboot.service" \ + "default.target" + +-# install_and_enable_unit "coreos-installer-noreboot.service" \ +-# "basic.target" +-# inst_simple "$moddir/coreos-installer-reboot.service" \ +-# "$systemdsystemunitdir/coreos-installer-reboot.service" +-# inst_simple "$moddir/coreos-installer-noreboot.service" \ +-# "$systemdsystemunitdir/coreos-installer-noreboot.service" +-# +-# inst_simple "$moddir/coreos-installer.target" \ +-# "$systemdsystemunitdir/coreos-installer.target" +-# +-# inst_simple "$moddir/coreos-installer-pre.target" \ +-# "$systemdsystemunitdir/coreos-installer-pre.target" +-# +-# inst_simple "$moddir/coreos-installer-post.target" \ +-# "$systemdsystemunitdir/coreos-installer-post.target" ++ install_and_enable_unit "growfs.service" \ ++ "default.target" ++ inst_script "$moddir/growfs" \ ++ /usr/sbin/growfs + } +diff --git a/scripts/growfs b/scripts/growfs +new file mode 100644 +index 0000000..45c495c +--- /dev/null ++++ b/scripts/growfs +@@ -0,0 +1,100 @@ ++#!/bin/bash ++set -euo pipefail ++ ++# This script grows the root ++ ++sleep 5 ++udevadm settle ++TYPE=$(lsblk --output FSTYPE /dev/disk/by-label/root | tail -n1) ++echo ${TYPE} ++dev=$(realpath /dev/disk/by-label/root) ++ ++mount -t ${TYPE} /dev/disk/by-label/root /sysroot ++ ++# We run after the rootfs is mounted at /sysroot ++path=/sysroot ++ ++# The use of tail is to avoid errors from duplicate mounts; ++# this shouldn't happen for us but we're being conservative. ++src=$(findmnt -nvr -o SOURCE "$path" | tail -n1) ++ ++partition=$(realpath /dev/disk/by-label/root) ++ ++# Go through each blockdev in the hierarchy and verify we know how to grow them ++lsblk -no TYPE "${partition}" | while read dev; do ++ case "${dev}" in ++ part|crypt) ;; ++ *) echo "error: Unsupported blockdev type ${dev}" 1>&2; exit 1 ;; ++ esac ++done ++ ++# Get the filesystem type before extending the partition. This matters ++# because the partition, once extended, might include leftover superblocks ++# from the previous contents of the disk (notably ZFS), causing blkid to ++eval $(blkid -o export "${src}") ++ ++ROOTFS_TYPE=${TYPE:-} ++case "${ROOTFS_TYPE}" in ++ xfs|ext4|btrfs) ;; ++ *) echo "error: Unsupported filesystem for ${path}: '${ROOTFS_TYPE}'" 1>&2; exit 1 ;; ++esac ++ ++# Now, go through the hierarchy, growing everything. Note we go one device at a ++# time using --nodeps, because ordering is buggy in el8: ++# https://bugzilla.redhat.com/show_bug.cgi?id=1940607 ++current_blkdev=${partition} ++while true; do ++ eval "$(lsblk --paths --nodeps --pairs -o NAME,TYPE,PKNAME "${current_blkdev}")" ++ MAJMIN=$(echo $(lsblk -dno MAJ:MIN "${NAME}")) ++ case "${TYPE}" in ++ part) ++ eval $(udevadm info --query property --export "${current_blkdev}" | grep ^DM_ || :) ++ if [ -n "${DM_MPATH:-}" ]; then ++ # Since growpart does not understand device mapper, we have to use sfdisk. ++ echo ", +" | sfdisk --no-reread --no-tell-kernel --force -N "${DM_PART}" "/dev/mapper/${DM_MPATH}" ++ udevadm settle # Wait for udev-triggered kpartx to update mappings ++ else ++ partnum=$(cat "/sys/dev/block/${MAJMIN}/partition") ++ # XXX: ideally this'd be idempotent and we wouldn't `|| :` ++ growpart "${PKNAME}" "${partnum}" || : ++ fi ++ ;; ++ crypt) ++ # XXX: yuck... we need to expose this sanely in clevis ++ (. /usr/bin/clevis-luks-common-functions ++ eval $(udevadm info --query=property --export "${NAME}") ++ # lsblk doesn't print PKNAME of crypt devices with --nodeps ++ PKNAME=/dev/$(ls "/sys/dev/block/${MAJMIN}/slaves") ++ clevis_luks_unlock_device "${PKNAME}" | cryptsetup resize -d- "${DM_NAME}" ++ ) ++ ;; ++ # already checked ++ *) echo "unreachable" 1>&2; exit 1 ;; ++ esac ++ holders="/sys/dev/block/${MAJMIN}/holders" ++ [ -d "${holders}" ] || break ++ nholders="$(ls "${holders}" | wc -l)" ++ if [ "${nholders}" -eq 0 ]; then ++ break ++ elif [ "${nholders}" -gt 1 ]; then ++ # this shouldn't happen since we've checked the partition types already ++ echo "error: Unsupported block device with multiple children: ${NAME}" 1>&2 ++ exit 1 ++ fi ++ current_blkdev=/dev/$(ls "${holders}") ++done ++ ++# Wipe any filesystem signatures from the extended partition that don't ++# correspond to the FS type we detected earlier. ++wipefs -af -t "no${ROOTFS_TYPE}" "${src}" ++ ++# TODO: Add XFS to https://github.com/systemd/systemd/blob/master/src/partition/growfs.c ++# and use it instead. ++case "${ROOTFS_TYPE}" in ++ xfs) xfs_growfs "${path}" ;; ++ ext4) resize2fs "${src}" ;; ++ btrfs) btrfs filesystem resize max ${path} ;; ++esac ++ ++# this is useful for tests ++touch /run/growfs.stamp +\ No newline at end of file +diff --git a/src/blockdev.rs b/src/blockdev.rs +index f9701b9..2fdd6f0 100644 +--- a/src/blockdev.rs ++++ b/src/blockdev.rs +@@ -970,7 +970,7 @@ pub fn udev_settle() -> Result<()> { + // udevd hasn't yet received updates from the kernel, settle will return + // immediately, and lsblk won't pick up partition labels. Try to sleep + // our way out of this. +- sleep(Duration::from_millis(200)); ++ sleep(Duration::from_millis(500)); + + runcmd!("udevadm", "settle")?; + Ok(()) +diff --git a/systemd/coreos-installer-reboot.service b/systemd/coreos-installer-reboot.service +index ad79614..f9ba80e 100644 +--- a/systemd/coreos-installer-reboot.service ++++ b/systemd/coreos-installer-reboot.service +@@ -1,6 +1,5 @@ + [Unit] + Description=Reboot after CoreOS Installer +-#Requires=coreos-installer.target + After=coreos-installer.service + OnFailure=emergency.target + OnFailureJobMode=replace-irreversibly +diff --git a/systemd/coreos-installer.service b/systemd/coreos-installer.service +index 716b783..e8199a9 100644 +--- a/systemd/coreos-installer.service ++++ b/systemd/coreos-installer.service +@@ -1,13 +1,5 @@ + [Unit] + Description=CoreOS Installer +-#Before=coreos-installer.target +-#After=nm-run.service +-#After=network-online.target +-#Wants=network-online.target +-# Until we retry HTTP requests let's wait here until +-# systemd-resolved comes up if enabled. +-# https://github.com/coreos/coreos-installer/issues/283 +-#After=systemd-resolved.service + + After=basic.target + # Network is enabled here +diff --git a/systemd/growfs.service b/systemd/growfs.service +new file mode 100644 +index 0000000..6d77aaa +--- /dev/null ++++ b/systemd/growfs.service +@@ -0,0 +1,13 @@ ++[Unit] ++Description=Grow root filesystem ++DefaultDependencies=false ++ ++After=coreos-installer.service ++Before=coreos-installer-reboot.service ++Requires=dev-disk-by\x2dlabel-root.device ++After=dev-disk-by\x2dlabel-root.device ++ ++[Service] ++Type=oneshot ++ExecStart=/usr/sbin/growfs ++RemainAfterExit=yes +\ No newline at end of file diff --git a/SOURCES/coidracut4.patch b/SOURCES/coidracut4.patch new file mode 100644 index 0000000..903b317 --- /dev/null +++ b/SOURCES/coidracut4.patch @@ -0,0 +1,80 @@ +diff --git a/systemd/coreos-installer-generator b/systemd/coreos-installer-generator +index b2bcaec..2b85dc5 100755 +--- a/systemd/coreos-installer-generator ++++ b/systemd/coreos-installer-generator +@@ -2,6 +2,8 @@ + # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- + # ex: ts=8 sw=4 sts=4 et filetype=sh + ++command -v getarg >/dev/null || . /usr/lib/dracut-lib.sh ++ + set -e + + # Generators don't have logging right now +@@ -10,6 +12,14 @@ exec 1>/dev/kmsg; exec 2>&1 + + UNIT_DIR="${1:-/tmp}" + ++add_requires() { ++ local name="$1"; shift ++ local target="$1"; shift ++ local requires_dir="${UNIT_DIR}/${target}.requires" ++ mkdir -p "${requires_dir}" ++ ln -sf "../${name}" "${requires_dir}/${name}" ++} ++ + cmdline=( $( /run/coreos-installer-reboot + fi + fi ++ ++add_requires run-media-iso.mount default.target ++ ++isoroot=$(getarg edge.liveiso= ||:) ++ ++mkdir -p /run/media/iso ++isosrc=dev/disk/by-label/${isoroot} ++isosrc_escaped=$(systemd-escape -p --suffix=device "${isosrc}") ++ ++if [ -n "${isoroot}" ]; then ++cat >"${UNIT_DIR}/run-media-iso.mount" < +Date: Mon, 7 Jun 2021 18:53:29 -0400 +Subject: [PATCH] add coreos.force_persist_ip to list of persisted dracut args + +xref: https://github.com/coreos/fedora-coreos-config/pull/1045 +--- + scripts/coreos-installer-service | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/coreos-installer-service b/scripts/coreos-installer-service +index ff9ff5f..347b5f5 100755 +--- a/scripts/coreos-installer-service ++++ b/scripts/coreos-installer-service +@@ -8,7 +8,7 @@ PERSIST_KERNEL_NET_PARAMS=("ipv6.disable" "net.ifnames" "net.naming-scheme") + # Dracut networking params to persist + # Everything other than rd.neednet. + # List from https://www.mankier.com/7/dracut.cmdline#Description-Network +-PERSIST_DRACUT_NET_PARAMS=("ip" "ifname" "rd.route" "bootdev" "BOOTIF" "rd.bootif" "nameserver" "rd.peerdns" "biosdevname" "vlan" "bond" "team" "bridge" "rd.net.timeout.carrier" "coreos.no_persist_ip") ++PERSIST_DRACUT_NET_PARAMS=("ip" "ifname" "rd.route" "bootdev" "BOOTIF" "rd.bootif" "nameserver" "rd.peerdns" "biosdevname" "vlan" "bond" "team" "bridge" "rd.net.timeout.carrier" "coreos.no_persist_ip" "coreos.force_persist_ip") + + # IBM S390X params to persist + PERSIST_S390X_PARAMS=("rd.dasd" "rd.zfcp" "rd.znet" "zfcp.allow_lun_scan" "cio_ignore") +-- +2.31.1 + diff --git a/SOURCES/s390x-support-virtio-dasd-0.9.1.patch b/SOURCES/s390x-support-virtio-dasd-0.9.1.patch new file mode 100644 index 0000000..bae8ba3 --- /dev/null +++ b/SOURCES/s390x-support-virtio-dasd-0.9.1.patch @@ -0,0 +1,166 @@ +From c4fabc7c801491019263523df3c9078cca99bb6e Mon Sep 17 00:00:00 2001 +From: Nikita Dubrovskii +Date: Wed, 2 Jun 2021 14:27:42 +0200 +Subject: [PATCH] s390: add support for virtio dasds + +This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1960485 + +Signed-off-by: Nikita Dubrovskii +--- + src/blockdev.rs | 30 ++++++++++++++++++++++++++++-- + src/cmdline.rs | 2 +- + src/install.rs | 6 +++--- + src/s390x/dasd.rs | 15 +++++++++++---- + 4 files changed, 43 insertions(+), 10 deletions(-) + +diff --git a/src/blockdev.rs b/src/blockdev.rs +index 90c6bee..df8e10a 100644 +--- a/src/blockdev.rs ++++ b/src/blockdev.rs +@@ -970,10 +970,36 @@ pub fn detect_formatted_sector_size(buf: &[u8]) -> Option { + } + + /// Checks if underlying device is IBM DASD disk +-pub fn is_dasd(device: &str) -> Result { ++pub fn is_dasd(device: &str, fd: Option<&mut File>) -> Result { + let target = + canonicalize(device).with_context(|| format!("getting absolute path to {}", device))?; +- Ok(target.to_string_lossy().starts_with("/dev/dasd")) ++ if target.to_string_lossy().starts_with("/dev/dasd") { ++ return Ok(true); ++ } ++ let read_magic = |device: &str, disk: &mut File| -> Result<[u8; 4]> { ++ let offset = disk ++ .seek(SeekFrom::Current(0)) ++ .with_context(|| format!("saving offset {}", device))?; ++ disk.seek(SeekFrom::Start(8194)) ++ .with_context(|| format!("seeking {}", device))?; ++ let mut lbl = [0u8; 4]; ++ disk.read_exact(&mut lbl) ++ .with_context(|| format!("reading label {}", device))?; ++ disk.seek(SeekFrom::Start(offset)) ++ .with_context(|| format!("restoring offset {}", device))?; ++ Ok(lbl) ++ }; ++ if target.to_string_lossy().starts_with("/dev/vd") { ++ let cdl_magic = [0xd3, 0xf1, 0xe5, 0xd6]; ++ let lbl = if let Some(t) = fd { ++ read_magic(device, t)? ++ } else { ++ let mut disk = File::open(device).with_context(|| format!("opening {}", device))?; ++ read_magic(device, &mut disk)? ++ }; ++ return Ok(cdl_magic == lbl); ++ } ++ Ok(false) + } + + // create unsafe ioctl wrappers +diff --git a/src/cmdline.rs b/src/cmdline.rs +index db3d1d0..53b8179 100644 +--- a/src/cmdline.rs ++++ b/src/cmdline.rs +@@ -853,7 +853,7 @@ fn parse_install(matches: &ArgMatches) -> Result { + // it changes to the recommended 4096 + // https://bugzilla.redhat.com/show_bug.cgi?id=1905159 + #[allow(clippy::match_bool, clippy::match_single_binding)] +- let sector_size = match is_dasd(&device) ++ let sector_size = match is_dasd(&device, None) + .with_context(|| format!("checking whether {} is an IBM DASD disk", device))? + { + #[cfg(target_arch = "s390x")] +diff --git a/src/install.rs b/src/install.rs +index baa3880..20d1f41 100644 +--- a/src/install.rs ++++ b/src/install.rs +@@ -47,7 +47,7 @@ pub fn install(config: &InstallConfig) -> Result<()> { + + #[cfg(target_arch = "s390x")] + { +- if is_dasd(&config.device)? { ++ if is_dasd(&config.device, None)? { + if !config.save_partitions.is_empty() { + // The user requested partition saving, but SavedPartitions + // doesn't understand DASD VTOCs and won't find any partitions +@@ -156,7 +156,7 @@ fn write_disk( + + // copy the image + #[allow(clippy::match_bool, clippy::match_single_binding)] +- let image_copy = match is_dasd(&config.device)? { ++ let image_copy = match is_dasd(&config.device, Some(dest))? { + #[cfg(target_arch = "s390x")] + true => s390x::image_copy_s390x, + _ => image_copy_default, +@@ -527,7 +527,7 @@ fn reset_partition_table( + ) -> Result<()> { + eprintln!("Resetting partition table"); + +- if is_dasd(&config.device)? { ++ if is_dasd(&config.device, Some(dest))? { + // Don't write out a GPT, since the backup GPT may overwrite + // something we're not allowed to touch. Just clear the first MiB + // of disk. +diff --git a/src/s390x/dasd.rs b/src/s390x/dasd.rs +index 7145071..b7dea78 100644 +--- a/src/s390x/dasd.rs ++++ b/src/s390x/dasd.rs +@@ -35,13 +35,15 @@ pub(crate) struct Range { + pub length: u64, + } + +-/// There are 2 types of DASD devices: ++/// There are 3 types of DASD devices: + /// - ECKD (Extended Count Key Data) - is regular DASD of type 3390 + /// - FBA (Fixed Block Access) - is used for emulated device that represents a real SCSI device ++/// - Virt - ECKD on LPAR/zKVM as virtio-device + /// Only ECKD disks require `dasdfmt, fdasd` linux tools to be configured. + enum DasdType { + Eckd, + Fba, ++ Virt, + } + + fn get_dasd_type>(device: P) -> Result { +@@ -53,6 +55,9 @@ fn get_dasd_type>(device: P) -> Result { + .with_context(|| format!("getting name of {}", device.display()))? + .to_string_lossy() + .to_string(); ++ if device.starts_with("vd") { ++ return Ok(DasdType::Virt); ++ } + let devtype_path = format!("/sys/class/block/{}/device/devtype", device); + let devtype_str = std::fs::read_to_string(&devtype_path) + .with_context(|| format!("reading {}", devtype_path))?; +@@ -66,7 +71,7 @@ fn get_dasd_type>(device: P) -> Result { + pub fn prepare_dasd(dasd: &str) -> Result<()> { + match get_dasd_type(dasd)? { + DasdType::Eckd => eckd_prepare(dasd), +- DasdType::Fba => Ok(()), ++ DasdType::Fba | DasdType::Virt => Ok(()), + } + } + +@@ -75,7 +80,7 @@ pub fn prepare_dasd(dasd: &str) -> Result<()> { + pub fn dasd_try_get_sector_size(dasd: &str) -> Result> { + match get_dasd_type(dasd)? { + DasdType::Eckd => eckd_try_get_sector_size(dasd), +- DasdType::Fba => Ok(None), ++ DasdType::Fba | DasdType::Virt => Ok(None), + } + } + +@@ -87,8 +92,10 @@ pub fn image_copy_s390x( + _saved: Option<&SavedPartitions>, + ) -> Result<()> { + let ranges = match get_dasd_type(dest_path)? { +- DasdType::Eckd => eckd_make_partitions(&dest_path.to_string_lossy(), dest_file, first_mb)?, + DasdType::Fba => fba_make_partitions(&dest_path.to_string_lossy(), dest_file, first_mb)?, ++ DasdType::Eckd | DasdType::Virt => { ++ eckd_make_partitions(&dest_path.to_string_lossy(), dest_file, first_mb)? ++ } + }; + + // copy each partition +-- +2.31.1 + diff --git a/SPECS/coreos-installer.spec b/SPECS/coreos-installer.spec new file mode 100644 index 0000000..efbd865 --- /dev/null +++ b/SPECS/coreos-installer.spec @@ -0,0 +1,223 @@ +# Generated by rust2rpm 13 +%define dracutlibdir %{_prefix}/lib/dracut +%bcond_without check +%global __cargo_skip_build 0 +# The library is for internal code reuse and is not a public API +%global __cargo_is_lib 0 + +%global crate coreos-installer + +Name: %{crate} +Version: 0.9.1 +Release: 17%{?dist} +Summary: Installer for Fedora CoreOS and RHEL CoreOS + +# Upstream license specification: Apache-2.0 +License: ASL 2.0 +URL: https://github.com/fedora-iot/coreos-installer +Source: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate +Source1: https://github.com/coreos/coreos-installer/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz + +# The RHEL 8 rust-toolset macros don't let us enable features from the +# %%cargo_* macros. Enable rdcore directly in Cargo.toml. +Patch0: enable-rdcore.patch +# LTO causes runtime crashes on s390x +# https://github.com/coreos/coreos-installer/pull/360 +# https://github.com/coreos/coreos-installer/issues/372 +# https://bugzilla.redhat.com/show_bug.cgi?id=1863466 +Patch1: disable-lto-0.6.0.patch +# Add coreos.force_persist_ip karg forwarding +# https://github.com/coreos/coreos-installer/pull/554 +Patch2: force_persist_ip-0.9.1.patch +# Support s390x DASDs in VMs via virtio +# https://github.com/coreos/coreos-installer/pull/552 +Patch3: s390x-support-virtio-dasd-0.9.1.patch +Patch4: coidracut.patch +Patch5: coidracut2.patch +Patch6: coidracut3.patch +Patch7: coidracut4.patch +Patch8: coidracut5.patch + +ExclusiveArch: %{rust_arches} +BuildRequires: openssl-devel +BuildRequires: rust-toolset +BuildRequires: systemd + +Requires: gnupg +Requires: kpartx +Requires: systemd-udev +Requires: util-linux +%ifarch s390x +# This should eventually be spelled "s390utils-core" but the binaries +# haven't been broken out of s390utils-base yet +Requires: /usr/sbin/chreipl +Requires: /usr/sbin/dasdfmt +Requires: /usr/sbin/fdasd +Requires: /usr/sbin/lszdev +Requires: /usr/sbin/zipl +%endif + +# Since `rust-coreos-installer` creates a `coreos-installer` +# subpackage with a newer version number, which supersedes the +# deprecated `coreos-installer` package (https://src.fedoraproject.org/rpms/coreos-installer), +# an explicit `Obsoletes:` for `coreos-installer` is not necessary. + +# Obsolete dracut modules as they are not provided in this package. +Obsoletes: coreos-installer-dracut < 0.0.1 + +%global _description %{expand: +coreos-installer installs Fedora CoreOS or RHEL CoreOS to bare-metal +machines (or, occasionally, to virtual machines). +} +%description %{_description} + +%files +%license LICENSE +%doc README.md +%{_bindir}/coreos-installer + +%prep +%autosetup -n %{crate}-%{version} -p1 +%cargo_prep -V 1 +# https://github.com/rust-lang-nursery/error-chain/pull/289 +find -name '*.rs' -executable -exec chmod a-x {} \; + +%build +%cargo_build + +%install +%cargo_install +# Install binaries, dracut modules, units, targets, generators for running via systemd +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore dracut/50rdcore/module-setup.sh +install -D -m 0755 -t %{buildroot}%{_libexecdir} scripts/coreos-installer-service +install -D -m 0755 -t %{buildroot}%{_libexecdir} scripts/coreos-installer-disable-device-auto-activation +install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer-disable-device-auto-activation.service +install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer.service +install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer-reboot.service +install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer-noreboot.service +install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer-pre.target +install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer.target +install -D -m 0644 -t %{buildroot}%{_unitdir} systemd/coreos-installer-post.target +install -D -m 0755 -t %{buildroot}%{_systemdgeneratordir} systemd/coreos-installer-generator +mv %{buildroot}%{_bindir}/rdcore %{buildroot}%{dracutlibdir}/modules.d/50rdcore/ +cp -a %{buildroot}%{_bindir}/coreos-installer %{buildroot}%{dracutlibdir}/modules.d/50rdcore/ +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore scripts/coreos-installer-service +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore scripts/growfs +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore scripts/coreos-installer-disable-device-auto-activation +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer-disable-device-auto-activation.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/growfs.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer-reboot.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer-noreboot.service +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer-pre.target +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer.target +install -D -m 0644 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer-post.target +install -D -m 0755 -t %{buildroot}%{dracutlibdir}/modules.d/50rdcore systemd/coreos-installer-generator + +%package -n %{crate}-bootinfra +Summary: %{crate} boot-time infrastructure for use on Fedora/RHEL CoreOS +Requires: %{crate} = %{version}-%{release} + +# Package was renamed from coreos-installer-systemd when rdcore was added +Provides: %{crate}-systemd = %{version}-%{release} +Obsoletes: %{crate}-systemd <= 0.3.0-2 + +%description -n %{crate}-bootinfra +This subpackage contains boot-time infrastructure for Fedora CoreOS and +RHEL CoreOS. It is not needed on other platforms. + +%files -n %{crate}-bootinfra +%{dracutlibdir}/modules.d/* +%{_libexecdir}/* +%{_unitdir}/* +%{_systemdgeneratordir}/* + +%if %{with check} +%check +%cargo_test +%endif + +%changelog +* Thu Jun 10 2021 Benjamin Gilbert - 0.9.1-3 +- Support s390x DASDs in VMs via virtio + +* Tue Jun 08 2021 Dusty Mabe - 0.9.1-2 +- Add coreos.force_persist_ip karg forwarding + +* Wed Apr 21 2021 Benjamin Gilbert - 0.9.0-3 +- Improve error message for busy disk referenced via symlink +- Fix failure on corrupt GPT + +* Fri Apr 9 2021 Sohan Kunkerkar - 0.9.0-2 +- Use macro for dracut library path + +* Thu Apr 8 2021 Sohan Kunkerkar - 0.9.0-1 +- New release + +* Fri Jan 15 2021 Benjamin Gilbert - 0.8.0-3 +- Fix rdcore rootmap on RAID devices + +* Tue Jan 12 2021 Benjamin Gilbert - 0.8.0-2 +- Disable LTO again to avoid crashes on s390x + +* Tue Jan 12 2021 Sohan Kunkerkar - 0.8.0-1 +- New release + +* Mon Jan 04 2021 Benjamin Gilbert - 0.7.2-2 +- Add Requires for programs invoked by coreos-installer +- Require Rust >= 1.45, re-enable LTO + +* Thu Oct 22 2020 Sohan Kunkerkar - 0.7.2-1 +- New release + +* Mon Sep 21 2020 Benjamin Gilbert - 0.6.0-3 +- Fix MBR handling when partition saving is enabled +- Fix base package Obsoletes being interpreted as part of package description + +* Wed Sep 02 2020 Benjamin Gilbert - 0.6.0-2 +- Disable LTO on s390x to avoid runtime crashes +- Drop legacy installer + +* Tue Aug 25 2020 Benjamin Gilbert - 0.6.0-1 +- New release + +* Fri Jul 31 2020 Benjamin Gilbert - 0.5.0-1 +- New release + +* Sat Jul 25 2020 Benjamin Gilbert - 0.4.0-1 +- New release +- Rename -systemd subpackage to -bootinfra +- Add rdcore Dracut module to -bootinfra + +* Wed Jul 22 2020 Benjamin Gilbert - 0.3.0-1 +- New release +- Make coreos-installer-{service,generator} world-readable + +* Wed Jun 17 2020 Dusty Mabe - 0.2.0-4.rhaos4.6 +- Include rhaos4.6 in the rpm release field + +* Thu May 28 2020 Colin Walters - 0.2.0-3 +- Backport osmet RHCOS+LUKS patches + +* Thu May 07 2020 Dusty Mabe - 0.2.0-2 +- Fix bug in dracut hook in legacy installer; see + https://github.com/coreos/coreos-installer/pull/234 + +* Mon Apr 27 2020 Colin Walters - 0.1.3-4 +- Merge in legacy installer; see + https://github.com/coreos/coreos-installer/pull/220 + +* Mon Mar 23 2020 Colin Walters - 0.1.3-2 +- https://github.com/coreos/coreos-installer/releases/tag/v0.1.3 + +* Wed Mar 04 2020 Colin Walters - 0.1.2-11 +- Backport no-signatures-available patch + +* Wed Feb 26 2020 Colin Walters - 0.1.2-10 +- Forked from Fedora +- I forgot about the weird `rust-` package name prefixing when + asking RCM to make the dist-git repo, and rather than redo + that I decided to just go with it. +- Stop depending on systemd-rpm-macros since it's not in RHEL8 apparently +- Drop other things only applicable to Fedora Rust packaging like + dynamic buildrequires