From e9f44b52de03138d9273eadd5a87a0cea11b4f5d Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 4 Aug 2014 13:31:58 -0600 Subject: [PATCH] Add "update-vendor.sh" script and vendor our current deps (minus Docker, since that'd make a circle) Also, updated .travis.yml to use the new "vendor" directory (since this is pretty pointless without that :D) Signed-off-by: Andrew Page --- .travis.yml | 8 +++++--- Dockerfile | 8 +++++--- MAINTAINERS | 1 + Makefile | 18 ++++++++++++++++-- update-vendor.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 8 deletions(-) create mode 100755 update-vendor.sh diff --git a/.travis.yml b/.travis.yml index 331227af..3ce0e27e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,13 +13,15 @@ env: - _GOOS=linux _GOARCH=arm CGO_ENABLED=0 install: + - go get code.google.com/p/go.tools/cmd/cover - mkdir -pv "${GOPATH%%:*}/src/github.com/docker" && [ -d "${GOPATH%%:*}/src/github.com/docker/libcontainer" ] || ln -sv "$(readlink -f .)" "${GOPATH%%:*}/src/github.com/docker/libcontainer" - if [ -z "$TRAVIS_GLOBAL_WTF" ]; then gvm cross "$_GOOS" "$_GOARCH"; export GOOS="$_GOOS" GOARCH="$_GOARCH"; fi + - export GOPATH="$GOPATH:$(pwd)/vendor" - if [ -z "$TRAVIS_GLOBAL_WTF" ]; then go env; fi - - go get -d -v ./... + - go get -d -v ./... # TODO remove this if /docker/docker gets purged from our includes - if [ "$TRAVIS_GLOBAL_WTF" ]; then export DOCKER_PATH="${GOPATH%%:*}/src/github.com/docker/docker"; mkdir -p "$DOCKER_PATH/hack/make"; @@ -30,5 +32,5 @@ install: script: - if [ "$TRAVIS_GLOBAL_WTF" ]; then bash "$DOCKER_PATH/hack/make/validate-dco"; fi - if [ "$TRAVIS_GLOBAL_WTF" ]; then bash "$DOCKER_PATH/hack/make/validate-gofmt"; fi - - if [ -z "$TRAVIS_GLOBAL_WTF" ]; then go build -v ./...; fi - - if [ -z "$TRAVIS_GLOBAL_WTF" -a "$GOARCH" != 'arm' ]; then go test -test.short -v ./...; fi + - if [ -z "$TRAVIS_GLOBAL_WTF" ]; then make direct-build; fi + - if [ -z "$TRAVIS_GLOBAL_WTF" -a "$GOARCH" != 'arm' ]; then make direct-test-short; fi diff --git a/Dockerfile b/Dockerfile index 1fbba3e5..65bf5731 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM crosbymichael/golang -RUN apt-get update && apt-get install -y gcc +RUN apt-get update && apt-get install -y gcc make RUN go get code.google.com/p/go.tools/cmd/cover # setup a playground for us to spawn containers in @@ -14,8 +14,10 @@ COPY . /go/src/github.com/docker/libcontainer WORKDIR /go/src/github.com/docker/libcontainer RUN cp sample_configs/minimal.json /busybox/container.json +ENV GOPATH $GOPATH:/go/src/github.com/docker/libcontainer/vendor + RUN go get -d -v ./... -RUN go install -v ./... +RUN make direct-install ENTRYPOINT ["/dind"] -CMD ["go", "test", "-cover", "./..."] +CMD ["make", "direct-test"] diff --git a/MAINTAINERS b/MAINTAINERS index 8c36d096..798d3ca6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2,3 +2,4 @@ Michael Crosby (@crosbymichael) Rohit Jnagal (@rjnagal) Victor Marmol (@vmarmol) .travis.yml: Tianon Gravi (@tianon) +update-vendor.sh: Tianon Gravi (@tianon) diff --git a/Makefile b/Makefile index 843b761e..f7b3031b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,21 @@ all: test: # we need NET_ADMIN for the netlink tests and SYS_ADMIN for mounting - docker run --rm --cap-add NET_ADMIN --cap-add SYS_ADMIN docker/libcontainer + docker run --rm -it --cap-add NET_ADMIN --cap-add SYS_ADMIN docker/libcontainer sh: - docker run --rm -ti -w /busybox --rm --cap-add NET_ADMIN --cap-add SYS_ADMIN docker/libcontainer nsinit exec sh + docker run --rm -it --cap-add NET_ADMIN --cap-add SYS_ADMIN -w /busybox docker/libcontainer nsinit exec sh + +GO_PACKAGES = $(shell find . -not \( -wholename ./vendor -prune \) -name '*.go' -print0 | xargs -0n1 dirname | sort -u) + +direct-test: + go test -cover -v $(GO_PACKAGES) + +direct-test-short: + go test -cover -test.short -v $(GO_PACKAGES) + +direct-build: + go build -v $(GO_PACKAGES) + +direct-install: + go install -v $(GO_PACKAGES) diff --git a/update-vendor.sh b/update-vendor.sh new file mode 100755 index 00000000..df66a0a8 --- /dev/null +++ b/update-vendor.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -e + +cd "$(dirname "$BASH_SOURCE")" + +# Downloads dependencies into vendor/ directory +mkdir -p vendor +cd vendor + +clone() { + vcs=$1 + pkg=$2 + rev=$3 + + pkg_url=https://$pkg + target_dir=src/$pkg + + echo -n "$pkg @ $rev: " + + if [ -d $target_dir ]; then + echo -n 'rm old, ' + rm -fr $target_dir + fi + + echo -n 'clone, ' + case $vcs in + git) + git clone --quiet --no-checkout $pkg_url $target_dir + ( cd $target_dir && git reset --quiet --hard $rev ) + ;; + hg) + hg clone --quiet --updaterev $rev $pkg_url $target_dir + ;; + esac + + echo -n 'rm VCS, ' + ( cd $target_dir && rm -rf .{git,hg} ) + + echo done +} + +# the following lines are in sorted order, FYI +clone git github.com/codegangsta/cli 1.1.0 +clone git github.com/coreos/go-systemd v2 +clone git github.com/godbus/dbus v1 +clone git github.com/syndtr/gocapability 3c85049eae + +# intentionally not vendoring Docker itself... that'd be a circle :)