Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Commit

Permalink
build: include git shortcommit in devel versions
Browse files Browse the repository at this point in the history
This commit populates rkt versions (both in the go binary and in the
generated stage1) with current git shortcommit.
  • Loading branch information
krnowak authored and iaguis committed Aug 6, 2015
1 parent 0d51cc2 commit 27a4432
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/configure
/makelib/variables.mk
/build-rkt-*
/stage1/aci/aci-manifest
23 changes: 18 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
AC_PREREQ([2.68])
AC_INIT([rkt], [0.7.0+git], [https://github.com/coreos/rkt/issues])

dnl if version ends with +git, append a short git-hash.
AS_IF([test `expr match 'AC_PACKAGE_VERSION' '.*+git$'` -gt 0],
dnl version has +git suffix
[RKT_VERSION="AC_PACKAGE_VERSION`git rev-parse --short HEAD`"],
dnl version has no +git suffix
[RKT_VERSION="AC_PACKAGE_VERSION"])

RKT_VERSION_LDFLAGS="-X github.com/coreos/rkt/version.Version '${RKT_VERSION}'"
AC_SUBST(RKT_VERSION)
AC_SUBST(RKT_VERSION_LDFLAGS)

AC_CANONICAL_HOST
AC_CANONICAL_BUILD

Expand Down Expand Up @@ -57,7 +68,6 @@ AS_CASE([${RKT_STAGE1_USR_FROM}],
AC_SUBST(RKT_STAGE1_USR_FROM)

m4_define(DEFAULT_STAGE1_NAME,coreos.com/rkt/stage1)
m4_define(DEFAULT_STAGE1_VERSION,AC_PACKAGE_VERSION)
AC_ARG_WITH(stage1-default-name,
AS_HELP_STRING([--with-stage1-default-name=stage1_name],
[default name of stage1, default: DEFAULT_STAGE1_NAME]),
Expand All @@ -66,7 +76,7 @@ AC_ARG_WITH(stage1-default-name,

AC_ARG_WITH(stage1-default-version,
AS_HELP_STRING([--with-stage1-default-version=stage1_version],
[default version of stage1, default: DEFAULT_STAGE1_VERSION]),
[default version of stage1, default: same as rkt version]),
[RKT_STAGE1_DEFAULT_VERSION="${withval}"],
[RKT_STAGE1_DEFAULT_VERSION=auto])

Expand All @@ -91,10 +101,12 @@ AS_VAR_IF([RKT_STAGE1_USR_FROM], [none],
AS_VAR_IF([RKT_STAGE1_DEFAULT_NAME], [auto],
[RKT_STAGE1_DEFAULT_NAME=DEFAULT_STAGE1_NAME])
AS_VAR_IF([RKT_STAGE1_DEFAULT_VERSION], [auto],
[RKT_STAGE1_DEFAULT_VERSION=DEFAULT_STAGE1_VERSION])
[RKT_STAGE1_DEFAULT_VERSION=${RKT_VERSION}])

RKT_STAGE1_DEFAULT_ACI_LDFLAGS="-X main.defaultStage1Name '${RKT_STAGE1_DEFAULT_NAME}' -X main.defaultStage1Version '${RKT_STAGE1_DEFAULT_VERSION}'"

AC_SUBST(RKT_STAGE1_DEFAULT_NAME)
AC_SUBST(RKT_STAGE1_DEFAULT_VERSION)
AC_SUBST(RKT_STAGE1_DEFAULT_ACI_LDFLAGS)

## STAGE1: Systemd git path for src flavor
Expand Down Expand Up @@ -228,10 +240,11 @@ RKT_REQ_PROG([GIT],[git],[git])
RKT_REQ_PROG([GOBINARY],[go],[go])
RKT_REQ_PROG([GOFMTBINARY],[gofmt],[gofmt])

AC_CONFIG_FILES([makelib/variables.mk])
AC_CONFIG_FILES([makelib/variables.mk
stage1/aci/aci-manifest])
AC_OUTPUT
AC_MSG_RESULT([
AC_PACKAGE_NAME AC_PACKAGE_VERSION
AC_PACKAGE_NAME ${RKT_VERSION}
stage1 flavor: '${RKT_STAGE1_USR_FROM}'
stage1 image path: '${RKT_STAGE1_IMAGE}'
Expand Down
7 changes: 5 additions & 2 deletions makelib/variables.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

# package specific substitution names
package := @PACKAGE_NAME@
version := @PACKAGE_VERSION@
plain_version := @PACKAGE_VERSION@
version := @RKT_VERSION@
tarname := @PACKAGE_TARNAME@
distdir := $(tarname)-$(version)
distdir := $(tarname)-$(plain_version)

# prefix-specific substitution names
prefix := @prefix@
Expand Down Expand Up @@ -50,6 +51,8 @@ RKT_STAGE1_IMAGE_LDFLAGS := @RKT_STAGE1_IMAGE_LDFLAGS@
RKT_RUN_FUNCTIONAL_TESTS := @RKT_RUN_FUNCTIONAL_TESTS@
# ld flags for default stage1 name and version
RKT_STAGE1_DEFAULT_ACI_LDFLAGS := @RKT_STAGE1_DEFAULT_ACI_LDFLAGS@
# ld flags for version
RKT_VERSION_LDFLAGS := @RKT_VERSION_LDFLAGS@

# build-related directories and binaries
BUILDDIR ?= $(MK_TOPLEVEL_ABS_SRCDIR)/build-$(distdir)
Expand Down
2 changes: 1 addition & 1 deletion rkt/rkt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RKT_BINARY := $(BINDIR)/$(LOCAL_NAME)
# variables for makelib/build_go_bin.mk
BGB_BINARY := $(RKT_BINARY)
BGB_PKG_IN_REPO := $(subst $(MK_TOPLEVEL_SRCDIR)/,,$(MK_SRCDIR))
BGB_GO_FLAGS := $(strip -ldflags "$(RKT_STAGE1_DEFAULT_ACI_LDFLAGS) $(RKT_STAGE1_IMAGE_LDFLAGS)" $(RKT_TAGS))
BGB_GO_FLAGS := $(strip -ldflags "$(RKT_STAGE1_DEFAULT_ACI_LDFLAGS) $(RKT_STAGE1_IMAGE_LDFLAGS) $(RKT_VERSION_LDFLAGS)" $(RKT_TAGS))

CLEAN_FILES += $(BGB_BINARY)
TOPLEVEL_STAMPS += $(RKT_STAMP)
Expand Down
4 changes: 2 additions & 2 deletions stage1/aci/aci-manifest → stage1/aci/aci-manifest.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"acKind": "ImageManifest",
"acVersion": "0.6.1",
"name": "coreos.com/rkt/stage1",
"name": "@RKT_STAGE1_DEFAULT_NAME@",
"labels": [
{
"name": "version",
"value": "0.7.0+git"
"value": "@RKT_STAGE1_DEFAULT_VERSION@"
},
{
"name": "arch",
Expand Down
3 changes: 2 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

package version

const Version = "0.7.0+git"
var Version string // value set with linker flags
// don't you dare modifying this value!

0 comments on commit 27a4432

Please sign in to comment.