| ... | ... |
@@ -10,6 +10,11 @@ ifeq ($(VERBOSE), 1) |
| 10 | 10 |
GO_OPTIONS += -v |
| 11 | 11 |
endif |
| 12 | 12 |
|
| 13 |
+GIT_COMMIT = $(shell git rev-parse --short HEAD) |
|
| 14 |
+GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES") |
|
| 15 |
+ |
|
| 16 |
+BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS)" |
|
| 17 |
+ |
|
| 13 | 18 |
SRC_DIR := $(GOPATH)/src |
| 14 | 19 |
|
| 15 | 20 |
DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) |
| ... | ... |
@@ -24,7 +29,7 @@ all: $(DOCKER_BIN) |
| 24 | 24 |
|
| 25 | 25 |
$(DOCKER_BIN): $(DOCKER_DIR) |
| 26 | 26 |
@mkdir -p $(dir $@) |
| 27 |
- @(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) -o $@) |
|
| 27 |
+ @(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@) |
|
| 28 | 28 |
@echo $(DOCKER_BIN_RELATIVE) is created. |
| 29 | 29 |
|
| 30 | 30 |
$(DOCKER_DIR): |
| ... | ... |
@@ -21,6 +21,8 @@ import ( |
| 21 | 21 |
|
| 22 | 22 |
const VERSION = "0.1.1" |
| 23 | 23 |
|
| 24 |
+var GIT_COMMIT string |
|
| 25 |
+ |
|
| 24 | 26 |
func (srv *Server) Name() string {
|
| 25 | 27 |
return "docker" |
| 26 | 28 |
} |
| ... | ... |
@@ -179,6 +181,7 @@ func (srv *Server) CmdWait(stdin io.ReadCloser, stdout io.Writer, args ...string |
| 179 | 179 |
// 'docker version': show version information |
| 180 | 180 |
func (srv *Server) CmdVersion(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
| 181 | 181 |
fmt.Fprintf(stdout, "Version:%s\n", VERSION) |
| 182 |
+ fmt.Fprintf(stdout, "Git Commit:%s\n", GIT_COMMIT) |
|
| 182 | 183 |
return nil |
| 183 | 184 |
} |
| 184 | 185 |
|
| ... | ... |
@@ -11,6 +11,8 @@ import ( |
| 11 | 11 |
"os/signal" |
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 |
+var GIT_COMMIT string |
|
| 15 |
+ |
|
| 14 | 16 |
func main() {
|
| 15 | 17 |
if docker.SelfPath() == "/sbin/init" {
|
| 16 | 18 |
// Running in init mode |
| ... | ... |
@@ -24,6 +26,7 @@ func main() {
|
| 24 | 24 |
if *flDebug {
|
| 25 | 25 |
os.Setenv("DEBUG", "1")
|
| 26 | 26 |
} |
| 27 |
+ docker.GIT_COMMIT = GIT_COMMIT |
|
| 27 | 28 |
if *flDaemon {
|
| 28 | 29 |
if flag.NArg() != 0 {
|
| 29 | 30 |
flag.Usage() |