Merge pull request #856 from hqhq/add_VERSION_file
Add VERSION file to contain the version info
This commit is contained in:
commit
37f27d5d3b
6
Makefile
6
Makefile
|
@ -20,11 +20,13 @@ MAN_PAGES = $(shell ls $(MAN_DIR)/*.8)
|
|||
MAN_PAGES_BASE = $(notdir $(MAN_PAGES))
|
||||
MAN_INSTALL_PATH := ${PREFIX}/share/man/man8/
|
||||
|
||||
VERSION := ${shell cat ./VERSION}
|
||||
|
||||
all: $(RUNC_LINK)
|
||||
go build -i -ldflags "-X main.gitCommit=${COMMIT}" -tags "$(BUILDTAGS)" -o runc .
|
||||
go build -i -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -tags "$(BUILDTAGS)" -o runc .
|
||||
|
||||
static: $(RUNC_LINK)
|
||||
CGO_ENABLED=1 go build -i -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT}" -o runc .
|
||||
CGO_ENABLED=1 go build -i -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -o runc .
|
||||
|
||||
$(RUNC_LINK):
|
||||
ln -sfn $(CURDIR) $(RUNC_LINK)
|
||||
|
|
11
main.go
11
main.go
|
@ -10,12 +10,15 @@ import (
|
|||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
// version will be populated by the Makefile, read from
|
||||
// VERSION file of the source code.
|
||||
var version = ""
|
||||
|
||||
// gitCommit will be the hash that the binary was built from
|
||||
// and will be populated by the Makefile
|
||||
var gitCommit = ""
|
||||
|
||||
const (
|
||||
version = "0.1.1"
|
||||
specConfig = "config.json"
|
||||
usage = `Open Container Initiative runtime
|
||||
|
||||
|
@ -46,8 +49,10 @@ func main() {
|
|||
app := cli.NewApp()
|
||||
app.Name = "runc"
|
||||
app.Usage = usage
|
||||
v := []string{
|
||||
version,
|
||||
|
||||
var v []string
|
||||
if version != "" {
|
||||
v = append(v, version)
|
||||
}
|
||||
if gitCommit != "" {
|
||||
v = append(v, fmt.Sprintf("commit: %s", gitCommit))
|
||||
|
|
Loading…
Reference in New Issue