From 19b3586d08c749c063f5ecc6a612a9f30b7e3aee Mon Sep 17 00:00:00 2001
From: Colleen Murphy <colleen.murphy@suse.com>
Date: Tue, 26 May 2020 13:46:01 -0700
Subject: [PATCH] Pre-install xz package in opensuse chroot

As of recently, opensuse-minimal images fail to build because of an
error installing the kernel-default package:

> Problem: kernel-default-5.6.12-1.3.x86_64 requires mkinitrd >= 2.7.1, but this requirement cannot be provided
>   not installable providers: dracut-050+suse.61.g0fe0e854-1.1.i586[repo-oss]
>                    dracut-050+suse.61.g0fe0e854-1.1.x86_64[repo-oss]

The problem is there is a recently added package `busybox-links` which
provides a subpackage `busybox-xz` which provides the /usr/bin/xz
utility. Since this is available, the `aaa_base` package installs it
during the root.d base installation phase to fulfill it's dependency on
/usr/bin/xz. On the other hand, the dracut package explicitly requires
the `xz` package, and this is not co-installable with the `busybox-xz`
package, so the dracut package is not installable during the install.d
phase. This change explicitly adds the `xz` package to the initial
chroot provisioning phase so that the /usr/bin/xz requirement is already
fulfilled and `busybox-xz` does not get installed.

Change-Id: Iba8c301eb496657873963e1aa99736aacf87cb00
---
 .../elements/zypper-minimal/root.d/08-zypper-chroot            | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot b/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot
index c5fc48fc5..e3ba94198 100755
--- a/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot
+++ b/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot
@@ -100,6 +100,9 @@ sudo mount -t sysfs none $TARGET_ROOT/sys
 
 # Install filesystem, base and useful tools
 sudo zypper ${ZYPPER_TARGET_OPTS} install --no-recommends filesystem
+# Install xz before base to avoid pulling in busybox-xz
+# https://bugzilla.opensuse.org/show_bug.cgi?id=1172209
+sudo zypper ${ZYPPER_TARGET_OPTS} install --no-recommends xz
 # Install basic components in order
 sudo zypper ${ZYPPER_TARGET_OPTS} install \
     ${DIB_OPENSUSE_PATTERNS} ${ZYPPER_INSTALL_SYSTEM_PYTHON} \