Skip to content

Commit

Permalink
Merge branch 'set-version-in-cl' into 'main'
Browse files Browse the repository at this point in the history
Allow package versions to be specified externally

See merge request nvidia/container-toolkit/libnvidia-container!227
  • Loading branch information
Evan Lezar committed Aug 9, 2023
2 parents 194d84c + 576dce2 commit 6a24508
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 332 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/dist
/.git/objects
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NVIDIA Container Toolkit Library and CLI Changelog

## 1.14.0~rc.3
* Generate debian and RPM changelogs automatically.

## 1.14.0~rc.2
* Include Shared Compiler Library (`libnvidia-gpucomp.so``) in the list of compute libaries.

## 1.14.0~rc.1
* Remove `linvidia-container0`` dependency on Ubuntu-based arm64 platforms
* Support OpenSSL 3 with the Encrypt/Decrypt library
36 changes: 27 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ BIN_SCRIPT = $(SRCS_DIR)/cli/$(BIN_NAME).lds
##### Target definitions #####

ARCH ?= $(call getarch)
MAJOR := $(call getdef,NVC_MAJOR,$(LIB_INCS))
MINOR := $(call getdef,NVC_MINOR,$(LIB_INCS))
PATCH := $(call getdef,NVC_PATCH,$(LIB_INCS))
# Extract the VERSION and TAG from the version header file. We strip quotes.
VERSION_STRING := $(subst ",,$(call getdef,NVC_VERSION,$(LIB_INCS)))
TAG := $(subst ",,$(call getdef,NVC_TAG,$(LIB_INCS)))
VERSION := $(MAJOR).$(MINOR).$(PATCH)

ifeq ($(MAJOR),)
$(error Invalid major version)
Expand All @@ -123,6 +116,14 @@ 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' | \
sed -e 's/{{NVC_MINOR}}/$(MINOR)/g' | \
sed -e 's/{{NVC_PATCH}}/$(PATCH)/g' | \
sed -e 's/{{NVC_TAG}}/$(if $(TAG),"$(TAG)",)/g' | \
sed -e 's/{{NVC_VERSION}}/"$(VERSION_STRING)"/g' > $@

BIN_NAME := nvidia-container-cli
LIB_NAME := libnvidia-container
LIB_STATIC := $(LIB_NAME).a
Expand Down Expand Up @@ -213,7 +214,7 @@ $(LIB_RPC_SRCS): $(LIB_RPC_SPEC)
$(RM) $@
cd $(dir $@) && $(RPCGEN) $(RPCGENFLAGS) -C -M -N -o $(notdir $@) $(LIB_RPC_SPEC)

$(LIB_OBJS): %.lo: %.c | deps
$(LIB_OBJS): %.lo: %.c | deps $(SRCS_DIR)/nvc.h
$(CC) $(LIB_CFLAGS) $(LIB_CPPFLAGS) -MMD -MF $*.d -c $(OUTPUT_OPTION) $<

$(BIN_OBJS): %.o: %.c | shared
Expand Down Expand Up @@ -335,12 +336,21 @@ clean: mostlyclean depsclean
distclean: clean
$(RM) -r $(DEPS_DIR) $(DIST_DIR) $(DEBUG_DIR)
$(RM) $(LIB_RPC_SRCS) $(LIB_STATIC) $(LIB_SHARED) $(BIN_NAME)
$(RM) -f $(SRCS_DIR)/nvc.h

deb: DESTDIR:=$(DIST_DIR)/$(LIB_NAME)_$(VERSION)_$(ARCH)
deb: prefix:=/usr
deb: libdir:=/usr/lib/@DEB_HOST_MULTIARCH@


PKG_VERS := $(VERSION)$(if $(TAG),~$(TAG),)
PKG_REV := 1
deb: install
$(CP) -T $(PKG_DIR)/deb $(DESTDIR)/debian
cd $(DESTDIR) && dch --create --package="$(PKG_NAME)" \
--newversion "$(PKG_VERS)-$(PKG_REV)" \
"See https://gitlab.com/nvidia/container-toolkit/libnvidia-container/-/blob/$(REVISION)/CHANGELOG.md for the changelog" && \
dch --controlmaint --release ""
cd $(DESTDIR) && debuild -eDISTRIB -eSECTION --dpkg-buildpackage-hook='debian/prepare %v' -a$(ARCH) -us -uc -B
cd $(DESTDIR) && (yes | debuild clean || yes | debuild -- clean)

Expand All @@ -350,5 +360,13 @@ rpm: all
$(CP) -T $(PKG_DIR)/rpm $(DESTDIR)
$(LN) -nsf $(CURDIR) $(DESTDIR)/BUILD
$(MKDIR) -p $(DESTDIR)/RPMS && $(LN) -nsf $(DIST_DIR) $(DESTDIR)/RPMS/$(ARCH)
cd $(DESTDIR) && rpmbuild --clean --target=$(ARCH) -bb -D"_topdir $(DESTDIR)" -D"_version $(VERSION)" $(and $(TAG),-D"_tag $(TAG)") -D"_major $(MAJOR)" SPECS/*
cd $(DESTDIR) && \
rpmbuild --clean --target=$(ARCH) -bb \
-D"_topdir $(DESTDIR)" \
-D "release_date $(shell date +'%a %b %d %Y')" \
-D"version $(PKG_VERS)" \
-D"release $(PKG_REV)" \
-D"_major $(MAJOR)" \
-D "git_commit ${REVISION}" \
SPECS/*.spec
-cd $(DESTDIR) && rpmlint RPMS/*
5 changes: 5 additions & 0 deletions mk/Dockerfile.amazonlinux
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ COPY . .

ARG REVISION
ENV REVISION=${REVISION}
ARG LIB_VERSION
ENV LIB_VERSION=${LIB_VERSION}
ARG LIB_TAG
ENV LIB_TAG=${LIB_TAG}

RUN make distclean && make -j"$(nproc)"

# Use the revision as the package version for the time being
Expand Down
5 changes: 5 additions & 0 deletions mk/Dockerfile.centos
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ ENV LDLIBS=${LDLIBS}

ARG REVISION
ENV REVISION=${REVISION}
ARG LIB_VERSION
ENV LIB_VERSION=${LIB_VERSION}
ARG LIB_TAG
ENV LIB_TAG=${LIB_TAG}

RUN make distclean && make -j"$(nproc)"

# Use the revision as the package version for the time being
Expand Down
5 changes: 5 additions & 0 deletions mk/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ ENV WITH_SECCOMP=${WITH_SECCOMP}

ARG REVISION
ENV REVISION=${REVISION}
ARG LIB_VERSION
ENV LIB_VERSION=${LIB_VERSION}
ARG LIB_TAG
ENV LIB_TAG=${LIB_TAG}

RUN make distclean && make -j"$(nproc)"

# Use the revision as the package version for the time being
Expand Down
5 changes: 5 additions & 0 deletions mk/Dockerfile.opensuse-leap
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ COPY . .

ARG REVISION
ENV REVISION=${REVISION}
ARG LIB_VERSION
ENV LIB_VERSION=${LIB_VERSION}
ARG LIB_TAG
ENV LIB_TAG=${LIB_TAG}

# 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
RUN export META_NOECHO=echo && \
Expand Down
4 changes: 4 additions & 0 deletions mk/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ ENV WITH_SECCOMP=${WITH_SECCOMP}

ARG REVISION
ENV REVISION=${REVISION}
ARG LIB_VERSION
ENV LIB_VERSION=${LIB_VERSION}
ARG LIB_TAG
ENV LIB_TAG=${LIB_TAG}

RUN make distclean && make -j"$(nproc)"

Expand Down
5 changes: 5 additions & 0 deletions mk/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ DIST_DIR ?= $(CURDIR)/dist
MAKE_DIR ?= $(CURDIR)/mk
REVISION ?= $(shell git rev-parse HEAD)

include $(CURDIR)/versions.mk

# Supported OSs by architecture
AMD64_TARGETS := ubuntu20.04 ubuntu18.04 ubuntu16.04 debian10 debian9
X86_64_TARGETS := centos7 centos8 rhel7 rhel8 amazonlinux2 opensuse-leap15.1
Expand Down Expand Up @@ -161,11 +163,14 @@ docker-build-%: $(ARTIFACTS_DIR)
--build-arg CFLAGS="$(CFLAGS)" \
--build-arg LDLIBS="$(LDLIBS)" \
--build-arg REVISION="$(REVISION)" \
--build-arg LIB_VERSION="$(LIB_VERSION)" \
--build-arg LIB_TAG="$(LIB_TAG)" \
$(EXTRA_BUILD_ARGS) \
--tag $(BUILDIMAGE) \
--file $(DOCKERFILE) .
$(DOCKER) run \
--platform=linux/$(ARCH) \
--rm \
-e TAG \
-v $(ARTIFACTS_DIR):/dist \
$(BUILDIMAGE)
Expand Down
7 changes: 2 additions & 5 deletions pkg/deb/changelog → pkg/deb/changelog.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
libnvidia-container (1.14.0~rc.3-1) experimental; urgency=medium

* Bump version to 1.14.0~rc.3

-- NVIDIA CORPORATION <cudatools@nvidia.com> Fri, 04 Aug 2023 15:14:19 +0200
# Note: as of 1.14.0~rc.3-1 this file is no longer updated, with a changelog
# entry for a given release generated as part of the packaging step.

libnvidia-container (1.14.0~rc.2-1) experimental; urgency=medium

Expand Down
Loading

0 comments on commit 6a24508

Please sign in to comment.