[OS-BUILD PATCHv3] redhat/kernel.spec.template: Add log_msg macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Prarit Bhargava <prarit@xxxxxxxxxx>

redhat/kernel.spec.template: Add log_msg macro

After last week's debugging session I was reminded why I hate debugging
the kernel.spec.  It's not that it's long, or that the code is difficult
to understand -- it's that it can be difficult to map precisely where the
fault in the spec file is.  This isn't due to poor design and is due to
the size of the kernel.spec and how rpmbuild creates bash scripts.

In the %prep and %build we often end up with an error that looks like

cc1: error: unrecognized command-line option '-mbranch-protection=standard'
cc1: error: unrecognized command-line option '-mbranch-protection=standard'
error: Bad exit status from /var/tmp/rpm-tmp.W1qm1T (%build)

In this example, the /var/tmp/rpm-tmp.W1qm1T script is created by
rpmbuild, and represents the %build stage of the spec file.  It is left to
the user to decipher the script and map that into the kernel.spec file to
find the exact command(s) that failed; sometimes that is easy to do, and
other times it is the most infuriating thing ever.  It's made me question
my choices in life and sent me into an existential crisis from which I'm
likely never to recover.

This changeset adds a log_msg macro. The hope is that this will be much
more useful than digging through the resulting prep, build, and install
scripts and trying to map the result to the spec file.

Add log_msg() to the %prep and %build stages, and prepopulate
the spec file with some log_msg's to indicate progress.

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>

diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index blahblah..blahblah 100644
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -1711,11 +1711,20 @@ Prebuilt 64k unified kernel image for virtual machines.
 %kernel_ipaclones_package
 %endif
 
+%define log_msg() set +x \
+	_log_msglineno=$(grep -n %{*} %{_specdir}/${RPM_PACKAGE_NAME}.spec | grep log_msg | cut -d":" -f1) \
+	echo "kernel.spec:${_log_msglineno}: %{*}" \
+	set -x
+
 %prep
+%{log_msg "Start of prep stage"}
+
+%{log_msg "Sanity checks"}
+
 # do a few sanity-checks for --with *only builds
 %if %{with_baseonly}
 %if !%{with_up}
-echo "Cannot build --with baseonly, up build is disabled"
+%{log_msg "Cannot build --with baseonly, up build is disabled"}
 exit 1
 %endif
 %endif
@@ -1724,7 +1733,7 @@ exit 1
 if [ "%{patches}" != "%%{patches}" ] ; then
   for patch in %{patches} ; do
     if [ ! -f $patch ] ; then
-      echo "ERROR: Patch  ${patch##/*/}  listed in specfile but is missing"
+	%{log_msg "ERROR: Patch  ${patch##/*/}  listed in specfile but is missing"}
       exit 1
     fi
   done
@@ -1740,7 +1749,7 @@ ApplyPatch()
   fi
   if ! grep -E "^Patch[0-9]+: $patch\$" %{_specdir}/${RPM_PACKAGE_NAME}.spec ; then
     if [ "${patch:0:8}" != "patch-%{kversion}." ] ; then
-      echo "ERROR: Patch  $patch  not listed as a source patch in specfile"
+	%{log_msg "ERROR: Patch  $patch  not listed as a source patch in specfile"}
       exit 1
     fi
   fi 2>/dev/null
@@ -1757,6 +1766,7 @@ ApplyOptionalPatch()
 {
   local patch=$1
   shift
+  %{log_msg "ApplyOptionalPatch: $1"}
   if [ ! -f $RPM_SOURCE_DIR/$patch ]; then
     exit 1
   fi
@@ -1766,12 +1776,14 @@ ApplyOptionalPatch()
   fi
 }
 
+%{log_msg "Untar kernel tarball"}
 %setup -q -n kernel-%{tarfile_release} -c
 mv linux-%{tarfile_release} linux-%{KVERREL}
 
 cd linux-%{KVERREL}
 cp -a %{SOURCE1} .
 
+%{log_msg "Start of patch applications"}
 %if !%{nopatches}
 
 ApplyOptionalPatch patch-%{patchversion}-redhat.patch
@@ -1779,10 +1791,11 @@ ApplyOptionalPatch patch-%{patchversion}-redhat.patch
 
 ApplyOptionalPatch linux-kernel-test.patch
 
+%{log_msg "End of patch applications"}
 # END OF PATCH APPLICATIONS
 
 # Any further pre-build tree manipulations happen here.
-
+%{log_msg "Pre-build tree manipulations"}
 chmod +x scripts/checkpatch.pl
 mv COPYING COPYING-%{specrpmversion}-%{release}
 
@@ -1797,7 +1810,7 @@ rm -f localversion-next
 # This fixes errors such as
 # *** ERROR: ambiguous python shebang in /usr/bin/kvm_stat: #!/usr/bin/python. Change it to python3 (or python2) explicitly.
 # We patch all sources below for which we got a report/error.
-echo "Fixing Python shebangs..."
+%{log_msg "Fixing Python shebangs..."}
 %py3_shebang_fix \
 	tools/kvm/kvm_stat/kvm_stat \
 	scripts/show_delta \
@@ -1817,6 +1830,7 @@ fi
 mkdir configs
 cd configs
 
+%{log_msg "Copy additional source files into buildroot"}
 # Drop some necessary files from the source dir into the buildroot
 cp $RPM_SOURCE_DIR/%{name}-*.config .
 cp %{SOURCE80} .
@@ -1828,6 +1842,7 @@ cp %{SOURCE3001} partial-kernel-local-debug-snip.config
 FLAVOR=%{primary_target} SPECPACKAGE_NAME=%{name} SPECVERSION=%{specversion} SPECRPMVERSION=%{specrpmversion} ./generate_all_configs.sh %{debugbuildsenabled}
 
 # Collect custom defined config options
+%{log_msg "Collect custom defined config options"}
 PARTIAL_CONFIGS=""
 %if %{with_gcov}
 PARTIAL_CONFIGS="$PARTIAL_CONFIGS %{SOURCE70} %{SOURCE71}"
@@ -1853,6 +1868,7 @@ GetArch()
 }
 
 # Merge in any user-provided local config option changes
+%{log_msg "Merge in any user-provided local config option changes"}
 %ifnarch %nobuildarches
 for i in %{all_configs}
 do
@@ -1877,6 +1893,7 @@ done
 
 # Add DUP and kpatch certificates to system trusted keys for RHEL
 %if 0%{?rhel}
+%{log_msg "Add DUP and kpatch certificates to system trusted keys for RHEL"}
 %if %{signkernel}%{signmodules}
 openssl x509 -inform der -in %{SOURCE100} -out rheldup3.pem
 openssl x509 -inform der -in %{SOURCE101} -out rhelkpatch1.pem
@@ -1894,11 +1911,13 @@ done
 
 # Adjust FIPS module name for RHEL
 %if 0%{?rhel}
+%{log_msg "Adjust FIPS module name for RHEL"}
 for i in *.config; do
   sed -i 's/CONFIG_CRYPTO_FIPS_NAME=.*/CONFIG_CRYPTO_FIPS_NAME="Red Hat Enterprise Linux %{rhel} - Kernel Cryptographic API"/' $i
 done
 %endif
 
+%{log_msg "Set process_configs.sh $OPTS"}
 cp %{SOURCE81} .
 OPTS=""
 %if %{with_configchecks}
@@ -1909,6 +1928,7 @@ for opt in %{clang_make_opts}; do
   OPTS="$OPTS -m $opt"
 done
 %endif
+%{log_msg "Generate redhat configs"}
 RHJOBS=$RPM_BUILD_NCPUS SPECPACKAGE_NAME=%{name} ./process_configs.sh $OPTS %{specrpmversion}
 
 # We may want to override files from the primary target in case of building
@@ -1923,20 +1943,21 @@ update_scripts() {
 	done
 }
 
+%{log_msg "Set scripts/SOURCES targets"}
 update_target=%{primary_target}
 if [ "%{primary_target}" == "rhel" ]; then
 : # no-op to avoid empty if-fi error
 %if 0%{?centos}
   update_scripts $update_target
-  echo "Updating scripts/sources to centos version"
+  %{log_msg "Updating scripts/sources to centos version"}
   update_target=centos
 %endif
 fi
 update_scripts $update_target
 
-# end of kernel config
 %endif
 
+%{log_msg "End of kernel config"}
 cd ..
 # # End of Configs stuff
 
@@ -1952,7 +1973,9 @@ cd ..
 ### build
 ###
 %build
+%{log_msg "Start of build stage"}
 
+%{log_msg "General arch build configuration"}
 rm -rf %{buildroot_unstripped} || true
 mkdir -p %{buildroot_unstripped}
 
@@ -1976,6 +1999,9 @@ cp_vmlinux()
 %define make %{__make} %{?cross_opts} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}"
 
 InitBuildVars() {
+    %{log_msg "InitBuildVars for $1"}
+
+    %{log_msg "InitBuildVars: Initialize build variables"}
     # Initialize the kernel .config file and create some variables that are
     # needed for the actual build process.
 
@@ -1987,6 +2013,7 @@ InitBuildVars() {
 
     KernelVer=%{specversion}-%{release}.%{_target_cpu}${Variant:++${Variant}}
 
+    %{log_msg "InitBuildVars: Update Makefile"}
     # make sure EXTRAVERSION says what we want it to say
     # Trim the release if this is a CI build, since KERNELVERSION is limited to 64 characters
     ShortRel=$(perl -e "print \"%{release}\" =~ s/\.pr\.[0-9A-Fa-f]{32}//r")
@@ -1996,6 +2023,7 @@ InitBuildVars() {
     # if we are post rc1 this should match anyway so this won't matter
     perl -p -i -e 's/^PATCHLEVEL.*/PATCHLEVEL = %{patchlevel}/' Makefile
 
+    %{log_msg "InitBuildVars: Copy files"}
     %{make} %{?_smp_mflags} mrproper
     cp configs/$Config .config
 
@@ -2004,23 +2032,26 @@ InitBuildVars() {
     %endif
 
     Arch=`head -1 .config | cut -b 3-`
-    echo USING ARCH=$Arch
+    %{log_msg "InitBuildVars: USING ARCH=$Arch"}
 
     KCFLAGS="%{?kcflags}"
 
     # add kpatch flags for base kernel
+    %{log_msg "InitBuildVars: Configure KCFLAGS"}
     if [ "$Variant" == "" ]; then
         KCFLAGS="$KCFLAGS %{?kpatch_kcflags}"
     fi
 }
 
 BuildKernel() {
+    %{log_msg "BuildKernel for $4"}
     MakeTarget=$1
     KernelImage=$2
     DoVDSO=$3
     Variant=$4
     InstallName=${5:-vmlinuz}
 
+    %{log_msg "Setup variables"}
     DoModules=1
     if [ "$Variant" = "zfcpdump" ]; then
 	    DoModules=0
@@ -2035,22 +2066,25 @@ BuildKernel() {
     fi
 
 %if %{with_gcov}
+    %{log_msg "Setup build directories"}
     # Make build directory unique for each variant, so that gcno symlinks
     # are also unique for each variant.
     if [ -n "$Variant" ]; then
         ln -s $(pwd) ../linux-%{KVERREL}-${Variant}
     fi
-    echo "GCOV - continuing build in: $(pwd)"
+    %{log_msg "GCOV - continuing build in: $(pwd)"}
     pushd ../linux-%{KVERREL}${Variant:+-${Variant}}
     pwd > ../kernel${Variant:+-${Variant}}-gcov.list
 %endif
 
+    %{log_msg "Calling InitBuildVars for $Variant"}
     InitBuildVars $Variant
 
-    echo BUILDING A KERNEL FOR ${Variant} %{_target_cpu}...
+    %{log_msg "BUILDING A KERNEL FOR ${Variant} %{_target_cpu}..."}
 
     %{make} ARCH=$Arch olddefconfig >/dev/null
 
+    %{log_msg "Setup build-ids"}
     # This ensures build-ids are unique to allow parallel debuginfo
     perl -p -i -e "s/^CONFIG_BUILD_SALT.*/CONFIG_BUILD_SALT=\"%{KVERREL}\"/" .config
     %{make} ARCH=$Arch KCFLAGS="$KCFLAGS" WITH_GCOV="%{?with_gcov}" %{?_smp_mflags} $MakeTarget %{?sparse_mflags} %{?kernel_mflags}
@@ -2058,6 +2092,7 @@ BuildKernel() {
 	%{make} ARCH=$Arch KCFLAGS="$KCFLAGS" WITH_GCOV="%{?with_gcov}" %{?_smp_mflags} modules %{?sparse_mflags} || exit 1
     fi
 
+    %{log_msg "Setup RPM_BUILD_ROOT directories"}
     mkdir -p $RPM_BUILD_ROOT/%{image_install_path}
     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer
     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/systemtap
@@ -2066,32 +2101,38 @@ BuildKernel() {
 %endif
 
 %ifarch aarch64
+    %{log_msg "Build dtb kernel"}
     %{make} ARCH=$Arch dtbs INSTALL_DTBS_PATH=$RPM_BUILD_ROOT/%{image_install_path}/dtb-$KernelVer
     %{make} ARCH=$Arch dtbs_install INSTALL_DTBS_PATH=$RPM_BUILD_ROOT/%{image_install_path}/dtb-$KernelVer
     cp -r $RPM_BUILD_ROOT/%{image_install_path}/dtb-$KernelVer $RPM_BUILD_ROOT/lib/modules/$KernelVer/dtb
     find arch/$Arch/boot/dts -name '*.dtb' -type f -delete
 %endif
 
+    %{log_msg "Cleanup temp btf files"}
     # Remove large intermediate files we no longer need to save space
     # (-f required for zfcpdump builds that do not enable BTF)
     rm -f vmlinux.o .tmp_vmlinux.btf
 
+    %{log_msg "Install files to RPM_BUILD_ROOT"}
     # Start installing the results
     install -m 644 .config $RPM_BUILD_ROOT/boot/config-$KernelVer
     install -m 644 .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/config
     install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-$KernelVer
     install -m 644 System.map $RPM_BUILD_ROOT/lib/modules/$KernelVer/System.map
 
+    %{log_msg "Create initrfamfs"}
     # We estimate the size of the initramfs because rpm needs to take this size
     # into consideration when performing disk space calculations. (See bz #530778)
     dd if=/dev/zero of=$RPM_BUILD_ROOT/boot/initramfs-$KernelVer.img bs=1M count=20
 
     if [ -f arch/$Arch/boot/zImage.stub ]; then
+      %{log_msg "Copy zImage.stub to RPM_BUILD_ROOT"}
       cp arch/$Arch/boot/zImage.stub $RPM_BUILD_ROOT/%{image_install_path}/zImage.stub-$KernelVer || :
       cp arch/$Arch/boot/zImage.stub $RPM_BUILD_ROOT/lib/modules/$KernelVer/zImage.stub-$KernelVer || :
     fi
 
     %if %{signkernel}
+    %{log_msg "Copy kernel for signing"}
     if [ "$KernelImage" = vmlinux ]; then
         # We can't strip and sign $KernelImage in place, because
         # we need to preserve original vmlinux for debuginfo.
@@ -2104,6 +2145,7 @@ BuildKernel() {
     SignImage=$KernelImage
 
     %ifarch x86_64 aarch64
+    %{log_msg "Sign kernel image"}
     %pesign -s -i $SignImage -o vmlinuz.tmp -a %{secureboot_ca_0} -c %{secureboot_key_0} -n %{pesign_name_0}
     %pesign -s -i vmlinuz.tmp -o vmlinuz.signed -a %{secureboot_ca_1} -c %{secureboot_key_1} -n %{pesign_name_1}
     rm vmlinuz.tmp
@@ -2120,31 +2162,35 @@ BuildKernel() {
     %endif
 
     if [ ! -s vmlinuz.signed ]; then
-        echo "pesigning failed"
+	%{log_msg "pesigning failed"}
         exit 1
     fi
     mv vmlinuz.signed $SignImage
     # signkernel
     %endif
 
+    %{log_msg "copy signed kernel"}
     $CopyKernel $KernelImage \
                 $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer
     chmod 755 $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer
     cp $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer $RPM_BUILD_ROOT/lib/modules/$KernelVer/$InstallName
 
     # hmac sign the kernel for FIPS
-    echo "Creating hmac file: $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac"
+    %{log_msg "hmac sign the kernel for FIPS"}
+    %{log_msg "Creating hmac file: $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac"}
     ls -l $RPM_BUILD_ROOT/%{image_install_path}/$InstallName-$KernelVer
     (cd $RPM_BUILD_ROOT/%{image_install_path} && sha512hmac $InstallName-$KernelVer) > $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac;
     cp $RPM_BUILD_ROOT/%{image_install_path}/.vmlinuz-$KernelVer.hmac $RPM_BUILD_ROOT/lib/modules/$KernelVer/.vmlinuz.hmac
 
     if [ $DoModules -eq 1 ]; then
+	%{log_msg "Install modules in RPM_BUILD_ROOT"}
 	# Override $(mod-fw) because we don't want it to install any firmware
 	# we'll get it from the linux-firmware package and we don't want conflicts
 	%{make} %{?_smp_mflags} ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT %{?_smp_mflags} modules_install KERNELRELEASE=$KernelVer mod-fw=
     fi
 
 %if %{with_gcov}
+    %{log_msg "install gcov-needed files to $BUILDROOT/$BUILD/"}
     # install gcov-needed files to $BUILDROOT/$BUILD/...:
     #   gcov_info->filename is absolute path
     #   gcno references to sources can use absolute paths (e.g. in out-of-tree builds)
@@ -2152,6 +2198,7 @@ BuildKernel() {
     find . \( -name '*.gcno' -o -name '*.[chS]' \) -exec install -D '{}' "$RPM_BUILD_ROOT/$(pwd)/{}" \;
 %endif
 
+    %{log_msg "Add VDSO files"}
     # add an a noop %%defattr statement 'cause rpm doesn't like empty file list files
     echo '%%defattr(-,-,-)' > ../kernel${Variant:+-${Variant}}-ldsoconf.list
     if [ $DoVDSO -ne 0 ]; then
@@ -2165,6 +2212,7 @@ BuildKernel() {
         rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/vdso/.build-id
     fi
 
+    %{log_msg "Save headers/makefiles, etc. for kernel-headers"}
     # And save the headers/makefiles etc for building modules against
     #
     # This all looks scary, but the end result is supposed to be:
@@ -2199,12 +2247,12 @@ BuildKernel() {
     # NOTENOTE: script which dynamically adds exported kernel symbol
     # NOTENOTE: checksums to the rpm metadata provides list.
     # NOTENOTE: if you change the symvers name, update the backend too
-    echo "**** GENERATING kernel ABI metadata ****"
+    %{log_msg "GENERATING kernel ABI metadata"}
     %compression --stdout %compression_flags < Module.symvers > $RPM_BUILD_ROOT/boot/symvers-$KernelVer.%compext
     cp $RPM_BUILD_ROOT/boot/symvers-$KernelVer.%compext $RPM_BUILD_ROOT/lib/modules/$KernelVer/symvers.%compext
 
 %if %{with_kabichk}
-    echo "**** kABI checking is enabled in kernel SPEC file. ****"
+    %{log_msg "kABI checking is enabled in kernel SPEC file."}
     chmod 0755 $RPM_SOURCE_DIR/check-kabi
     if [ -e $RPM_SOURCE_DIR/Module.kabi_%{_target_cpu}$Variant ]; then
         cp $RPM_SOURCE_DIR/Module.kabi_%{_target_cpu}$Variant $RPM_BUILD_ROOT/Module.kabi
@@ -2212,19 +2260,19 @@ BuildKernel() {
         # for now, don't keep it around.
         rm $RPM_BUILD_ROOT/Module.kabi
     else
-        echo "**** NOTE: Cannot find reference Module.kabi file. ****"
+	%{log_msg "NOTE: Cannot find reference Module.kabi file."}
     fi
 %endif
 
 %if %{with_kabidupchk}
-    echo "**** kABI DUP checking is enabled in kernel SPEC file. ****"
+    %{log_msg "kABI DUP checking is enabled in kernel SPEC file."}
     if [ -e $RPM_SOURCE_DIR/Module.kabi_dup_%{_target_cpu}$Variant ]; then
         cp $RPM_SOURCE_DIR/Module.kabi_dup_%{_target_cpu}$Variant $RPM_BUILD_ROOT/Module.kabi
         $RPM_SOURCE_DIR/check-kabi -k $RPM_BUILD_ROOT/Module.kabi -s Module.symvers || exit 1
         # for now, don't keep it around.
         rm $RPM_BUILD_ROOT/Module.kabi
     else
-        echo "**** NOTE: Cannot find DUP reference Module.kabi file. ****"
+	%{log_msg "NOTE: Cannot find DUP reference Module.kabi file."}
     fi
 %endif
 
@@ -2237,7 +2285,7 @@ BuildKernel() {
         mkdir -p $RPM_BUILD_ROOT/kabi-dwarf/stablelists
         tar -xvf %{SOURCE300} -C $RPM_BUILD_ROOT/kabi-dwarf/stablelists
 
-        echo "**** GENERATING DWARF-based kABI baseline dataset ****"
+	%{log_msg "GENERATING DWARF-based kABI baseline dataset"}
         chmod 0755 $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh
         $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh generate \
             "$RPM_BUILD_ROOT/kabi-dwarf/stablelists/kabi-current/kabi_stablelist_%{_target_cpu}" \
@@ -2256,26 +2304,27 @@ BuildKernel() {
             mkdir -p $RPM_BUILD_ROOT/kabi-dwarf/stablelists
             tar -xvf %{SOURCE300} -C $RPM_BUILD_ROOT/kabi-dwarf/stablelists
 
-            echo "**** GENERATING DWARF-based kABI dataset ****"
+	    %{log_msg "GENERATING DWARF-based kABI dataset"}
             chmod 0755 $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh
             $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh generate \
                 "$RPM_BUILD_ROOT/kabi-dwarf/stablelists/kabi-current/kabi_stablelist_%{_target_cpu}" \
                 "$(pwd)" \
                 "$RPM_BUILD_ROOT/kabi-dwarf/base/%{_target_cpu}${Variant:+.${Variant}}.tmp" || :
 
-            echo "**** kABI DWARF-based comparison report ****"
+	    %{log_msg "kABI DWARF-based comparison report"}
             $RPM_BUILD_ROOT/kabi-dwarf/run_kabi-dw.sh compare \
                 "$RPM_BUILD_ROOT/kabi-dwarf/base/%{_target_cpu}${Variant:+.${Variant}}" \
                 "$RPM_BUILD_ROOT/kabi-dwarf/base/%{_target_cpu}${Variant:+.${Variant}}.tmp" || :
-            echo "**** End of kABI DWARF-based comparison report ****"
+	    %{log_msg "End of kABI DWARF-based comparison report"}
         else
-            echo "**** Baseline dataset for kABI DWARF-BASED comparison report not found ****"
+	    %{log_msg "Baseline dataset for kABI DWARF-BASED comparison report not found"}
         fi
 
         rm -rf $RPM_BUILD_ROOT/kabi-dwarf
     fi
 %endif
 
+   %{log_msg "Cleanup Makefiles/Kconfig files"}
     # then drop all but the needed Makefiles/Kconfig files
     rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts
     rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include
@@ -2287,11 +2336,13 @@ BuildKernel() {
 %ifarch s390x
     # CONFIG_EXPOLINE_EXTERN=y produces arch/s390/lib/expoline/expoline.o
     # which is needed during external module build.
+    %{log_msg "Copy expoline.o"}
     if [ -f arch/s390/lib/expoline/expoline.o ]; then
       cp -a --parents arch/s390/lib/expoline/expoline.o $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
     fi
 %endif
 
+    %{log_msg "Copy additional files for make targets"}
     # Files for 'make scripts' to succeed with kernel-devel.
     mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/security/selinux/include
     cp -a --parents security/selinux/include/classmap.h $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
@@ -2385,6 +2436,7 @@ BuildKernel() {
     cp -a --parents tools/objtool/arch/x86/ $RPM_BUILD_ROOT/lib/modules/$KernelVer/build
 
 %endif
+    %{log_msg "Clean up intermediate tools files"}
     # Clean up intermediate tools files
     find $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/tools \( -iname "*.o" -o -iname "*.cmd" \) -exec rm -f {} +
 
@@ -2398,6 +2450,7 @@ BuildKernel() {
     eu-readelf -n vmlinux | grep "Build ID" | awk '{print $NF}' > vmlinux.id
     cp vmlinux.id $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/vmlinux.id
 
+    %{log_msg "Copy additional files for kernel-debuginfo rpm"}
     #
     # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm
     # (use mv + symlink instead of cp to reduce disk space requirements)
@@ -2417,13 +2470,14 @@ BuildKernel() {
     fi
 %endif
 
+    %{log_msg "Create modnames"}
     find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" -type f >modnames
 
     # mark modules executable so that strip-to-file can strip them
     xargs --no-run-if-empty chmod u+x < modnames
 
     # Generate a list of modules for block and networking.
-
+    %{log_msg "Generate a list of modules for block and networking"}
     grep -F /drivers/ modnames | xargs --no-run-if-empty nm -upA |
     sed -n 's,^.*/\([^/]*\.ko\):  *U \(.*\)$,\1 \2,p' > drivers.undef
 
@@ -2445,6 +2499,7 @@ BuildKernel() {
     collect_modules_list modesetting \
       'drm_crtc_init'
 
+    %{log_msg "detect missing or incorrect license tags"}
     # detect missing or incorrect license tags
     ( find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name '*.ko' | xargs /sbin/modinfo -l | \
         grep -E -v 'GPL( v2)?$|Dual BSD/GPL$|Dual MPL/GPL$|GPL and additional rights$' ) && exit 1
@@ -2460,8 +2515,10 @@ BuildKernel() {
         popd
     }
 
+    %{log_msg "Remove depmod files"}
     remove_depmod_files
 
+    %{log_msg "Identify modules in kenrel-modules-* packages"}
     # Identify modules in the kernel-modules-extras package
     %{SOURCE20} $RPM_BUILD_ROOT lib/modules/$KernelVer $(realpath configs/mod-extra.list)
     # Identify modules in the kernel-modules-internal package
@@ -2478,6 +2535,7 @@ BuildKernel() {
     #
     # Generate the kernel-core and kernel-modules files lists
     #
+    %{log_msg "Gemerate the kernel-core and kernel-modules files lists"}
 
     # Copy the System.map file for depmod to use, and create a backup of the
     # full module tree so we can restore it after we're done filtering
@@ -2487,6 +2545,7 @@ BuildKernel() {
     mkdir restore
     cp -r lib/modules/$KernelVer/* restore/.
 
+    %{log_msg "Remove files in the kernel-modules-* file lists"}
     # don't include anything going into kernel-modules-extra in the file lists
     xargs rm -rf < mod-extra.list
     # don't include anything going into kernel-modules-internal in the file lists
@@ -2501,6 +2560,7 @@ BuildKernel() {
     fi
 
     if [ $DoModules -eq 1 ]; then
+	%{log_msg "Filter files into core and modules lists"}
 	# Find all the module files and filter them out into the core and
 	# modules lists.  This actually removes anything going into -modules
 	# from the dir.
@@ -2511,13 +2571,14 @@ BuildKernel() {
 	# Run depmod on the resulting module tree and make sure it isn't broken
 	depmod -b . -aeF ./System.map $KernelVer &> depmod.out
 	if [ -s depmod.out ]; then
-	    echo "Depmod failure"
+	    %{log_msg "Depmod failure"}
 	    cat depmod.out
 	    exit 1
 	else
 	    rm depmod.out
 	fi
     else
+	%{log_msg "Create empty files for RPM packaging"}
 	# Ensure important files/directories exist to let the packaging succeed
 	echo '%%defattr(-,-,-)' > modules.list
 	echo '%%defattr(-,-,-)' > k-d.list
@@ -2529,9 +2590,10 @@ BuildKernel() {
     fi
 
     if [[ "$Variant" == "rt" || "$Variant" == "rt-debug" ]]; then
-        echo "Skipping efiuki build"
+	%{log_msg "Skipping efiuki build"}
     else
 %if %{with_efiuki}
+	%{log_msg "Setup the EFI UKI kernel"}
 	popd
 
 	KernelUnifiedImageDir="$RPM_BUILD_ROOT/lib/modules/$KernelVer"
@@ -2551,13 +2613,13 @@ BuildKernel() {
 	   $KernelUnifiedImage
 
 %if %{signkernel}
-
+	%{log_msg "Sign the EFI UKI kernel"}
 	%pesign -s -i $KernelUnifiedImage -o $KernelUnifiedImage.tmp -a %{secureboot_ca_0} -c %{secureboot_key_0} -n %{pesign_name_0}
     	%pesign -s -i $KernelUnifiedImage.tmp -o $KernelUnifiedImage.signed -a %{secureboot_ca_1} -c %{secureboot_key_1} -n %{pesign_name_1}
     	rm -f $KernelUnifiedImage.tmp
 
     	if [ ! -s $KernelUnifiedImage.signed ]; then
-      	   echo "pesigning failed"
+	   %{log_msg "pesigning failed"}
       	   exit 1
     	fi
     	mv $KernelUnifiedImage.signed $KernelUnifiedImage
@@ -2579,6 +2641,7 @@ BuildKernel() {
     find lib/modules/$KernelVer/kernel -mindepth 1 -type d | sort -n > module-dirs.list
 
     # Cleanup
+    %{log_msg "Cleanup build files"}
     rm System.map
     # Just "cp -r" can be very slow: here, it rewrites _existing files_
     # with open(O_TRUNC). Many filesystems synchronously wait for metadata
@@ -2593,6 +2656,7 @@ BuildKernel() {
 
     # Make sure the files lists start with absolute paths or rpmbuild fails.
     # Also add in the dir entries
+    %{log_msg "Create module list files for all kernel variants"}
     sed -e 's/^lib*/\/lib/' %{?zipsed} $RPM_BUILD_ROOT/k-d.list > ../kernel${Variant:+-${Variant}}-modules.list
     sed -e 's/^lib*/%dir \/lib/' %{?zipsed} $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Variant:+-${Variant}}-modules-core.list
     sed -e 's/^lib*/\/lib/' %{?zipsed} $RPM_BUILD_ROOT/modules.list >> ../kernel${Variant:+-${Variant}}-modules-core.list
@@ -2601,7 +2665,8 @@ BuildKernel() {
     	sed -e 's/^lib*/\/lib/' %{?zipsed} $RPM_BUILD_ROOT/mod-kvm.list >> ../kernel${Variant:+-${Variant}}-kvm.list
     fi
 
-    # Cleanup
+    # Cleanup kernel variant module lists
+    %{log_msg "Clean up kernel variant module lists"}
     rm -f $RPM_BUILD_ROOT/k-d.list
     rm -f $RPM_BUILD_ROOT/modules.list
     rm -f $RPM_BUILD_ROOT/module-dirs.list
@@ -2616,6 +2681,7 @@ BuildKernel() {
 
 %if %{signmodules}
     if [ $DoModules -eq 1 ]; then
+	%{log_msg "Save the signing keys for modules"}
 	# Save the signing keys so we can sign the modules in __modsign_install_post
 	cp certs/signing_key.pem certs/signing_key.pem.sign${Variant:++${Variant}}
 	cp certs/signing_key.x509 certs/signing_key.x509.sign${Variant:++${Variant}}
@@ -2623,6 +2689,7 @@ BuildKernel() {
 %endif
 
     # Move the devel headers out of the root file system
+    %{log_msg "Move the devel headers to RPM_BUILD_ROOT"}
     mkdir -p $RPM_BUILD_ROOT/usr/src/kernels
     mv $RPM_BUILD_ROOT/lib/modules/$KernelVer/build $RPM_BUILD_ROOT/$DevelDir
 
@@ -2635,6 +2702,7 @@ BuildKernel() {
     # Generate vmlinux.h and put it to kernel-devel path
     # zfcpdump build does not have btf anymore
     if [ "$Variant" != "zfcpdump" ]; then
+	%{log_msg "Build the bootstrap bpftool to generate vmlinux.h"}
         # Build the bootstrap bpftool to generate vmlinux.h
         export BPFBOOTSTRAP_CFLAGS=$(echo "%{__global_compiler_flags}" | sed -r "s/\-specs=[^\ ]+\/redhat-annobin-cc1//")
         export BPFBOOTSTRAP_LDFLAGS=$(echo "%{__global_ldflags}" | sed -r "s/\-specs=[^\ ]+\/redhat-annobin-cc1//")
@@ -2643,12 +2711,14 @@ BuildKernel() {
         tools/bpf/bpftool/bootstrap/bpftool btf dump file vmlinux format c > $RPM_BUILD_ROOT/$DevelDir/vmlinux.h
     fi
 
+    %{log_msg "Cleanup kernel-devel and kernel-debuginfo files"}
     # prune junk from kernel-devel
     find $RPM_BUILD_ROOT/usr/src/kernels -name ".*.cmd" -delete
     # prune junk from kernel-debuginfo
     find $RPM_BUILD_ROOT/usr/src/kernels -name "*.mod.c" -delete
 
     # Red Hat UEFI Secure Boot CA cert, which can be used to authenticate the kernel
+    %{log_msg "Install certs"}
     mkdir -p $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer
     %ifarch x86_64 aarch64
        install -m 0644 %{secureboot_ca_0} $RPM_BUILD_ROOT%{_datadir}/doc/kernel-keys/$KernelVer/kernel-signing-ca-20200609.cer
@@ -2670,6 +2740,7 @@ BuildKernel() {
     %endif
 
 %if %{with_ipaclones}
+    %{log_msg "install IPA clones"}
     MAXPROCS=$(echo %{?_smp_mflags} | sed -n 's/-j\s*\([0-9]\+\)/\1/p')
     if [ -z "$MAXPROCS" ]; then
         MAXPROCS=1
@@ -2698,7 +2769,6 @@ cd linux-%{KVERREL}
 
 %if %{with_debug}
 %if %{with_realtime}
-echo "building rt-debug"
 BuildKernel %make_target %kernel_image %{_use_vdso} rt-debug
 %endif
 
@@ -2711,7 +2781,6 @@ BuildKernel %make_target %kernel_image %{_use_vdso} 64k-debug
 %endif
 
 %if %{with_up}
-echo "building main debug package"
 BuildKernel %make_target %kernel_image %{_use_vdso} debug
 %endif
 %endif
@@ -2740,6 +2809,7 @@ BuildKernel %make_target %kernel_image %{_use_vdso}
 %if !%{with_debug} && !%{with_zfcpdump} && !%{with_up} && !%{with_arm64_16k} && !%{with_arm64_64k} && !%{with_realtime}
 # If only building the user space tools, then initialize the build environment
 # and some variables so that the various userspace tools can be built.
+%{log_msg "Initialize userspace tools build environment"}
 InitBuildVars
 %endif
 %endif
@@ -2750,6 +2820,7 @@ InitBuildVars
 %global perf_make \
   %{__make} %{?make_opts} EXTRA_CFLAGS="${RPM_OPT_FLAGS}" EXTRA_CXXFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags} -Wl,-E" %{?cross_opts} -C tools/perf V=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 LIBBPF_DYNAMIC=1 LIBTRACEEVENT_DYNAMIC=1 %{?perf_build_extra_opts} prefix=%{_prefix} PYTHON=%{__python3}
 %if %{with_perf}
+%{log_msg "Build perf"}
 # perf
 # make sure check-headers.sh is executable
 chmod +x tools/perf/check-headers.sh
@@ -2759,6 +2830,7 @@ chmod +x tools/perf/check-headers.sh
 %if %{with_libperf}
 %global libperf_make \
   %{__make} %{?make_opts} EXTRA_CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" %{?cross_opts} -C tools/lib/perf V=1
+  %{log_msg "build libperf"}
 %{libperf_make} DESTDIR=$RPM_BUILD_ROOT
 %endif
 
@@ -2770,44 +2842,56 @@ chmod +x tools/perf/check-headers.sh
 # cpupower
 # make sure version-gen.sh is executable.
 chmod +x tools/power/cpupower/utils/version-gen.sh
+%{log_msg "build cpupower"}
 %{tools_make} %{?_smp_mflags} -C tools/power/cpupower CPUFREQ_BENCH=false DEBUG=false
 %ifarch x86_64
     pushd tools/power/cpupower/debug/x86_64
+    %{log_msg "build centrino-decode powernow-k8-decode"}
     %{tools_make} %{?_smp_mflags} centrino-decode powernow-k8-decode
     popd
 %endif
 %ifarch x86_64
    pushd tools/power/x86/x86_energy_perf_policy/
+   %{log_msg "build x86_energy_perf_policy"}
    %{tools_make}
    popd
    pushd tools/power/x86/turbostat
+   %{log_msg "build turbostat"}
    %{tools_make}
    popd
    pushd tools/power/x86/intel-speed-select
+   %{log_msg "build intel-speed-select"}
    %{tools_make}
    popd
    pushd tools/arch/x86/intel_sdsi
+   %{log_msg "build intel_sdsi"}
    %{tools_make} CFLAGS="${RPM_OPT_FLAGS}"
    popd
 %endif
 %endif
 pushd tools/thermal/tmon/
+%{log_msg "build tmon"}
 %{tools_make}
 popd
 pushd tools/iio/
+%{log_msg "build iio"}
 %{tools_make}
 popd
 pushd tools/gpio/
+%{log_msg "build gpio"}
 %{tools_make}
 popd
 # build VM tools
 pushd tools/mm/
+%{log_msg "build slabinfo page_owner_sort"}
 %{tools_make} slabinfo page_owner_sort
 popd
 pushd tools/verification/rv/
+%{log_msg "build rv"}
 %{tools_make}
 popd
 pushd tools/tracing/rtla
+%{log_msg "build rtla"}
 %{tools_make}
 popd
 %endif
@@ -2819,26 +2903,31 @@ fi
 %if %{with_bpftool}
 %global bpftool_make \
   %{__make} EXTRA_CFLAGS="${RPM_OPT_FLAGS}" EXTRA_LDFLAGS="%{__global_ldflags}" DESTDIR=$RPM_BUILD_ROOT %{?make_opts} VMLINUX_H="${RPM_VMLINUX_H}" V=1
+%{log_msg "build bpftool"}
 pushd tools/bpf/bpftool
 %{bpftool_make}
 popd
 %else
-echo "bpftools disabled ... disabling selftests"
+%{log_msg "bpftools disabled ... disabling selftests"}
 %endif
 
 %if %{with_selftests}
+%{log_msg "start build selftests"}
 # Unfortunately, samples/bpf/Makefile expects that the headers are installed
 # in the source tree. We installed them previously to $RPM_BUILD_ROOT/usr
 # but there's no way to tell the Makefile to take them from there.
+%{log_msg "install headers for selftests"}
 %{make} %{?_smp_mflags} headers_install
 
 # If we re building only tools without kernel, we need to generate config
 # headers and prepare tree for modules building. The modules_prepare target
 # will cover both.
 if [ ! -f include/generated/autoconf.h ]; then
+   %{log_msg "modules_prepare for selftests"}
    %{make} %{?_smp_mflags} modules_prepare
 fi
 
+%{log_msg "build samples/bpf"}
 %{make} %{?_smp_mflags} ARCH=$Arch V=1 M=samples/bpf/ VMLINUX_H="${RPM_VMLINUX_H}" || true
 
 # Prevent bpf selftests to build bpftool repeatedly:
@@ -2853,10 +2942,12 @@ pushd tools/testing/selftests
   force_targets=""
 %endif
 
+%{log_msg "main selftests compile"}
 %{make} %{?_smp_mflags} ARCH=$Arch V=1 TARGETS="bpf mm livepatch net net/forwarding net/mptcp netfilter tc-testing memfd drivers/net/bonding" SKIP_TARGETS="" $force_targets INSTALL_PATH=%{buildroot}%{_libexecdir}/kselftests VMLINUX_H="${RPM_VMLINUX_H}" install
 
 # 'make install' for bpf is broken and upstream refuses to fix it.
 # Install the needed files manually.
+%{log_msg "install selftests"}
 for dir in bpf bpf/no_alu32 bpf/progs; do
 	# In ARK, the rpm build continues even if some of the selftests
 	# cannot be built. It's not always possible to build selftests,
@@ -2873,15 +2964,19 @@ done
 %buildroot_save_unstripped "usr/libexec/kselftests/bpf/test_progs-no_alu32"
 popd
 export -n BPFTOOL
+%{log_msg "end build selftests"}
 %endif
 
 %if %{with_doc}
+%{log_msg "start install docs"}
 # Make the HTML pages.
+%{log_msg "build html docs"}
 %{__make} PYTHON=/usr/bin/python3 htmldocs || %{doc_build_fail}
 
 # sometimes non-world-readable files sneak into the kernel source tree
 chmod -R a=rX Documentation
 find Documentation -type d | xargs chmod u+w
+%{log_msg "end install docs"}
 %endif
 
 # Module signing (modsign)
@@ -2893,17 +2988,17 @@ find Documentation -type d | xargs chmod u+w
 
 %define __modsign_install_post \
   if [ "%{signmodules}" -eq "1" ]; then \
-    echo "Signing kernel modules ..." \
+    %{log_msg "Signing kernel modules ..."} \
     modules_dirs="$(shopt -s nullglob; echo $RPM_BUILD_ROOT/lib/modules/%{KVERREL}*)" \
     for modules_dir in $modules_dirs; do \
         variant_suffix="${modules_dir#$RPM_BUILD_ROOT/lib/modules/%{KVERREL}}" \
         [ "$variant_suffix" == "+zfcpdump" ] && continue \
-        echo "Signing modules for %{KVERREL}${variant_suffix}" \
+	%{log_msg "Signing modules for %{KVERREL}${variant_suffix}"} \
         %{modsign_cmd} certs/signing_key.pem.sign${variant_suffix} certs/signing_key.x509.sign${variant_suffix} $modules_dir/ \
     done \
   fi \
   if [ "%{zipmodules}" -eq "1" ]; then \
-    echo "Compressing kernel modules ..." \
+    %{log_msg "Compressing kernel modules ..."} \
     find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs -n 16 -P${RPM_BUILD_NCPUS} -r %compression %compression_flags; \
   fi \
 %{nil}

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2952
--
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux