Control: tags -1 + patch On Wed, Nov 29, 2017 at 02:33:53AM +0100, Matthias Klose wrote: > as discussed on irc, the alternative solution should be preferred.
Ah, right. Thank you for the reminder. In the mean time, I tried to agree on a better header name for "X-DH-Build-For-Type: target" with Guillem and Niels, but we ultimately failed. Thus we will end up using the debhelper extension name and do without support from dpkg for now. Doing without dpkg means that dh_gencontrol does not fully honour this header and we'll have to change DEB_HOST_ARCH and friends before running it. Luckily, gcc already does this using cross_gencontrol. So I've split up this patch into four patches, because they kinda solve four different subproblems. I hope this makes reviewing them easier. #1 gcc-dhp-flags.patch This patch is only relevant to DEB_STAGE=rtlibs. While performing a DEB_STAGE=rtlibs build, we are in the strange situation that all binary packages are considered architecture independent and files like "debian/arch_binaries" and "debian/arch_binaries.all" and up being completely empty. The foreach loops generating the -p flags for debhelper will thus be empty and no -p flag will be generated at all. Rather that processing no packages, this will make the various dh_* tools process all packages. This is a bug even before debhelper became strict, but now it became fatal. #2 gcc-target-vars.patch The gcc packaging has a set of make variables DEB_TARGET_* that pretty closely mimic the dpkg-architecture variables. We need to export these as debhelper is going to use them. Furthermore, dpkg-architecture gained some new variables and those should be added here. #3 gcc-target-package.patch This patch simply adds a layer of indirection. It defines a m4 macro for the new header in control.m4. This macro makes it easy to remove the header if it turns out to be problematic. For instance, it could be made empty if the release we are building for is very old or we are not performing a cross compiler build. It also makes the next "patch" easier. #4 Adding the headers I didn't implement this change as a patch, but as a sed expression: sed -i -e '/^Package: .*`'"'"'LS$/aTARGET_PACKAGE`'"'dnl" debian/control.m4 What it does is simple enough: It looks for every package that ends in "LS" and appends the header to that package. This is the suffix that turns architecture dependent packages into -$arch-cross packages for cross compilers (other than DEB_STAGE=rtlibs). This $arch is the target architecture, so this LS suffix precisely identifies the packages that need to be enabled. I've tested cross compiler builds for gcc-7 and gcc-8 for a fair number of targets now. None of the aspects changed touch native builds in any significant way. Thus I think this patch is pretty safe. In a distant future, this change will allow us to remove a lot of magic like cross_shlibdeps, cross_makeshlibs and cross_clean as this tagging will have turned into a tagging that is performed in debian/control instead. Helmut
--- a/debian/rules2 +++ b/debian/rules2 @@ -2396,10 +2396,12 @@ cat debian/arch_binaries debian/arch_binaries.epoch > debian/arch_binaries.all binary-arch: debian/arch_binaries.all + test ! -s debian/arch_binaries.all || \ dh_compress $(foreach p,$(shell echo `cat debian/arch_binaries.all`),-p$(p)) \ -X.log.xz -X.sum.xz -X.c -X.txt -X.tag -X.map -XREADME.Bugs ifeq ($(i586_symlinks),yes) cd debian; \ + test ! -s arch_binaries || \ for x in $$(find `cat arch_binaries` -type l -name 'i686-*'); do \ link=$$(echo $$x | sed 's/i686-/i586-/'); \ tgt=$$(basename $$x); \ @@ -2407,7 +2409,9 @@ rm -f $$link; cp -a $$x $$link; \ done endif + test ! -s debian/arch_binaries.all || \ dh_fixperms $(foreach p,$(shell echo `cat debian/arch_binaries.all`),-p$(p)) + test ! -s debian/arch_binaries || \ dh_gencontrol $(foreach p,$(shell echo `cat debian/arch_binaries`),-p$(p)) \ -- -v$(DEB_VERSION) $(common_substvars) @set -e; \ @@ -2416,8 +2420,11 @@ echo dh_gencontrol $$pkgs -- -v$(DEB_EVERSION) $(common_substvars); \ dh_gencontrol $$pkgs -- -v$(DEB_EVERSION) $(common_substvars); \ fi + test ! -s debian/arch_binaries.all || \ dh_installdeb $(foreach p,$(shell echo `cat debian/arch_binaries.all`),-p$(p)) + test ! -s debian/arch_binaries.all || \ dh_md5sums $(foreach p,$(shell echo `cat debian/arch_binaries.all`),-p$(p)) + test ! -s debian/arch_binaries.all || \ dh_builddeb $(foreach p,$(shell echo `cat debian/arch_binaries.all`),-p$(p)) ifeq ($(with_check),yes) @echo Done
--- a/debian/rules.defs +++ b/debian/rules.defs @@ -161,6 +161,11 @@ DEB_TARGET_GNU_TYPE := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_TYPE) DEB_TARGET_GNU_SYSTEM := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_SYSTEM) DEB_TARGET_MULTIARCH := $(call vafilt,$(TARGET_VARS),DEB_HOST_MULTIARCH) +DEB_TARGET_ARCH_ABI := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_ABI) +DEB_TARGET_ARCH_BITS := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_BITS) +DEB_TARGET_ARCH_ENDIAN := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_ENDIAN) +DEB_TARGET_ARCH_LIBC := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_LIBC) +export DEB_TARGET_ARCH DEB_TARGET_ARCH_ABI DEB_TARGET_ARCH_BITS DEB_TARGET_ARCH_CPU DEB_TARGET_ARCH_OS DEB_TARGET_ARCH_ENDIAN DEB_TARGET_ARCH_LIBC DEB_TARGET_GNU_CPU DEB_TARGET_GNU_TYPE DEB_TARGET_GNU_SYSTEM DEB_TARGET_MULTIARCH ifeq ($(derivative),Ubuntu) ifeq (,$(filter $(distrelease),dapper lucid))
--- a/debian/control.m4 +++ b/debian/control.m4 @@ -33,6 +33,8 @@ define(`BUILT_USING', ifelse(add_built_using,yes,`Built-Using: ${Built-Using} ')) +define(`TARGET_PACKAGE',`X-DH-Build-For-Type: target +') divert`'dnl dnl --------------------------------------------------------------------------