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
|
BUILDTAGS=seccomp
|
||||||
RUNC_BUILD_PATH=/go/src/github.com/opencontainers/runc/runc
|
RUNC_BUILD_PATH=/go/src/github.com/opencontainers/runc/runc
|
||||||
RUNC_INSTANCE=runc_dev
|
RUNC_INSTANCE=runc_dev
|
||||||
|
COMMIT=$(shell git rev-parse HEAD 2> /dev/null || true)
|
||||||
export GOPATH:=$(CURDIR)/Godeps/_workspace:$(GOPATH)
|
export GOPATH:=$(CURDIR)/Godeps/_workspace:$(GOPATH)
|
||||||
|
|
||||||
.PHONY=dbuild
|
.PHONY=dbuild
|
||||||
|
|
||||||
all:
|
all:
|
||||||
ln -sfn $(CURDIR) $(CURDIR)/Godeps/_workspace/src/github.com/opencontainers/runc
|
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:
|
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:
|
vet:
|
||||||
go get golang.org/x/tools/cmd/vet
|
go get golang.org/x/tools/cmd/vet
|
||||||
|
|
14
main.go
14
main.go
|
@ -3,12 +3,17 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/opencontainers/specs/specs-go"
|
"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 (
|
const (
|
||||||
version = "0.0.9"
|
version = "0.0.9"
|
||||||
specConfig = "config.json"
|
specConfig = "config.json"
|
||||||
|
@ -41,7 +46,14 @@ func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "runc"
|
app.Name = "runc"
|
||||||
app.Usage = usage
|
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{
|
app.Flags = []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "debug",
|
Name: "debug",
|
||||||
|
|
Loading…
Reference in New Issue