2013-03-25 21:48:46 +00:00
|
|
|
DOCKER_PACKAGE := github.com/dotcloud/docker
|
2013-04-24 01:32:59 +00:00
|
|
|
RELEASE_VERSION := $(shell git tag | grep -E "v[0-9\.]+$$" | sort -nr | head -n 1)
|
|
|
|
SRCRELEASE := docker-$(RELEASE_VERSION)
|
|
|
|
BINRELEASE := docker-$(RELEASE_VERSION).tgz
|
2013-06-24 22:01:51 +00:00
|
|
|
BUILD_SRC := build_src
|
|
|
|
BUILD_PATH := ${BUILD_SRC}/src/${DOCKER_PACKAGE}
|
2013-03-25 21:48:46 +00:00
|
|
|
|
2013-04-24 01:32:59 +00:00
|
|
|
GIT_ROOT := $(shell git rev-parse --show-toplevel)
|
2013-03-26 00:23:36 +00:00
|
|
|
BUILD_DIR := $(CURDIR)/.gopath
|
2013-03-25 21:48:46 +00:00
|
|
|
|
|
|
|
GOPATH ?= $(BUILD_DIR)
|
|
|
|
export GOPATH
|
|
|
|
|
2013-07-05 23:49:55 +00:00
|
|
|
GO_OPTIONS ?= -a -ldflags='-w -d'
|
2013-03-26 06:28:35 +00:00
|
|
|
ifeq ($(VERBOSE), 1)
|
|
|
|
GO_OPTIONS += -v
|
|
|
|
endif
|
|
|
|
|
2013-04-02 14:38:08 +00:00
|
|
|
GIT_COMMIT = $(shell git rev-parse --short HEAD)
|
|
|
|
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES")
|
|
|
|
|
2013-06-15 00:43:12 +00:00
|
|
|
BUILD_OPTIONS = -a -ldflags "-X main.GITCOMMIT $(GIT_COMMIT)$(GIT_STATUS) -d -w"
|
2013-04-01 18:12:56 +00:00
|
|
|
|
2013-03-25 21:48:46 +00:00
|
|
|
SRC_DIR := $(GOPATH)/src
|
|
|
|
|
|
|
|
DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE)
|
|
|
|
DOCKER_MAIN := $(DOCKER_DIR)/docker
|
|
|
|
|
2013-03-26 14:30:01 +00:00
|
|
|
DOCKER_BIN_RELATIVE := bin/docker
|
|
|
|
DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE)
|
2013-03-25 21:48:46 +00:00
|
|
|
|
2013-04-24 02:41:38 +00:00
|
|
|
.PHONY: all clean test hack release srcrelease $(BINRELEASE) $(SRCRELEASE) $(DOCKER_BIN) $(DOCKER_DIR)
|
2013-03-25 21:48:46 +00:00
|
|
|
|
|
|
|
all: $(DOCKER_BIN)
|
|
|
|
|
|
|
|
$(DOCKER_BIN): $(DOCKER_DIR)
|
|
|
|
@mkdir -p $(dir $@)
|
2013-06-03 20:18:44 +00:00
|
|
|
@(cd $(DOCKER_MAIN); CGO_ENABLED=0 go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@)
|
2013-03-26 14:30:01 +00:00
|
|
|
@echo $(DOCKER_BIN_RELATIVE) is created.
|
2013-03-25 21:48:46 +00:00
|
|
|
|
|
|
|
$(DOCKER_DIR):
|
|
|
|
@mkdir -p $(dir $@)
|
2013-05-03 19:58:44 +00:00
|
|
|
@if [ -h $@ ]; then rm -f $@; fi; ln -sf $(CURDIR)/ $@
|
2013-05-08 20:50:26 +00:00
|
|
|
@(cd $(DOCKER_MAIN); go get -d $(GO_OPTIONS))
|
2013-03-25 21:48:46 +00:00
|
|
|
|
2013-04-24 01:32:59 +00:00
|
|
|
whichrelease:
|
|
|
|
echo $(RELEASE_VERSION)
|
|
|
|
|
|
|
|
release: $(BINRELEASE)
|
2013-05-02 18:32:55 +00:00
|
|
|
s3cmd -P put $(BINRELEASE) s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-$(RELEASE_VERSION).tgz
|
2013-06-14 05:14:29 +00:00
|
|
|
s3cmd -P put docker-latest.tgz s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-latest.tgz
|
2013-07-11 00:39:00 +00:00
|
|
|
s3cmd -P put $(SRCRELEASE)/bin/docker s3://get.docker.io/builds/`uname -s`/`uname -m`/docker
|
2013-07-30 17:18:19 +00:00
|
|
|
echo $(RELEASE_VERSION) > latest ; s3cmd -P put latest s3://get.docker.io/latest ; rm latest
|
2013-05-02 18:32:55 +00:00
|
|
|
|
2013-04-24 02:41:38 +00:00
|
|
|
srcrelease: $(SRCRELEASE)
|
|
|
|
deps: $(DOCKER_DIR)
|
2013-04-24 01:32:59 +00:00
|
|
|
|
2013-04-24 02:41:38 +00:00
|
|
|
# A clean checkout of $RELEASE_VERSION, with vendored dependencies
|
2013-04-24 01:32:59 +00:00
|
|
|
$(SRCRELEASE):
|
|
|
|
rm -fr $(SRCRELEASE)
|
|
|
|
git clone $(GIT_ROOT) $(SRCRELEASE)
|
2013-04-24 01:50:53 +00:00
|
|
|
cd $(SRCRELEASE); git checkout -q $(RELEASE_VERSION)
|
2013-04-24 01:32:59 +00:00
|
|
|
|
|
|
|
# A binary release ready to be uploaded to a mirror
|
|
|
|
$(BINRELEASE): $(SRCRELEASE)
|
|
|
|
rm -f $(BINRELEASE)
|
|
|
|
cd $(SRCRELEASE); make; cp -R bin docker-$(RELEASE_VERSION); tar -f ../$(BINRELEASE) -zv -c docker-$(RELEASE_VERSION)
|
2013-06-14 05:14:29 +00:00
|
|
|
cd $(SRCRELEASE); cp -R bin docker-latest; tar -f ../docker-latest.tgz -zv -c docker-latest
|
2013-03-25 21:48:46 +00:00
|
|
|
clean:
|
|
|
|
@rm -rf $(dir $(DOCKER_BIN))
|
|
|
|
ifeq ($(GOPATH), $(BUILD_DIR))
|
|
|
|
@rm -rf $(BUILD_DIR)
|
|
|
|
else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR)))
|
|
|
|
@rm -f $(DOCKER_DIR)
|
|
|
|
endif
|
2013-03-25 22:15:37 +00:00
|
|
|
|
2013-06-24 22:01:51 +00:00
|
|
|
test:
|
|
|
|
# Copy docker source and dependencies for testing
|
|
|
|
rm -rf ${BUILD_SRC}; mkdir -p ${BUILD_PATH}
|
|
|
|
tar --exclude=${BUILD_SRC} -cz . | tar -xz -C ${BUILD_PATH}
|
|
|
|
GOPATH=${CURDIR}/${BUILD_SRC} go get -d
|
|
|
|
# Do the test
|
2013-07-05 23:49:55 +00:00
|
|
|
sudo -E GOPATH=${CURDIR}/${BUILD_SRC} CGO_ENABLED=0 go test ${GO_OPTIONS}
|
2013-06-19 18:21:46 +00:00
|
|
|
|
|
|
|
testall: all
|
2013-07-05 23:49:55 +00:00
|
|
|
@(cd $(DOCKER_DIR); CGO_ENABLED=0 sudo -E go test ./... $(GO_OPTIONS))
|
2013-04-01 20:05:00 +00:00
|
|
|
|
|
|
|
fmt:
|
2013-04-01 21:50:25 +00:00
|
|
|
@gofmt -s -l -w .
|
2013-04-09 21:30:10 +00:00
|
|
|
|
|
|
|
hack:
|
2013-05-01 18:20:10 +00:00
|
|
|
cd $(CURDIR)/hack && vagrant up
|
|
|
|
|
|
|
|
ssh-dev:
|
|
|
|
cd $(CURDIR)/hack && vagrant ssh
|