Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
| 1 | 1 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,117 @@ |
| 0 |
+#!/usr/bin/env bash |
|
| 1 |
+ |
|
| 2 |
+# Downloads dependencies into vendor/ directory |
|
| 3 |
+mkdir -p vendor |
|
| 4 |
+ |
|
| 5 |
+rm -rf .gopath |
|
| 6 |
+mkdir -p .gopath/src/github.com/docker |
|
| 7 |
+ln -sf ../../../.. .gopath/src/github.com/docker/docker |
|
| 8 |
+export GOPATH="${PWD}/.gopath:${PWD}/vendor"
|
|
| 9 |
+ |
|
| 10 |
+clone() {
|
|
| 11 |
+ local vcs="$1" |
|
| 12 |
+ local pkg="$2" |
|
| 13 |
+ local rev="$3" |
|
| 14 |
+ |
|
| 15 |
+ local url="https://$pkg" |
|
| 16 |
+ local target="vendor/src/$pkg" |
|
| 17 |
+ |
|
| 18 |
+ echo -n "$pkg @ $rev: " |
|
| 19 |
+ |
|
| 20 |
+ if [ -d "$target" ]; then |
|
| 21 |
+ echo -n 'rm old, ' |
|
| 22 |
+ rm -rf "$target" |
|
| 23 |
+ fi |
|
| 24 |
+ |
|
| 25 |
+ echo -n 'clone, ' |
|
| 26 |
+ case "$vcs" in |
|
| 27 |
+ git) |
|
| 28 |
+ git clone --quiet --no-checkout "$url" "$target" |
|
| 29 |
+ ( cd "$target" && git reset --quiet --hard "$rev" ) |
|
| 30 |
+ ;; |
|
| 31 |
+ hg) |
|
| 32 |
+ hg clone --quiet --updaterev "$rev" "$url" "$target" |
|
| 33 |
+ ;; |
|
| 34 |
+ esac |
|
| 35 |
+ |
|
| 36 |
+ echo -n 'rm VCS, ' |
|
| 37 |
+ ( cd "$target" && rm -rf .{git,hg} )
|
|
| 38 |
+ |
|
| 39 |
+ echo -n 'rm vendor, ' |
|
| 40 |
+ ( cd "$target" && rm -rf vendor Godeps/_workspace ) |
|
| 41 |
+ |
|
| 42 |
+ echo done |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+# get an ENV from the Dockerfile with support for multiline values |
|
| 46 |
+_dockerfile_env() {
|
|
| 47 |
+ local e="$1" |
|
| 48 |
+ awk ' |
|
| 49 |
+ $1 == "ENV" && $2 == "'"$e"'" {
|
|
| 50 |
+ sub(/^ENV +([^ ]+) +/, ""); |
|
| 51 |
+ inEnv = 1; |
|
| 52 |
+ } |
|
| 53 |
+ inEnv {
|
|
| 54 |
+ if (sub(/\\$/, "")) {
|
|
| 55 |
+ printf "%s", $0; |
|
| 56 |
+ next; |
|
| 57 |
+ } |
|
| 58 |
+ print; |
|
| 59 |
+ exit; |
|
| 60 |
+ } |
|
| 61 |
+ ' Dockerfile |
|
| 62 |
+} |
|
| 63 |
+ |
|
| 64 |
+clean() {
|
|
| 65 |
+ local packages=( |
|
| 66 |
+ github.com/docker/docker/docker # package main |
|
| 67 |
+ github.com/docker/docker/dockerinit # package main |
|
| 68 |
+ github.com/docker/docker/integration-cli # external tests |
|
| 69 |
+ ) |
|
| 70 |
+ |
|
| 71 |
+ local dockerPlatforms=( linux/amd64 $(_dockerfile_env DOCKER_CROSSPLATFORMS) ) |
|
| 72 |
+ local dockerBuildTags="$(_dockerfile_env DOCKER_BUILDTAGS)" |
|
| 73 |
+ local buildTagCombos=( |
|
| 74 |
+ '' |
|
| 75 |
+ 'experimental' |
|
| 76 |
+ "$dockerBuildTags" |
|
| 77 |
+ "daemon $dockerBuildTags" |
|
| 78 |
+ "experimental $dockerBuildTags" |
|
| 79 |
+ "experimental daemon $dockerBuildTags" |
|
| 80 |
+ ) |
|
| 81 |
+ |
|
| 82 |
+ echo |
|
| 83 |
+ |
|
| 84 |
+ echo -n 'collecting import graph, ' |
|
| 85 |
+ local IFS=$'\n' |
|
| 86 |
+ local imports=( $( |
|
| 87 |
+ for platform in "${dockerPlatforms[@]}"; do
|
|
| 88 |
+ export GOOS="${platform%/*}";
|
|
| 89 |
+ export GOARCH="${platform##*/}";
|
|
| 90 |
+ for buildTags in "${buildTagCombos[@]}"; do
|
|
| 91 |
+ go list -e -tags "$buildTags" -f '{{join .Deps "\n"}}' "${packages[@]}"
|
|
| 92 |
+ done |
|
| 93 |
+ done | grep -vE '^github.com/docker/docker' | sort -u |
|
| 94 |
+ ) ) |
|
| 95 |
+ imports=( $(go list -e -f '{{if not .Standard}}{{.ImportPath}}{{end}}' "${imports[@]}") )
|
|
| 96 |
+ unset IFS |
|
| 97 |
+ |
|
| 98 |
+ echo -n 'pruning unused packages, ' |
|
| 99 |
+ findArgs=() |
|
| 100 |
+ for import in "${imports[@]}"; do
|
|
| 101 |
+ [ "${#findArgs[@]}" -eq 0 ] || findArgs+=( -or )
|
|
| 102 |
+ findArgs+=( -path "vendor/src/$import" ) |
|
| 103 |
+ done |
|
| 104 |
+ local IFS=$'\n' |
|
| 105 |
+ local prune=( $(find vendor -depth -type d -not '(' "${findArgs[@]}" ')') )
|
|
| 106 |
+ unset IFS |
|
| 107 |
+ for dir in "${prune[@]}"; do
|
|
| 108 |
+ find "$dir" -maxdepth 1 -not -type d -exec rm -f '{}' +
|
|
| 109 |
+ rmdir "$dir" 2>/dev/null || true |
|
| 110 |
+ done |
|
| 111 |
+ |
|
| 112 |
+ echo -n 'pruning unused files, ' |
|
| 113 |
+ find vendor -type f -name '*_test.go' -exec rm '{}' +
|
|
| 114 |
+ |
|
| 115 |
+ echo done |
|
| 116 |
+} |
| ... | ... |
@@ -2,45 +2,7 @@ |
| 2 | 2 |
set -e |
| 3 | 3 |
|
| 4 | 4 |
cd "$(dirname "$BASH_SOURCE")/.." |
| 5 |
- |
|
| 6 |
-# Downloads dependencies into vendor/ directory |
|
| 7 |
-mkdir -p vendor |
|
| 8 |
-cd vendor |
|
| 9 |
- |
|
| 10 |
-clone() {
|
|
| 11 |
- vcs=$1 |
|
| 12 |
- pkg=$2 |
|
| 13 |
- rev=$3 |
|
| 14 |
- |
|
| 15 |
- pkg_url=https://$pkg |
|
| 16 |
- target_dir=src/$pkg |
|
| 17 |
- |
|
| 18 |
- echo -n "$pkg @ $rev: " |
|
| 19 |
- |
|
| 20 |
- if [ -d $target_dir ]; then |
|
| 21 |
- echo -n 'rm old, ' |
|
| 22 |
- rm -fr $target_dir |
|
| 23 |
- fi |
|
| 24 |
- |
|
| 25 |
- echo -n 'clone, ' |
|
| 26 |
- case $vcs in |
|
| 27 |
- git) |
|
| 28 |
- git clone --quiet --no-checkout $pkg_url $target_dir |
|
| 29 |
- ( cd $target_dir && git reset --quiet --hard $rev ) |
|
| 30 |
- ;; |
|
| 31 |
- hg) |
|
| 32 |
- hg clone --quiet --updaterev $rev $pkg_url $target_dir |
|
| 33 |
- ;; |
|
| 34 |
- esac |
|
| 35 |
- |
|
| 36 |
- echo -n 'rm VCS, ' |
|
| 37 |
- ( cd $target_dir && rm -rf .{git,hg} )
|
|
| 38 |
- |
|
| 39 |
- echo -n 'rm vendor, ' |
|
| 40 |
- ( cd $target_dir && rm -rf vendor Godeps/_workspace ) |
|
| 41 |
- |
|
| 42 |
- echo done |
|
| 43 |
-} |
|
| 5 |
+source 'hack/.vendor-helpers.sh' |
|
| 44 | 6 |
|
| 45 | 7 |
# the following lines are in sorted order, FYI |
| 46 | 8 |
clone git github.com/Sirupsen/logrus v0.8.2 # logrus is a common dependency among multiple deps |
| ... | ... |
@@ -61,13 +23,6 @@ clone git github.com/vishvananda/netlink 8eb64238879fed52fd51c5b30ad20b928fb4c36 |
| 61 | 61 |
|
| 62 | 62 |
# get distribution packages |
| 63 | 63 |
clone git github.com/docker/distribution b9eeb328080d367dbde850ec6e94f1e4ac2b5efe |
| 64 |
-mv src/github.com/docker/distribution/digest tmp-digest |
|
| 65 |
-mv src/github.com/docker/distribution/registry/api tmp-api |
|
| 66 |
-rm -rf src/github.com/docker/distribution |
|
| 67 |
-mkdir -p src/github.com/docker/distribution |
|
| 68 |
-mv tmp-digest src/github.com/docker/distribution/digest |
|
| 69 |
-mkdir -p src/github.com/docker/distribution/registry |
|
| 70 |
-mv tmp-api src/github.com/docker/distribution/registry/api |
|
| 71 | 64 |
|
| 72 | 65 |
clone git github.com/docker/libcontainer v2.1.1 |
| 73 | 66 |
# libcontainer deps (see src/github.com/docker/libcontainer/update-vendor.sh) |
| ... | ... |
@@ -76,3 +31,5 @@ clone git github.com/godbus/dbus v2 |
| 76 | 76 |
clone git github.com/syndtr/gocapability 66ef2aa7a23ba682594e2b6f74cf40c0692b49fb |
| 77 | 77 |
clone git github.com/golang/protobuf 655cdfa588ea |
| 78 | 78 |
clone git github.com/Graylog2/go-gelf 6c62a85f1d47a67f2a5144c0e745b325889a8120 |
| 79 |
+ |
|
| 80 |
+clean |