On Mon, Jul 20, 2015 at 10:04:32PM +0200, Tollef Fog Heen wrote: > ]] Helmut Grohne > > 1. Triggering on /usr/bin/$arch-gcc is equivalent to triggering on > > /usr/bin, because triggers cannot contain wildcards. Triggering on > > /usr/bin is equivalent to triggering on every other package > > installation. This sounds like a very bad idea. > > The list of arches is effectively static (and can be gotten from dpkg), > so I don't see why that matters. You'd just add a trigger on all of > them.
Given that I am in the bootstrap business, I disagree. In the short time that I worked with cross building, that static list changed four times. By copying it into pkg-config, you inflict this pain to architecture bootstrappers. Please don't. > That doesn't matter, you still need build-essential installed, which > pulls in gcc. That argument is moot unless pkg-config actually depends on build-essential. Currently, you can use pkg-config without build-essential or a compiler. But let's just drop triggers and move to something where we can agree: > > +post-invoke=if test \( "$DPKG_HOOK_ACTION" = add-architecture -o > > "$DPKG_HOOK_ACTION" = remove-architecture \) -a -x > > /usr/share/pkg-config-dpkghook; then /usr/share/pkg-config-dpkghook update; > > fi > > That runs in shell context and -o / -a are XSIsms, so should probably > rather use && and || instead. I updated the patch to address this concern. I also added a dependency on libdpkg-perl, which was missing in the previous patch (forgot to regenerate it, sorry). > From a quick skim, it looks pretty good. I'll certainly play with this > and assuming I don't encounter problems or concerns, merge it. Looking forward to finally finding a solution to this problem. Lots of packages currently FTCBFS due to this. From the top 50 packages by popcon, man-db, libedit, libx11, openssh, util-linux, and wget all fail due to this. Helmut
diff -u pkg-config-0.28/debian/changelog pkg-config-0.28/debian/changelog --- pkg-config-0.28/debian/changelog +++ pkg-config-0.28/debian/changelog @@ -1,3 +1,11 @@ +pkg-config (0.28-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Add symlinks to pkg-config-crosswrapper using dpkg hooks. (Closes: + #759556) + + -- Helmut Grohne <[email protected]> Fri, 12 Jun 2015 23:02:08 +0200 + pkg-config (0.28-1) unstable; urgency=medium * New upstream release. (Closes: #699476, #744031) diff -u pkg-config-0.28/debian/control pkg-config-0.28/debian/control --- pkg-config-0.28/debian/control +++ pkg-config-0.28/debian/control @@ -9,7 +9,9 @@ Package: pkg-config Architecture: any Multi-Arch: foreign -Depends: ${shlibs:Depends}, ${misc:Depends} +Depends: ${shlibs:Depends}, ${misc:Depends}, +# pkg-config-dpkghook uses Dpkg::Arch + libdpkg-perl Description: manage compile and link flags for libraries pkg-config is a system for managing library compile and link flags that works with automake and autoconf. diff -u pkg-config-0.28/debian/pkg-config.install pkg-config-0.28/debian/pkg-config.install --- pkg-config-0.28/debian/pkg-config.install +++ pkg-config-0.28/debian/pkg-config.install @@ -1,0 +2,2 @@ +debian/pkg-config-dpkghook usr/share +debian/pkg-config-hook-config etc/dpkg/dpkg.cfg.d/ diff -u pkg-config-0.28/debian/rules pkg-config-0.28/debian/rules --- pkg-config-0.28/debian/rules +++ pkg-config-0.28/debian/rules @@ -30,7 +30,7 @@ override_dh_auto_clean: [ ! -f Makefile ] || $(MAKE) distclean DIST_SUBDIRS="check" - chmod +x debian/pkg-config-crosswrapper + chmod +x debian/pkg-config-crosswrapper debian/pkg-config-dpkghook override_dh_auto_test: dh_auto_test -- TESTS_ENVIRONMENT=PKG_CONFIG=../pkg-config LOG_COMPILER=/bin/bash only in patch2: unchanged: --- pkg-config-0.28.orig/debian/pkg-config-dpkghook +++ pkg-config-0.28/debian/pkg-config-dpkghook @@ -0,0 +1,51 @@ +#!/usr/bin/perl +# +# Sets up /usr/bin/*-pkg-config symlinks to point to the cross wrapper. +# +# It is called from dpkg --post-invoke and from postinst with the "update" +# argument to instate the necessary symlinks. +# +# It is called from prerm with the "remove" argument to remove all symlinks. +# + +use strict; +use warnings; + +use Dpkg::Arch qw(debarch_to_gnutriplet); +use Dpkg::ErrorHandling qw(error); + +my $crosswrapper = "/usr/share/pkg-config-crosswrapper"; + +my $action = $ARGV[0]; +error("parameter must be 'remove' or 'update'") + unless defined $action && ($action eq "remove" || $action eq "update"); + +my $arch = `dpkg --print-architecture`; +error('dpkg --print-architecture failed') if $? >> 8; +my @architectures = `dpkg --print-foreign-architectures`; +error('dpkg --print-foreign-architectures failed') if $? >> 8; +push @architectures, $arch; +chomp @architectures; + +my %gnutriplets = map { debarch_to_gnutriplet($_) => 1 } @architectures; + +my %symlinks = map { $_ => 1 } </usr/bin/*-pkg-config>; + +foreach my $symlink (keys %symlinks) { + $symlink =~ m,^/usr/bin/([^-]+-[^-]+-[^-]+)-pkg-config, or next; + next if exists $gnutriplets{$1} && $action eq "update"; + next unless -l $symlink; + next unless readlink $symlink eq $crosswrapper; + unlink $symlink or + error("failed to remove symlink $symlink: $!"); +} + +if ($action eq 'update') { + foreach (keys %gnutriplets) { + my $linktarget = "/usr/bin/${_}-pkg-config"; + next if exists $symlinks{$linktarget}; + next if -e $linktarget; + symlink $crosswrapper, $linktarget or + error("failed to create symlink $linktarget to $crosswrapper: $!"); + } +} only in patch2: unchanged: --- pkg-config-0.28.orig/debian/pkg-config-hook-config +++ pkg-config-0.28/debian/pkg-config-hook-config @@ -0,0 +1 @@ +post-invoke=if { test "$DPKG_HOOK_ACTION" = add-architecture || test "$DPKG_HOOK_ACTION" = remove-architecture; } && test -x /usr/share/pkg-config-dpkghook; then /usr/share/pkg-config-dpkghook update; fi only in patch2: unchanged: --- pkg-config-0.28.orig/debian/pkg-config.postinst +++ pkg-config-0.28/debian/pkg-config.postinst @@ -0,0 +1,7 @@ +#!/bin/sh + +#DEBHELPER# + +if test "$1" = configure; then + /usr/share/pkg-config-dpkghook update +fi only in patch2: unchanged: --- pkg-config-0.28.orig/debian/pkg-config.prerm +++ pkg-config-0.28/debian/pkg-config.prerm @@ -0,0 +1,7 @@ +#!/bin/sh + +#DEBHELPER# + +if test "$1" = remove; then + /usr/share/pkg-config-dpkghook remove +fi

