git-sync icon indicating copy to clipboard operation
git-sync copied to clipboard

Issue with building Git Sync Container

Open rahulmishra opened this issue 1 year ago • 3 comments

I am trying to build git-sync on mac os for a linux machine. I am checking out the v4.2.4 tag and it fails with:

make container GOOS=linux GOARCH=amd64 DBG_MAKEFILE=1

find: -printf: unknown primary or operator
echo "making bin/linux_amd64/git-sync"
making bin/linux_amd64/git-sync
docker run                                                 \
	    -i                                                     \
	    --rm                                                   \
	    -u $(id -u):$(id -g)                                 \
	    -v $(pwd):/src                                        \
	    -w /src                                                \
	    -v $(pwd)/.go/bin/linux_amd64:/go/bin               \
	    -v $(pwd)/.go/bin/linux_amd64:/go/bin/linux_amd64 \
	    -v $(pwd)/.go/cache:/.cache                           \
	    --env HTTP_PROXY=                         \
	    --env HTTPS_PROXY=                       \
	    golang:1.22                                         \
	    /bin/sh -c "                                           \
	        ARCH=amd64                                       \
	        OS=linux                                           \
	        VERSION=v4.2.4                                 \
	        BUILD_DEBUG=                                 \
	        ./build/build.sh                                   \
	    "
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
make: *** [.go/bin/linux_amd64/git-sync.stamp] Error 1

I can build the v4.2.3 tag just fine.

Any help on this is appreciated.

Go Version: go version go1.22.5 darwin/arm64

rahulmishra avatar Jul 22 '24 17:07 rahulmishra

The -printf argument to find was first used over a year ago - does that appear when you build 4.2.3? It seems like a red herring.

Both 4.2.3 and 4.2.4 build with Go 1.22, but 4.2.3 used golang:1.22-alpine while 4.2.4 uses golang:1.22 - that should not matter.

We did bump the Go compatibility from 1.20 to 1.22 in go.mod.

You might try adding a set -x near the top of build/build.sh ?

thockin avatar Jul 22 '24 19:07 thockin

Yes, the printf argument does appear when i build 4.2.3 and it does complete the build successfully despite that warning. i did try debugging the script

make container GOOS=linux GOARCH=amd64 DBG_MAKEFILE=1
find: -printf: unknown primary or operator
echo "making bin/linux_amd64/git-sync"
making bin/linux_amd64/git-sync
docker run                                                 \
	    -i                                                     \
	    --rm                                                   \
	    -u $(id -u):$(id -g)                                 \
	    -v $(pwd):/src                                        \
	    -w /src                                                \
	    -v $(pwd)/.go/bin/linux_amd64:/go/bin               \
	    -v $(pwd)/.go/bin/linux_amd64:/go/bin/linux_amd64 \
	    -v $(pwd)/.go/cache:/.cache                           \
	    --env HTTP_PROXY=                         \
	    --env HTTPS_PROXY=                       \
	    golang:1.22                                         \
	    /bin/sh -c "                                           \
	        ARCH=amd64                                       \
	        OS=linux                                           \
	        VERSION=v4.2.4-dirty                                 \
	        BUILD_DEBUG=                                 \
	        ./build/build.sh                                   \
	    "
+ set -o errexit
+ set -o nounset
+ set -o pipefail
+ '[' -z amd64 ']'
+ '[' -z linux ']'
+ '[' -z v4.2.4-dirty ']'
+ export CGO_ENABLED=0
+ CGO_ENABLED=0
+ export GOARCH=amd64
+ GOARCH=amd64
+ export GOOS=linux
+ GOOS=linux
+ [[ 0 == 1 ]]
++ pwd
+ goasmflags=all=-trimpath=/src
++ pwd
+ gogcflags=all=-trimpath=/src
+ goldflags='-s -w'
++ go list -m
+ always_ldflags='-X k8s.io/git-sync/pkg/version.VERSION=v4.2.4-dirty'
+ go install -installsuffix static -gcflags=all=-trimpath=/src -asmflags=all=-trimpath=/src '-ldflags=-X k8s.io/git-sync/pkg/version.VERSION=v4.2.4-dirty -s -w' ./...
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.
make: *** [.go/bin/linux_amd64/git-sync.stamp] Error 1

rahulmishra avatar Jul 22 '24 20:07 rahulmishra

Could be this? https://github.com/golang/go/issues/53532

It might just be that it uses a newer git.

Can you run id and ls -ld . .git on your shell (in the git repo) and maybe add the same into the build.sh?

thockin avatar Jul 22 '24 20:07 thockin

Did anyone find any solution to this? I tried to build the binary and faced the same error.

akshayjain3450 avatar Jan 24 '25 11:01 akshayjain3450

OP never responded so it got closed. If you want a solution, perhaps you can try the debugging I suggested? I do not have a local repro for this.

thockin avatar Jan 24 '25 15:01 thockin