#989477 dh-golang: autopkgtest failure in package using dh-golang: copy/symlink conflict

#989477#5
Date:
2021-06-04 20:18:02 UTC
From:
To:
Greetings!

I was investigating autopkgtest failures for golang-yaml.v2 in Ubuntu, and
found what I believe is a bug in dh-golang.  I can reproduce equivalent
failures on sid/bullseye as well.

dh-golang attempts to use cp -a to populate a directory with go source code,
but that directory is already partially populated with some symlinks, and cp -a
doesn't like that.  This fails the autopkgtest.

adt log snippet:
  cp -a /usr/share/gocode/src "obj-x86_64-linux-gnu"
  cp: '/usr/share/gocode/src/gopkg.in/check.v1' and 'obj-x86_64-linux-gnu/src/gopkg.in/check.v1' are the same file
  cp: '/usr/share/gocode/src/github.com' and 'obj-x86_64-linux-gnu/src/github.com' are the same file
  cp: '/usr/share/gocode/src/launchpad.net' and 'obj-x86_64-linux-gnu/src/launchpad.net' are the same file

Steps to reproduce:
<download source for golang-yaml.v2>
autopkgtest-build-lxd images:debian/sid
autopkgtest golang-yaml.v2_2.4.0-1.dsc -- lxd autopkgtest/debian/sid/amd64

Note that this slightly different test passes!
autopkgtest golang-yaml.v2 -- lxd autopkgtest/debian/sid/amd64

I assume this isn't golang-yaml.v2 specific, but have not proven that.

I've got a suggested fix, using find to locate the symlinks and remove them
before "cp -a".  Please see my merge proposal, which adds a find invocation
to remove symlinks.

https://salsa.debian.org/go-team/packages/dh-golang/-/merge_requests/17

Thanks.