From 96b96735ed198806286f979af64283b9e1fd14cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 5 Apr 2016 16:53:04 +0200 Subject: [PATCH 1/2] Allow keeping vendor subdirectories in vendored packages github.com/coreos/etcd as of v2.2.5 uses a Godeps subdirectory, and imports packages by including the Godeps path fragments directly in the package name; so we can't just remove the subdirectory and vendor the included package directly. So, add a flag to clone() to surpress removing the vendor subdirectories. --- hack/.vendor-helpers.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hack/.vendor-helpers.sh b/hack/.vendor-helpers.sh index d5d8661f..fd64227c 100755 --- a/hack/.vendor-helpers.sh +++ b/hack/.vendor-helpers.sh @@ -10,6 +10,12 @@ export GOPATH="$GOPATH:${PWD}/vendor" find="/usr/bin/find" clone() { + local delete_vendor=true + if [ "x$1" = x--keep-vendor ]; then + delete_vendor=false + shift + fi + local vcs="$1" local pkg="$2" local rev="$3" @@ -39,8 +45,10 @@ clone() { echo -n 'rm VCS, ' ( cd "$target" && rm -rf .{git,hg} ) - echo -n 'rm vendor, ' - ( cd "$target" && rm -rf vendor Godeps/_workspace ) + if $delete_vendor; then + echo -n 'rm vendor, ' + ( cd "$target" && rm -rf vendor Godeps/_workspace ) + fi echo done } From f7b81b5627ce4ed116f3668abbf97db7d67bb36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 5 Apr 2016 16:55:39 +0200 Subject: [PATCH 2/2] Fix dependency computation Set GOPATH to start with ./vendor so that we use the dependencies in our vendored versions instead of dependencies in whatever other version is elsewhere in GOPATH. And then undo it when trying to list the non-vendor subpackages in the current directory. --- hack/.vendor-helpers.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hack/.vendor-helpers.sh b/hack/.vendor-helpers.sh index fd64227c..1a1d5db0 100755 --- a/hack/.vendor-helpers.sh +++ b/hack/.vendor-helpers.sh @@ -5,7 +5,8 @@ PROJECT=github.com/projectatomic/skopeo # Downloads dependencies into vendor/ directory mkdir -p vendor -export GOPATH="$GOPATH:${PWD}/vendor" +original_GOPATH=$GOPATH +export GOPATH="${PWD}/vendor:$GOPATH" find="/usr/bin/find" @@ -54,7 +55,9 @@ clone() { } clean() { - local packages=($(go list -e ./... | grep -v "^${PROJECT}/vendor")) + # If $GOPATH starts with ./vendor, (go list) shows the short-form import paths for packages inside ./vendor. + # So, reset GOPATH to the external value (without ./vendor), so that the grep -v works. + local packages=($(GOPATH=$original_GOPATH go list -e ./... | grep -v "^${PROJECT}/vendor")) local platforms=( linux/amd64 linux/386 ) local buildTags=( )