DEB_* environment variables not set when using /usr/share/dpkg/buildflags.mk

Bug #2070015 reported by Gianfranco Costamagna
26
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cdbs (Ubuntu)
Fix Released
Undecided
Unassigned
dpkg (Ubuntu)
Fix Released
Critical
Benjamin Drung

Bug Description

Hello, few things broke with last dpkg uploads:
https://pastebin.ubuntu.com/p/2GN5fdtpsz/
configure:2498: gcc -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/rp-pppoe-4.0-1ubuntu1=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/rp-pppoe-4.0-1ubuntu1=/usr/src/rp-pppoe-4.0-1ubuntu1 -Wdate-time -D_FORTIFY_SOURCE=3 -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -specs=/usr/share/dpkg/elf-package-metadata.specs conftest.c >&5
gcc: fatal error: environment variable 'DEB_VERSION' not defined

(probably this is due to not having the standard dh calls)

Also,
Use of uninitialized value in string eq at /usr/bin/dpkg-genbuildinfo line 337.
Are printed for newly introduced variables:
DEB_BUILD_OS_RELEASE_ID DEB_SOURCE DEB_VERSION

Example of failing package:
https://bugs.launchpad.net/ubuntu/+source/dpkg/+bug/2070015

Related branches

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :
Changed in dpkg (Ubuntu):
importance: Undecided → Critical
assignee: nobody → Benjamin Drung (bdrung)
tags: added: block-proposed
description: updated
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Not sure how much this makes sense, but the warnings might disappear with this patch?

diff -Nru dpkg-1.22.6ubuntu13/scripts/t/mk/buildflags.mk dpkg-1.22.6ubuntu14/scripts/t/mk/buildflags.mk
--- dpkg-1.22.6ubuntu13/scripts/t/mk/buildflags.mk 2024-06-14 16:08:27.000000000 +0200
+++ dpkg-1.22.6ubuntu14/scripts/t/mk/buildflags.mk 2024-06-21 08:19:46.000000000 +0200
@@ -24,3 +24,5 @@
  test "$(OBJCFLAGS_FOR_BUILD)" = "$(TEST_OBJCFLAGS_FOR_BUILD)"
  test "$(OBJCXXFLAGS)" = "$(TEST_OBJCXXFLAGS)"
  test "$(OBJCXXFLAGS_FOR_BUILD)" = "$(TEST_OBJCXXFLAGS_FOR_BUILD)"
+ test "$(RUSTFLAGS)" = "$(TEST_RUSTFLAGS)"
+ test "$(RUSTFLAGS_FOR_BUILD)" = "$(TEST_RUSTFLAGS_FOR_BUILD)"
--- dpkg-1.22.6ubuntu13/scripts/Dpkg/BuildFlags.pm 2024-06-18 19:48:56.000000000 +0200
+++ dpkg-1.22.6ubuntu14/scripts/Dpkg/BuildFlags.pm 2024-06-21 08:17:23.000000000 +0200
@@ -94,6 +94,8 @@
         FCFLAGS_FOR_BUILD
         LDFLAGS
         LDFLAGS_FOR_BUILD
+ RUSTFLAGS
+ RUSTFLAGS_FOR_BUILD
     );

     $self->{features} = {};

Revision history for this message
Benjamin Drung (bdrung) wrote :

I found the reason:

rp-pppoe does not use dh but includes /usr/share/dpkg/buildflags.mk which calls `dpkg-buildflags --get LDFLAGS`. This command only exports LDFLAGS but does not expose the needed environment variables.

So we need to expose them in /usr/share/dpkg/buildflags.mk as well.

Benjamin Drung (bdrung)
Changed in dpkg (Ubuntu):
status: New → In Progress
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Same problem with libreoffice which makes use of /usr/share/dpkg/buildflags.mk too

https://launchpad.net/ubuntu/+source/libreoffice/4:24.2.4-0ubuntu1

Benjamin Drung (bdrung)
summary: - dpkg-buildpackage broke rp-pppoe building
+ DEB_* environment variables not set when using
+ /usr/share/dpkg/buildflags.mk
Revision history for this message
Benjamin Drung (bdrung) wrote :

Here are the proposed changes: https://code.launchpad.net/~bdrung/ubuntu/+source/dpkg/+git/dpkg/+merge/467994

I successfully tested it with rp-pppoe. Following failures will be fixed with it as well:

```
Use of uninitialized value in string eq at /usr/bin/dpkg-genbuildinfo line 336.
```

Benjamin Drung (bdrung)
Changed in dpkg (Ubuntu):
status: In Progress → Fix Committed
tags: removed: block-proposed
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Setting back to block-proposed since cdbs packages are still FTBFS

dvbstreamer fails with very same issue:

configure:3734: checking whether the C compiler works
configure:3756: gcc -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/dvbstreamer-2.1.0=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/dvbstreamer-2.1.0=/usr/src/dvbstreamer-2.1.0-5.7 -Wdate-time -D_FORTIFY_SOURCE=3 -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -specs=/usr/share/dpkg/elf-package-metadata.specs conftest.c >&5
gcc: fatal error: environment variable 'DEB_VERSION' not defined
compilation terminated.
configure:3760: $? = 1
configure:3800: result: no
configure: failed program was:

Reason is to be found inside rules file:
https://sources.debian.org/src/dvbstreamer/2.1.0-5.7/debian/rules/
#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/class/autotools.mk

tags: added: block-proposed
Revision history for this message
Benjamin Drung (bdrung) wrote :

dvbstreamer fixed in cdbs 0.4.166ubuntu1

tags: removed: block-proposed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cdbs - 0.4.166ubuntu1

---------------
cdbs (0.4.166ubuntu1) oracular; urgency=medium

  * Export environment variables needed for ELF package metadata (LP: #2070015)

 -- Benjamin Drung <email address hidden> Tue, 25 Jun 2024 12:25:40 +0200

Changed in cdbs (Ubuntu):
status: New → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dpkg - 1.22.6ubuntu14

---------------
dpkg (1.22.6ubuntu14) oracular; urgency=medium

  * Export environment variables DEB_BUILD_OS_RELEASE_ID, DEB_HOST_ARCH,
    DEB_SOURCE, and DEB_VERSION when including buildflags.mk (LP: #2070015)
  * buildflags: document RUSTFLAGS
  * buildflags: Always set RUSTFLAGS
  * buildflags: set origin of env vars for ELF package metadata

 -- Benjamin Drung <email address hidden> Fri, 21 Jun 2024 18:46:10 +0200

Changed in dpkg (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.