From 507baf0a83671bdadba6834c377e98ad5ae3aae3 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 16:17:40 +0000 Subject: [PATCH 01/17] Provide npcap distribution internally --- .gitignore | 1 + Jenkinsfile | 19 +++++++++++++++++++ Makefile | 12 ++++++++++++ go1.16/Makefile.debian10 | 2 +- go1.16/Makefile.debian8 | 2 +- go1.16/Makefile.debian9 | 2 +- go1.16/libpcap/.dockerignore | 1 + go1.16/libpcap/Dockerfile.tmpl | 17 +++++++++++++++++ go1.16/libpcap/Makefile | 1 + go1.16/libpcap/lib/.gitkeep | 0 go1.17/Makefile.debian10 | 2 +- go1.17/Makefile.debian8 | 2 +- go1.17/Makefile.debian9 | 2 +- go1.17/libpcap/.dockerignore | 1 + go1.17/libpcap/Dockerfile.tmpl | 17 +++++++++++++++++ go1.17/libpcap/Makefile | 1 + go1.17/libpcap/lib/.gitkeep | 0 17 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 go1.16/libpcap/.dockerignore create mode 100644 go1.16/libpcap/Dockerfile.tmpl create mode 100644 go1.16/libpcap/Makefile create mode 100644 go1.16/libpcap/lib/.gitkeep create mode 100644 go1.17/libpcap/.dockerignore create mode 100644 go1.17/libpcap/Dockerfile.tmpl create mode 100644 go1.17/libpcap/Makefile create mode 100644 go1.17/libpcap/lib/.gitkeep diff --git a/.gitignore b/.gitignore index 3a9cb7f4..737331be 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ Dockerfile .status.* *.bck CHANGELOG.md +libpcap/lib/*.exe diff --git a/Jenkinsfile b/Jenkinsfile index fb2833a1..94c06cff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -101,6 +101,7 @@ pipeline { withGithubNotify(context: "Build ${GO_FOLDER} ${MAKEFILE} ${PLATFORM}") { deleteDir() unstash 'source' + prepareNcap() buildImages() } } @@ -115,6 +116,7 @@ pipeline { withGithubNotify(context: "Staging ${GO_FOLDER} ${MAKEFILE} ${PLATFORM}") { // It will use the already cached docker images that were created in the // Build stage. But it's required to retag them with the staging repo. + prepareNcap() buildImages() publishImages() } @@ -156,6 +158,23 @@ pipeline { } } +def prepareNcap() { + if (PLATFORM?.trim().equals('arm')) { + log(level: 'INFO', text: "prepareNcap is not supported for ${PLATFORM}") + return + } + log(level: 'INFO', text: "prepareNcap ${GO_FOLDER} with ${MAKEFILE} for ${PLATFORM}") + withGoEnv(){ + withGoogleBucket() { + dir("${env.BASE_DIR}"){ + retryWithSleep(retries: 3, seconds: 15, backoff: true) { + sh "make -C ${GO_FOLDER} -f ${MAKEFILE} copy-npcap" + } + } + } + } +} + def buildImages(){ log(level: 'INFO', text: "buildImages ${GO_FOLDER} with ${MAKEFILE} for ${PLATFORM}") withGoEnv(){ diff --git a/Makefile b/Makefile index 314afbfc..089ecf57 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,17 @@ TARGETS=go1.16 go1.17 ARM_TARGETS=go1.16 go1.17 +NCAP_FILE=npcap-1.60-oem.exe + +# Requires login at google storage. +copy-npcap: status=".status.copy-npcap" +copy-npcap: +ifeq ($(CI),true) + @echo '0' > ${status} + $(foreach var,$(TARGETS), \ + gsutil cp gs://obs-ci-cache/private/$(NCAP_FILE) $(var)/libpcap/lib/$(NCAP_FILE) || echo '1' > ${status}) +else + @echo 'Only available if running in the CI' +endif build: status=".status.build" build: diff --git a/go1.16/Makefile.debian10 b/go1.16/Makefile.debian10 index 5e1bd9fc..547a84b8 100644 --- a/go1.16/Makefile.debian10 +++ b/go1.16/Makefile.debian10 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 diff --git a/go1.16/Makefile.debian8 b/go1.16/Makefile.debian8 index 11834e52..d9532e7a 100644 --- a/go1.16/Makefile.debian8 +++ b/go1.16/Makefile.debian8 @@ -1,4 +1,4 @@ -IMAGES := base main darwin +IMAGES := base main darwin npcap DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 diff --git a/go1.16/Makefile.debian9 b/go1.16/Makefile.debian9 index acc9dc87..91c452c5 100644 --- a/go1.16/Makefile.debian9 +++ b/go1.16/Makefile.debian9 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 diff --git a/go1.16/libpcap/.dockerignore b/go1.16/libpcap/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.16/libpcap/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.16/libpcap/Dockerfile.tmpl b/go1.16/libpcap/Dockerfile.tmpl new file mode 100644 index 00000000..c13b39f0 --- /dev/null +++ b/go1.16/libpcap/Dockerfile.tmpl @@ -0,0 +1,17 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-main${TAG_EXTENSION} + +COPY lib /installer + +# Build-time metadata as defined at http://label-schema.org. +ARG BUILD_DATE +ARG IMAGE +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.16/libpcap/Makefile b/go1.16/libpcap/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.16/libpcap/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.16/libpcap/lib/.gitkeep b/go1.16/libpcap/lib/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/go1.17/Makefile.debian10 b/go1.17/Makefile.debian10 index 5e1bd9fc..547a84b8 100644 --- a/go1.17/Makefile.debian10 +++ b/go1.17/Makefile.debian10 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 diff --git a/go1.17/Makefile.debian8 b/go1.17/Makefile.debian8 index 11834e52..d9532e7a 100644 --- a/go1.17/Makefile.debian8 +++ b/go1.17/Makefile.debian8 @@ -1,4 +1,4 @@ -IMAGES := base main darwin +IMAGES := base main darwin npcap DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 diff --git a/go1.17/Makefile.debian9 b/go1.17/Makefile.debian9 index acc9dc87..91c452c5 100644 --- a/go1.17/Makefile.debian9 +++ b/go1.17/Makefile.debian9 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 diff --git a/go1.17/libpcap/.dockerignore b/go1.17/libpcap/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go1.17/libpcap/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go1.17/libpcap/Dockerfile.tmpl b/go1.17/libpcap/Dockerfile.tmpl new file mode 100644 index 00000000..c13b39f0 --- /dev/null +++ b/go1.17/libpcap/Dockerfile.tmpl @@ -0,0 +1,17 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-main${TAG_EXTENSION} + +COPY lib /installer + +# Build-time metadata as defined at http://label-schema.org. +ARG BUILD_DATE +ARG IMAGE +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go1.17/libpcap/Makefile b/go1.17/libpcap/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go1.17/libpcap/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go1.17/libpcap/lib/.gitkeep b/go1.17/libpcap/lib/.gitkeep new file mode 100644 index 00000000..e69de29b From 762c0671e5e4be30a407096359b6e4b923f2e523 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 16:19:36 +0000 Subject: [PATCH 02/17] test: for testing purposes --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 089ecf57..9bfb699c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ TARGETS=go1.16 go1.17 ARM_TARGETS=go1.16 go1.17 -NCAP_FILE=npcap-1.60-oem.exe +# TODO: to be replaced once we validate it works as expected +# TODO: version to be tagged too. +#NPCAP_FILE=npcap-1.60-oem.exe +NPCAP_FILE=test.txt # Requires login at google storage. copy-npcap: status=".status.copy-npcap" @@ -8,7 +11,7 @@ copy-npcap: ifeq ($(CI),true) @echo '0' > ${status} $(foreach var,$(TARGETS), \ - gsutil cp gs://obs-ci-cache/private/$(NCAP_FILE) $(var)/libpcap/lib/$(NCAP_FILE) || echo '1' > ${status}) + gsutil cp gs://obs-ci-cache/private/$(NPCAP_FILE) $(var)/libpcap/lib/$(NPCAP_FILE) || echo '1' > ${status}) else @echo 'Only available if running in the CI' endif From 740920822f90fb25d833dcfc51637df469d143b6 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 16:20:36 +0000 Subject: [PATCH 03/17] Renamed --- go1.16/{libpcap => npcap}/.dockerignore | 0 go1.16/{libpcap => npcap}/Dockerfile.tmpl | 0 go1.16/{libpcap => npcap}/Makefile | 0 go1.16/{libpcap => npcap}/lib/.gitkeep | 0 go1.17/{libpcap => npcap}/.dockerignore | 0 go1.17/{libpcap => npcap}/Dockerfile.tmpl | 0 go1.17/{libpcap => npcap}/Makefile | 0 go1.17/{libpcap => npcap}/lib/.gitkeep | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename go1.16/{libpcap => npcap}/.dockerignore (100%) rename go1.16/{libpcap => npcap}/Dockerfile.tmpl (100%) rename go1.16/{libpcap => npcap}/Makefile (100%) rename go1.16/{libpcap => npcap}/lib/.gitkeep (100%) rename go1.17/{libpcap => npcap}/.dockerignore (100%) rename go1.17/{libpcap => npcap}/Dockerfile.tmpl (100%) rename go1.17/{libpcap => npcap}/Makefile (100%) rename go1.17/{libpcap => npcap}/lib/.gitkeep (100%) diff --git a/go1.16/libpcap/.dockerignore b/go1.16/npcap/.dockerignore similarity index 100% rename from go1.16/libpcap/.dockerignore rename to go1.16/npcap/.dockerignore diff --git a/go1.16/libpcap/Dockerfile.tmpl b/go1.16/npcap/Dockerfile.tmpl similarity index 100% rename from go1.16/libpcap/Dockerfile.tmpl rename to go1.16/npcap/Dockerfile.tmpl diff --git a/go1.16/libpcap/Makefile b/go1.16/npcap/Makefile similarity index 100% rename from go1.16/libpcap/Makefile rename to go1.16/npcap/Makefile diff --git a/go1.16/libpcap/lib/.gitkeep b/go1.16/npcap/lib/.gitkeep similarity index 100% rename from go1.16/libpcap/lib/.gitkeep rename to go1.16/npcap/lib/.gitkeep diff --git a/go1.17/libpcap/.dockerignore b/go1.17/npcap/.dockerignore similarity index 100% rename from go1.17/libpcap/.dockerignore rename to go1.17/npcap/.dockerignore diff --git a/go1.17/libpcap/Dockerfile.tmpl b/go1.17/npcap/Dockerfile.tmpl similarity index 100% rename from go1.17/libpcap/Dockerfile.tmpl rename to go1.17/npcap/Dockerfile.tmpl diff --git a/go1.17/libpcap/Makefile b/go1.17/npcap/Makefile similarity index 100% rename from go1.17/libpcap/Makefile rename to go1.17/npcap/Makefile diff --git a/go1.17/libpcap/lib/.gitkeep b/go1.17/npcap/lib/.gitkeep similarity index 100% rename from go1.17/libpcap/lib/.gitkeep rename to go1.17/npcap/lib/.gitkeep From 5faa37fab89ef2000edd97592bb85aa443da4340 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 16:45:07 +0000 Subject: [PATCH 04/17] Ensure it only publishes to a private docker registry when npcap --- Makefile.common | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index 9a29610d..ff3494d9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -4,8 +4,19 @@ VCS_URL := https://github.com/elastic/golang-crossbuild BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") .DEFAULT_GOAL := build -# Requires login at https://docker.elastic.co:7000/. push: +ifeq ($(NAME),npcap) +ifeq ($(NAME),docker.elastic.co/observability-ci) + $(MAKE) atomic-push +else + @echo 'npcap can only be published in an internal docker registry' +else + $(MAKE) atomic-push +endif +endif + +# Requires login at https://docker.elastic.co:7000/. +atomic-push: echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" From ae28a32d0eb26933f61f85213eea392b25bf9792 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 17:25:07 +0000 Subject: [PATCH 05/17] Use the GCP --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 94c06cff..80f26893 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -165,7 +165,7 @@ def prepareNcap() { } log(level: 'INFO', text: "prepareNcap ${GO_FOLDER} with ${MAKEFILE} for ${PLATFORM}") withGoEnv(){ - withGoogleBucket() { + withGCPEnv(secret: 'secret/observability-team/ci/elastic-observability-account-auth'){ dir("${env.BASE_DIR}"){ retryWithSleep(retries: 3, seconds: 15, backoff: true) { sh "make -C ${GO_FOLDER} -f ${MAKEFILE} copy-npcap" From 9abcd05c0a107ee16f73fab30dc44b6a647eb70b Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 17:35:05 +0000 Subject: [PATCH 06/17] Run the make default goal --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 80f26893..56db72e0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -163,12 +163,12 @@ def prepareNcap() { log(level: 'INFO', text: "prepareNcap is not supported for ${PLATFORM}") return } - log(level: 'INFO', text: "prepareNcap ${GO_FOLDER} with ${MAKEFILE} for ${PLATFORM}") + log(level: 'INFO', text: "prepareNcap for ${PLATFORM}") withGoEnv(){ withGCPEnv(secret: 'secret/observability-team/ci/elastic-observability-account-auth'){ dir("${env.BASE_DIR}"){ retryWithSleep(retries: 3, seconds: 15, backoff: true) { - sh "make -C ${GO_FOLDER} -f ${MAKEFILE} copy-npcap" + sh "make copy-npcap" } } } From 429b9928b7e69ec12ed8f09aed0db8dace1746b8 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 18:19:00 +0000 Subject: [PATCH 07/17] Fix makefile condition --- Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index ff3494d9..b1e3e302 100644 --- a/Makefile.common +++ b/Makefile.common @@ -10,10 +10,10 @@ ifeq ($(NAME),docker.elastic.co/observability-ci) $(MAKE) atomic-push else @echo 'npcap can only be published in an internal docker registry' +endif else $(MAKE) atomic-push endif -endif # Requires login at https://docker.elastic.co:7000/. atomic-push: From 98efac14459a6bc6e1b0a8fdb9998a50ffcc5fac Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 18:19:11 +0000 Subject: [PATCH 08/17] Add file to explain how to bump the version --- NPCAP.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 NPCAP.md diff --git a/NPCAP.md b/NPCAP.md new file mode 100644 index 00000000..13b7b857 --- /dev/null +++ b/NPCAP.md @@ -0,0 +1,9 @@ +# NPCAP + +If you'd like to bump the npcap version please follow the below steps: + +1) Update `NPCAP_FILE` value in the `Makefile`. +2) Download the new artifact. +3) Upload the artifact to `gs://obs-ci-cache/private`. + +Credentials to the artifact service can be found in the APM-Shared folder in the password management tool. From 146a15766a8270b4ddf2567fc02be15cebc3dc8d Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 11 Jan 2022 18:55:53 +0000 Subject: [PATCH 09/17] use NPCAP_VERSION --- Makefile | 5 ++++- Makefile.common | 9 ++++++--- NPCAP.md | 2 +- go1.16/Makefile.common | 9 ++++++++- go1.16/Makefile.debian10 | 5 +++-- go1.16/Makefile.debian8 | 5 +++-- go1.16/Makefile.debian9 | 5 +++-- go1.17/Makefile.common | 9 ++++++++- go1.17/Makefile.debian10 | 5 +++-- go1.17/Makefile.debian8 | 5 +++-- go1.17/Makefile.debian9 | 5 +++-- 11 files changed, 45 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 9bfb699c..bf2f4710 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,12 @@ TARGETS=go1.16 go1.17 ARM_TARGETS=go1.16 go1.17 # TODO: to be replaced once we validate it works as expected # TODO: version to be tagged too. -#NPCAP_FILE=npcap-1.60-oem.exe +NPCAP_VERSION=1.60 +#NPCAP_FILE=npcap-$(NPCAP_VERSION)-oem.exe NPCAP_FILE=test.txt +export NPCAP_VERSION + # Requires login at google storage. copy-npcap: status=".status.copy-npcap" copy-npcap: diff --git a/Makefile.common b/Makefile.common index b1e3e302..e17b4573 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,13 +3,16 @@ VCS_REF := $(shell git rev-parse HEAD) VCS_URL := https://github.com/elastic/golang-crossbuild BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") .DEFAULT_GOAL := build +NPCAP := npcap +SUFFIX_NPCAP_VERSION := $(NPCAP)-$(NPCAP_VERSION) push: -ifeq ($(NAME),npcap) +ifeq ($(NAME),$(NPCAP)) ifeq ($(NAME),docker.elastic.co/observability-ci) - $(MAKE) atomic-push + @echo "override suffix with the $(NPCAP): $(SUFFIX_NPCAP_VERSION)" + SUFFIX=$(SUFFIX_NPCAP_VERSION) $(MAKE) atomic-push else - @echo 'npcap can only be published in an internal docker registry' + @echo "$(NPCAP) can only be published in an internal docker registry" endif else $(MAKE) atomic-push diff --git a/NPCAP.md b/NPCAP.md index 13b7b857..4c08bcb0 100644 --- a/NPCAP.md +++ b/NPCAP.md @@ -2,7 +2,7 @@ If you'd like to bump the npcap version please follow the below steps: -1) Update `NPCAP_FILE` value in the `Makefile`. +1) Update `NPCAP_VERSION` value in the `Makefile`. 2) Download the new artifact. 3) Upload the artifact to `gs://obs-ci-cache/private`. diff --git a/go1.16/Makefile.common b/go1.16/Makefile.common index 5f30cb57..1508dfd2 100644 --- a/go1.16/Makefile.common +++ b/go1.16/Makefile.common @@ -6,10 +6,17 @@ VERSION := 1.16.9 DEBIAN_VERSION ?= 9 SUFFIX := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: +ifeq ($(NAME),$(NPCAP)) +ifeq ($(NAME),docker.elastic.co/observability-ci) + @echo "override suffix with the $(NPCAP): $(SUFFIX_NPCAP_VERSION)" + SUFFIX=$(SUFFIX_NPCAP_VERSION) +endif +endif @echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile @docker build -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \ diff --git a/go1.16/Makefile.debian10 b/go1.16/Makefile.debian10 index 547a84b8..54554ddf 100644 --- a/go1.16/Makefile.debian10 +++ b/go1.16/Makefile.debian10 @@ -1,8 +1,9 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 $(NPCAP) DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) diff --git a/go1.16/Makefile.debian8 b/go1.16/Makefile.debian8 index d9532e7a..70104fbc 100644 --- a/go1.16/Makefile.debian8 +++ b/go1.16/Makefile.debian8 @@ -1,8 +1,9 @@ -IMAGES := base main darwin npcap +IMAGES := base main darwin $(NPCAP) DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: export |grep TAG_EXTENSION diff --git a/go1.16/Makefile.debian9 b/go1.16/Makefile.debian9 index 91c452c5..bcdc90de 100644 --- a/go1.16/Makefile.debian9 +++ b/go1.16/Makefile.debian9 @@ -1,9 +1,10 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x $(NPCAP) ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) diff --git a/go1.17/Makefile.common b/go1.17/Makefile.common index 9c5651ac..a34ea7e6 100644 --- a/go1.17/Makefile.common +++ b/go1.17/Makefile.common @@ -6,10 +6,17 @@ VERSION := 1.17.6 DEBIAN_VERSION ?= 9 SUFFIX := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: +ifeq ($(NAME),$(NPCAP)) +ifeq ($(NAME),docker.elastic.co/observability-ci) + @echo "override suffix with the $(NPCAP): $(SUFFIX_NPCAP_VERSION)" + SUFFIX=$(SUFFIX_NPCAP_VERSION) +endif +endif @echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile @docker build -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \ diff --git a/go1.17/Makefile.debian10 b/go1.17/Makefile.debian10 index 547a84b8..54554ddf 100644 --- a/go1.17/Makefile.debian10 +++ b/go1.17/Makefile.debian10 @@ -1,8 +1,9 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 $(NPCAP) DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) diff --git a/go1.17/Makefile.debian8 b/go1.17/Makefile.debian8 index d9532e7a..70104fbc 100644 --- a/go1.17/Makefile.debian8 +++ b/go1.17/Makefile.debian8 @@ -1,8 +1,9 @@ -IMAGES := base main darwin npcap +IMAGES := base main darwin $(NPCAP) DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: export |grep TAG_EXTENSION diff --git a/go1.17/Makefile.debian9 b/go1.17/Makefile.debian9 index 91c452c5..bcdc90de 100644 --- a/go1.17/Makefile.debian9 +++ b/go1.17/Makefile.debian9 @@ -1,9 +1,10 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x $(NPCAP) ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 +NPCAP_VERSION ?= -export DEBIAN_VERSION TAG_EXTENSION +export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) From 16a245d2dea0bbb2a58f154b7285b97b41e7bf80 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 10:12:14 +0000 Subject: [PATCH 10/17] use hardcoded string --- Makefile.common | 9 ++++----- go1.16/Makefile.common | 4 ++-- go1.16/Makefile.debian10 | 2 +- go1.16/Makefile.debian8 | 2 +- go1.16/Makefile.debian9 | 2 +- go1.17/Makefile.common | 4 ++-- go1.17/Makefile.debian10 | 2 +- go1.17/Makefile.debian8 | 2 +- go1.17/Makefile.debian9 | 2 +- 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Makefile.common b/Makefile.common index e17b4573..d8da70fc 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,16 +3,15 @@ VCS_REF := $(shell git rev-parse HEAD) VCS_URL := https://github.com/elastic/golang-crossbuild BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") .DEFAULT_GOAL := build -NPCAP := npcap -SUFFIX_NPCAP_VERSION := $(NPCAP)-$(NPCAP_VERSION) +SUFFIX_NPCAP_VERSION := npcap-$(NPCAP_VERSION) push: -ifeq ($(NAME),$(NPCAP)) +ifeq ($(NAME),npcap) ifeq ($(NAME),docker.elastic.co/observability-ci) - @echo "override suffix with the $(NPCAP): $(SUFFIX_NPCAP_VERSION)" + @echo "override suffix with the npcap: $(SUFFIX_NPCAP_VERSION)" SUFFIX=$(SUFFIX_NPCAP_VERSION) $(MAKE) atomic-push else - @echo "$(NPCAP) can only be published in an internal docker registry" + @echo "npcap can only be published in an internal docker registry" endif else $(MAKE) atomic-push diff --git a/go1.16/Makefile.common b/go1.16/Makefile.common index 1508dfd2..7a5a468c 100644 --- a/go1.16/Makefile.common +++ b/go1.16/Makefile.common @@ -11,9 +11,9 @@ NPCAP_VERSION ?= export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: -ifeq ($(NAME),$(NPCAP)) +ifeq ($(NAME),npcap) ifeq ($(NAME),docker.elastic.co/observability-ci) - @echo "override suffix with the $(NPCAP): $(SUFFIX_NPCAP_VERSION)" + @echo "override suffix with the npcap: $(SUFFIX_NPCAP_VERSION)" SUFFIX=$(SUFFIX_NPCAP_VERSION) endif endif diff --git a/go1.16/Makefile.debian10 b/go1.16/Makefile.debian10 index 54554ddf..4879fc75 100644 --- a/go1.16/Makefile.debian10 +++ b/go1.16/Makefile.debian10 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 $(NPCAP) +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 NPCAP_VERSION ?= diff --git a/go1.16/Makefile.debian8 b/go1.16/Makefile.debian8 index 70104fbc..ff5e1bb9 100644 --- a/go1.16/Makefile.debian8 +++ b/go1.16/Makefile.debian8 @@ -1,4 +1,4 @@ -IMAGES := base main darwin $(NPCAP) +IMAGES := base main darwin npcap DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 NPCAP_VERSION ?= diff --git a/go1.16/Makefile.debian9 b/go1.16/Makefile.debian9 index bcdc90de..1bd49243 100644 --- a/go1.16/Makefile.debian9 +++ b/go1.16/Makefile.debian9 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x $(NPCAP) +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 diff --git a/go1.17/Makefile.common b/go1.17/Makefile.common index a34ea7e6..1c0f350d 100644 --- a/go1.17/Makefile.common +++ b/go1.17/Makefile.common @@ -11,9 +11,9 @@ NPCAP_VERSION ?= export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION build: -ifeq ($(NAME),$(NPCAP)) +ifeq ($(NAME),npcap) ifeq ($(NAME),docker.elastic.co/observability-ci) - @echo "override suffix with the $(NPCAP): $(SUFFIX_NPCAP_VERSION)" + @echo "override suffix with the npcap: $(SUFFIX_NPCAP_VERSION)" SUFFIX=$(SUFFIX_NPCAP_VERSION) endif endif diff --git a/go1.17/Makefile.debian10 b/go1.17/Makefile.debian10 index 54554ddf..4879fc75 100644 --- a/go1.17/Makefile.debian10 +++ b/go1.17/Makefile.debian10 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 $(NPCAP) +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 NPCAP_VERSION ?= diff --git a/go1.17/Makefile.debian8 b/go1.17/Makefile.debian8 index 70104fbc..ff5e1bb9 100644 --- a/go1.17/Makefile.debian8 +++ b/go1.17/Makefile.debian8 @@ -1,4 +1,4 @@ -IMAGES := base main darwin $(NPCAP) +IMAGES := base main darwin npcap DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 NPCAP_VERSION ?= diff --git a/go1.17/Makefile.debian9 b/go1.17/Makefile.debian9 index bcdc90de..1bd49243 100644 --- a/go1.17/Makefile.debian9 +++ b/go1.17/Makefile.debian9 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x $(NPCAP) +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 From ad859c78aca6df230913361a2f04643df329ecde Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 10:15:31 +0000 Subject: [PATCH 11/17] Add npcap image --- go1.16/Makefile | 2 +- go1.17/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go1.16/Makefile b/go1.16/Makefile index c016e6c5..d884e469 100644 --- a/go1.16/Makefile +++ b/go1.16/Makefile @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm build: diff --git a/go1.17/Makefile b/go1.17/Makefile index c016e6c5..d884e469 100644 --- a/go1.17/Makefile +++ b/go1.17/Makefile @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x +IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm build: From 8fe8e98410cbb35c78a99fab38f2eb2cd33e205a Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 11:24:23 +0000 Subject: [PATCH 12/17] substitute the ifeq with a shell specific approach ifeq in Make with the include and variables created on the fly don't work as expected --- Makefile.common | 24 +++++++++++------------- go1.16/Makefile.common | 14 +++++++------- go1.17/Makefile.common | 14 +++++++------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Makefile.common b/Makefile.common index d8da70fc..bc335f85 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,27 +3,25 @@ VCS_REF := $(shell git rev-parse HEAD) VCS_URL := https://github.com/elastic/golang-crossbuild BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") .DEFAULT_GOAL := build -SUFFIX_NPCAP_VERSION := npcap-$(NPCAP_VERSION) +SUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION) +NPCAP_REPOSITORY := docker.elastic.co/observability-ci push: -ifeq ($(NAME),npcap) -ifeq ($(NAME),docker.elastic.co/observability-ci) - @echo "override suffix with the npcap: $(SUFFIX_NPCAP_VERSION)" - SUFFIX=$(SUFFIX_NPCAP_VERSION) $(MAKE) atomic-push -else - @echo "npcap can only be published in an internal docker registry" -endif -else - $(MAKE) atomic-push -endif + @[ "$(SUFFIX)" = "$(SUFFIX_NPCAP_VERSION)" ] \ + && ( \ + [ "$(REPOSITORY)" = "$(NPCAP_REPOSITORY)" ] \ + && $(MAKE) atomic-push \ + || echo "NOTE: $(SUFFIX) can only be published in $(NPCAP_REPOSITORY)" \ + ) \ + || $(MAKE) atomic-push # Requires login at https://docker.elastic.co:7000/. atomic-push: - echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" + @echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" push-arm: - echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" + @echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" .PHONY: push push-arm diff --git a/go1.16/Makefile.common b/go1.16/Makefile.common index 7a5a468c..3b90642d 100644 --- a/go1.16/Makefile.common +++ b/go1.16/Makefile.common @@ -4,19 +4,19 @@ include $(SELF_DIR)/../Makefile.common NAME := golang-crossbuild VERSION := 1.16.9 DEBIAN_VERSION ?= 9 -SUFFIX := -$(shell basename $(CURDIR)) +FOLDER := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= NPCAP_VERSION ?= export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION -build: -ifeq ($(NAME),npcap) -ifeq ($(NAME),docker.elastic.co/observability-ci) - @echo "override suffix with the npcap: $(SUFFIX_NPCAP_VERSION)" - SUFFIX=$(SUFFIX_NPCAP_VERSION) -endif +ifeq ($(FOLDER),-npcap) +SUFFIX = $(SUFFIX_NPCAP_VERSION) +else +SUFFIX = $(FOLDER) endif + +build: @echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile @docker build -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \ diff --git a/go1.17/Makefile.common b/go1.17/Makefile.common index 1c0f350d..129800d0 100644 --- a/go1.17/Makefile.common +++ b/go1.17/Makefile.common @@ -4,19 +4,19 @@ include $(SELF_DIR)/../Makefile.common NAME := golang-crossbuild VERSION := 1.17.6 DEBIAN_VERSION ?= 9 -SUFFIX := -$(shell basename $(CURDIR)) +FOLDER := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= NPCAP_VERSION ?= export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION -build: -ifeq ($(NAME),npcap) -ifeq ($(NAME),docker.elastic.co/observability-ci) - @echo "override suffix with the npcap: $(SUFFIX_NPCAP_VERSION)" - SUFFIX=$(SUFFIX_NPCAP_VERSION) -endif +ifeq ($(FOLDER),-npcap) +SUFFIX = $(SUFFIX_NPCAP_VERSION) +else +SUFFIX = $(FOLDER) endif + +build: @echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile @docker build -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \ From 44cbaa4471dbe6fcb6d149bedfa88677adfd293f Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 11:26:09 +0000 Subject: [PATCH 13/17] use npcap instead --- .gitignore | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 737331be..9f96714d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ Dockerfile .status.* *.bck CHANGELOG.md -libpcap/lib/*.exe +npcap/lib/*.exe diff --git a/Makefile b/Makefile index bf2f4710..aca65636 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ copy-npcap: ifeq ($(CI),true) @echo '0' > ${status} $(foreach var,$(TARGETS), \ - gsutil cp gs://obs-ci-cache/private/$(NPCAP_FILE) $(var)/libpcap/lib/$(NPCAP_FILE) || echo '1' > ${status}) + gsutil cp gs://obs-ci-cache/private/$(NPCAP_FILE) $(var)/npcap/lib/$(NPCAP_FILE) || echo '1' > ${status}) else @echo 'Only available if running in the CI' endif From cc80a4e4d9d4f7c39db8c728c5e7a1813d34e78a Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 14:06:20 +0000 Subject: [PATCH 14/17] Add explicit argument to the consumer Otherwise the version was empty Let's see whether it works --- Makefile.common | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.common b/Makefile.common index bc335f85..48c846bc 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,6 +3,7 @@ VCS_REF := $(shell git rev-parse HEAD) VCS_URL := https://github.com/elastic/golang-crossbuild BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") .DEFAULT_GOAL := build +NPCAP_VERSION ?= SUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION) NPCAP_REPOSITORY := docker.elastic.co/observability-ci From c26271bef5f2dbb56124abb5f40bc1b1703b77c7 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 14:56:55 +0000 Subject: [PATCH 15/17] Fix the variables when using either the top level root makefile or the specific makefile in the go1.X version folder --- Makefile | 9 ++------- Makefile.common | 5 ++++- go1.16/Makefile.common | 3 +-- go1.17/Makefile.common | 3 +-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index aca65636..bbf45121 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,7 @@ +include Makefile.common + TARGETS=go1.16 go1.17 ARM_TARGETS=go1.16 go1.17 -# TODO: to be replaced once we validate it works as expected -# TODO: version to be tagged too. -NPCAP_VERSION=1.60 -#NPCAP_FILE=npcap-$(NPCAP_VERSION)-oem.exe -NPCAP_FILE=test.txt - -export NPCAP_VERSION # Requires login at google storage. copy-npcap: status=".status.copy-npcap" diff --git a/Makefile.common b/Makefile.common index 48c846bc..564f7be7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -3,7 +3,10 @@ VCS_REF := $(shell git rev-parse HEAD) VCS_URL := https://github.com/elastic/golang-crossbuild BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") .DEFAULT_GOAL := build -NPCAP_VERSION ?= +NPCAP_VERSION := 1.60 +# TODO: to be replaced once we validate it works as expected +#NPCAP_FILE := npcap-$(NPCAP_VERSION)-oem.exe +NPCAP_FILE := test.txt SUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION) NPCAP_REPOSITORY := docker.elastic.co/observability-ci diff --git a/go1.16/Makefile.common b/go1.16/Makefile.common index 3b90642d..f667881d 100644 --- a/go1.16/Makefile.common +++ b/go1.16/Makefile.common @@ -6,9 +6,8 @@ VERSION := 1.16.9 DEBIAN_VERSION ?= 9 FOLDER := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION ifeq ($(FOLDER),-npcap) SUFFIX = $(SUFFIX_NPCAP_VERSION) diff --git a/go1.17/Makefile.common b/go1.17/Makefile.common index 129800d0..54b72a2f 100644 --- a/go1.17/Makefile.common +++ b/go1.17/Makefile.common @@ -6,9 +6,8 @@ VERSION := 1.17.6 DEBIAN_VERSION ?= 9 FOLDER := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION ifeq ($(FOLDER),-npcap) SUFFIX = $(SUFFIX_NPCAP_VERSION) From 0d2e610e684819485c33139a497fd3b75c156d6c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 17:15:51 +0000 Subject: [PATCH 16/17] refactor and use go1.1x/npcap/Makefile then the push can be override --- Makefile.common | 18 ++++++------------ go1.16/Makefile.common | 8 +------- go1.16/Makefile.debian10 | 3 +-- go1.16/Makefile.debian8 | 3 +-- go1.16/Makefile.debian9 | 3 +-- go1.16/npcap/Makefile | 7 +++++++ go1.17/Makefile.common | 8 +------- go1.17/Makefile.debian10 | 3 +-- go1.17/Makefile.debian8 | 3 +-- go1.17/Makefile.debian9 | 3 +-- go1.17/npcap/Makefile | 7 +++++++ 11 files changed, 28 insertions(+), 38 deletions(-) diff --git a/Makefile.common b/Makefile.common index 564f7be7..7e9c94a6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -11,21 +11,15 @@ SUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION) NPCAP_REPOSITORY := docker.elastic.co/observability-ci push: - @[ "$(SUFFIX)" = "$(SUFFIX_NPCAP_VERSION)" ] \ - && ( \ - [ "$(REPOSITORY)" = "$(NPCAP_REPOSITORY)" ] \ - && $(MAKE) atomic-push \ - || echo "NOTE: $(SUFFIX) can only be published in $(NPCAP_REPOSITORY)" \ - ) \ - || $(MAKE) atomic-push - -# Requires login at https://docker.elastic.co:7000/. -atomic-push: - @echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" - @docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" + $(MAKE) atomic-push push-arm: @echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" .PHONY: push push-arm + +# Requires login at https://docker.elastic.co:7000/. +atomic-push: + @echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" + @docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" diff --git a/go1.16/Makefile.common b/go1.16/Makefile.common index f667881d..5f30cb57 100644 --- a/go1.16/Makefile.common +++ b/go1.16/Makefile.common @@ -4,17 +4,11 @@ include $(SELF_DIR)/../Makefile.common NAME := golang-crossbuild VERSION := 1.16.9 DEBIAN_VERSION ?= 9 -FOLDER := -$(shell basename $(CURDIR)) +SUFFIX := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= export DEBIAN_VERSION TAG_EXTENSION -ifeq ($(FOLDER),-npcap) -SUFFIX = $(SUFFIX_NPCAP_VERSION) -else -SUFFIX = $(FOLDER) -endif - build: @echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile diff --git a/go1.16/Makefile.debian10 b/go1.16/Makefile.debian10 index 4879fc75..547a84b8 100644 --- a/go1.16/Makefile.debian10 +++ b/go1.16/Makefile.debian10 @@ -1,9 +1,8 @@ IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) diff --git a/go1.16/Makefile.debian8 b/go1.16/Makefile.debian8 index ff5e1bb9..ad60c8dc 100644 --- a/go1.16/Makefile.debian8 +++ b/go1.16/Makefile.debian8 @@ -1,9 +1,8 @@ IMAGES := base main darwin npcap DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION build: export |grep TAG_EXTENSION diff --git a/go1.16/Makefile.debian9 b/go1.16/Makefile.debian9 index 1bd49243..91c452c5 100644 --- a/go1.16/Makefile.debian9 +++ b/go1.16/Makefile.debian9 @@ -2,9 +2,8 @@ IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) diff --git a/go1.16/npcap/Makefile b/go1.16/npcap/Makefile index 0a42375f..3c659eff 100644 --- a/go1.16/npcap/Makefile +++ b/go1.16/npcap/Makefile @@ -1 +1,8 @@ include ../Makefile.common + +SUFFIX = $(SUFFIX_NPCAP_VERSION) + +push: + @[ "$(REPOSITORY)" = "$(NPCAP_REPOSITORY)" ] \ + && $(MAKE) atomic-push \ + || echo "WARNING: $(SUFFIX_NPCAP_VERSION) can only be published in $(NPCAP_REPOSITORY)" diff --git a/go1.17/Makefile.common b/go1.17/Makefile.common index 54b72a2f..9c5651ac 100644 --- a/go1.17/Makefile.common +++ b/go1.17/Makefile.common @@ -4,17 +4,11 @@ include $(SELF_DIR)/../Makefile.common NAME := golang-crossbuild VERSION := 1.17.6 DEBIAN_VERSION ?= 9 -FOLDER := -$(shell basename $(CURDIR)) +SUFFIX := -$(shell basename $(CURDIR)) TAG_EXTENSION ?= export DEBIAN_VERSION TAG_EXTENSION -ifeq ($(FOLDER),-npcap) -SUFFIX = $(SUFFIX_NPCAP_VERSION) -else -SUFFIX = $(FOLDER) -endif - build: @echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" @go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile diff --git a/go1.17/Makefile.debian10 b/go1.17/Makefile.debian10 index 4879fc75..547a84b8 100644 --- a/go1.17/Makefile.debian10 +++ b/go1.17/Makefile.debian10 @@ -1,9 +1,8 @@ IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64 npcap DEBIAN_VERSION := 10 TAG_EXTENSION := -debian10 -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) diff --git a/go1.17/Makefile.debian8 b/go1.17/Makefile.debian8 index ff5e1bb9..ad60c8dc 100644 --- a/go1.17/Makefile.debian8 +++ b/go1.17/Makefile.debian8 @@ -1,9 +1,8 @@ IMAGES := base main darwin npcap DEBIAN_VERSION := 8 TAG_EXTENSION := -debian8 -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION build: export |grep TAG_EXTENSION diff --git a/go1.17/Makefile.debian9 b/go1.17/Makefile.debian9 index 1bd49243..91c452c5 100644 --- a/go1.17/Makefile.debian9 +++ b/go1.17/Makefile.debian9 @@ -2,9 +2,8 @@ IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x npcap ARM_IMAGES := base-arm DEBIAN_VERSION := 9 TAG_EXTENSION := -debian9 -NPCAP_VERSION ?= -export DEBIAN_VERSION NPCAP_VERSION TAG_EXTENSION +export DEBIAN_VERSION TAG_EXTENSION build: @$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;) diff --git a/go1.17/npcap/Makefile b/go1.17/npcap/Makefile index 0a42375f..3c659eff 100644 --- a/go1.17/npcap/Makefile +++ b/go1.17/npcap/Makefile @@ -1 +1,8 @@ include ../Makefile.common + +SUFFIX = $(SUFFIX_NPCAP_VERSION) + +push: + @[ "$(REPOSITORY)" = "$(NPCAP_REPOSITORY)" ] \ + && $(MAKE) atomic-push \ + || echo "WARNING: $(SUFFIX_NPCAP_VERSION) can only be published in $(NPCAP_REPOSITORY)" From 4ff485582fce128d71e8b1589b6b4930d2f4e42c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 12 Jan 2022 17:18:04 +0000 Subject: [PATCH 17/17] Enable ncpap --- Makefile.common | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.common b/Makefile.common index 7e9c94a6..7d0b3bff 100644 --- a/Makefile.common +++ b/Makefile.common @@ -4,9 +4,7 @@ VCS_URL := https://github.com/elastic/golang-crossbuild BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") .DEFAULT_GOAL := build NPCAP_VERSION := 1.60 -# TODO: to be replaced once we validate it works as expected -#NPCAP_FILE := npcap-$(NPCAP_VERSION)-oem.exe -NPCAP_FILE := test.txt +NPCAP_FILE := npcap-$(NPCAP_VERSION)-oem.exe SUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION) NPCAP_REPOSITORY := docker.elastic.co/observability-ci