Blob Blame History Raw
%global pkg exfat

%global driver_version 4.18.0-0.el8

%global kernel_version 4.18.0-348.el8

%global _use_internal_dependency_generator 0
%global __find_requires /usr/lib/rpm/redhat/find-requires
%global __find_provides /usr/lib/rpm/redhat/find-provides

%global debug_package %{nil}

%global __spec_install_post \
  %{?__debug_package:%{__debug_install_post}} \
  %{__arch_install_post} \
  %{__os_install_post} \
  %{__mod_compress_install_post}

%global __mod_compress_install_post find %{buildroot}/lib/modules -type f -name \*.ko -exec xz \{\} \\;


Name:             kmod-%{pkg}
Version:          4.18.0.0
Release:          3%{?dist}
Summary:          exFAT filesystem support

License:          GPLv2 and GPLv2+
URL:              https://www.kernel.org/

Source0:          %{pkg}-%{driver_version}.tar.xz
Patch1:           0001-exfat-add-in-memory-and-on-disk-structures-and-heade.patch
Patch2:           0002-exfat-add-super-block-operations.patch
Patch3:           0003-exfat-add-inode-operations.patch
Patch4:           0004-exfat-add-directory-operations.patch
Patch5:           0005-exfat-add-file-operations.patch
Patch6:           0006-exfat-add-fat-entry-operations.patch
Patch7:           0007-exfat-add-bitmap-operations.patch
Patch8:           0008-exfat-add-exfat-cache.patch
Patch9:           0009-exfat-add-misc-operations.patch
Patch10:          0010-exfat-add-nls-operations.patch
Patch11:          0011-exfat-add-Kconfig-and-Makefile.patch
Patch12:          0012-exfat-update-file-system-parameter-handling.patch
Patch13:          0013-exfat-Fix-discard-support.patch
Patch14:          0014-exfat-add-missing-MODULE_ALIAS_FS.patch
Patch15:          0015-exfat-Unify-access-to-the-boot-sector.patch
Patch16:          0016-exfat-remove-bps-mount-option.patch
Patch17:          0017-exfat-properly-set-s_time_gran.patch
Patch18:          0018-exfat-truncate-atimes-to-2s-granularity.patch
Patch19:          0019-exfat-use-iter_file_splice_write.patch
Patch20:          0020-exfat-fix-possible-memory-leak-in-exfat_find.patch
Patch21:          0021-exfat-add-the-dummy-mount-options-to-be-backward-com.patch
#Patch22:          0022-fs-convert-mpage_readpages-to-mpage_readahead.patch
Patch23:          0023-exfat-Simplify-exfat_utf8_d_cmp-for-code-points-abov.patch
Patch24:          0024-exfat-Use-a-more-common-logging-style.patch
Patch25:          0025-exfat-Simplify-exfat_utf8_d_hash-for-code-points-abo.patch
Patch26:          0026-exfat-Remove-unused-functions-exfat_high_surrogate-a.patch
Patch27:          0027-exfat-remove-the-assignment-of-0-to-bool-variable.patch
Patch28:          0028-exfat-replace-time_ms-with-time_cs.patch
Patch29:          0029-exfat-optimize-dir-cache.patch
Patch30:          0030-exfat-redefine-PBR-as-boot_sector.patch
Patch31:          0031-exfat-separate-the-boot-sector-analysis.patch
Patch32:          0032-exfat-add-boot-region-verification.patch
Patch33:          0033-exfat-standardize-checksum-calculation.patch
Patch34:          0034-exfat-remove-unnecessary-reassignment-of-p_uniname-n.patch
Patch35:          0035-exfat-fix-memory-leak-in-exfat_parse_param.patch
Patch36:          0036-exfat-fix-incorrect-update-of-stream-entry-in-__exfa.patch
Patch37:          0037-exfat-fix-range-validation-error-in-alloc-and-free-c.patch
Patch38:          0038-exfat-Fix-potential-use-after-free-in-exfat_load_upc.patch
Patch39:          0039-exfat-Set-the-unused-characters-of-FileName-field-to.patch
Patch40:          0040-exfat-add-missing-brelse-calls-on-error-paths.patch
Patch41:          0041-exfat-call-sync_filesystem-for-read-only-remount.patch
Patch42:          0042-exfat-move-setting-VOL_DIRTY-over-exfat_remove_entri.patch
Patch43:          0043-exfat-flush-dirty-metadata-in-fsync.patch
Patch44:          0044-exfat-fix-overflow-issue-in-exfat_cluster_to_sector.patch
Patch45:          0045-exfat-fix-wrong-hint_stat-initialization-in-exfat_fi.patch
Patch46:          0046-exfat-fix-wrong-size-update-of-stream-entry-by-typo.patch
Patch47:          0047-exfat-fix-name_hash-computation-on-big-endian-system.patch
Patch48:          0048-exfat-remove-EXFAT_SB_DIRTY-flag.patch
Patch49:          0049-exfat-write-multiple-sectors-at-once.patch
Patch50:          0050-exfat-add-error-check-when-updating-dir-entries.patch
Patch51:          0051-exfat-optimize-exfat_zeroed_cluster.patch
Patch52:          0052-exfat-retain-VolumeFlags-properly.patch
Patch53:          0053-exfat-fix-pointer-error-checking.patch
Patch54:          0054-exfat-fix-use-of-uninitialized-spinlock-on-error-pat.patch
Patch55:          0055-exfat-fix-misspellings-using-codespell-tool.patch
Patch56:          0056-exfat-use-i_blocksize-to-get-blocksize.patch
Patch57:          0057-exfat-eliminate-dead-code-in-exfat_find.patch
Patch58:          0058-exfat-remove-useless-directory-scan-in-exfat_add_ent.patch
Patch59:          0059-exfat-replace-memcpy-with-structure-assignment.patch
Patch60:          0060-exfat-remove-rwoffset-in-exfat_inode_info.patch
Patch61:          0061-exfat-remove-useless-check-in-exfat_move_file.patch
#Patch62:          0062-PATCH-reduce-boilerplate-in-fsid-handling.patch
Patch63:          0063-exfat-Avoid-allocating-upcase-table-using-kcalloc.patch
#Patch64:          0064-block-use-an-on-stack-bio-in-blkdev_issue_flush.patch
Patch65:          0065-exfat-fix-shift-out-of-bounds-in-exfat_fill_super.patch
Patch66:          0066-exfat-improve-performance-of-exfat_free_cluster-when.patch
#Patch67:          0067-attr-handle-idmapped-mounts.patch
#Patch68:          0068-stat-handle-idmapped-mounts.patch
#Patch69:          0069-fs-make-helpers-idmap-mount-aware.patch
Patch70:          0070-exfat-fix-erroneous-discard-when-clear-cluster-bit.patch
Patch71:          0071-exfat-introduce-bitmap_lock-for-cluster-bitmap-acces.patch
Patch72:          0072-exfat-add-support-ioctl-and-FITRIM-function.patch
Patch73:          0073-exfat-improve-write-performance-when-dirsync-enabled.patch
Patch74:          0074-exfat-speed-up-iterate-lookup-by-fixing-start-point-.patch
Patch75:          0075-mm-require-set_page_dirty-to-be-explicitly-wired-up.patch
Patch76:          0076-exfat-avoid-incorrectly-releasing-for-root-inode.patch
Patch77:          0077-exfat-handle-wrong-stream-entry-size-in-exfat_readdi.patch
Patch78:          0078-exfat-fix-incorrect-loading-of-i_blocks-for-large-fi.patch
Patch9001:        9001-Compat-for-missing-inode-method-free_inode.patch
Patch9999:        9999-enable-exfat.patch

ExclusiveArch:    x86_64 aarch64 ppc64le

BuildRequires:    elfutils-libelf-devel
BuildRequires:    gcc
BuildRequires:    kernel-rpm-macros
BuildRequires:    kmod
BuildRequires:    make
BuildRequires:    redhat-rpm-config
BuildRequires:    xz

BuildRequires:    kernel-abi-stablelists = %{kernel_version}
BuildRequires:    kernel-devel = %{kernel_version}
BuildRequires:    kernel-devel-uname-r = %{kernel_version}.%{_arch}

Requires:         kernel >= %{kernel_version}
Requires:         kernel-uname-r >= %{kernel_version}.%{_arch}
Requires:         kernel-modules >= %{kernel_version}
Requires:         kernel-modules-uname-r >= %{kernel_version}.%{_arch}

Provides:         installonlypkg(kernel-module)
Provides:         kernel-modules >= %{kernel_version}.%{_arch}

Requires(post):   %{_sbindir}/depmod
Requires(postun): %{_sbindir}/depmod

Requires(post):   %{_sbindir}/weak-modules
Requires(postun): %{_sbindir}/weak-modules

Supplements:      exfatprogs
Recommends:       exfatprogs


%if "%{version}" == "4.18.0.0" && "%{release}" == "2%{?dist}"
Obsoletes:        kmod-%{pkg} = %{?epoch:%{epoch}:}%{version}-1%{?dist}
%endif

%if "%{version}" == "4.18.0.0" && "%{release}" == "3%{?dist}"
Obsoletes:        kmod-%{pkg} = %{?epoch:%{epoch}:}%{version}-1%{?dist}
Obsoletes:        kmod-%{pkg} = %{?epoch:%{epoch}:}%{version}-2%{?dist}
%endif


%description
This package provides the required kernel module (exfat) to mount devices
formatted with the exFAT file system.


%prep
%autosetup -p1 -n %{pkg}-%{driver_version}


%build
pushd src
%{__make} -C /usr/src/kernels/%{kernel_version}.%{_arch} %{?_smp_mflags} M=$PWD modules
popd


%install
%{__install} -D -t %{buildroot}/lib/modules/%{kernel_version}.%{_arch}/extra/fs/%{pkg} src/%{pkg}.ko

# Make .ko objects temporarily executable for automatic stripping
find %{buildroot}/lib/modules -type f -name \*.ko -exec chmod u+x \{\} \+


%clean
%{__rm} -rf %{buildroot}


%post
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
printf '%s\n' "/lib/modules/%{kernel_version}.%{_arch}/extra/fs/%{pkg}/%{pkg}.ko.xz" >> %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add


%preun
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
rpm -ql kmod-%{pkg}-%{?epoch:%{epoch}:}%{version}-%{release}.%{_arch} | grep '/lib/modules/%{kernel_version}.%{_arch}/.*\.ko\.xz$' >> %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove


%postun
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove ]
then
    modules=( $(cat %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove) )
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
    printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --remove-modules
fi


%pretrans -p <lua>
posix.unlink("%{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add")
posix.unlink("%{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove")


%posttrans
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add ]
then
    modules=( $(cat %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add) )
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
    printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --add-modules
fi


%files
%defattr(644,root,root,755)
/lib/modules/%{kernel_version}.%{_arch}
%license LICENSES


%changelog
* Thu Jan 27 2022 Peter Georg <peter.georg@physik.uni-regensburg.de> - 4.18.0.0-3
- Add obsoletes for update path

* Sat Jan 22 2022 Peter Georg <peter.georg@physik.uni-regensburg.de> - 4.18.0.0-2
- Enable ppc64le

* Thu Jan 13 2022 Kmods SIG <sig-kmods@centosproject.org> - 4.18.0.0-1
- Switch to EL kernel source and versioning
- kABI tracking kmod package (kernel >= 4.18.0-348.el8)