Contents
Upstream Module Relocations & Re-Naming Guideline
Based on recent mailing list discussions regarding package renames:
1. Import Path Changes: Changing an upstream import path(eg: append major version) requires a new source/binary package, a ITP bug(mention if it's rename for Module-Aware Builds or upstream rename), and DFSG team is already aware during ?DebConf26 that these renamed package will going through the NEW queue very quickly.
2. Git History: When creating new Salsa repositories for renamed modules, please fork/copy git history from the original repository rather than running a fresh dh-make-golang make.
3. Naming Conventions (Hyphens vs. Dots): Convert slashes (/) in Go import paths into hyphens (-) rather than dots (.) when naming Debian packages (e.g., /v3 becomes -v3, and /pkg.v3 becomes -pkg.v3). Because dots are valid characters inside domain names and paths, using hyphens avoids naming confusion in the future.
4. Verification: When you unsure, check https://pkg.go.dev to align the major version with the package name before renaming.
Debian Go Team - Module-Aware Builds Migration FAQ
This page tracks common build issues encountered during the migration to modern, module-aware builds with dh-go and provides the recommended fixes and workarounds.
Based on our previous discussions on mailing list, here is the exact raw content we currently have structured for the MigrationFAQ wiki page.
Case-by-Case Breakdown
Align XS-Go-Import-Path
The Issue
If XS-Go-Import-Path in debian/control does not match the module path declared in upstream's go.mod (such as a missing /v2 or /v3 major version suffix), dh-go cannot construct the workspace directory structure.
This causes dependencies to fail during build time with an error similar to:
dh_auto_build: error: Unable to open directory debian/_build/src/github.com/foo/bar/v3 No such file or directory
Solution
When porting or updating a package to dh-go:
1. Align XS-Go-Import-Path: Find the module path on line 1 of the upstream go.mod file for example: github.com/foo/bar/v3.
2. Update debian/control: Ensure XS-Go-Import-Path matches the go.mod path verbatim:
XS-Go-Import-Path: github.com/foo/bar/v3
3. Handle Build Dependencies with Versioned Import Path (/v+):
Compare upstream go.mod against Build-Depends in debian/control. If a dependency uses a versioned import path e.g., github.com/foo/pub/v2, debian/control still references the unversioned legacy package, fork the repository under go-team/packages namespace on Salsa.
Rename source and binary package Follow the module-aware naming convention by appending the major version suffix e.g., rename source package to golang-github-foo-pub-v2 and binary package to golang-github-foo-pub-v2-dev.
Upload the renamed package: File an ITP or upload directly as appropriate.
4. Update Build-Depends: Switch your Go application's debian/control to build-depend on the new versioned -dev package (e.g., golang-github-foo-pub-v2-dev) and upload.
5. Do Not Delete Legacy Repositories: Leave existing legacy -dev packages untouched. Simon's zombie cleanup script will identify unreferenced dependencies and file RoM automatically when all reverse-dependency transitioned.
Unvendoring embedded libraries causes go.mod errors
Several upstreams include embedded/vendored copies of code from other libraries. This violates Debian Policy, and we generally have tried to remove the vendored copies when packaging the library for Debian. However, with the switch to module-aware builds, the go compiler complains if a downstream consumer's go.mod doesn't include the additional indirect dependency.
First seen with golang-github-klauspost-compress which vendors xxhash, this will likely affect several go libraries currently packaged for Debian.
We should probably have dh-golang dynamically refresh the go.mod file during build by running go mod tidy (or similar). Attempting to patch all consumers to modify their go.mod files won't scale well and will likely require frequent rebasing.
Double-nesting directory structure and misplaced go.mod (e.g. /v2/v2/go.mod)
Symptom
The package builds but results in a completely wrong and duplicated directory layout on the filesystem. The Go files are duplicated under both /v2 and /v2/v2, and the generated go.mod is placed in the wrong nested directory:
/usr/share/gocode/src/github.com/jcmturner/dnsutils/v2/srv.go /usr/share/gocode/src/github.com/jcmturner/dnsutils/v2/v2/srv.go /usr/share/gocode/src/github.com/jcmturner/dnsutils/v2/v2/go.mod
Cause
This is common in legacy .v2 Debian packages packaged around 2020 (the Go 1.13 version), where upstream did not use standard Go module layouts. Instead of a root go.mod, upstream often duplicated their entire codebase into a /v2 directory, placing the go.mod file only inside that subdirectory.
When Debian packaged these, the dh-golang got confused by the versioned suffix (like .v2 or /v2) and duplicated the directory structure, placing the go.mod file at /v2/v2/go.mod.
Furthermore, setting XS-Go-Import-Path to include /v2 (e.g., github.com/jcmturner/dnsutils/v2) is actually incorrect here, as the build system tries to append the version suffix a second time.
Solution
The clean way to resolve this is to correct the target import path metadata and manually patch the source root so that modern dh-golang builds it normally.
1. Fix metadata: Set XS-Go-Import-Path in debian/control to the root import path without the v2 suffix:
XS-Go-Import-Path: github.com/jcmturner/dnsutils
2. Add a root go.mod via patch: Since upstream is missing a proper top-level module configuration, write a minimal go.mod file for the root directory, run go mod tidy on it, and include this file as a Debian quilt patch:
module github.com/jcmturner/dnsutils/v2 go 1.13
3. Clean up debian/rules: Ensure that the helper tools are not instructed to copy or preserve the redundant nested /v2 subdirectory during the install phase.
How to pin the Major version release in watch file
Here is example that pin the Major Version to v60:
Version: 5 Source: https://github.com/google/go-github.git Matching-Pattern: refs/tags/v(60\.[\d.]+) Mode: git Uversionmangle: auto
