Source: gcc-defaults
Version: 1.219
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

Hi Matthias,

I am sorry for having introduced another problem into the gcc packaging.
As it turns out the *-for-host packages are not actually coinstallable
at present even though they should be. Attempting to do so results in an
unpack error. The root cause for this is the way I implemented
documentation linking where the TOOL-for-host package links to the
TOOL-GNU_TRIPLET package and that triplet is architecture-dependent of
course.

For the cpp-for-host package, there is no more fundamental package that
we could link documentation to, so I propose that it gains a real
documentation directory (thus incurring a symlink_to_dir conversion).
All other *-for-host packages transitively depend on cpp-for-host
already, so I propose making that dependency explicit and linking there.
Please find a patch implementing this conversion attached.

I tested the upgrade path and noticed that after unpacking the
documentation links are not updated reliably. This is due to a corner
case in dpkg where it looks up the actual link targets and if both the
old link and the new link refer to the same directory, it skips
replacing the symbolic link on disk. In a typical upgrade, cpp-for-host
is not the first package to be unpacked and therefore, some of the other
*-for-host packages' documentation links are not updated. (Thanks to
Guillem for pointing at
https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/src/main/archives.c#n793
for understanding the cause.)

It is not clear to me whether this is worth mitigating. The old
documentation symlinks will continue to be valid as we do not loosen any
dependencies. Also dpkg --verify does not spot any issue as the dpkg
database does not record link targets. If the *-for-host packages are
upgraded another time, the links will be corrected. Since the *-for-host
packages have not been part of bookworm and I expect that two more
versions of gcc-defaults reach testing before we release trixie, this
may be a fair compromise.

The alternative likely is adding more maintainer scripts in a similar
way to dpkg-maintscript-helper for doing a symlink_to_symlink
conversion. Let me know if you prefer this route, but I note that we'd
be adding 21 maintainer scripts.

Helmut
diff --minimal -Nru gcc-defaults-1.219/debian/changelog 
gcc-defaults-1.219+nmu1/debian/changelog
--- gcc-defaults-1.219/debian/changelog 2024-07-23 11:22:47.000000000 +0200
+++ gcc-defaults-1.219+nmu1/debian/changelog    2024-09-18 14:17:40.000000000 
+0200
@@ -1,3 +1,10 @@
+gcc-defaults (1.219+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix Multi-Arch coinstallability of *-for-host packages. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Wed, 18 Sep 2024 14:17:40 +0200
+
 gcc-defaults (1.219) unstable; urgency=medium
 
   * Build gdc and gm2 packages for loong64. Closes: #1069714,
diff --minimal -Nru gcc-defaults-1.219/debian/control 
gcc-defaults-1.219+nmu1/debian/control
--- gcc-defaults-1.219/debian/control   2024-07-23 11:22:47.000000000 +0200
+++ gcc-defaults-1.219+nmu1/debian/control      2024-09-18 14:17:40.000000000 
+0200
@@ -372,7 +372,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: g++${native:suffix} (= ${version:gpp}), cpp${native:suffix} (= 
${version:cpp}),
-  gcc-for-host (= ${version:gcc}), g++-${pv:gpp}-for-host ${reqv:gpp},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
g++-${pv:gpp}-for-host ${reqv:gpp},
   ${misc:Depends}
 Description: GNU C++ compiler for the host architecture
  This is the GNU C++ compiler, a fairly portable optimizing compiler for C++.
@@ -425,7 +425,7 @@
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}),
   gcc${native:suffix} (>= ${version:cpp}), gobjc${native:suffix} (= 
${version:gobjc}),
-  gcc-for-host (= ${version:gcc}), gobjc-${pv:gobjc}-for-host ${reqv:gobjc},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gobjc-${pv:gobjc}-for-host ${reqv:gobjc},
   ${misc:Depends}
 Description: GNU Objective-C compiler for the host architecture
  This is the GNU Objective-C compiler, which compiles Objective-C on platforms
@@ -482,7 +482,7 @@
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}),
   gcc${native:suffix} (>= ${version:cpp}), gobjc++${native:suffix} (= 
${version:gobjcxx}),
-  gobjc-for-host (= ${version:gobjc}), g++-for-host (= ${version:gpp}),
+  cpp-for-host (= ${version:cpp}), gobjc-for-host (= ${version:gobjc}), 
g++-for-host (= ${version:gpp}),
   gobjc++-${pv:gobjcxx}-for-host ${reqv:gobjcxx}, ${misc:Depends}
 Description: GNU Objective-C++ compiler for the host architecture
  This is the GNU Objective-C++ compiler, which compiles
@@ -538,7 +538,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}), gcc${native:suffix} (= 
${version:gcc}),
-  gcc-for-host (= ${version:gcc}), gfortran-${pv:gfort}-for-host ${reqv:gfort},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gfortran-${pv:gfort}-for-host ${reqv:gfort},
   gfortran${native:suffix} (= ${version:gfort}), ${misc:Depends}
 Description: GNU Fortran 95 compiler for the host architecture
  This is the GNU Fortran 95 compiler, which compiles Fortran 95 on platforms
@@ -592,7 +592,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}), gcc${native:suffix} (>= 
${version:gcc}),
-  gcc-for-host (= ${version:gcc}), gccgo-${pv:ggo}-for-host ${reqv:ggo},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gccgo-${pv:ggo}-for-host ${reqv:ggo},
   gccgo${native:suffix} (= ${version:ggo}), ${misc:Depends}
 Description: Go compiler, based on the GCC backend for the host architecture
  This is the GNU Go compiler, which compiles Go on platforms supported by
@@ -644,7 +644,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: gdc${native:suffix} (= ${version:gdc}), ${dep:libgphobos},
-  gcc-for-host (= ${version:gcc}), gdc-${pv:gdc}-for-host ${reqv:gdc}, 
${misc:Depends}
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gdc-${pv:gdc}-for-host ${reqv:gdc}, ${misc:Depends}
 Description: D compiler (language version 2) for the host architecture
  This is a dependency package providing the default D compiler.
  Per policy, all packages that contain D sources must use this package
@@ -701,7 +701,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}), gm2${native:suffix} (= 
${version:gm2}),
-  gcc-for-host (= ${version:gcc}), gm2-${pv:gm2}-for-host ${reqv:gm2}, 
${misc:Depends}
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gm2-${pv:gm2}-for-host ${reqv:gm2}, ${misc:Depends}
 Description: GNU Modula-2 compiler for the host architecture, based on the GCC 
backend
  This is a dependency package providing the default GNU Modula-2 compiler.
  .
diff --minimal -Nru gcc-defaults-1.219/debian/control.native.in 
gcc-defaults-1.219+nmu1/debian/control.native.in
--- gcc-defaults-1.219/debian/control.native.in 2024-01-27 18:41:19.000000000 
+0100
+++ gcc-defaults-1.219+nmu1/debian/control.native.in    2024-09-18 
14:17:40.000000000 +0200
@@ -361,7 +361,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: g++${native:suffix} (= ${version:gpp}), cpp${native:suffix} (= 
${version:cpp}),
-  gcc-for-host (= ${version:gcc}), g++-${pv:gpp}-for-host ${reqv:gpp},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
g++-${pv:gpp}-for-host ${reqv:gpp},
   ${misc:Depends}
 Description: GNU C++ compiler for the host architecture
  This is the GNU C++ compiler, a fairly portable optimizing compiler for C++.
@@ -414,7 +414,7 @@
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}),
   gcc${native:suffix} (>= ${version:cpp}), gobjc${native:suffix} (= 
${version:gobjc}),
-  gcc-for-host (= ${version:gcc}), gobjc-${pv:gobjc}-for-host ${reqv:gobjc},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gobjc-${pv:gobjc}-for-host ${reqv:gobjc},
   ${misc:Depends}
 Description: GNU Objective-C compiler for the host architecture
  This is the GNU Objective-C compiler, which compiles Objective-C on platforms
@@ -471,7 +471,7 @@
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}),
   gcc${native:suffix} (>= ${version:cpp}), gobjc++${native:suffix} (= 
${version:gobjcxx}),
-  gobjc-for-host (= ${version:gobjc}), g++-for-host (= ${version:gpp}),
+  cpp-for-host (= ${version:cpp}), gobjc-for-host (= ${version:gobjc}), 
g++-for-host (= ${version:gpp}),
   gobjc++-${pv:gobjcxx}-for-host ${reqv:gobjcxx}, ${misc:Depends}
 Description: GNU Objective-C++ compiler for the host architecture
  This is the GNU Objective-C++ compiler, which compiles
@@ -528,7 +528,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}), gcc${native:suffix} (= 
${version:gcc}),
-  gcc-for-host (= ${version:gcc}), gfortran-${pv:gfort}-for-host ${reqv:gfort},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gfortran-${pv:gfort}-for-host ${reqv:gfort},
   gfortran${native:suffix} (= ${version:gfort}), ${misc:Depends}
 Description: GNU Fortran 95 compiler for the host architecture
  This is the GNU Fortran 95 compiler, which compiles Fortran 95 on platforms
@@ -582,7 +582,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}), gcc${native:suffix} (>= 
${version:gcc}),
-  gcc-for-host (= ${version:gcc}), gccgo-${pv:ggo}-for-host ${reqv:ggo},
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gccgo-${pv:ggo}-for-host ${reqv:ggo},
   gccgo${native:suffix} (= ${version:ggo}), ${misc:Depends}
 Description: Go compiler, based on the GCC backend for the host architecture
  This is the GNU Go compiler, which compiles Go on platforms supported by
@@ -634,7 +634,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: gdc${native:suffix} (= ${version:gdc}), ${dep:libgphobos},
-  gcc-for-host (= ${version:gcc}), gdc-${pv:gdc}-for-host ${reqv:gdc}, 
${misc:Depends}
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gdc-${pv:gdc}-for-host ${reqv:gdc}, ${misc:Depends}
 Description: D compiler (language version 2) for the host architecture
  This is a dependency package providing the default D compiler.
  Per policy, all packages that contain D sources must use this package
@@ -691,7 +691,7 @@
 Architecture: any
 Multi-Arch: same
 Depends: cpp${native:suffix} (= ${version:cpp}), gm2${native:suffix} (= 
${version:gm2}),
-  gcc-for-host (= ${version:gcc}), gm2-${pv:gm2}-for-host ${reqv:gm2}, 
${misc:Depends}
+  cpp-for-host (= ${version:cpp}), gcc-for-host (= ${version:gcc}), 
gm2-${pv:gm2}-for-host ${reqv:gm2}, ${misc:Depends}
 Description: GNU Modula-2 compiler for the host architecture, based on the GCC 
backend
  This is a dependency package providing the default GNU Modula-2 compiler.
  .
diff --minimal -Nru gcc-defaults-1.219/debian/cpp-for-host.maintscript.in 
gcc-defaults-1.219+nmu1/debian/cpp-for-host.maintscript.in
--- gcc-defaults-1.219/debian/cpp-for-host.maintscript.in       1970-01-01 
01:00:00.000000000 +0100
+++ gcc-defaults-1.219+nmu1/debian/cpp-for-host.maintscript.in  2024-09-18 
14:17:40.000000000 +0200
@@ -0,0 +1 @@
+symlink_to_dir /usr/share/doc/cpp-for-host cpp@NATIVE_SUFFIX@ 4:14.1.0-2
diff --minimal -Nru gcc-defaults-1.219/debian/rules 
gcc-defaults-1.219+nmu1/debian/rules
--- gcc-defaults-1.219/debian/rules     2024-07-23 11:22:47.000000000 +0200
+++ gcc-defaults-1.219+nmu1/debian/rules        2024-09-18 14:17:40.000000000 
+0200
@@ -789,7 +789,7 @@
        rm -rf build
        rm -f debian/control.tmp*
        rm -f debian/substvars.*
-       rm -f debian/cpp.maintscript debian/gcc.postinst debian/g++.postinst 
debian/gdc.maintscript debian/gfortran.postinst
+       rm -f debian/cpp.maintscript debian/gcc.postinst debian/g++.postinst 
debian/gdc.maintscript debian/gfortran.postinst debian/cpp-for-host.maintscript
        dh_clean
 
 pre-install: build substvars
@@ -812,6 +812,8 @@
        dh_link -pcpp \
          /usr/bin/cpp-$(PV_CPP) /usr/bin/cpp \
          /usr/share/doc/cpp$(NATIVE_SUFFIX) /usr/share/doc/cpp
+       sed -e 's/@NATIVE_SUFFIX@/$(NATIVE_SUFFIX)/g' \
+               debian/cpp-for-host.maintscript.in > 
debian/cpp-for-host.maintscript
 
   ifeq ($(with_gfdl_docs),yes)
        for i in gfdl.7 gpl.7 fsf-funding.7; do \
@@ -964,7 +966,7 @@
 ifneq (,$(filter gdc-for-host, $(packages)))
        : # gdc-for-host
        dh_installdirs -pgdc-for-host
-       dh_link -pgdc-for-host /usr/share/doc/gdc$(NATIVE_SUFFIX) 
/usr/share/doc/gdc-for-host
+       dh_link -pgdc-for-host /usr/share/doc/cpp-for-host 
/usr/share/doc/gdc-for-host
 endif
 
 ifneq (,$(filter gm2, $(packages)))
@@ -1358,10 +1360,12 @@
        dh_testroot
 #      dh_installdebconf
        dh_installdocs -pcpp$(NATIVE_SUFFIX)
-       for p in `dh_listpackages -a $(nopkgs_native) -Ncpp$(NATIVE_SUFFIX) 
$(if $(filter yes,$(with_gfdl_docs)),-Ncpp-doc -Ngcc-doc -Ngfortran-doc 
-Ngccgo-doc) -Ngdc -Ngdc$(NATIVE_SUFFIX) -Ngdc-for-host -Nlibgphobos-dev`; do \
+       dh_installdocs -pcpp-for-host
+       for p in `dh_listpackages -a $(nopkgs_native) -Ncpp$(NATIVE_SUFFIX) 
-Ncpp-for-host $(if $(filter yes,$(with_gfdl_docs)),-Ncpp-doc -Ngcc-doc 
-Ngfortran-doc -Ngccgo-doc) -Ngdc -Ngdc$(NATIVE_SUFFIX) -Ngdc-for-host 
-Nlibgphobos-dev`; do \
          case "$$p" in \
            *$(NATIVE_SUFFIX)) t=cpp$(NATIVE_SUFFIX) ;; \
            *-gnu*|*-kfreebsd*|gcc-hppa64-linux-gnu) continue;; \
+           *-for-host) t=cpp-for-host ;; \
            *) t=cpp$(NATIVE_SUFFIX); \
          esac; \
          echo ln -sf $$t debian/$$p/usr/share/doc/$$p; \
@@ -1372,6 +1376,7 @@
 
        for p in \
          cpp$(NATIVE_SUFFIX) \
+         cpp-for-host \
          $(if $(filter $(DEB_HOST_ARCH), $(d_archs)), gdc$(NATIVE_SUFFIX)) \
          $(if $(filter $(DEB_HOST_ARCH), $(phobos_archs)), libgphobos-dev); \
        do \

Reply via email to