From a6fa245cd6dc030672f8a95808c6c3a0ee51c9a3 Mon Sep 17 00:00:00 2001 From: MSVSphere Packaging Team Date: Mon, 11 Dec 2023 16:22:56 +0300 Subject: [PATCH] import kmod-redhat-ahci-3.0_dup8.8-1.el8_8 --- .gitignore | 1 + .kmod-redhat-ahci.metadata | 1 + ...-for-Dell-S140-and-later-controllers.patch | 52 +++ SOURCES/9000-add-Makefile.patch | 8 + SOURCES/9001-rename-kmod.patch | 22 ++ SOURCES/9002-bump-version.patch | 13 + SOURCES/9003-trim-unused-parts.patch | 237 ++++++++++++ SPECS/kmod-redhat-ahci.spec | 336 ++++++++++++++++++ 8 files changed, 670 insertions(+) create mode 100644 .gitignore create mode 100644 .kmod-redhat-ahci.metadata create mode 100644 SOURCES/0001-ahci-Add-support-for-Dell-S140-and-later-controllers.patch create mode 100644 SOURCES/9000-add-Makefile.patch create mode 100644 SOURCES/9001-rename-kmod.patch create mode 100644 SOURCES/9002-bump-version.patch create mode 100644 SOURCES/9003-trim-unused-parts.patch create mode 100644 SPECS/kmod-redhat-ahci.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..652df62 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/ahci-redhat-3.0_dup8.8.tar.bz2 diff --git a/.kmod-redhat-ahci.metadata b/.kmod-redhat-ahci.metadata new file mode 100644 index 0000000..082af63 --- /dev/null +++ b/.kmod-redhat-ahci.metadata @@ -0,0 +1 @@ +891a9bd9bae79077bb30f8a6beed28b938b9eece SOURCES/ahci-redhat-3.0_dup8.8.tar.bz2 diff --git a/SOURCES/0001-ahci-Add-support-for-Dell-S140-and-later-controllers.patch b/SOURCES/0001-ahci-Add-support-for-Dell-S140-and-later-controllers.patch new file mode 100644 index 0000000..046c2c3 --- /dev/null +++ b/SOURCES/0001-ahci-Add-support-for-Dell-S140-and-later-controllers.patch @@ -0,0 +1,52 @@ +From 00c2a0c89cd08bf4bef96456e0497948e3f98bd3 Mon Sep 17 00:00:00 2001 +From: Tomas Henzl +Date: Wed, 2 Aug 2023 16:52:34 +0200 +Subject: [PATCH] ahci: Add support for Dell S140 and later controllers + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2222879 + +This patch enables support for Dell S140 and later controllers +that use Intel's PCHs configured as PCI_CLASS_STORAGE_RAID. + +Reviewed-by: Mika Westerberg +Signed-off-by: Charles Rose +Link: https://lore.kernel.org/r/20210615190801.1744466-1-charles.rose@dell.com +Signed-off-by: Jens Axboe +(cherry picked from commit 9c54cd10e43947caa64920aaa7a30858193f8ef5) +Signed-off-by: Tomas Henzl +--- + drivers/ata/ahci.c | 4 ++++ + include/linux/pci_ids.h | 2 ++ + 2 files changed, 6 insertions(+) + +diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c +index 55e4295f9d874..9b0faef9f9c6c 100644 +--- a/drivers/ata/ahci.c ++++ b/drivers/ata/ahci.c +@@ -464,6 +464,10 @@ static const struct pci_device_id ahci_pci_tbl[] = { + { PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci }, + ++ /* Dell S140/S150 */ ++ { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_SUBVENDOR_ID_DELL, PCI_ANY_ID, ++ PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci }, ++ + /* VIA */ + { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ + { PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */ +diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h +index 71e7e4409b8dd..0bc83c584dc7a 100644 +--- a/include/linux/pci_ids.h ++++ b/include/linux/pci_ids.h +@@ -631,6 +631,8 @@ + #define PCI_DEVICE_ID_DELL_RAC4 0x0012 + #define PCI_DEVICE_ID_DELL_PERC5 0x0015 + ++#define PCI_SUBVENDOR_ID_DELL 0x1028 ++ + #define PCI_VENDOR_ID_MATROX 0x102B + #define PCI_DEVICE_ID_MATROX_MGA_2 0x0518 + #define PCI_DEVICE_ID_MATROX_MIL 0x0519 +-- +2.13.6 + diff --git a/SOURCES/9000-add-Makefile.patch b/SOURCES/9000-add-Makefile.patch new file mode 100644 index 0000000..b4853ea --- /dev/null +++ b/SOURCES/9000-add-Makefile.patch @@ -0,0 +1,8 @@ +Index: src/drivers/ata/Makefile +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ src/drivers/ata/Makefile 2023-08-05 22:03:52.769089708 +0200 +@@ -0,0 +1,3 @@ ++ahci_dup88-y := ahci.o ++ ++obj-m := ahci_dup88.o diff --git a/SOURCES/9001-rename-kmod.patch b/SOURCES/9001-rename-kmod.patch new file mode 100644 index 0000000..82a93bd --- /dev/null +++ b/SOURCES/9001-rename-kmod.patch @@ -0,0 +1,22 @@ +Index: src/drivers/ata/ahci.c +=================================================================== +--- src.orig/drivers/ata/ahci.c 2023-08-05 22:01:45.253625031 +0200 ++++ src/drivers/ata/ahci.c 2023-08-05 22:16:23.939337170 +0200 +@@ -50,7 +50,7 @@ + #include + #include "ahci.h" + +-#define DRV_NAME "ahci" ++#define DRV_NAME "ahci_dup88" + #define DRV_VERSION "3.0" + + enum { +@@ -116,7 +116,7 @@ + #endif /* CONFIG_PM */ + + static struct scsi_host_template ahci_sht = { +- AHCI_SHT("ahci"), ++ AHCI_SHT(DRV_NAME), + }; + + static struct ata_port_operations ahci_vt8251_ops = { diff --git a/SOURCES/9002-bump-version.patch b/SOURCES/9002-bump-version.patch new file mode 100644 index 0000000..b229706 --- /dev/null +++ b/SOURCES/9002-bump-version.patch @@ -0,0 +1,13 @@ +Index: src/drivers/ata/ahci.c +=================================================================== +--- src.orig/drivers/ata/ahci.c 2023-08-05 22:16:23.939337170 +0200 ++++ src/drivers/ata/ahci.c 2023-08-05 22:17:36.154536550 +0200 +@@ -51,7 +51,7 @@ + #include "ahci.h" + + #define DRV_NAME "ahci_dup88" +-#define DRV_VERSION "3.0" ++#define DRV_VERSION "3.0_dup88" + + enum { + AHCI_PCI_BAR_STA2X11 = 0, diff --git a/SOURCES/9003-trim-unused-parts.patch b/SOURCES/9003-trim-unused-parts.patch new file mode 100644 index 0000000..6fe25ab --- /dev/null +++ b/SOURCES/9003-trim-unused-parts.patch @@ -0,0 +1,237 @@ +Index: src/drivers/ata/ahci.c +=================================================================== +--- src.orig/drivers/ata/ahci.c 2023-08-05 22:17:36.154536550 +0200 ++++ src/drivers/ata/ahci.c 2023-08-05 22:44:46.371682515 +0200 +@@ -64,6 +64,7 @@ + enum board_ids { + /* board IDs by feature in alphabetical order */ + board_ahci, ++#if 0 + board_ahci_ign_iferr, + board_ahci_mobile, + board_ahci_nomsi, +@@ -93,11 +94,13 @@ + board_ahci_mcp67 = board_ahci_mcp65, + board_ahci_mcp73 = board_ahci_mcp65, + board_ahci_mcp79 = board_ahci_mcp77, ++#endif + }; + + static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); + static void ahci_remove_one(struct pci_dev *dev); + static void ahci_shutdown_one(struct pci_dev *dev); ++#if 0 + static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, + unsigned long deadline); + static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class, +@@ -106,6 +109,7 @@ + static bool is_mcp89_apple(struct pci_dev *pdev); + static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, + unsigned long deadline); ++#endif + #ifdef CONFIG_PM + static int ahci_pci_device_runtime_suspend(struct device *dev); + static int ahci_pci_device_runtime_resume(struct device *dev); +@@ -119,6 +123,7 @@ + AHCI_SHT(DRV_NAME), + }; + ++#if 0 + static struct ata_port_operations ahci_vt8251_ops = { + .inherits = &ahci_ops, + .hardreset = ahci_vt8251_hardreset, +@@ -133,6 +138,7 @@ + .inherits = &ahci_ops, + .hardreset = ahci_avn_hardreset, + }; ++#endif + + static const struct ata_port_info ahci_port_info[] = { + /* by features */ +@@ -142,6 +148,7 @@ + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_ops, + }, ++#if 0 + [board_ahci_ign_iferr] = { + AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR), + .flags = AHCI_FLAG_COMMON, +@@ -257,9 +264,11 @@ + .udma_mask = ATA_UDMA6, + .port_ops = &ahci_ops, + }, ++#endif + }; + + static const struct pci_device_id ahci_pci_tbl[] = { ++#if 0 + /* Intel */ + { PCI_VDEVICE(INTEL, 0x06d6), board_ahci }, /* Comet Lake PCH-H RAID */ + { PCI_VDEVICE(INTEL, 0x2652), board_ahci }, /* ICH6 */ +@@ -463,11 +472,13 @@ + /* AMD is using RAID class only for ahci controllers */ + { PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci }, ++#endif + + /* Dell S140/S150 */ + { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_SUBVENDOR_ID_DELL, PCI_ANY_ID, + PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci }, + ++#if 0 + /* VIA */ + { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ + { PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */ +@@ -624,6 +635,7 @@ + /* Generic, PCI class code for AHCI */ + { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci }, ++#endif + + { } /* terminate list */ + }; +@@ -709,6 +721,7 @@ + ahci_init_controller(host); + } + ++#if 0 + static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, + unsigned long deadline) + { +@@ -849,6 +862,7 @@ + DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class); + return rc; + } ++#endif + + + #ifdef CONFIG_PM +@@ -913,9 +927,11 @@ + struct ata_host *host = pci_get_drvdata(pdev); + int rc; + ++#if 0 + /* Apple BIOS helpfully mangles the registers on resume */ + if (is_mcp89_apple(pdev)) + ahci_mcp89_apple_enable(pdev); ++#endif + + if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { + rc = ahci_reset_controller(host); +@@ -973,6 +989,7 @@ + ahci_print_info(host, scc_s); + } + ++#if 0 + /* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is + * hardwired to on-board SIMG 4726. The chipset is ICH8 and doesn't + * support PMP and the 4726 either directly exports the device +@@ -1477,6 +1494,7 @@ + } + } + } ++#endif + + #ifdef CONFIG_ARM64 + /* +@@ -1648,9 +1666,11 @@ + if (!id || id->vendor != PCI_VENDOR_ID_INTEL) + return; + ++#if 0 + /* Skip applying the quirk on Denverton and beyond */ + if (((enum board_ids) id->driver_data) >= board_ahci_pcs7) + return; ++#endif + + /* + * port_map is determined from PORTS_IMPL PCI register which is +@@ -1696,6 +1716,7 @@ + + ata_print_version_once(&pdev->dev, DRV_VERSION); + ++#if 0 + /* The AHCI driver can only drive the SATA ports, the PATA driver + can drive them all so if both drivers are selected make sure + AHCI stays out of the way */ +@@ -1725,12 +1746,14 @@ + if (pdev->device == 0xa084) + ahci_pci_bar = AHCI_PCI_BAR_CAVIUM_GEN5; + } ++#endif + + /* acquire resources */ + rc = pcim_enable_device(pdev); + if (rc) + return rc; + ++#if 0 + if (pdev->vendor == PCI_VENDOR_ID_INTEL && + (pdev->device == 0x2652 || pdev->device == 0x2653)) { + u8 map; +@@ -1746,6 +1769,7 @@ + return -ENODEV; + } + } ++#endif + + /* AHCI controllers often implement SFF compatible interface. + * Grab all PCI BARs just in case. +@@ -1761,6 +1785,7 @@ + return -ENOMEM; + hpriv->flags |= (unsigned long)pi.private_data; + ++#if 0 + /* MCP65 revision A1 and A2 can't do MSI */ + if (board_id == board_ahci_mcp65 && + (pdev->revision == 0xa1 || pdev->revision == 0xa2)) +@@ -1773,6 +1798,7 @@ + /* only some SB600s can do 64bit DMA */ + if (ahci_sb600_enable_64bit(pdev)) + hpriv->flags &= ~AHCI_HFLAG_32BIT_ONLY; ++#endif + + hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar]; + +@@ -1783,9 +1809,11 @@ + &dev_attr_remapped_nvme.attr, + NULL); + ++#if 0 + /* must set flag prior to save config in order to take effect */ + if (ahci_broken_devslp(pdev)) + hpriv->flags |= AHCI_HFLAG_NO_DEVSLP; ++#endif + + #ifdef CONFIG_ARM64 + if (pdev->vendor == 0x177d && pdev->device == 0xa01c) +@@ -1827,6 +1855,7 @@ + + ahci_set_em_messages(hpriv, &pi); + ++#if 0 + if (ahci_broken_system_poweroff(pdev)) { + pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN; + dev_info(&pdev->dev, +@@ -1854,6 +1883,7 @@ + + /* Acer SA5-271 workaround modifies private_data */ + acer_sa5_271_workaround(hpriv, pdev); ++#endif + + /* CAP.NP sometimes indicate the index of the last enabled + * port, at other times, that of the last possible port, so +@@ -1899,11 +1929,13 @@ + ap->ops = &ata_dummy_port_ops; + } + ++#if 0 + /* apply workaround for ASUS P5W DH Deluxe mainboard */ + ahci_p5wdh_workaround(host); + + /* apply gtf filter quirk */ + ahci_gtf_filter_workaround(host); ++#endif + + /* initialize adapter */ + rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); diff --git a/SPECS/kmod-redhat-ahci.spec b/SPECS/kmod-redhat-ahci.spec new file mode 100644 index 0000000..5ae6127 --- /dev/null +++ b/SPECS/kmod-redhat-ahci.spec @@ -0,0 +1,336 @@ +%define kmod_name ahci +%define kmod_vendor redhat +%define kmod_rpm_name kmod-redhat-ahci +%define kmod_driver_version 3.0_dup8.8 +%define kmod_driver_epoch %{nil} +%define kmod_rpm_release 1 +%define kmod_kernel_version 4.18.0-477.10.1.el8_8 +%define kmod_kernel_version_min 4.18.0-477 +%define kmod_kernel_version_dep 4.18.0-477.el8 +%define kmod_kbuild_dir drivers/ata +%define kmod_dependencies %{nil} +%define kmod_dist_build_deps %{nil} +%define kmod_build_dependencies %{nil} +%define kmod_provides %{nil} +%define kmod_devel_package 1 +%define kmod_devel_src_paths include/linux/pci_ids.h +%define kmod_install_path extra/kmod-redhat-ahci +%define kmod_files_package 0 +%define kmod_files_noarch 1 +%define kernel_pkg kernel +%define kernel_devel_pkg kernel-devel +%define kernel_modules_pkg kernel-modules + +%{!?dist: %define dist .el8_8} +%{!?make_build: %define make_build make} + +%if "%{kmod_kernel_version_dep}" == "" +%define kmod_kernel_version_dep %{kmod_kernel_version} +%endif + +%if "%{kmod_dist_build_deps}" == "" +%if (0%{?rhel} > 8) || (0%{?centos} > 8) +%define abi_list stablelist +%define kmod_dist_build_deps redhat-rpm-config kernel-abi-stablelists elfutils-libelf-devel kernel-rpm-macros kmod +%else +%if (0%{?rhel} > 7) || (0%{?centos} > 7) +%define abi_list whitelist +%define kmod_dist_build_deps redhat-rpm-config kernel-abi-whitelists elfutils-libelf-devel kernel-rpm-macros kmod +%else +%define abi_list whitelist +%define kmod_dist_build_deps redhat-rpm-config kernel-abi-whitelists +%endif +%endif +%endif + +Source0: %{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}.tar.bz2 +# Source code patches +Patch0: 0001-ahci-Add-support-for-Dell-S140-and-later-controllers.patch +Patch1: 9000-add-Makefile.patch +Patch2: 9001-rename-kmod.patch +Patch3: 9002-bump-version.patch +Patch4: 9003-trim-unused-parts.patch + +%define findpat %( echo "%""P" ) +%define __find_requires /usr/lib/rpm/redhat/find-requires.ksyms +%define __find_provides /usr/lib/rpm/redhat/find-provides.ksyms %{kmod_name} %{?epoch:%{epoch}:}%{version}-%{release} +%define sbindir %( if [ -d "/sbin" -a \! -h "/sbin" ]; then echo "/sbin"; else echo %{_sbindir}; fi ) +%define dup_state_dir %{_localstatedir}/lib/rpm-state/kmod-dups +%define kver_state_dir %{dup_state_dir}/kver +%define kver_state_file %{kver_state_dir}/%{kmod_kernel_version}.%(arch) +%define dup_module_list %{dup_state_dir}/rpm-kmod-%{kmod_name}-modules + +Name: kmod-redhat-ahci +Version: %{kmod_driver_version} +Release: %{kmod_rpm_release}%{?dist} +%if "%{kmod_driver_epoch}" != "" +Epoch: %{kmod_driver_epoch} +%endif +Summary: ahci kernel module for Driver Update Program +Group: System/Kernel +License: GPLv2 +URL: https://www.kernel.org/ +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +BuildRequires: %kernel_devel_pkg = %kmod_kernel_version +%if "%{kmod_dist_build_deps}" != "" +BuildRequires: %{kmod_dist_build_deps} +%endif +ExclusiveArch: x86_64 +%global kernel_source() /usr/src/kernels/%{kmod_kernel_version}.$(arch) + +%global _use_internal_dependency_generator 0 +%if "%{?kmod_kernel_version_min}" != "" +Provides: %kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu} +%else +Provides: %kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu} +%endif +Provides: kmod-%{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires(post): %{sbindir}/weak-modules +Requires(postun): %{sbindir}/weak-modules +Requires: kernel >= 4.18.0-477 +%if 0 +Requires: firmware(%{kmod_name}) = ENTER_FIRMWARE_VERSION +%endif +%if "%{kmod_build_dependencies}" != "" +BuildRequires: %{kmod_build_dependencies} +%endif +%if "%{kmod_dependencies}" != "" +Requires: %{kmod_dependencies} +%endif +%if "%{kmod_provides}" != "" +Provides: %{kmod_provides} +%endif +# if there are multiple kmods for the same driver from different vendors, +# they should conflict with each other. +Conflicts: kmod-%{kmod_name} + +%description +ahci kernel module for Driver Update Program + +%if 0 + +%package -n kmod-redhat-ahci-firmware +Version: ENTER_FIRMWARE_VERSION +Summary: ahci firmware for Driver Update Program +Provides: firmware(%{kmod_name}) = ENTER_FIRMWARE_VERSION +%if "%{kmod_kernel_version_min}" != "" +Provides: %kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu} +%else +Provides: %kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu} +%endif +%description -n kmod-redhat-ahci-firmware +ahci firmware for Driver Update Program + + +%files -n kmod-redhat-ahci-firmware +%defattr(644,root,root,755) +%{FIRMWARE_FILES} + +%endif + +# Development package +%if 0%{kmod_devel_package} +%package -n kmod-redhat-ahci-devel +Version: %{kmod_driver_version} +Summary: ahci development files for Driver Update Program + +%description -n kmod-redhat-ahci-devel +ahci development files for Driver Update Program + + +%files -n kmod-redhat-ahci-devel +%defattr(644,root,root,755) +/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/ +%endif + +# Extra files package +%if 0%{kmod_files_package} +%package -n kmod-redhat-ahci-files +Version: %{kmod_driver_version} +Summary: ahci additional files for Driver Update Program +%if 0%{kmod_files_noarch} +BuildArch: noarch +%endif +%if "%{?kmod_kernel_version_min}" != "" +Provides: %kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu} +%else +Provides: %kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu} +%endif + +%description -n kmod-redhat-ahci-files +ahci additional files for Driver Update Program + + +%files -n kmod-redhat-ahci-files +%defattr(644,root,root,755) + + +%endif + +%post +modules=( $(find /lib/modules/%{kmod_kernel_version}.%(arch)/%{kmod_install_path} | grep '\.ko$') ) +printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --add-modules --no-initramfs + +mkdir -p "%{kver_state_dir}" +touch "%{kver_state_file}" + +exit 0 + +%posttrans +# We have to re-implement part of weak-modules here because it doesn't allow +# calling initramfs regeneration separately +if [ -f "%{kver_state_file}" ]; then + kver_base="%{kmod_kernel_version_dep}" + kvers=$(ls -d "/lib/modules/${kver_base%%.*}"*) + + for k_dir in $kvers; do + k="${k_dir#/lib/modules/}" + + tmp_initramfs="/boot/initramfs-$k.tmp" + dst_initramfs="/boot/initramfs-$k.img" + + # The same check as in weak-modules: we assume that the kernel present + # if the symvers file exists. + if [ -e "/boot/symvers-$k.gz" ] || [ -e "$k_dir/symvers.gz" ]; then + /usr/bin/dracut -f "$tmp_initramfs" "$k" || exit 1 + cmp -s "$tmp_initramfs" "$dst_initramfs" + if [ "$?" = 1 ]; then + mv "$tmp_initramfs" "$dst_initramfs" + else + rm -f "$tmp_initramfs" + fi + fi + done + + rm -f "%{kver_state_file}" + rmdir "%{kver_state_dir}" 2> /dev/null +fi + +rmdir "%{dup_state_dir}" 2> /dev/null + +exit 0 + +%preun +if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then + mkdir -p "%{kver_state_dir}" + touch "%{kver_state_file}" +fi + +mkdir -p "%{dup_state_dir}" +rpm -ql kmod-redhat-ahci-%{kmod_driver_version}-%{kmod_rpm_release}%{?dist}.$(arch) | \ + grep '\.ko$' > "%{dup_module_list}" + +%postun +if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then + initramfs_opt="--no-initramfs" +else + initramfs_opt="" +fi + +modules=( $(cat "%{dup_module_list}") ) +rm -f "%{dup_module_list}" +printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --remove-modules $initramfs_opt + +rmdir "%{dup_state_dir}" 2> /dev/null + +exit 0 + +%files +%defattr(644,root,root,755) +/lib/modules/%{kmod_kernel_version}.%(arch) +/etc/depmod.d/%{kmod_name}.conf +%doc /usr/share/doc/%{kmod_rpm_name}/greylist.txt +%if !0%{kmod_files_package} + + +%endif + +%prep +%setup -n %{kmod_name}-%{kmod_vendor}-%{kmod_driver_version} + +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +set -- * +mkdir source +mv "$@" source/ +mkdir obj + +%build +rm -rf obj +cp -r source obj + +PWD_PATH="$PWD" +%if "%{workaround_no_pwd_rel_path}" != "1" +PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD") +%endif +%{make_build} -C %{kernel_source} V=1 M="$PWD_PATH/obj/%{kmod_kbuild_dir}" \ + NOSTDINC_FLAGS="-I$PWD_PATH/obj/include -I$PWD_PATH/obj/include/uapi %{nil}" \ + EXTRA_CFLAGS="%{nil}" \ + %{nil} +# mark modules executable so that strip-to-file can strip them +find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -exec chmod u+x '{}' + + +kabilist="/lib/modules/kabi-current/kabi_%{abi_list}_%{_target_cpu}" +for modules in $( find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -printf "%{findpat}\n" | sed 's|\.ko$||' | sort -u ) ; do + # update depmod.conf + module_weak_path=$(echo "$modules" | sed 's/[\/]*[^\/]*$//') + if [ -z "$module_weak_path" ]; then + module_weak_path=%{name} + else + module_weak_path=%{name}/$module_weak_path + fi + echo "override $(echo $modules | sed 's/.*\///')" \ + "$(echo "%{kmod_kernel_version_dep}" | + sed 's/\.[^\.]*$//; + s/\([.+?^$\/\\|()\[]\|\]\)/\\\0/g').*" \ + "weak-updates/$module_weak_path" >> source/depmod.conf + + # update greylist + nm -u obj/%{kmod_kbuild_dir}/$modules.ko | sed 's/.*U //' | sed 's/^\.//' | sort -u | while read -r symbol; do + grep -q "^\s*$symbol\$" $kabilist || echo "$symbol" >> source/greylist + done +done +sort -u source/greylist | uniq > source/greylist.txt + +%install +export INSTALL_MOD_PATH=$RPM_BUILD_ROOT +export INSTALL_MOD_DIR=%{kmod_install_path} +PWD_PATH="$PWD" +%if "%{workaround_no_pwd_rel_path}" != "1" +PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD") +%endif +make -C %{kernel_source} modules_install \ + M=$PWD_PATH/obj/%{kmod_kbuild_dir} +# Cleanup unnecessary kernel-generated module dependency files. +find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \; + +install -m 644 -D source/depmod.conf $RPM_BUILD_ROOT/etc/depmod.d/%{kmod_name}.conf +install -m 644 -D source/greylist.txt $RPM_BUILD_ROOT/usr/share/doc/%{kmod_rpm_name}/greylist.txt +%if 0 +%{FIRMWARE_FILES_INSTALL} +%endif +%if 0%{kmod_devel_package} +install -m 644 -D $PWD/obj/%{kmod_kbuild_dir}/Module.symvers $RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/Module.symvers + +if [ -n "%{kmod_devel_src_paths}" ]; then + for i in %{kmod_devel_src_paths}; do + mkdir -p "$RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/$(dirname "$i")" + cp -rv "$PWD/source/$i" \ + "$RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/$i" + done +fi +%endif + + + +%clean +rm -rf $RPM_BUILD_ROOT + +%changelog +* Tue Sep 12 2023 Eugene Syromiatnikov 3.0_dup8.8-1 +- 4011c4649205bce50b42d290bba04f0504d928c2 +- ahci kernel module for Driver Update Program +- Resolves: #bz2233801