Hi all, I found regclient today and packaged it:
https://github.com/regclient/regclient https://build.opensuse.org/package/show/home:ojkastl_buildservice:Branch_Vir...
Unfortunately, the version output is broken, as the package uses the go debug.buildinfo internally:
https://github.com/regclient/regclient/blob/410091ab2d89e76ffa039f36e5695477...
$ regctl version VCSTag: 0.6.1 VCSRef: unknown VCSCommit: unknown VCSState: unknown VCSDate: unknown Platform: linux/amd64 GoVer: go1.22.5 GoCompiler: gc $ No matter what I do, I cannot get it to properly show the version. I changed the _service file to include the .git directory (in both obs_scm and the buildtime tar repackaging) and made sure git-core was installed. But it errors out with the generic "error obtaining VCS status: exit status 128" error that means that something went wrong with git. My guess is that git cannot reach the remote, due to being offline in OBS. Removing the remote before building (git remote remove origin) does not solve this issue. So, besides patching the file to have the actual desired information init, is there a way to get "go build" to spit out a binary containing the debuginfo? I tried various combinations of options and ldflags for the go build command, but to no avail. Any ideas, anyone? Kind Regards, Johannes
On Thu, Jul 11, 2024 at 12:30 PM Johannes Kastl <mail@johannes-kastl.de> wrote:
Hi all,
I found regclient today and packaged it:
https://build.opensuse.org/package/show/home:ojkastl_buildservice:Branch_Vir...
Unfortunately, the version output is broken, as the package uses the go debug.buildinfo internally:
https://github.com/regclient/regclient/blob/410091ab2d89e76ffa039f36e5695477...
$ regctl version VCSTag: 0.6.1 VCSRef: unknown VCSCommit: unknown VCSState: unknown VCSDate: unknown Platform: linux/amd64 GoVer: go1.22.5 GoCompiler: gc $
Hello Johannes, The regctl repository tags differ in some way from most Go repositories. The one difference I can point to is that tag v0.6.1 is not contained by any branch, main in particular. It may not be possible for debug.buildinfo to infer a version under those conditions. regclient> git checkout --detach v0.6.1 regclient> git branch --contains tags/v0.6.1 * (HEAD detached at v0.6.1) (notably, master/main is not in this list) # build binary up one level to prevent dirty VCS tree regclient> go build -o ../regctl-bin ./cmd/regctl/ && ../regctl-bin version VCSTag: (devel) VCSRef: 766ee6291f882778207ff42207f9ca8b1da54e57 VCSCommit: 766ee6291f882778207ff42207f9ca8b1da54e57 VCSState: clean VCSDate: 2024-05-14T13:18:19Z Platform: linux/amd64 GoVer: go1.22.4 GoCompiler: gc regclient> go version -m ../regctl-bin ../regctl-bin: go1.22.4 path github.com/regclient/regclient/cmd/regctl mod github.com/regclient/regclient (devel) dep github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:(snip) dep github.com/klauspost/compress v1.17.8 h1:(snip) dep github.com/opencontainers/go-digest v1.0.0 h1:(snip) dep github.com/sirupsen/logrus v1.9.3 h1:(snip) dep github.com/spf13/cobra v1.8.0 h1:(snip) dep github.com/spf13/pflag v1.0.5 h1:(snip) dep github.com/ulikunitz/xz v0.5.12 h1:(snip) dep golang.org/x/sys v0.20.0 h1:(snip) dep golang.org/x/term v0.20.0 h1:(snip) build -buildmode=exe build -compiler=gc build DefaultGODEBUG=httplaxcontentlength=1,httpmuxgo121=1,panicnil=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1 build CGO_ENABLED=1 build CGO_CFLAGS= build CGO_CPPFLAGS= build CGO_CXXFLAGS= build CGO_LDFLAGS= build GOARCH=amd64 build GOOS=linux build GOAMD64=v1 build vcs=git build vcs.revision=766ee6291f882778207ff42207f9ca8b1da54e57 build vcs.time=2024-05-14T13:18:19Z build vcs.modified=true regclient> git branch --contains tags/v0.6.1 * (HEAD detached at v0.6.1) (notably, main is not in this list) regclient> git switch main Previous HEAD position was 766ee62 Release v0.6.1 Switched to branch 'main' Your branch is up to date with 'origin/main'. regclient> git branch --contains tags/v0.6.1 (empty) regclient> git branch --contains v0.6.1 (empty) For comparison, the tags in the hugo repository behave as we would expect: hugo> git checkout --detach v0.128.2 HEAD is now at de36c1a9 releaser: Bump versions for release of 0.128.2 hugo> git branch --contains tags/v0.128.2 * (HEAD detached at v0.128.2) master hugo> go build -o ../hugo-bin && ../hugo-bin version hugo v0.128.2-de36c1a95d28595d8243fd8b891665b069ed0850 linux/amd64 BuildDate=2024-07-04T08:13:25Z -- Jeff Kowalczyk Software Engineer, Go Developer Experience SUSE Linux Email jkowalczyk@suse.com Timezone US/Pacific http://suse.com
Hi Jeff, thanks for the fast reply. On 12.07.24 06:48 Jeff Kowalczyk wrote:
The regctl repository tags differ in some way from most Go repositories. The one difference I can point to is that tag v0.6.1 is not contained by any branch, main in particular. It may not be possible for debug.buildinfo to infer a version under those conditions.
Thanks for checking! That was a really thorough research you did... :-) From what I understood it might just be a "problem" in this repository? Not a general problem with the buildinfo in OBS? Which steps do I have to take to use the buildinfo in OBS? Just make sure .git is present and git is installed? Kind Regards, Johannes
Hi Jeff, going through your analysis in more details I noticed one more thing. On 12.07.24 06:48 Jeff Kowalczyk wrote:
# build binary up one level to prevent dirty VCS tree regclient> go build -o ../regctl-bin ./cmd/regctl/ && ../regctl-bin version VCSTag: (devel) VCSRef: 766ee6291f882778207ff42207f9ca8b1da54e57 VCSCommit: 766ee6291f882778207ff42207f9ca8b1da54e57 VCSState: clean VCSDate: 2024-05-14T13:18:19Z Platform: linux/amd64 GoVer: go1.22.4 GoCompiler: gc
The "(devel)" is to be expected, because they use a ldflag for VCSTag. While they use buildinfo for the rest. But this means the buildinfo itself is working. You did this outside of OBS, right? While connected to the network? Kind Regards, Johannes
participants (2)
-
Jeff Kowalczyk
-
Johannes Kastl