2013-03-15 02:44:32 +00:00
|
|
|
PKG_NAME=dotcloud-docker
|
2013-03-14 04:11:05 +00:00
|
|
|
PKG_ARCH=amd64
|
2013-03-14 00:08:04 +00:00
|
|
|
PKG_VERSION=1
|
|
|
|
ROOT_PATH:=$(PWD)
|
2013-03-14 04:11:05 +00:00
|
|
|
BUILD_PATH=build # Do not change, decided by dpkg-buildpackage
|
2013-03-14 00:08:04 +00:00
|
|
|
BUILD_SRC=build_src
|
|
|
|
GITHUB_PATH=src/github.com/dotcloud/docker
|
|
|
|
INSDIR=usr/bin
|
2013-03-15 04:13:33 +00:00
|
|
|
SOURCE_PACKAGE=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
|
2013-03-14 04:11:05 +00:00
|
|
|
DEB_PACKAGE=$(PKG_NAME)_$(PKG_VERSION)_$(PKG_ARCH).deb
|
2013-03-15 04:13:33 +00:00
|
|
|
EXTRA_GO_PKG=fs auth
|
|
|
|
|
2013-03-15 05:48:45 +00:00
|
|
|
TMPDIR=$(shell mktemp -d -t XXXXXX)
|
2013-03-15 04:13:33 +00:00
|
|
|
|
|
|
|
|
2013-03-14 04:11:05 +00:00
|
|
|
# Build a debian source package
|
2013-03-17 18:59:59 +00:00
|
|
|
all: clean build_in_deb
|
2013-03-14 04:11:05 +00:00
|
|
|
|
|
|
|
build_in_deb:
|
|
|
|
echo "GOPATH = " $(ROOT_PATH)
|
|
|
|
mkdir bin
|
|
|
|
cd $(GITHUB_PATH)/docker; GOPATH=$(ROOT_PATH) go build -o $(ROOT_PATH)/bin/docker
|
2013-03-13 00:25:11 +00:00
|
|
|
|
2013-03-14 00:08:04 +00:00
|
|
|
# DESTDIR provided by Debian packaging
|
2013-03-14 04:11:05 +00:00
|
|
|
install:
|
|
|
|
# Call this from a go environment (as packaged for deb source package)
|
2013-03-14 00:08:04 +00:00
|
|
|
mkdir -p $(DESTDIR)/$(INSDIR)
|
|
|
|
mkdir -p $(DESTDIR)/etc/init
|
2013-03-14 04:11:05 +00:00
|
|
|
install -m 0755 bin/docker $(DESTDIR)/$(INSDIR)
|
2013-03-15 02:44:32 +00:00
|
|
|
install -o root -m 0755 etc/docker.upstart $(DESTDIR)/etc/init/docker.conf
|
2013-03-14 04:11:05 +00:00
|
|
|
|
2013-03-17 18:53:37 +00:00
|
|
|
$(BUILD_SRC): clean
|
2013-03-14 04:11:05 +00:00
|
|
|
# Copy ourselves into $BUILD_SRC to comply with unusual golang constraints
|
|
|
|
tar --exclude=*.tar.gz --exclude=checkout.tgz -f checkout.tgz -cz *
|
|
|
|
mkdir -p $(BUILD_SRC)/$(GITHUB_PATH)
|
|
|
|
tar -f checkout.tgz -C $(BUILD_SRC)/$(GITHUB_PATH) -xz
|
|
|
|
cd $(BUILD_SRC)/$(GITHUB_PATH)/docker; GOPATH=$(ROOT_PATH)/$(BUILD_SRC) go get -d
|
|
|
|
for d in `find $(BUILD_SRC) -name '.git*'`; do rm -rf $$d; done
|
|
|
|
# Populate source build with debian stuff
|
|
|
|
cp -R -L ./deb/* $(BUILD_SRC)
|
|
|
|
|
|
|
|
$(SOURCE_PACKAGE): $(BUILD_SRC)
|
|
|
|
rm -f $(SOURCE_PACKAGE)
|
|
|
|
# Create the debian source package
|
|
|
|
tar -f $(SOURCE_PACKAGE) -C ${ROOT_PATH}/${BUILD_SRC} -cz .
|
2013-03-13 00:25:11 +00:00
|
|
|
|
2013-03-14 00:08:04 +00:00
|
|
|
# Build deb package fetching go dependencies and cleaning up git repositories
|
2013-03-14 04:22:30 +00:00
|
|
|
deb: $(DEB_PACKAGE)
|
2013-03-15 04:13:33 +00:00
|
|
|
|
2013-03-14 04:22:30 +00:00
|
|
|
$(DEB_PACKAGE): $(SOURCE_PACKAGE)
|
2013-03-14 04:11:05 +00:00
|
|
|
# dpkg-buildpackage looks for source package tarball in ../
|
|
|
|
cd $(BUILD_SRC); dpkg-buildpackage
|
2013-03-14 00:08:04 +00:00
|
|
|
rm -rf $(BUILD_PATH) debian/$(PKG_NAME)* debian/files
|
2013-03-13 00:25:11 +00:00
|
|
|
|
2013-03-14 04:11:05 +00:00
|
|
|
debsrc: $(SOURCE_PACKAGE)
|
|
|
|
|
2013-03-15 05:48:45 +00:00
|
|
|
# Build local sources
|
|
|
|
#$(PKG_NAME): build_local
|
|
|
|
|
|
|
|
build_local:
|
|
|
|
-@mkdir -p bin
|
|
|
|
cd docker && go build -o ../bin/docker
|
|
|
|
|
|
|
|
gotest:
|
|
|
|
@echo "\033[36m[Testing]\033[00m docker..."
|
|
|
|
@sudo -E GOPATH=$(ROOT_PATH)/$(BUILD_SRC) go test -v && \
|
|
|
|
echo -n "\033[32m[OK]\033[00m" || \
|
|
|
|
echo -n "\033[31m[FAIL]\033[00m"; \
|
|
|
|
echo " docker"
|
|
|
|
@echo "Testing extra repos {$(EXTRA_GO_PKG)}"
|
|
|
|
@for package in $(EXTRA_GO_PKG); do \
|
|
|
|
echo "\033[36m[Testing]\033[00m docker/$$package..." && \
|
|
|
|
cd $$package ; \
|
|
|
|
sudo -E GOPATH=$(ROOT_PATH)/$(BUILD_SRC) go test -v && \
|
|
|
|
echo -n "\033[32m[OK]\033[00m" || \
|
|
|
|
echo -n "\033[31m[FAIL]\033[00m" ; \
|
|
|
|
echo " docker/$$package" ; \
|
|
|
|
cd .. ;\
|
|
|
|
done
|
|
|
|
@sudo rm -rf /tmp/docker-*
|
|
|
|
|
2013-03-17 18:53:37 +00:00
|
|
|
clean:
|
2013-03-17 18:54:05 +00:00
|
|
|
rm -rf $(BUILD_PATH) debian/$(PKG_NAME)* debian/files $(BUILD_SRC) checkout.tgz bin
|