diff options
Diffstat (limited to 'recipes-networking/netns')
-rw-r--r-- | recipes-networking/netns/files/0001-Allow-selection-of-go-compiler.patch | 107 | ||||
-rw-r--r-- | recipes-networking/netns/netns_git.bb | 16 |
2 files changed, 115 insertions, 8 deletions
diff --git a/recipes-networking/netns/files/0001-Allow-selection-of-go-compiler.patch b/recipes-networking/netns/files/0001-Allow-selection-of-go-compiler.patch new file mode 100644 index 00000000..84fb9a43 --- /dev/null +++ b/recipes-networking/netns/files/0001-Allow-selection-of-go-compiler.patch | |||
@@ -0,0 +1,107 @@ | |||
1 | From 6576f228339b7931e05a8e861f085f483817806b Mon Sep 17 00:00:00 2001 | ||
2 | From: Paul Barker <pbarker@toganlabs.com> | ||
3 | Date: Tue, 8 May 2018 11:01:14 +0000 | ||
4 | Subject: [PATCH] Allow selection of go compiler | ||
5 | |||
6 | By running `make GO=/path/to/go` we can now select the appropriate go compiler | ||
7 | to use. This also makes it possible to cross compile netns more easily. | ||
8 | |||
9 | Signed-off-by: Paul Barker <pbarker@toganlabs.com> | ||
10 | Upstream-status: Pending | ||
11 | --- | ||
12 | Makefile | 25 ++++++++++++++----------- | ||
13 | 1 file changed, 14 insertions(+), 11 deletions(-) | ||
14 | |||
15 | diff --git a/Makefile b/Makefile | ||
16 | index 3a22f3e..476cb9b 100644 | ||
17 | --- a/src/import/Makefile | ||
18 | +++ b/src/import/Makefile | ||
19 | @@ -23,6 +23,9 @@ CTIMEVAR=-X $(PKG)/version.GITCOMMIT=$(GITCOMMIT) -X $(PKG)/version.VERSION=$(VE | ||
20 | GO_LDFLAGS=-ldflags "-w $(CTIMEVAR)" | ||
21 | GO_LDFLAGS_STATIC=-ldflags "-w $(CTIMEVAR) -extldflags -static" | ||
22 | |||
23 | +# Set our default go compiler | ||
24 | +GO := go | ||
25 | + | ||
26 | # List the GOOS and GOARCH to build | ||
27 | GOOSARCHES = linux/arm linux/arm64 linux/amd64 linux/386 | ||
28 | |||
29 | @@ -33,12 +36,12 @@ build: $(NAME) ## Builds a dynamic executable or package | ||
30 | |||
31 | $(NAME): *.go VERSION.txt | ||
32 | @echo "+ $@" | ||
33 | - go build -tags "$(BUILDTAGS)" ${GO_LDFLAGS} -o $(NAME) . | ||
34 | + $(GO) build -tags "$(BUILDTAGS)" ${GO_LDFLAGS} -o $(NAME) . | ||
35 | |||
36 | .PHONY: static | ||
37 | static: ## Builds a static executable | ||
38 | @echo "+ $@" | ||
39 | - CGO_ENABLED=0 go build \ | ||
40 | + CGO_ENABLED=0 $(GO) build \ | ||
41 | -tags "$(BUILDTAGS) static_build" \ | ||
42 | ${GO_LDFLAGS_STATIC} -o $(NAME) . | ||
43 | |||
44 | @@ -55,23 +58,23 @@ lint: ## Verifies `golint` passes | ||
45 | .PHONY: test | ||
46 | test: ## Runs the go tests | ||
47 | @echo "+ $@" | ||
48 | - @go test -v -tags "$(BUILDTAGS) cgo" $(shell go list ./... | grep -v vendor) | ||
49 | + @$(GO) test -v -tags "$(BUILDTAGS) cgo" $(shell $(GO) list ./... | grep -v vendor) | ||
50 | |||
51 | .PHONY: vet | ||
52 | vet: ## Verifies `go vet` passes | ||
53 | @echo "+ $@" | ||
54 | - @go vet $(shell go list ./... | grep -v vendor) | grep -v '.pb.go:' | tee /dev/stderr | ||
55 | + @$(GO) vet $(shell $(GO) list ./... | grep -v vendor) | grep -v '.pb.go:' | tee /dev/stderr | ||
56 | |||
57 | .PHONY: staticcheck | ||
58 | staticcheck: ## Verifies `staticcheck` passes | ||
59 | @echo "+ $@" | ||
60 | - @staticcheck $(shell go list ./... | grep -v vendor) | grep -v '.pb.go:' | tee /dev/stderr | ||
61 | + @staticcheck $(shell $(GO) list ./... | grep -v vendor) | grep -v '.pb.go:' | tee /dev/stderr | ||
62 | |||
63 | .PHONY: cover | ||
64 | cover: ## Runs go test with coverage | ||
65 | @echo "" > coverage.txt | ||
66 | - @for d in $(shell go list ./... | grep -v vendor); do \ | ||
67 | - go test -race -coverprofile=profile.out -covermode=atomic "$$d"; \ | ||
68 | + @for d in $(shell $(GO) list ./... | grep -v vendor); do \ | ||
69 | + $(GO) test -race -coverprofile=profile.out -covermode=atomic "$$d"; \ | ||
70 | if [ -f profile.out ]; then \ | ||
71 | cat profile.out >> coverage.txt; \ | ||
72 | rm profile.out; \ | ||
73 | @@ -81,11 +84,11 @@ cover: ## Runs go test with coverage | ||
74 | .PHONY: install | ||
75 | install: ## Installs the executable or package | ||
76 | @echo "+ $@" | ||
77 | - go install -a -tags "$(BUILDTAGS)" ${GO_LDFLAGS} . | ||
78 | + $(GO) install -a -tags "$(BUILDTAGS)" ${GO_LDFLAGS} . | ||
79 | |||
80 | define buildpretty | ||
81 | mkdir -p $(BUILDDIR)/$(1)/$(2); | ||
82 | -GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build \ | ||
83 | +GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 $(GO) build \ | ||
84 | -o $(BUILDDIR)/$(1)/$(2)/$(NAME) \ | ||
85 | -a -tags "$(BUILDTAGS) static_build netgo" \ | ||
86 | -installsuffix netgo ${GO_LDFLAGS_STATIC} .; | ||
87 | @@ -99,7 +102,7 @@ cross: *.go VERSION.txt ## Builds the cross-compiled binaries, creating a clean | ||
88 | $(foreach GOOSARCH,$(GOOSARCHES), $(call buildpretty,$(subst /,,$(dir $(GOOSARCH))),$(notdir $(GOOSARCH)))) | ||
89 | |||
90 | define buildrelease | ||
91 | -GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 go build \ | ||
92 | +GOOS=$(1) GOARCH=$(2) CGO_ENABLED=0 $(GO) build \ | ||
93 | -o $(BUILDDIR)/$(NAME)-$(1)-$(2) \ | ||
94 | -a -tags "$(BUILDTAGS) static_build netgo" \ | ||
95 | -installsuffix netgo ${GO_LDFLAGS_STATIC} .; | ||
96 | @@ -115,7 +118,7 @@ release: *.go VERSION.txt ## Builds the cross-compiled binaries, naming them in | ||
97 | .PHONY: bump-version | ||
98 | BUMP := patch | ||
99 | bump-version: ## Bump the version in the version file. Set BUMP to [ patch | major | minor ] | ||
100 | - @go get -u github.com/jessfraz/junk/sembump # update sembump tool | ||
101 | + @$(GO) get -u github.com/jessfraz/junk/sembump # update sembump tool | ||
102 | $(eval NEW_VERSION = $(shell sembump --kind $(BUMP) $(VERSION))) | ||
103 | @echo "Bumping VERSION.txt from $(VERSION) to $(NEW_VERSION)" | ||
104 | echo $(NEW_VERSION) > VERSION.txt | ||
105 | -- | ||
106 | 2.7.4 | ||
107 | |||
diff --git a/recipes-networking/netns/netns_git.bb b/recipes-networking/netns/netns_git.bb index d35836ef..82a961bf 100644 --- a/recipes-networking/netns/netns_git.bb +++ b/recipes-networking/netns/netns_git.bb | |||
@@ -1,13 +1,13 @@ | |||
1 | HOMEPAGE = "https://github.com/jfrazelle/netns" | 1 | HOMEPAGE = "https://github.com/jfrazelle/netns" |
2 | SUMMARY = "Runc hook for setting up default bridge networking." | 2 | SUMMARY = "Runc hook for setting up default bridge networking." |
3 | LICENSE = "MIT" | 3 | LICENSE = "MIT" |
4 | LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=20ce4c6a4f32d6ee4a68e3a7506db3f1" | 4 | LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=48ef0979a2bcc3fae14ff30b8a7f5dbf" |
5 | 5 | ||
6 | SRC_URI = "git://github.com/jessfraz/netns;branch=master \ | 6 | SRC_URI = "git://github.com/genuinetools/netns;branch=master \ |
7 | file://0001-Use-correct-go-cross-compiler.patch \ | 7 | file://0001-Allow-selection-of-go-compiler.patch \ |
8 | " | 8 | " |
9 | SRCREV = "74e23a0e5c4e7ac011aafcc4623586c196f1b3ef" | 9 | SRCREV = "0da6ab0997707024debe68c91e940c9168041bf8" |
10 | PV = "0.2.1" | 10 | PV = "0.4.0" |
11 | GO_IMPORT = "import" | 11 | GO_IMPORT = "import" |
12 | 12 | ||
13 | S = "${WORKDIR}/git" | 13 | S = "${WORKDIR}/git" |
@@ -26,9 +26,9 @@ do_compile() { | |||
26 | # We also need to link in the ipallocator and version directories as | 26 | # We also need to link in the ipallocator and version directories as |
27 | # they are not under the src directory. | 27 | # they are not under the src directory. |
28 | ln -sfn . "${S}/src/import/vendor/src" | 28 | ln -sfn . "${S}/src/import/vendor/src" |
29 | mkdir -p "${S}/src/import/vendor/src/github.com/jessfraz/netns" | 29 | mkdir -p "${S}/src/import/vendor/src/github.com/genuinetools/netns" |
30 | ln -sfn "${S}/src/import/ipallocator" "${S}/src/import/vendor/src/github.com/jessfraz/netns/ipallocator" | 30 | ln -sfn "${S}/src/import/ipallocator" "${S}/src/import/vendor/src/github.com/genuinetools/netns/ipallocator" |
31 | ln -sfn "${S}/src/import/version" "${S}/src/import/vendor/src/github.com/jessfraz/netns/version" | 31 | ln -sfn "${S}/src/import/version" "${S}/src/import/vendor/src/github.com/genuinetools/netns/version" |
32 | export GOPATH="${S}/src/import/vendor" | 32 | export GOPATH="${S}/src/import/vendor" |
33 | 33 | ||
34 | # Pass the needed cflags/ldflags so that cgo | 34 | # Pass the needed cflags/ldflags so that cgo |