Skip to content

Commit 15d53f3

Browse files
committed
Simplify for Go modules
1 parent 4493070 commit 15d53f3

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

Makefile

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
# The binary to build (just the basename).
1616
BIN := git-sync
1717

18-
# This repo's root import path (under GOPATH).
19-
PKG := k8s.io/git-sync
20-
2118
# Where to push the docker image.
2219
REGISTRY ?= staging-k8s.gcr.io
2320

@@ -82,10 +79,7 @@ build: bin/$(OS)_$(ARCH)/$(BIN)
8279

8380
BUILD_DIRS := \
8481
bin/$(OS)_$(ARCH) \
85-
.go/src/$(PKG) \
86-
.go/pkg \
8782
.go/bin/$(OS)_$(ARCH) \
88-
.go/std/$(OS)_$(ARCH) \
8983
.go/cache
9084

9185
# The following structure defeats Go's (intentional) behavior to always touch
@@ -103,21 +97,18 @@ $(OUTBIN): .go/$(OUTBIN).stamp
10397
-ti \
10498
--rm \
10599
-u $$(id -u):$$(id -g) \
106-
-v $$(pwd):/go/src/$(PKG) \
107-
-v $$(pwd)/.go:/go \
100+
-v $$(pwd):/src \
101+
-w /src \
108102
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
109103
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
110-
-v $$(pwd)/.go/std/$(OS)_$(ARCH):/usr/local/go/pkg/$(OS)_$(ARCH)_static \
111104
-v $$(pwd)/.go/cache:/.cache \
112-
-w /go/src/$(PKG) \
113105
--env HTTP_PROXY=$(HTTP_PROXY) \
114106
--env HTTPS_PROXY=$(HTTPS_PROXY) \
115107
$(BUILD_IMAGE) \
116108
/bin/sh -c " \
117109
ARCH=$(ARCH) \
118110
OS=$(OS) \
119111
VERSION=$(VERSION) \
120-
PKG=$(PKG) \
121112
./build/build.sh \
122113
"
123114
@if ! cmp -s .go/$(OUTBIN) $(OUTBIN); then \
@@ -172,15 +163,13 @@ test: $(BUILD_DIRS)
172163
@docker run \
173164
-ti \
174165
-u $$(id -u):$$(id -g) \
175-
-v $$(pwd):/go/src/$(PKG) \
176-
-v $$(pwd)/.go:/go \
166+
-v $$(pwd):/src \
167+
-w /src \
177168
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
178169
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
179-
-v $$(pwd)/.go/std/$(OS)_$(ARCH):/usr/local/go/pkg/$(OS)_$(ARCH)_static \
180170
-v $$(pwd)/.go/cache:/.cache \
181171
--env HTTP_PROXY=$(HTTP_PROXY) \
182172
--env HTTPS_PROXY=$(HTTPS_PROXY) \
183-
-w /go/src/$(PKG) \
184173
$(BUILD_IMAGE) \
185174
/bin/sh -c " \
186175
./build/test.sh $(SRC_DIRS) \

build/build.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
if [ -z "${PKG:-}" ]; then
22-
echo "PKG must be set"
23-
exit 1
24-
fi
2521
if [ -z "${ARCH:-}" ]; then
2622
echo "ARCH must be set"
2723
exit 1
@@ -40,7 +36,7 @@ export GOARCH="${ARCH}"
4036
export GOOS="${OS}"
4137
export GOFLAGS="-mod=vendor"
4238

43-
go install \
44-
-installsuffix "static" \
45-
-ldflags "-X ${PKG}/pkg/version.VERSION=${VERSION}" \
39+
go install \
40+
-installsuffix "static" \
41+
-ldflags "-X $(go list -m)/pkg/version.VERSION=${VERSION}" \
4642
./...

0 commit comments

Comments
 (0)