Source: golang Severity: normal Tags: patch -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
In order to make Go packages available on as many architectures as possible, we can make these packages depend on gccgo on architectures where golang-go is not yet available. Initially, I suggested patching dh-make-golang to expand the Build-Depends field in the automatically generated debian/control template for Go programs (dh-make-golang -type program)like so: Build-Depends: golang-go [amd64 arm64 armel armhf i386 ppc64 ppc64el], gccgo [!amd64 !arm64 !armel !armhf !i386 !ppc64 !ppc64el] However, that would mean a massive effort in updating many such packages every time golang-go supports a new architecture. As per discussion at https://github.com/Debian/dh-make-golang/pull/36 on GitHub, it was decided that a golang-any package should be created in src:golang instead, so for Go program-type packages that need it, a simple "Build-Depends: golang-any" suffices in providing the default Go compiler for each architecture. Excerpts from our earlier discussion on GitHub: @stapelberg: > It’s a bit unfortunate that we’d have to maintain the list of > architectures if we merged this pull request. Especially since it might > change in the future, and then we’d need to update all our packages. I’m > not saying this isn’t doable, but I’m not aware of any communication > with regards to mass-changes in our packages. > > Is there a way with which we can use golang-go or gccgo automatically, > depending on availability? E.g. Depends: golang-go | gccgo? @anthonyfok (foka): > It is indeed a bit unfortunate, but it seems to be the only way it > would work with sbuild (buildd.debian.org) because, as we are now all > aware, sbuild ignores alternatives in Build-Depends, so Build-Depends: > golang-go | gccgo does not work. > > ... > > Or, another way, perhaps, would be to create some kind of a > architecture-specific default-golang (just a random name that popped > into my head) that depends on golang-go or gccgo depending on which > architecture it is? That way, it is only one package to maintain. @stapelberg: > That sounds reasonable to me, at least as a workaround for the time > being. I think a slightly better naming choice might be golang-any > > @tianon @paultag Do you agree to have golang-any in src:golang? @tianon: > I definitely like the golang-any solution better than what was proposed > in 780355. :+1: (Although really interested in @paultag's thoughts on > the subject too.) @paultag: > Yeah, maintaining a list of arches on every source package seems like it > won't scale super well. I don't really want to get into bike shedding a > name, so golang-any sounds great. > > As for the concept of golang-any, it's interesting. It matches with my > worldview and will give us a single place to pick a golang compiler. > This might come in handy once (or rather, if) we need to have two > versions of go in the archive at the same time. > > I'm with @tianon, sounds better than other ideas so far, anyway. > > I say let's go for it. @stapelberg: > Great, it looks like we all agree. > > @anthonyfok Could you prepare a patch to add the golang-any package to > the golang source package please? Attached is the patch to do so. It has been tested on my amd64 laptop and on zelenka.debian.org (s390x porterbox). Cheers, Anthony - -- System Information: Debian Release: stretch/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.5.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) - -- no debconf information -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCAAGBQJXID+kAAoJEOolALQSxZrPzwkQAJDrZx64lmI83ovAV8XBEDyq dB/JY8Y5sf698Rw5+mCaUkFrw/AMIaRlLrC8PUoOO9Hfll9aeqnbO9YogoJIZoKV WQVE3JIwyHpRqI4b8NyYAx6WwkgQG6osXcyyvw1KCugqK+ffFuIiioo28c1T6uzm RAzIlBzVKUdh4eX+gdwLxEp1PbnWjvSrS3UcqWMGna82NQL+ihxex+Yh0TebP2YY 2z4NUsVRK8exstMOTR93lry67/rNGU2ip1gWO7Ag0TMVJMovaYDaodMjpQ+BIH4W kgR13TwckZZdc23HCinahBHCUCI4y18tULxAXk4nq6OfsEvhM8bfXgsuwSIXsjaz mf31ZurOxqWOfpTHMMut1fG2coGxwdZgXg75zX0gT/mtf9TeIJ36IsavE33fKfrk tihsiyBZgWl58pDCLe0+HmAArJQKAiRdMZoFcS5KXpjGvyAxd4iG7tARB1rTJj+Q FCOhz5yerS4vcFL86ztuhdB9Ay+/HsQpQD3ZrdNObR/VaZ3fWxFOklCb0192OsPj hFacycVPOc4gO2RhW0aMLep0jBIcgxYXtGnXcppAT5WMxH4tcDrAnVSuVr9qH3bJ P59TwSQgRR38+aGCTsFC5f6BSsXVvRbee2pBMRX5cUFM8IvL21aGf6xhpSNKqBD6 8KiZ4Q5m49e+CpbDM1ld =8iS9 -----END PGP SIGNATURE-----
--- a/debian/control +++ b/debian/control @@ -124,3 +124,14 @@ Description: Go programming language compiler - metapackage . This package is a metapackage that, when installed, guarantees that (most of) a full Go development environment is installed. + +Package: golang-any +Priority: extra +Depends: golang-go [amd64 arm64 armel armhf i386 ppc64 ppc64el], + gccgo [!amd64 !arm64 !armel !armhf !i386 !ppc64 !ppc64el] +Architecture: any +Description: Go compiler - dependency package for Debian packaging + This is a dependency package which installs the default Go compiler + for the architecture, i.e., golang-go (gc compiler) where available, + and gccgo if otherwise. This simplifies the Build-Depends field for + Debian packaging of software written in the Go programming language. --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,12 @@ export GOROOT := $(CURDIR) export GOROOT_FINAL := /usr/lib/go DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null) +RUN_BUILD := true RUN_TESTS := true +ifeq (,$(findstring $(DEB_HOST_ARCH_CPU),amd64 arm64 armel armhf i386 ppc64 ppc64el)) + RUN_BUILD := false + RUN_TESTS := false +endif ifeq (ppc64, $(DEB_HOST_ARCH_CPU)) RUN_TESTS := false endif @@ -56,6 +61,7 @@ override_dh_install-indep: override_dh_install-arch: dh_install --fail-missing +ifeq (true, $(RUN_BUILD)) # Remove Plan9 rc(1) scripts find debian/golang-src/usr/share/go/src -type f -name '*.rc' -delete # Remove empty /usr/share/go/src from golang-go, it is provided by golang-src @@ -63,6 +69,9 @@ override_dh_install-arch: # Touch built and installed files and directories to have same timestamp touch debian/golang-go/usr/lib/go/pkg find debian/golang-go/usr/lib/go/pkg -exec touch -r $(CURDIR)/debian/golang-go/usr/lib/go/pkg {} \; +else + # skip installing golang-go and golang-src on unsupported platforms +endif override_dh_strip: dh_strip -Xtestdata @@ -71,11 +80,15 @@ override_dh_shlibdeps: dh_shlibdeps -Xtestdata -Xtest override_dh_auto_build-arch: +ifeq (true, $(RUN_BUILD)) [ -f VERSION ] || echo "debian snapshot +$$(dpkg-parsechangelog -SVersion)" > VERSION export GOROOT_BOOTSTRAP=$$(env -i go env GOROOT) \ && cd src \ && $(CURDIR)/debian/helpers/goenv.sh \ bash ./make.bash --no-banner +else + # skip building golang-go and golang-src on unsupported platforms +endif opt_no_act := ifneq (,$(findstring n,$(MAKEFLAGS)))