Skip to content

Commit

Permalink
Automatically determine go-srpm-macros version
Browse files Browse the repository at this point in the history
The go-srpm-macros RPM changes infrequently, but we might as well
handle updates automatically.
  • Loading branch information
mjmac committed Feb 17, 2017
1 parent 885da1d commit 3d107d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packaging/docker/go-el7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ ENV GOPATH=/go \
RUN go get github.com/tools/godep && cp /go/bin/godep /usr/local/bin

ARG go_version
ARG go_macros_version

# Bootstrap a go1.7 build from Fedora Rawhide, but disable tests because they require privileged mode
RUN rpm -ivh http://mirrors.kernel.org/fedora/development/rawhide/Everything/x86_64/os/Packages/g/go-srpm-macros-2-7.fc25.noarch.rpm \
# Bootstrap a golang RPM build from Fedora Rawhide, but disable tests because they require privileged mode
RUN rpm -ivh http://mirrors.kernel.org/fedora/development/rawhide/Everything/x86_64/os/Packages/g/go-srpm-macros-${go_macros_version}.noarch.rpm \
&& ln -s /usr/lib/rpm/macros.d/macros.go-srpm /etc/rpm/ \
&& rpmbuild --define '%check exit 0' --rebuild http://mirrors.kernel.org/fedora/development/rawhide/Everything/source/tree/Packages/g/golang-${go_version}.src.rpm \
&& cd /root/rpmbuild/RPMS/x86_64 && rpm -Uvh golang-*.rpm ../noarch/golang-src-*.rpm
3 changes: 2 additions & 1 deletion packaging/docker/go-el7/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FEDORA_GOLANG ?= $(shell curl -s http://mirrors.kernel.org/fedora/development/rawhide/Everything/source/tree/Packages/g/ | awk '/>golang-1.*\.src\.rpm</ {print $2}' | sed -E 's/.*golang-(1.*)\.src\.rpm.*/\1/')
FEDORA_GOLANG_MACROS ?= $(shell curl -s http://mirrors.kernel.org/fedora/development/rawhide/Everything/x86_64/os/Packages/g/ | awk '/>go-srpm-macros.*\.noarch\.rpm</ {print $2}' | sed -E 's/.*go-srpm-macros-(.*)\.noarch\.rpm.*/\1/')
REPO ?= $(notdir $(CURDIR))

IMAGE := $(shell latest=$$(docker images | awk "/$(REPO).*$(FEDORA_GOLANG)/ {print \$$2}"); if [ "$$latest" == $(FEDORA_GOLANG) ]; then true; else echo $(REPO)/$(FEDORA_GOLANG); fi)
Expand All @@ -7,7 +8,7 @@ $(FEDORA_GOLANG): $(IMAGE)

$(IMAGE): Dockerfile
@echo "Building $(IMAGE) for $(FEDORA_GOLANG)"
docker build -t $(subst /,:,$(IMAGE)) -t $(REPO):latest --build-arg=go_version=$(FEDORA_GOLANG) $(BUILD_VARS) .
docker build -t $(subst /,:,$(IMAGE)) -t $(REPO):latest --build-arg=go_version=$(FEDORA_GOLANG) --build-arg=go_macros_version=$(FEDORA_GOLANG_MACROS) $(BUILD_VARS) .

clean:
docker rmi $(subst /,:,$(IMAGE)) $(REPO):latest
Expand Down

0 comments on commit 3d107d4

Please sign in to comment.