[DTrace-devel] [PATCH 2/2] spec: support building from RPMs again

Kris Van Hees kris.van.hees at oracle.com
Tue Jan 2 18:47:53 UTC 2024


On Tue, Nov 21, 2023 at 09:48:26PM +0000, Nick Alcock wrote:
> We need a way to override the /source and /build suffixes which
> /lib/modules/$(uname -r) needs after it to find the kernel
> headers, because devel rpms don't use either (things are just
> directly in /usr/src/kernels/$(kernel)/, with no suffix).
> 
> Introduce KERNELSRCSUFFIX and KERNELBUILDSUFFIX which the
> specfile can set to nothing to make the RPMs build again.

Hm, can we for consistency use KERNELSRCSUFFIX and KERNELBLDSUFFIX?
Then again, perhaps KERNELSRCNAME and KERNELBLDNAME might be more clear since
this is more like a directory component name rather than a suffix.

> (As a benefit, this might mean we can be made to build fine
> without a source/ link at all, which current upstream kernels
> are now doing.  Not tested that yet, though.)
> 
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
> ---
>  GNUmakefile     | 5 +++++
>  dtrace.spec     | 2 +-
>  libdtrace/Build | 4 ++--
>  3 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/GNUmakefile b/GNUmakefile
> index 926d84c5f4e1..368bf5c1ecad 100644
> --- a/GNUmakefile
> +++ b/GNUmakefile
> @@ -71,8 +71,13 @@ UNPRIV_HOME ?= /run/initramfs
>  # tree.  If the kernel was built within the source tree, KERNELOBJDIR need not
>  # be specified.
>  
> +# For RPM builds, set KERNELMODDIR to the root of the rpmsrc tree, and set
> +# KERNELSRCSUFFIX and KERNELBUILDSUFFIX to the empty string.
> +
>  KERNELS = $(shell uname -r)
>  KERNELMODDIR = /lib/modules
> +KERNELSRCSUFFIX=/source
> +KERNELBUILDSUFFIX=/build

Wouldn't it be safer to not include the leading / since you add that in the
substitution rules below already?

>  ifdef KERNELSRCDIR
>  KERNELOBJDIR ?= $(KERNELSRCDIR)
> diff --git a/dtrace.spec b/dtrace.spec
> index ff1f380822ab..474a09a37b68 100644
> --- a/dtrace.spec
> +++ b/dtrace.spec
> @@ -165,7 +165,7 @@ it always tests the installed DTrace.
>  
>  %build
>  make -j $(getconf _NPROCESSORS_ONLN) VERSION=%{version} \
> -	KERNELDIRPREFIX=/usr/src/kernels KERNELDIRSUFFIX= \
> +	KERNELMODDIR=/usr/src/kernels KERNELSRCSUFFIX= KERNELBUILDSUFFIX= verbose=yes \
>  	KERNELS="%{kerneldirs}" %{maybe_use_fuse2}
>  
>  # Force off debuginfo splitting.  We have no debuginfo in dtrace proper,
> diff --git a/libdtrace/Build b/libdtrace/Build
> index 76fd32e44a2f..76a3268cd47a 100644
> --- a/libdtrace/Build
> +++ b/libdtrace/Build
> @@ -167,8 +167,8 @@ $(objdir)/dlibs/.dir.stamp:
>  define dlib-kernel-ver-template
>  $(objdir)/dlibs/$(shell printf %s $(1) | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/')/%.d: override SHORTKERNELVER := $(shell printf %s $(1) | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/' | awk -F. '{ print $$1 * 1000 * 1000 + $$2 * 1000 + $$3 }')
>  $(objdir)/dlibs/$(shell printf %s $(1) | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/')/%.d: override KERNELVER := $(1)
> -$(objdir)/dlibs/$(shell printf %s $(1) | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/')/%.d: override KERNELSRCDIR ?= $(KERNELMODDIR)/$(1)/source
> -$(objdir)/dlibs/$(shell printf %s $(1) | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/')/%.d: override KERNELOBJDIR ?= $(KERNELMODDIR)/$(1)/build
> +$(objdir)/dlibs/$(shell printf %s $(1) | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/')/%.d: override KERNELSRCDIR ?= $(KERNELMODDIR)/$(1)/$(KERNELSRCSUFFIX)
> +$(objdir)/dlibs/$(shell printf %s $(1) | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*$$/\1.\2.\3/')/%.d: override KERNELOBJDIR ?= $(KERNELMODDIR)/$(1)/$(KERNELBUILDSUFFIX)
>  endef
>  
>  $(foreach kernel,$(KERNELS),$(eval $(call dlib-kernel-ver-template,$(kernel))))
> -- 
> 2.42.0.271.g85384428f1
> 
> 



More information about the DTrace-devel mailing list