Package: dh-make-golang Version: 0.4.0-1+b1 Severity: normal File: /usr/bin/dh-make-golang
Dear Maintainer, Trying dh-make-golang on a git repo where upstream has a debian/ subdirectory errors with version 0.4.0. This patch temporarily moves aside an existing debian/ directory, and then moves it into debian/upstream_debian . Example of this error situation in v0.4.0: $ dh-make-golang make -type="prog" github.com/la5nta/pat ... 2021/02/20 21:51:01 Could not create debian/ from templates: mkdir /tmp/x0/pat/debian: file exists See attached patch or PR https://github.com/Debian/dh-make-golang/pull/158 for a workaround this issue. donfede -- System Information: Debian Release: bullseye/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-3-amd64 (SMP w/2 CPU threads) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages dh-make-golang depends on: ii git 1:2.30.0-1 ii git-buildpackage 0.9.22 ii golang-any 2:1.15~1 ii libc6 2.31-9 ii pristine-tar 1.49 Versions of packages dh-make-golang recommends: ii golang-golang-x-tools 1:0.1.0+ds-1 ii postfix [mail-transport-agent] 3.5.6-1 dh-make-golang suggests no packages. -- no debconf information Control: tag -1 patch --- template.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/template.go b/template.go index 4fe70c4..4db065a 100644 --- a/template.go +++ b/template.go @@ -16,7 +16,18 @@ func writeTemplates(dir, gopkg, debsrc, debLib, debProg, debversion string, ) error { if err := os.Mkdir(filepath.Join(dir, "debian"), 0755); err != nil { - return err + // If upstream debian dir exists, try to move it aside, and then below. + if err := os.Rename(filepath.Join(dir, "debian"), filepath.Join(dir, "upstream_debian")); err != nil { + return err + } else { // Second attempt to create template debian dir, after moving upstream dir aside. + if err := os.Mkdir(filepath.Join(dir, "debian"), 0755); err != nil { + return err + } + if err := os.Rename(filepath.Join(dir, "upstream_debian"), filepath.Join(dir, "debian/upstream_debian")); err != nil { + return err + } + log.Printf("WARNING: Upstream debian/ dir found, and relocated to debian/upstream_debian/\n") + } } if err := os.Mkdir(filepath.Join(dir, "debian", "source"), 0755); err != nil { return err -- 2.30.0