#57 Problems to package cloud.google.com/go/ modules
Closed by mikelo2. Opened by mikelo2.

Google Cloud's golang SDK used to be a large package, but now each module has different lifecycle while still being a monorepo. This means that multiple subpackages need to be created.

While creating these packages I found a strange behavior with doc files: doc files are installed also in what it would be the original root goipath, causing file conflicts between all submodules.

Error: Transaction test error:
  file /usr/share/gocode/src/cloud.google.com/go/CHANGES.md conflicts between attempted installs of golang-cloud-google-compute-metadata-devel-0.2.3-1.fc40~bootstrap.noarch and golang-cloud-google-devel-0.110.9-1.fc40~bootstrap.noarch
  file /usr/share/gocode/src/cloud.google.com/go/CONTRIBUTING.md conflicts between attempted installs of golang-cloud-google-compute-metadata-devel-0.2.3-1.fc40~bootstrap.noarch and golang-cloud-google-devel-0.110.9-1.fc40~bootstrap.noarch
  file /usr/share/gocode/src/cloud.google.com/go/README.md conflicts between attempted installs of golang-cloud-google-compute-metadata-devel-0.2.3-1.fc40~bootstrap.noarch and golang-cloud-google-devel-0.110.9-1.fc40~bootstrap.noarch
  file /usr/share/gocode/src/cloud.google.com/go/compute/CHANGES.md conflicts between attempted installs of golang-cloud-google-compute-devel-1.23.2-1.fc40~bootstrap.noarch and golang-cloud-google-compute-metadata-devel-0.2.3-1.fc40~bootstrap.noarch

Checking compute/metadata module, it can be seen that doc files are installed in different paths (marked with <--):

(...)
/usr/share/gocode/src/cloud.google.com
/usr/share/gocode/src/cloud.google.com/go
/usr/share/gocode/src/cloud.google.com/go/CHANGES.md <--
/usr/share/gocode/src/cloud.google.com/go/CODE_OF_CONDUCT.md <--
/usr/share/gocode/src/cloud.google.com/go/CONTRIBUTING.md <--
/usr/share/gocode/src/cloud.google.com/go/README.md <--
/usr/share/gocode/src/cloud.google.com/go/RELEASING.md <--
/usr/share/gocode/src/cloud.google.com/go/SECURITY.md <--
/usr/share/gocode/src/cloud.google.com/go/compute
/usr/share/gocode/src/cloud.google.com/go/compute/CHANGES.md <--
/usr/share/gocode/src/cloud.google.com/go/compute/README.md <--
/usr/share/gocode/src/cloud.google.com/go/compute/metadata
/usr/share/gocode/src/cloud.google.com/go/compute/metadata/.goipath
/usr/share/gocode/src/cloud.google.com/go/compute/metadata/CHANGES.md <--
/usr/share/gocode/src/cloud.google.com/go/compute/metadata/CODE_OF_CONDUCT.md <--
/usr/share/gocode/src/cloud.google.com/go/compute/metadata/CONTRIBUTING.md <--
/usr/share/gocode/src/cloud.google.com/go/compute/metadata/README.md <--
/usr/share/gocode/src/cloud.google.com/go/compute/metadata/RELEASING.md <--
/usr/share/gocode/src/cloud.google.com/go/compute/metadata/SECURITY.md <--
(...)

The spec has the following setting for goipath:

%global goipath         cloud.google.com/go/%{module}

That means that files should be installed under the module path cloud.google.com/go/%{module}, not in the root cloud.google.com/go

Checking one of the Azure's SDK spec files, that now has also subpackages as Google's, I see "root" goipath doesn't have doc files installed, only in the module goipath:

(...)
/usr/share/gocode/src/github.com
/usr/share/gocode/src/github.com/Azure
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go <-- no files
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk <-- no files
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage  <-- no files
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/.goipath
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/CHANGELOG.md
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/CODE_OF_CONDUCT.md
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/CONTRIBUTING.md
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/README.md
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/SECURITY.md
/usr/share/gocode/src/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/SUPPORT.md
(...)

The spec file doesn't have anything special other than having to move the module to the root of the builddir. This is also done in the Azure spec files.

  • Google's compute/metadata spec: https://raw.githubusercontent.com/mikelolasagasti/google-sdk-ng/main/golang-cloud-google-compute-metadata.spec
  • Azure's storage/azblob spec: https://src.fedoraproject.org/rpms/golang-github-azure-sdk-storage-azblob/raw/rawhide/f/golang-github-azure-sdk-storage-azblob.spec

Inspecting in a mock shell I see golang-cloud-google-compute-metadata-devel.file-list includes all the correct and wrong paths. Moving that file and running manually go-rpm-integration I see less files being installed:

(...)
go-rpm-integration install -i cloud.google.com/go/compute/metadata -b /builddir/build/BUILD/google-cloud-go-compute-metadata-v0.2.3/_build/bin -s /builddir/build/BUILD/google-cloud-go-compute-metadata-v0.2.3/_build -o golang-cloud-google-compute-metadata-devel.file-list -O /builddir/build/BUILD/google-cloud-go-compute-metadata-v0.2.3 -V 0.2.3-1.fc40~bootstrap -T compute/metadata/v0.2.3 -p /builddir/build/BUILDROOT/golang-cloud-google-compute-metadata-0.2.3-1.fc40~bootstrap.x86_64 -g /usr/share/gocode -r '.*example.*'
(...)
<mock-chroot> sh-5.2# diff -u golang-cloud-google-compute-metadata-devel.file-list golang-cloud-google-compute-metadata-devel.file-list.old 
--- golang-cloud-google-compute-metadata-devel.file-list    2023-11-04 18:58:25.691910878 +0100
+++ golang-cloud-google-compute-metadata-devel.file-list.old    2023-11-04 18:53:36.369990645 +0100
@@ -10,8 +10,19 @@
 "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/retry_linux_test.go"
 "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/retry_test.go"
 "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/tidyfix.go"
+%dir "/usr/share/gocode/src/cloud.google.com"
+%dir "/usr/share/gocode/src/cloud.google.com/go"
+%dir "/usr/share/gocode/src/cloud.google.com/go/compute"
 %dir "/usr/share/gocode/src/cloud.google.com/go/compute/metadata"
 %dir "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/internal"
+%doc "/usr/share/gocode/src/cloud.google.com/go/CHANGES.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/CODE_OF_CONDUCT.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/CONTRIBUTING.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/README.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/RELEASING.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/SECURITY.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/compute/CHANGES.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/compute/README.md"
 %doc "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/CHANGES.md"
 %doc "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/CODE_OF_CONDUCT.md"
 %doc "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/CONTRIBUTING.md"
@@ -20,3 +31,5 @@
 %doc "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/SECURITY.md"
 %doc "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/migration.md"
 %doc "/usr/share/gocode/src/cloud.google.com/go/compute/metadata/testing.md"
+%doc "/usr/share/gocode/src/cloud.google.com/go/testing.md"
+%license "LICENSE"

I don't know when those other %dir, %doc and %license% are being added, I guess it's part of go-rpm-macros's job.

I modified spec's goipath from cloud.google.com/go/%{module} to github.com/GoogleCloudPlatform/google.com/go/%{module} just for testing purposes and the package only includes the required %docs.

I tried removing %global godocs but didn't work. The only workaround I see that may work is editing .file-list file to remove unneeded files.


This is fixed in latest golist

https://pagure.io/golist/c/4a2511bb0089458eef3b78acc0f1dbc264c9c15a?branch=master

Also update to go2rpm 1.10.0 for your templates.

This is fixed in latest golist

https://pagure.io/golist/c/4a2511bb0089458eef3b78acc0f1dbc264c9c15a?branch=master

I'm building against rawhide, so already using golist-0.10.4 that includes that patch:

<mock-chroot> sh-5.2# rpm -qa |grep golist
golist-0.10.4-1.fc40.x86_64

Also update to go2rpm 1.10.0 for your templates.

AFAIU 1.10.0 is about versioning, not related to the issue. I will update though.

Seems fixed by https://pagure.io/go-rpm-macros/pull-request/58

Thanks @eclipseo for the fast fix.

Metadata Update from @mikelo2:
- Issue status updated to: Closed (was: Open)

Metadata