Harald Hoyer fe68ba
From 0bb9a683d4df27427a0ab1d247b6dbb8343d820e Mon Sep 17 00:00:00 2001
Harald Hoyer fe68ba
From: Lukas Nykryn <lnykryn@redhat.com>
Harald Hoyer fe68ba
Date: Thu, 15 Mar 2018 16:57:47 +0100
Harald Hoyer fe68ba
Subject: [PATCH] spec: drop support for legacy distributions
Harald Hoyer fe68ba
Harald Hoyer fe68ba
rhel <= 7 has its own branch and there is no point in supporting the old
Harald Hoyer fe68ba
fedora
Harald Hoyer fe68ba
---
Harald Hoyer fe68ba
 51-dracut-rescue-postinst.sh | 68 ---------------------------------------
Harald Hoyer fe68ba
 dracut.spec                  | 75 +++++++-------------------------------------
Harald Hoyer fe68ba
 2 files changed, 12 insertions(+), 131 deletions(-)
Harald Hoyer fe68ba
Harald Hoyer fe68ba
diff --git a/51-dracut-rescue-postinst.sh b/51-dracut-rescue-postinst.sh
Harald Hoyer fe68ba
deleted file mode 100755
Harald Hoyer fe68ba
index 67f5b717..00000000
Harald Hoyer fe68ba
--- a/51-dracut-rescue-postinst.sh
Harald Hoyer fe68ba
+++ /dev/null
Harald Hoyer fe68ba
@@ -1,68 +0,0 @@
Harald Hoyer fe68ba
-#!/bin/bash
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-export LANG=C
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-KERNEL_VERSION="$1"
Harald Hoyer fe68ba
-KERNEL_IMAGE="$2"
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-[[ -f /etc/os-release ]] && . /etc/os-release
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
Harald Hoyer fe68ba
-    systemd-machine-id-setup
Harald Hoyer fe68ba
-fi
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-[[ $MACHINE_ID ]] || exit 1
Harald Hoyer fe68ba
-[[ -f $KERNEL_IMAGE ]] || exit 1
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
Harald Hoyer fe68ba
-NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-dropindirs_sort()
Harald Hoyer fe68ba
-{
Harald Hoyer fe68ba
-    suffix=$1; shift
Harald Hoyer fe68ba
-    args=("$@")
Harald Hoyer fe68ba
-    files=$(
Harald Hoyer fe68ba
-        while (( $# > 0 )); do
Harald Hoyer fe68ba
-            for i in ${1}/*${suffix}; do
Harald Hoyer fe68ba
-                [[ -f $i ]] && echo ${i##*/}
Harald Hoyer fe68ba
-            done
Harald Hoyer fe68ba
-            shift
Harald Hoyer fe68ba
-        done | sort -Vu
Harald Hoyer fe68ba
-    )
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-    for f in $files; do
Harald Hoyer fe68ba
-        for d in "${args[@]}"; do
Harald Hoyer fe68ba
-            if [[ -f "$d/$f" ]]; then
Harald Hoyer fe68ba
-                echo "$d/$f"
Harald Hoyer fe68ba
-                continue 2
Harald Hoyer fe68ba
-            fi
Harald Hoyer fe68ba
-        done
Harald Hoyer fe68ba
-    done
Harald Hoyer fe68ba
-}
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-# source our config dir
Harald Hoyer fe68ba
-for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
Harald Hoyer fe68ba
-    [[ -e $f ]] && . "$f"
Harald Hoyer fe68ba
-done
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-[[ $dracut_rescue_image != "yes" ]] && exit 0
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-if [[ ! -f $INITRDFILE ]]; then
Harald Hoyer fe68ba
-    dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
Harald Hoyer fe68ba
-    ((ret+=$?))
Harald Hoyer fe68ba
-fi
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
Harald Hoyer fe68ba
-    cp --reflink=auto "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
Harald Hoyer fe68ba
-    ((ret+=$?))
Harald Hoyer fe68ba
-fi
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-((ret+=$?))
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-exit $ret
Harald Hoyer fe68ba
diff --git a/dracut.spec b/dracut.spec
Harald Hoyer fe68ba
index 725f89d6..9c2fc9d4 100644
Harald Hoyer fe68ba
--- a/dracut.spec
Harald Hoyer fe68ba
+++ b/dracut.spec
Harald Hoyer fe68ba
@@ -5,15 +5,6 @@
Harald Hoyer fe68ba
 # strip the automatically generated dep here and instead co-own the
Harald Hoyer fe68ba
 # directory.
Harald Hoyer fe68ba
 %global __requires_exclude pkg-config
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-# Variables must be defined
Harald Hoyer fe68ba
-%define with_nbd                1
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-# nbd in Fedora only
Harald Hoyer fe68ba
-%if 0%{?rhel} >= 6
Harald Hoyer fe68ba
-%define with_nbd 0
Harald Hoyer fe68ba
-%endif
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
 %define dist_free_release xxx
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
 Name: dracut
Harald Hoyer fe68ba
@@ -46,6 +37,7 @@ BuildRequires: gcc
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
 %if 0%{?fedora} || 0%{?rhel}
Harald Hoyer fe68ba
 BuildRequires: pkgconfig
Harald Hoyer fe68ba
+BuildRequires: systemd
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 %if 0%{?fedora}
Harald Hoyer fe68ba
 BuildRequires: bash-completion
Harald Hoyer fe68ba
@@ -63,31 +55,11 @@ BuildRequires: docbook-style-xsl docbook-dtds libxslt
Harald Hoyer fe68ba
 BuildRequires: asciidoc
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-%if 0%{?fedora} > 12 || 0%{?rhel}
Harald Hoyer fe68ba
-# no "provides", because dracut does not offer
Harald Hoyer fe68ba
-# all functionality of the obsoleted packages
Harald Hoyer fe68ba
-Obsoletes: mkinitrd < 6.0.94
Harald Hoyer fe68ba
-Obsoletes: mkinitrd-devel < 6.0.94
Harald Hoyer fe68ba
-Obsoletes: nash < 6.0.94
Harald Hoyer fe68ba
-Obsoletes: libbdevid-python < 6.0.94
Harald Hoyer fe68ba
-%endif
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-%if 0%{?fedora} > 16 || 0%{?rhel} > 6
Harald Hoyer fe68ba
-BuildRequires: systemd-units
Harald Hoyer fe68ba
-%endif
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
 %if 0%{?suse_version} > 9999
Harald Hoyer fe68ba
 Obsoletes: mkinitrd < 2.6.1
Harald Hoyer fe68ba
 Provides: mkinitrd = 2.6.1
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-Obsoletes: dracut-kernel < 005
Harald Hoyer fe68ba
-Provides:  dracut-kernel = %{version}-%{release}
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-Obsoletes: dracut < 030
Harald Hoyer fe68ba
-Obsoletes: dracut-norescue < 030
Harald Hoyer fe68ba
-Provides:  dracut-norescue = %{version}-%{release}
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
 Requires: bash >= 4
Harald Hoyer fe68ba
 Requires: coreutils
Harald Hoyer fe68ba
 Requires: cpio
Harald Hoyer fe68ba
@@ -99,33 +71,23 @@ Requires: sed
Harald Hoyer fe68ba
 Requires: xz
Harald Hoyer fe68ba
 Requires: gzip
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-%if 0%{?fedora} > 22 || 0%{?rhel} > 7
Harald Hoyer fe68ba
+%if 0%{?fedora} || 0%{?rhel}
Harald Hoyer fe68ba
 Recommends: grubby
Harald Hoyer fe68ba
 Recommends: hardlink
Harald Hoyer fe68ba
 Recommends: pigz
Harald Hoyer fe68ba
 Recommends: kpartx
Harald Hoyer fe68ba
-%else
Harald Hoyer fe68ba
-Requires: hardlink
Harald Hoyer fe68ba
-Requires: gzip
Harald Hoyer fe68ba
-Requires: kpartx
Harald Hoyer fe68ba
-%endif
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
-%if 0%{?fedora} || 0%{?rhel} > 6
Harald Hoyer fe68ba
 Requires: util-linux >= 2.21
Harald Hoyer fe68ba
 Requires: systemd >= 219
Harald Hoyer fe68ba
 Requires: systemd-udev >= 219
Harald Hoyer fe68ba
 Requires: procps-ng
Harald Hoyer fe68ba
-Conflicts: grubby < 8.23
Harald Hoyer fe68ba
-Conflicts: initscripts < 8.63-1
Harald Hoyer fe68ba
-Conflicts: plymouth < 0.8.0-0.2009.29.09.19.1
Harald Hoyer fe68ba
-Conflicts: bcache-tools < 0-0.14.20130909git
Harald Hoyer fe68ba
 %else
Harald Hoyer fe68ba
+Requires: hardlink
Harald Hoyer fe68ba
+Requires: gzip
Harald Hoyer fe68ba
+Requires: kpartx
Harald Hoyer fe68ba
 Requires: udev > 166
Harald Hoyer fe68ba
 Requires: util-linux-ng >= 2.21
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-Conflicts: mdadm < 3.2.6-14
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
 %description
Harald Hoyer fe68ba
 dracut contains tools to create bootable initramfses for the Linux
Harald Hoyer fe68ba
 kernel. Unlike previous implementations, dracut hard-codes as little
Harald Hoyer fe68ba
@@ -155,17 +117,12 @@ Provides:  dracut-generic = %{version}-%{release}
Harald Hoyer fe68ba
 This package requires everything which is needed to build a generic
Harald Hoyer fe68ba
 all purpose initramfs with network support with dracut.
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-%if 0%{?fedora} || 0%{?rhel} >= 6 || 0%{?suse_version}
Harald Hoyer fe68ba
+%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
Harald Hoyer fe68ba
 %package fips
Harald Hoyer fe68ba
 Summary: dracut modules to build a dracut initramfs with an integrity check
Harald Hoyer fe68ba
 Requires: %{name} = %{version}-%{release}
Harald Hoyer fe68ba
 Requires: hmaccalc
Harald Hoyer fe68ba
-%if 0%{?rhel} > 5
Harald Hoyer fe68ba
-# For Alpha 3, we want nss instead of nss-softokn
Harald Hoyer fe68ba
 Requires: nss
Harald Hoyer fe68ba
-%else
Harald Hoyer fe68ba
-Requires: nss-softokn
Harald Hoyer fe68ba
-%endif
Harald Hoyer fe68ba
 Requires: nss-softokn-freebl
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
 %description fips
Harald Hoyer fe68ba
@@ -250,9 +207,6 @@ cp %{SOURCE1} .
Harald Hoyer fe68ba
 make %{?_smp_mflags}
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
 %install
Harald Hoyer fe68ba
-%if 0%{?fedora} || 0%{?rhel}
Harald Hoyer fe68ba
-rm -rf -- $RPM_BUILD_ROOT
Harald Hoyer fe68ba
-%endif
Harald Hoyer fe68ba
 make %{?_smp_mflags} install \
Harald Hoyer fe68ba
      DESTDIR=$RPM_BUILD_ROOT \
Harald Hoyer fe68ba
      libdir=%{_prefix}/lib
Harald Hoyer fe68ba
@@ -314,16 +268,12 @@ install -m 0644 dracut.conf.d/suse.conf.example   $RPM_BUILD_ROOT%{dracutlibdir}
Harald Hoyer fe68ba
 install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/40-fips.conf
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-%if 0%{?fedora} <= 12 && 0%{?rhel} < 6 && 0%{?suse_version} <= 9999
Harald Hoyer fe68ba
+%if 0%{?fedora} == 0 && 0%{?rhel} == 0 && 0%{?suse_version} <= 9999
Harald Hoyer fe68ba
 rm -f -- $RPM_BUILD_ROOT%{_bindir}/mkinitrd
Harald Hoyer fe68ba
 rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-%if 0%{?fedora} || 0%{?rhel} > 6
Harald Hoyer fe68ba
-# FIXME: remove after F19
Harald Hoyer fe68ba
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
Harald Hoyer fe68ba
-install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
Harald Hoyer fe68ba
-
Harald Hoyer fe68ba
+%if 0%{?fedora} || 0%{?rhel}
Harald Hoyer fe68ba
 echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
Harald Hoyer fe68ba
 echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
@@ -342,7 +292,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
Harald Hoyer fe68ba
 %{_bindir}/dracut
Harald Hoyer fe68ba
 %{_datadir}/bash-completion/completions/dracut
Harald Hoyer fe68ba
 %{_datadir}/bash-completion/completions/lsinitrd
Harald Hoyer fe68ba
-%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
Harald Hoyer fe68ba
+%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version} > 9999
Harald Hoyer fe68ba
 %{_bindir}/mkinitrd
Harald Hoyer fe68ba
 %{_bindir}/lsinitrd
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
@@ -368,7 +318,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
Harald Hoyer fe68ba
 %if %{with doc}
Harald Hoyer fe68ba
 %{_mandir}/man8/dracut.8*
Harald Hoyer fe68ba
 %{_mandir}/man8/*service.8*
Harald Hoyer fe68ba
-%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
Harald Hoyer fe68ba
+%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version} > 9999
Harald Hoyer fe68ba
 %{_mandir}/man8/mkinitrd.8*
Harald Hoyer fe68ba
 %{_mandir}/man1/lsinitrd.1*
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
@@ -462,7 +412,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
Harald Hoyer fe68ba
 %{_unitdir}/initrd.target.wants/dracut-pre-udev.service
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
-%if 0%{?fedora} || 0%{?rhel} > 6
Harald Hoyer fe68ba
+%if 0%{?fedora} || 0%{?rhel}
Harald Hoyer fe68ba
 %{_prefix}/lib/kernel/install.d/50-dracut.install
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
@@ -527,9 +477,8 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
Harald Hoyer fe68ba
 %files config-rescue
Harald Hoyer fe68ba
 %defattr(-,root,root,0755)
Harald Hoyer fe68ba
 %{dracutlibdir}/dracut.conf.d/02-rescue.conf
Harald Hoyer fe68ba
-%if 0%{?fedora} || 0%{?rhel} > 6
Harald Hoyer fe68ba
+%if 0%{?fedora} || 0%{?rhel}
Harald Hoyer fe68ba
 %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
Harald Hoyer fe68ba
-%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
Harald Hoyer fe68ba
 %endif
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
 %changelog
Harald Hoyer fe68ba