[Bug 2071468] [NEW] ELF package metadata failure: environment variable ‘DEB_HOST_ARCH’ not defined

Launchpad Bug Tracker 2071468 at bugs.launchpad.net
Thu Jul 11 14:01:56 UTC 2024


You have been subscribed to a public bug by Nathan Teodosio (nteodosio):

The ELF package note metadata introduced in dpkg 1.22.6ubuntu11 (refined
in 1.22.6ubuntu14) can cause this failure:

```
gcc fatal error: environment variable ‘DEB_HOST_ARCH’ not defined
```

This happens when the `-specs=/usr/share/dpkg/elf-package-
metadata.specs` parameter is set but the needed environment variables
are not set. Cases:

1. Only the LDFLAGS is queried from dpkg-buildflags. Affected source
packages builds: python3.12, openjdk-21, cdbs (causing dvbstreamer and
rp-pppoe fail to build)

2. autopkgtests

3. debugging a crash of an application build with the -spec parameter

4. People like to iteratively continue building the software in the
build dir while hacking on the package and then have no environment
variable set.

This approach is too fragile. An alternative approach would be to specify the `--package-metadata` linker flag directly. The problem with that approach is that the curly brackets and quotation marks need to be escaped. Example failure: Building dpkg would add this parameter to the LDFLAGS:
```
-Wl,--package-metadata,{"type":"deb","os":"ubuntu","name":"dpkg","version":"1.22.6ubuntu15","architecture":"amd64"}
```
The following configure script call (non-relevant parameters deleted):
```
$ gcc -Wl,--package-metadata,{type:deb,os:ubuntu,name:dpkg,version:1.22.6ubuntu15,architecture:amd64}
/usr/bin/ld: cannot find {type:deb: No such file or directory
/usr/bin/ld: cannot find os:ubuntu: No such file or directory
/usr/bin/ld: cannot find name:dpkg: No such file or directory
/usr/bin/ld: cannot find version:1.22.6ubuntu15: No such file or directory
/usr/bin/ld: cannot find architecture:amd64}: No such file or directory
```

Proposed solution: Add support for an `--escaped-package-metadata` parameter to the linkers that takes an URL encoded (RFC 3986) parameter. Example:
```
-Wl,--encoded-package-metadata,%7B%22type%22:%22deb%22%2C%22os%22:%22ubuntu%22%2C%22name%22:%22dpkg%22%2C%22version%22:%221.22.6ubuntu15%22%2C%22architecture%22:%22amd64%22%7D
```

** Affects: asymptote (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: curl (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: dpkg (Ubuntu)
     Importance: High
         Status: Triaged

** Affects: graphite2 (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: gsequencer (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: haskell-devscripts (Ubuntu)
     Importance: Undecided
         Status: Fix Released

** Affects: jose (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: libreoffice (Ubuntu)
     Importance: Undecided
         Status: Fix Released

** Affects: libtpms (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: mosh (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: mwrap (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: proftpd (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: proftpd-dfsg (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: serf (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: speech-dispatcher (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: squid (Ubuntu)
     Importance: High
         Status: Fix Released

** Affects: swtpm (Ubuntu)
     Importance: Undecided
         Status: Fix Released

** Affects: texinfo (Ubuntu)
     Importance: High
         Status: Triaged


** Tags: ftbfs oracular update-excuse
-- 
ELF package metadata failure: environment variable ‘DEB_HOST_ARCH’ not defined
https://bugs.launchpad.net/bugs/2071468
You received this bug notification because you are a member of Ubuntu Sponsors, which is subscribed to the bug report.



More information about the Ubuntu-sponsors mailing list