diff --git a/Makefile b/Makefile index 36c43e57ed93d02d50e515e0791e115fa0b9e3b4..a374cc098d95f4ca9308933964c34b42583c7d11 100644 --- a/Makefile +++ b/Makefile @@ -112,10 +112,6 @@ ifeq ($(PATCH),) $(error Invalid patch version) endif -ifneq ($(VERSION_STRING),$(VERSION)$(if $(TAG),-$(TAG),)) -$(error Version not updated correctly: $(VERSION_STRING) != $(VERSION)$(if $(TAG),-$(TAG),)) -endif - $(SRCS_DIR)/nvc.h: $(SRCS_DIR)/nvc.h.template cat $< | \ sed -e 's/{{NVC_MAJOR}}/$(MAJOR)/g' | \ @@ -343,7 +339,7 @@ deb: prefix:=/usr deb: libdir:=/usr/lib/@DEB_HOST_MULTIARCH@ -PKG_VERS := $(VERSION)$(if $(TAG),~$(TAG),) +PKG_VERS := $(VERSION_STRING) PKG_REV := 1 deb: install $(CP) -T $(PKG_DIR)/deb $(DESTDIR)/debian diff --git a/mk/Dockerfile.amazonlinux b/mk/Dockerfile.amazonlinux index 0e1f228235904b16ad933045fe9ff84f315348ec..1afdb7b01a560b67b2d766d9e2ee46e7cd1a9b63 100644 --- a/mk/Dockerfile.amazonlinux +++ b/mk/Dockerfile.amazonlinux @@ -57,6 +57,8 @@ ARG LIB_VERSION ENV LIB_VERSION=${LIB_VERSION} ARG LIB_TAG ENV LIB_TAG=${LIB_TAG} +ARG LIB_BUILD +ENV LIB_BUILD=${LIB_BUILD} RUN make distclean && make -j"$(nproc)" diff --git a/mk/Dockerfile.centos b/mk/Dockerfile.centos index f1f4e5930d72e652857c0f4a9a5575028e0224c6..c81750a572fd2acef2d09fb5e5e65a5fd49ef436 100644 --- a/mk/Dockerfile.centos +++ b/mk/Dockerfile.centos @@ -62,6 +62,8 @@ ARG LIB_VERSION ENV LIB_VERSION=${LIB_VERSION} ARG LIB_TAG ENV LIB_TAG=${LIB_TAG} +ARG LIB_BUILD +ENV LIB_BUILD=${LIB_BUILD} RUN make distclean && make -j"$(nproc)" diff --git a/mk/Dockerfile.debian b/mk/Dockerfile.debian index bdeca6bfb5083690712c5dc94f3f647f6ffb6b83..daac997d50da0f1894028b50d699fb243fa8dff3 100644 --- a/mk/Dockerfile.debian +++ b/mk/Dockerfile.debian @@ -55,6 +55,8 @@ ARG LIB_VERSION ENV LIB_VERSION=${LIB_VERSION} ARG LIB_TAG ENV LIB_TAG=${LIB_TAG} +ARG LIB_BUILD +ENV LIB_BUILD=${LIB_BUILD} RUN make distclean && make -j"$(nproc)" diff --git a/mk/Dockerfile.opensuse-leap b/mk/Dockerfile.opensuse-leap index 1441e8e53322609e0505bedd9db4f2c40260909d..82654386395da7140a1bb3e398cf31a047c7f562 100644 --- a/mk/Dockerfile.opensuse-leap +++ b/mk/Dockerfile.opensuse-leap @@ -50,6 +50,8 @@ ARG LIB_VERSION ENV LIB_VERSION=${LIB_VERSION} ARG LIB_TAG ENV LIB_TAG=${LIB_TAG} +ARG LIB_BUILD +ENV LIB_BUILD=${LIB_BUILD} # META_NOECHO=echo is required to work around a bug in Leap 15's version of bmake, # see also https://github.com/ptt/pttbbs/issues/30 diff --git a/mk/Dockerfile.ubuntu b/mk/Dockerfile.ubuntu index ce072f450d384b4b623e1dfaf73b466e087260c8..c0719df282fb92d5e06ab8ebd76a25e235ba38a3 100644 --- a/mk/Dockerfile.ubuntu +++ b/mk/Dockerfile.ubuntu @@ -54,6 +54,8 @@ ARG LIB_VERSION ENV LIB_VERSION=${LIB_VERSION} ARG LIB_TAG ENV LIB_TAG=${LIB_TAG} +ARG LIB_BUILD +ENV LIB_BUILD=${LIB_BUILD} RUN make distclean && make -j"$(nproc)" diff --git a/mk/docker.mk b/mk/docker.mk index 812bbb39cb0350af960ee89ae871df1613666610..8058af8a3319481fcc208c7fc496f360fed33319 100644 --- a/mk/docker.mk +++ b/mk/docker.mk @@ -166,6 +166,7 @@ docker-build-%: $(ARTIFACTS_DIR) --build-arg REVISION="$(REVISION)" \ --build-arg LIB_VERSION="$(LIB_VERSION)" \ --build-arg LIB_TAG="$(LIB_TAG)" \ + --build-arg LIB_BUILD="$(LIB_BUILD)" \ $(EXTRA_BUILD_ARGS) \ --tag $(BUILDIMAGE) \ --file $(DOCKERFILE) . diff --git a/versions.mk b/versions.mk index 2ff399422253561919e58f9ba757c14342129baa..66b7b26644b6bc75ca78368d7b1822abe1db5f08 100644 --- a/versions.mk +++ b/versions.mk @@ -16,8 +16,27 @@ GIT_TAG ?= $(patsubst v%,%,$(shell git describe --tags 2>/dev/null)) GIT_COMMIT ?= $(shell git describe --match="" --dirty --long --always --abbrev=40 2> /dev/null || echo "") LIB_NAME := libnvidia-container -LIB_VERSION ?= $(word 1,$(subst -, ,$(GIT_TAG))) -LIB_TAG ?= $(subst -,+,$(patsubst $(LIB_VERSION)-%,%,$(GIT_TAG))) + +PARTS := $(subst -, ,$(GIT_TAG)) +build_start = 2 +build_end = $(words $(PARTS)) +ifeq ($(LIB_VERSION),) +# If LIB_VERSION is not already set we infer all versions from the git tag +auto_version = yes +LIB_VERSION ?= $(word 1,$(PARTS)) +ifeq ($(LIB_TAG),) +ifneq ($(patsubst rc.%,%,$(word 2,$(PARTS))),$(word 2,$(PARTS))) +LIB_TAG = $(word 2,$(PARTS)) +build_start = 3 +endif +endif +endif + +ifeq ($(auto_version),yes) +empty := +space := $(empty) $(empty) +LIB_BUILD ?= $(subst $(space),.,$(strip $(wordlist $(build_start),$(build_end),$(PARTS)))) +endif VERSION_PARTS := $(subst ., ,$(LIB_VERSION)) MAJOR := $(word 1,$(VERSION_PARTS)) @@ -26,4 +45,5 @@ PATCH := $(word 3,$(VERSION_PARTS)) VERSION := $(LIB_VERSION) TAG := $(LIB_TAG) -VERSION_STRING := $(LIB_VERSION)$(if $(TAG),-$(TAG),) +BUILD := $(LIB_BUILD) +VERSION_STRING := $(LIB_VERSION)$(if $(TAG),-$(TAG),)$(if $(BUILD),+$(BUILD),)