File kernel-subpackage-spec of Package kernel-source

%define rpm_kver %(rpm -q --qf '%%{VERSION}' %kernel_package_name)
%define rpm_krel %(rpm -q --qf '%%{RELEASE}' %kernel_package_name)

# Force bzip2 instead of lzma compression to
# 1) allow install on older dist versions, and
# 2) decrease build times (bsc#962356)
# %%define _binary_payload w9.bzdio
# Do not recompute the build-id of vmlinux in find-debuginfo.sh (bsc#964063)
%undefine _unique_build_ids
%define _no_recompute_build_ids 1
# prevent usr/lib/debug/boot/vmlinux-4.12.14-11.10-default-4.12.14-11.10.ppc64le.debug
%undefine _unique_debug_names

%define kernel_requires        %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'manual,' | sed -e 's/.*,//' | tr '\\n' ' ')
%define kernel_requires_pre    %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'pre,' | sed -e 's/.*,//' | tr '\\n' ' ')
%define kernel_requires_preun  %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'preun,' | sed -e 's/.*,//' | tr '\\n' ' ')
%define kernel_requires_post   %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'post,' | sed -e 's/.*,//' | tr '\\n' ' ')
%define kernel_requires_postun %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'postun,' | sed -e 's/.*,//' | tr '\\n' ' ')

%if ! %(expr 1 - 1)
%if "%{kernel_requires}" != ""
Requires:       %kernel_requires
%endif
%if "%{kernel_requires_pre}" != ""
Requires(pre):  %kernel_requires_pre
%endif
%if "%{kernel_requires_preun}" != ""
Requires(preun):%kernel_requires_preun
%endif
%if "%{kernel_requires_post}" != ""
Requires(post): %kernel_requires_post
%endif
%if "%{kernel_requires_postun}" != ""
Requires(postun):%kernel_requires_postun
%endif
%endif
Provides:       %(rpm -q --queryformat '[%%{PROVIDENEVRS}\n]' %kernel_package_name | sed -E 's/^%kernel_package_name(-srchash| =)/%name\1/g' | grep -vE '^(ksym|kmod|firmware)[(]' | tr '\n' ' )')
Obsoletes:      %(rpm -q --queryformat '[%%{OBSOLETENEVRS}\n]' %kernel_package_name | sed -E 's/^%kernel_package_name(-srchash| =)/%name\1/g' | grep -vE '^(ksym|kmod|firmware)[(]' | tr '\n' ' )')
Conflicts:      %(rpm -q --queryformat '[%%{CONFLICTNEVRS}\n]' %kernel_package_name | grep -vE '^(ksym|kmod|firmware)[(]' | tr '\n' ' )')
Recommends:     %(rpm -q --queryformat '[%%{RECOMMENDNEVRS}\n]' %kernel_package_name | grep -vE '^(ksym|kmod|firmware)[(]' | tr '\n' ' )')
# This is in place of obsolete_rebuilds. This should give Conflicts: %%kernel_package_name = %%source_rel as old kernel-default-base did.
Conflicts:      %(rpm -q --queryformat '[%%{PROVIDENEVRS}\n]' %kernel_package_name | grep '^%kernel_package_name =' | sort -V | head -n 1)

%description
%(rpm -q --qf '%%{DESCRIPTION}' %kernel_package_name)
%extradescription

This is a subpackage of %kernel_package_name. Development files are in
%kernel_package_name-devel, sources in kernel-source%variant, and
debug information in %kernel_package_name-debuginfo.

%package rebuild
Summary: Empty package to ensure rebuilding %name in OBS
Group: Other
Requires: %kernel_package_name = %rpm_kver-%rpm_krel

%description rebuild
This is empty package that ensures %name is rebuilt every time
%kernel_package_name is rebuilt in OBS.

There is no reason to install this package.

%files rebuild

%prep

%build

%install

echo "%{?modules}" | tr ', ' '\n\n' > request-modules
%scriptdir/kernel-subpackage-build %kernel_package_name %rpm_kver-%rpm_krel %package_name-%version-%release

%preun -f preun.sh

%postun -f postun.sh

%pre -f prein.sh

%post -f postin.sh

%files -f subpackage.flist

%changelog