On Mon, 2021-08-23 at 19:22:54 -0700, Vagrant Cascadian wrote:
> Ok, a slightly more complicated workflow pseudocode:
> 
> if DEB_BUILD_PATH && fixfilepath
> then
>   -spec=/usr/share/dpkg/fixfilepath.spec ...
> else if fixfilepath
>   -ffile-prefix-map= build_path ...
> fi

While in theory something like this might work, I'm afraid this is
still a potentially pretty dangerous thing to do. The problem I see is
that we'd be checking for the presence of an envvar deep in a call
stack that is going to be completely independent from the ones that
are going to be evaluating the spec file with its own envvar fetching,
where something could have set the envvar for the first branch but not
the second (or unset it). But see down below…

> In other words, only pass the spec file that requires DEB_BUILD_PATH to
> be set when DEB_BUILD_PATH *is* set, falling back to the previous
> behavior setting ffile-prefix-map directly?
> 
> Another pseudocode idea:
> 
> if fixfilepath
> then
>   setenv DEB_BUILD_PATH $build_path
>   export DEB_BUILD_PATH
>   -spec=/usr/share/dpkg/fixfilepath.spec
> fi

I don't think that's workable, as per the above.


There's also the perennial problem with GNU make not exposing variables
exported within a Makefile into $(shell) directives, but I guess in
those scenarios that might work in our favor in most cases.

  ,--- test.mk ---
  export DEB_BUILD_PATH = something
  all:
        echo $(shell dpkg-buildflags | grep something)
  `---

Something I've noticed now is that buildflags.mk is missing passing
DEB_BUILD_PATH explicitly to the dpkg-buildflags call, so I'm merging
the following into git main:

diff --git i/scripts/mk/buildflags.mk w/scripts/mk/buildflags.mk
index 442b7d671..f7ebe8f2c 100644
--- i/scripts/mk/buildflags.mk
+++ w/scripts/mk/buildflags.mk
@@ -31,6 +31,7 @@ endef
 
 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_OPTIONS))
 $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS))
+$(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_PATH))
 $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
   $(foreach operation,SET STRIP APPEND PREPEND,\
     $(eval $(call 
dpkg_buildflags_export_envvar,DEB_$(flag)_MAINT_$(operation)))))


And after checking with codesearch.d.o, I see only Linux is setting
DEB_BUILD_PATH explicitly from debian/*. But that does not guarantee
build machinery is not resetting envvars f.ex. which would break the
build.

Perhaps a soothing check would be to do an archive rebuild using the
first workflow you proposed above (w/ and w/o setting DEB_BUILD_PATH
externally)? Would that be too cumbersome?

If that's successful, and even though that still has the potential to
break stuff (including non-Debian source packages), at that point it
might be OKish to set it from dpkg-buildpackage because even if it is
not set I'd expect things to be more or less fine.

Thanks,
Guillem

Reply via email to