Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 289094

Summary: app-arch/dpkg bootstrap problem breaks dpkg-architecture
Product: Gentoo Linux Reporter: Fiona Klute <fiona.klute>
Component: Current packagesAssignee: Debian-related package maintainers [DISBANDED] <deb-tools+disabled>
Status: RESOLVED FIXED    
Severity: minor CC: java
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 266733    
Attachments: Set $pkgdatadir to srcdir in configure
Do the previous thing and also FIX the FIXME in Arch.pm

Description Fiona Klute 2009-10-14 19:53:25 UTC
After a fresh install of app-arch/dpkg, "dpkg --print-architecture" and subsequently "dpkg-architecture" will return broken output. "dpkg --print-architecture" prints just an empty line. "dpkg-architecture" uses this to determine the values of the DEB_BUILD_* variables. The results are empty DEB_BUILD_* vars and some warnings from perl. Additionally, both commands do not return error codes, which breaks scripts relying on dpkg-architecture. Recompiling app-arch/dpkg fixes the problem.
(If you want to know how this bug was found, see bug #266733.)

Reproducible: Always

Steps to Reproduce:
1. Uninstall app-arch/dpkg if it is installed
2. Install app-arch/dpkg
3. Run "dpkg-architecture" or "dpkg --print-architecture"
Actual Results:  
Output of "dpkg-architecture" and "dpkg --print-architecture" on my amd64-system:

$ dpkg --print-architecture

$ dpkg-architecture 
Use of uninitialized value in split at /usr/bin/dpkg-architecture line 184.
DEB_BUILD_ARCH=
Use of uninitialized value in concatenation (.) or string at /usr/bin/dpkg-architecture line 195.
DEB_BUILD_ARCH_OS=
Use of uninitialized value in concatenation (.) or string at /usr/bin/dpkg-architecture line 195.
DEB_BUILD_ARCH_CPU=
Use of uninitialized value in concatenation (.) or string at /usr/bin/dpkg-architecture line 195.
DEB_BUILD_ARCH_BITS=
Use of uninitialized value in concatenation (.) or string at /usr/bin/dpkg-architecture line 195.
DEB_BUILD_ARCH_ENDIAN=
Use of uninitialized value in concatenation (.) or string at /usr/bin/dpkg-architecture line 195.
DEB_BUILD_GNU_CPU=
Use of uninitialized value in concatenation (.) or string at /usr/bin/dpkg-architecture line 195.
DEB_BUILD_GNU_SYSTEM=
Use of uninitialized value in concatenation (.) or string at /usr/bin/dpkg-architecture line 195.
DEB_BUILD_GNU_TYPE=
DEB_HOST_ARCH=amd64
DEB_HOST_ARCH_OS=linux
DEB_HOST_ARCH_CPU=amd64
DEB_HOST_ARCH_BITS=64
DEB_HOST_ARCH_ENDIAN=little
DEB_HOST_GNU_CPU=x86_64
DEB_HOST_GNU_SYSTEM=linux-gnu
DEB_HOST_GNU_TYPE=x86_64-linux-gnu

Expected Results:  
After recompiling app-arch/dpkg, both "dpkg-architecture" and "dpkg --print-architecture" produce sane output. 

$ dpkg --print-architecture
amd64
$ dpkg-architecture 
DEB_BUILD_ARCH=amd64
DEB_BUILD_ARCH_OS=linux
DEB_BUILD_ARCH_CPU=amd64
DEB_BUILD_ARCH_BITS=64
DEB_BUILD_ARCH_ENDIAN=little
DEB_BUILD_GNU_CPU=x86_64
DEB_BUILD_GNU_SYSTEM=linux-gnu
DEB_BUILD_GNU_TYPE=x86_64-linux-gnu
DEB_HOST_ARCH=amd64
DEB_HOST_ARCH_OS=linux
DEB_HOST_ARCH_CPU=amd64
DEB_HOST_ARCH_BITS=64
DEB_HOST_ARCH_ENDIAN=little
DEB_HOST_GNU_CPU=x86_64
DEB_HOST_GNU_SYSTEM=linux-gnu
DEB_HOST_GNU_TYPE=x86_64-linux-gnu

The value returned by "dpkg --print-architecture" is set at configure-time by calling the to-be-installed dpkg-architecture (see m4/arch.m4 in the dpkg source). This doesn't work properly if dpkg is not available (see FIXME comment in sub get_raw_build_arch() in the Dpkg::Arch module).
I was able to reproduce the bug with dpkg 1.15.2 and 1.15.4. It is probably safe to assume that it applies to 1.15.3 and 1.15.3.1 as well.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-05 06:14:02 UTC
That's quite funny actually. So the steps to reproduce would go like this:

emerge -C dpkg; emerge dpkg && dpkg-architecture
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-05 06:49:21 UTC
(In reply to comment #0)
> The value returned by "dpkg --print-architecture" is set at configure-time by
> calling the to-be-installed dpkg-architecture (see m4/arch.m4 in the dpkg
> source). This doesn't work properly if dpkg is not available (see FIXME
> comment in sub get_raw_build_arch() in the Dpkg::Arch module).

The real question is, why /does/ it work the second time? What has in the mean time put the information in the right place for the second emerge to install a useful program after all? Is it as simple as fixing the path where the script is found in the ./configure script? Or the paths to ostable, cputable and so on?

> I was able to reproduce the bug with dpkg 1.15.2 and 1.15.4. It is probably
> safe to assume that it applies to 1.15.3 and 1.15.3.1 as well.

All versions in the tree suffer this problem. Luckily, only few packages in the tree use dpkg-architecture. :)
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-05 07:08:38 UTC
Created attachment 218489 [details, diff]
Set $pkgdatadir to srcdir in configure

Good you give this patch a spin, please? I am thinking about preparing a similar configure.ac patch (in m4/dpkg-arch.m4 that is) that $upstream might want.
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-05 07:29:26 UTC
Comment on attachment 218489 [details, diff]
Set $pkgdatadir to srcdir in configure

No, this isn't in itself going to work. Even the m4 version I prepared would fail because in its ultimate wisdom, dpkg-architecture ends up calling `dpkg --print-architecture', which, hey, isn't installed yet, and worse still, isn't built yet at ./configure time. :-\
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-05 08:00:07 UTC
Created attachment 218499 [details, diff]
Do the previous thing and also FIX the FIXME in Arch.pm

The additional patch in this file simply makes sure that when dpkg isn't found, DEB_BUILD_ARCH equals DEB_HOST_ARCH. Please try it out.
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-05 08:03:04 UTC
With the patch, you should now see something like:

astrid ~ # emerge -C dpkg; emerge -v dpkg && dpkg-architecture
[...]
>>> /etc/dpkg/
>>> /etc/dpkg/dpkg.cfg.d/
>>> /etc/dpkg/dselect.cfg.d/
>>> /etc/alternatives/
>>> /etc/alternatives/README
>>> Regenerating /etc/ld.so.cache...
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.
DEB_BUILD_ARCH=i386
DEB_BUILD_ARCH_OS=linux
DEB_BUILD_ARCH_CPU=i386
DEB_BUILD_ARCH_BITS=32
DEB_BUILD_ARCH_ENDIAN=little
DEB_BUILD_GNU_CPU=i486
DEB_BUILD_GNU_SYSTEM=linux-gnu
DEB_BUILD_GNU_TYPE=i486-linux-gnu
DEB_HOST_ARCH=i386
DEB_HOST_ARCH_OS=linux
DEB_HOST_ARCH_CPU=i386
DEB_HOST_ARCH_BITS=32
DEB_HOST_ARCH_ENDIAN=little
DEB_HOST_GNU_CPU=i486
DEB_HOST_GNU_SYSTEM=linux-gnu
DEB_HOST_GNU_TYPE=i486-linux-gnu
Comment 7 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-05 08:19:39 UTC
Or more conveniently, try dpkg-1.15.5.6-r1 which is in the tree now to specifically solve this issue. Reopen this bug report if it turns out to be unsatisfactory.
Comment 8 Fiona Klute 2010-02-06 09:49:56 UTC
app-arch/dpkg-1.15.5.6-r1 works after a fresh install, thanks.