Commit 033a60b5 authored by Arnaud Rebillout's avatar Arnaud Rebillout
Browse files

Add version and gitcommit to the build ldflags. (Closes: #909644)



We need to maintain a table to know what is the git commit for a given
tag. This table is in the file `debian/upstream-version-gitcommit`.

This commit also adds a simple helper to retrieve the git commit easily
from the command-line, given the version. Just so that it's easy to
maintain this table in the future.

Signed-off-by: default avatarArnaud Rebillout <arnaud.rebillout@collabora.com>
parent c31a892e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
#!/bin/bash

set -e

TAG=$1
URL=https://api.github.com/repos/opencontainers/runc/tags

fail() { echo >&2 "$@"; exit 1; }

if [ -z "$TAG" ]; then
	echo >&2 "Usage: $0 TAG (eg. v1.0.0-rc6)"
	exit 1
fi

wget -q "$URL" -O- | jq -r ".[] | select(.name==\"$TAG\") | .commit.sha"
+7 −1
Original line number Diff line number Diff line
@@ -7,6 +7,12 @@ export DH_GOPKG := github.com/opencontainers/runc
export DH_GOLANG_INSTALL_EXTRA := libcontainer/seccomp/fixtures
TAGS=apparmor seccomp selinux ambient

RUNC_VERSION := $(shell cat VERSION)
RUNC_GITCOMMIT := $(shell sed -n "s/$(RUNC_VERSION): //p" debian/upstream-version-gitcommits)
ifndef RUNC_GITCOMMIT
  $(error Missing RUNC_GITCOMMIT - see debian/upstream-version-gitcommits)
endif

%:
	dh $@ --buildsystem=golang --with=golang --builddirectory=_build

@@ -33,7 +39,7 @@ override_dh_auto_configure:
#	ln -svrf vendor/github.com/opencontainers/specs  _build/src/github.com/opencontainers/

override_dh_auto_build:
	dh_auto_build -- -tags "$(TAGS)"
	dh_auto_build -- -ldflags "-X main.version=$(RUNC_VERSION) -X main.gitCommit=$(RUNC_GITCOMMIT)" -tags "$(TAGS)"

override_dh_auto_test:
	DH_GOLANG_EXCLUDES="libcontainer/integration" \
+11 −0
Original line number Diff line number Diff line
# This file gives the git commit corresponding to an upstream tag.
#
# If you update the package to a new upstream release, you'll need to
# add a line to this file. Here are the steps:
#
# VERSION=$(cat VERSION)
# GITCOMMIT=$(debian/helpers/get-gitcommit-for-tag v${VERSION:?})
# echo "${VERSION:?}: ${GITCOMMIT:?}" >> debian/upstream-version-gitcommits
#

1.0.0-rc6: ccb5efd37fb7c86364786e9137e22948751de7ed