Merge pull request #636 from crosbymichael/git-version
Add gitcommit to runc builds
This commit is contained in:
commit
bab300c28e
5
Makefile
5
Makefile
|
@ -5,16 +5,17 @@ TEST_DOCKERFILE=script/test_Dockerfile
|
|||
BUILDTAGS=seccomp
|
||||
RUNC_BUILD_PATH=/go/src/github.com/opencontainers/runc/runc
|
||||
RUNC_INSTANCE=runc_dev
|
||||
COMMIT=$(shell git rev-parse HEAD 2> /dev/null || true)
|
||||
export GOPATH:=$(CURDIR)/Godeps/_workspace:$(GOPATH)
|
||||
|
||||
.PHONY=dbuild
|
||||
|
||||
all:
|
||||
ln -sfn $(CURDIR) $(CURDIR)/Godeps/_workspace/src/github.com/opencontainers/runc
|
||||
go build -tags "$(BUILDTAGS)" -o runc .
|
||||
go build -ldflags "-X main.gitCommit=${COMMIT}" -tags "$(BUILDTAGS)" -o runc .
|
||||
|
||||
static:
|
||||
CGO_ENABLED=1 go build -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static" -o runc .
|
||||
CGO_ENABLED=1 go build -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT}" -o runc .
|
||||
|
||||
vet:
|
||||
go get golang.org/x/tools/cmd/vet
|
||||
|
|
14
main.go
14
main.go
|
@ -3,12 +3,17 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/opencontainers/specs/specs-go"
|
||||
)
|
||||
|
||||
// gitCommit will be the hash that the binary was built from
|
||||
// and will be populated by the Makefile
|
||||
var gitCommit = ""
|
||||
|
||||
const (
|
||||
version = "0.0.9"
|
||||
specConfig = "config.json"
|
||||
|
@ -41,7 +46,14 @@ func main() {
|
|||
app := cli.NewApp()
|
||||
app.Name = "runc"
|
||||
app.Usage = usage
|
||||
app.Version = fmt.Sprintf("%s\nspec version %s", version, specs.Version)
|
||||
v := []string{
|
||||
version,
|
||||
}
|
||||
if gitCommit != "" {
|
||||
v = append(v, fmt.Sprintf("commit: %s", gitCommit))
|
||||
}
|
||||
v = append(v, fmt.Sprintf("spec: %s", specs.Version))
|
||||
app.Version = strings.Join(v, "\n")
|
||||
app.Flags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "debug",
|
||||
|
|
Loading…
Reference in New Issue