From 36ba909e9cfebb413a85a38930da7c75cda78c19 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Apr 06 2023 08:45:32 +0000 Subject: Define kernel-vanilla as source variant The vanilla_only macro is overloaded. It is used for determining if there should be two kernel sources built as well as for the purpose of determmioning if vanilla kernel should be used for kernel-obs-build. While the former can be determined at build time the latter needs to be baked into the spec file template. Separate the two while also making the latter more generic. $build_dtbs is enabled on every single rt and azure branch since 15.3 when the setting was introduced, gate on the new $obs_build_variant setting as well. Signed-off-by: Michal Suchanek --- diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in index 0c7d83c..45104ff 100644 --- a/rpm/kernel-binary.spec.in +++ b/rpm/kernel-binary.spec.in @@ -20,7 +20,6 @@ %define srcversion @SRCVERSION@ %define patchversion @PATCHVERSION@ %define variant @VARIANT@%{nil} -%define vanilla_only @VANILLA_ONLY@ %define compress_modules @COMPRESS_MODULES@ %define compress_vmlinux @COMPRESS_VMLINUX@ %define livepatch @LIVEPATCH@%{nil} @@ -31,6 +30,7 @@ %define build_flavor @FLAVOR@ %define build_default ("%build_flavor" == "default") %define build_vanilla ("%build_flavor" == "vanilla") +%define vanilla_only %{lua: if (rpm.expand("%variant") == "-vanilla") then print(1) else print(0) end} %if ! %build_vanilla %define src_install_dir /usr/src/linux-%kernelrelease%variant @@ -391,7 +391,7 @@ awk '{ cd linux-%srcversion %_sourcedir/apply-patches \ -%if %{build_vanilla} +%if %{build_vanilla} && ! %vanilla_only --vanilla \ %endif %_sourcedir/series.conf .. $SYMBOLS @@ -1325,7 +1325,7 @@ Summary: Development files necessary for building kernel modules Group: Development/Sources Provides: %name-devel = %version-%source_rel Provides: multiversion(kernel) -%if ! %build_vanilla +%if ! %build_vanilla && ! %vanilla_only Requires: kernel-devel%variant = %version-%source_rel Recommends: make Recommends: gcc diff --git a/rpm/kernel-obs-build.spec.in b/rpm/kernel-obs-build.spec.in index 7c00206..10c8859 100644 --- a/rpm/kernel-obs-build.spec.in +++ b/rpm/kernel-obs-build.spec.in @@ -21,7 +21,6 @@ %define patchversion @PATCHVERSION@ %define variant @VARIANT@%{nil} -%define vanilla_only @VANILLA_ONLY@ %include %_sourcedir/kernel-spec-macros @@ -31,8 +30,8 @@ BuildRequires: device-mapper BuildRequires: util-linux %if 0%{?suse_version} -%if %vanilla_only -%define kernel_flavor -vanilla +%if "@OBS_BUILD_VARIANT@" +%define kernel_flavor @OBS_BUILD_VARIANT@ %else %ifarch %ix86 %define kernel_flavor -pae diff --git a/rpm/kernel-source.spec.in b/rpm/kernel-source.spec.in index 0754cb7..0f74e3d 100644 --- a/rpm/kernel-source.spec.in +++ b/rpm/kernel-source.spec.in @@ -19,7 +19,6 @@ %define srcversion @SRCVERSION@ %define patchversion @PATCHVERSION@ %define variant @VARIANT@%{nil} -%define vanilla_only @VANILLA_ONLY@ %include %_sourcedir/kernel-spec-macros @@ -231,11 +230,7 @@ sed -ie 's,/lib/modules/,%{kernel_module_directory}/,' linux-%kernelrelease%vari %endif %if %do_vanilla -%if %vanilla_only - mv \ -%else cp -al \ -%endif linux-%kernelrelease%variant linux-%kernelrelease-vanilla cd linux-%kernelrelease-vanilla %_sourcedir/apply-patches --vanilla %_sourcedir/series.conf %my_builddir %symbols @@ -245,7 +240,6 @@ rm -f $(find . -name ".gitignore") cd .. %endif -%if ! %vanilla_only cd linux-%kernelrelease%variant %_sourcedir/apply-patches %_sourcedir/series.conf %my_builddir %symbols rm -f $(find . -name ".gitignore") @@ -256,10 +250,8 @@ fi # Hardlink duplicate files automatically (from package fdupes). %fdupes $PWD cd .. -%endif popd -%if ! %vanilla_only # Install the documentation and example Kernel Module Package. DOC=/usr/share/doc/packages/%name-%kernelrelease mkdir -p %buildroot/$DOC @@ -286,7 +278,6 @@ perl "%_sourcedir/group-source-files.pl" \ -D "$OLDPWD/devel.files" -N "$OLDPWD/nondevel.files" \ -L "%src_install_dir" popd -%endif find %{buildroot}/usr/src/linux* -type f -name '*.[ch]' -perm /0111 -exec chmod -v a-x {} + # OBS checks don't like /usr/bin/env in script interpreter lines @@ -301,7 +292,6 @@ done ts="$(head -n1 %_sourcedir/source-timestamp)" find %buildroot/usr/src/linux* ! -type l | xargs touch -d "$ts" -%if ! %vanilla_only %post %relink_function @@ -329,7 +319,6 @@ relink linux-%kernelrelease%variant /usr/src/linux%variant /usr/lib/rpm/kernel/* %endif -%endif %if %do_vanilla diff --git a/rpm/mkspec b/rpm/mkspec index c415073..0e21c34 100755 --- a/rpm/mkspec +++ b/rpm/mkspec @@ -35,8 +35,9 @@ my @kmps = read_kmps(); # config.sh variables my %vars = parse_config_sh(); -my ($srcversion, $variant, $vanilla_only) = - ($vars{'SRCVERSION'}, $vars{'VARIANT'}, $vars{'VANILLA_ONLY'}); +my ($srcversion, $variant, $obs_build_variant) = + ($vars{'SRCVERSION'}, $vars{'VARIANT'}, $vars{'OBS_BUILD_VARIANT'}); +$obs_build_variant = ($obs_build_variant ? $variant : "" ); my $compress_modules = 'none'; my $compress_vmlinux = 'gz'; my $build_dtbs = (); @@ -60,7 +61,6 @@ if (defined($vars{'LIVEPATCH_RT'})) { $livepatch_rt = $vars{'LIVEPATCH_RT'}; $livepatch_rt = "" if $livepatch_rt =~ /^(0+|no|none)$/i; } -$vanilla_only ||= "0"; if (!defined ($rpmrelease)) { $rpmrelease = $vars{'RELEASE'} || 0; } @@ -114,7 +114,7 @@ my $commit_full = get_commit(1); my %macros = ( VARIANT => $variant, - VANILLA_ONLY => $vanilla_only, + OBS_BUILD_VARIANT => $obs_build_variant . "%{nil}", SRCVERSION => $srcversion, PATCHVERSION => $patchversion, RPMVERSION => $rpmversion, @@ -216,14 +216,16 @@ if ($variant eq "") { } # kernel-obs-*.spec -if (!$variant) { +if (!$variant || $obs_build_variant) { my @default_archs; - - if ($vanilla_only) { - @default_archs = arch2rpm(@{$flavor_archs{vanilla}}); + my $flavor = $obs_build_variant; + if ($flavor) { + $flavor =~ s/^-//; } else { - @default_archs = arch2rpm(@{$flavor_archs{default}}); + $flavor = 'default'; } + + @default_archs = arch2rpm(@{$flavor_archs{$flavor}}); # No kernel-obs-* for 32bit ppc and x86 @default_archs = grep { $_ ne "ppc" && $_ ne '%ix86' } @default_archs; my $default_archs = join(" ", @default_archs); @@ -234,7 +236,7 @@ if (!$variant) { } # dtb-*.spec -if (!$variant && $build_dtbs) { +if ((!$variant || $obs_build_variant) && $build_dtbs) { do_spec('dtb', "dtb.spec.in", %macros); print "./mkspec-dtb $all_archs\n"; system("./mkspec-dtb $all_archs\n");