From dbc8de7ddc1467f4e9fb861b1db30d1571a937be Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 22 Mar 2016 11:49:01 -0700 Subject: [PATCH 1/3] Add function for copy containerd This adds a function for copying containerd and other binaries as well as adding a hash for those files. Signed-off-by: Michael Crosby Upstream-commit: 78568f2eb54a6455dad566923f3c6f03ac300405 Component: engine --- components/engine/hack/make.sh | 22 ++++++++++++++++++++++ components/engine/hack/make/binary | 16 +--------------- components/engine/hack/make/gccgo | 16 +--------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/components/engine/hack/make.sh b/components/engine/hack/make.sh index e2f9dfefbd..950b426a77 100755 --- a/components/engine/hack/make.sh +++ b/components/engine/hack/make.sh @@ -289,6 +289,28 @@ bundle() { source "$SCRIPTDIR/make/$bundle" "$@" } +copy_containerd() { + dir="$1" + # Add nested executables to bundle dir so we have complete set of + # them available, but only if the native OS/ARCH is the same as the + # OS/ARCH of the build target + if [ "$(go env GOOS)/$(go env GOARCH)" == "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then + (set -x + if [ -x /usr/local/bin/runc ]; then + echo "Copying nested executables into $dir" + cp /usr/local/bin/runc "$dir/" + cp /usr/local/bin/ctr "$dir/" + cp /usr/local/bin/containerd "$dir/" + cp /usr/local/bin/containerd-shim "$dir/" + hash_files "$dir/runc" + hash_files "$dir/ctr" + hash_files "$dir/containerd" + hash_files "$dir/containerd-shim" + fi + ) + fi +} + main() { # We want this to fail if the bundles already exist and cannot be removed. # This is to avoid mixing bundles from different versions of the code. diff --git a/components/engine/hack/make/binary b/components/engine/hack/make/binary index 20c7d2484c..119c38342e 100644 --- a/components/engine/hack/make/binary +++ b/components/engine/hack/make/binary @@ -61,19 +61,5 @@ go build \ echo "Created binary: $DEST/$BINARY_FULLNAME" ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION" +copy_containerd "$DEST" hash_files "$DEST/$BINARY_FULLNAME" - -# Add nested executables to bundle dir so we have complete set of -# them available, but only if the native OS/ARCH is the same as the -# OS/ARCH of the build target -if [ "$(go env GOOS)/$(go env GOARCH)" == "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then - echo "Copying nested executables into $DEST" - (set -x - if [ -x /usr/local/bin/runc ]; then - cp /usr/local/bin/runc $DEST/ - cp /usr/local/bin/ctr $DEST/ - cp /usr/local/bin/containerd $DEST/ - cp /usr/local/bin/containerd-shim $DEST/ - fi - ) -fi diff --git a/components/engine/hack/make/gccgo b/components/engine/hack/make/gccgo index 39a3f8556a..f7a1530235 100644 --- a/components/engine/hack/make/gccgo +++ b/components/engine/hack/make/gccgo @@ -26,19 +26,5 @@ go build -compiler=gccgo \ echo "Created binary: $DEST/$BINARY_FULLNAME" ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION" +copy_containerd "$DEST" hash_files "$DEST/$BINARY_FULLNAME" - -# Add nested executables to bundle dir so we have complete set of -# them available, but only if the native OS/ARCH is the same as the -# OS/ARCH of the build target -if [ "$(go env GOOS)/$(go env GOARCH)" == "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then - echo "Copying nested executables into $DEST" - (set -x - if [ -x /usr/local/bin/runc ]; then - cp /usr/local/bin/runc $DEST/ - cp /usr/local/bin/ctr $DEST/ - cp /usr/local/bin/containerd $DEST/ - cp /usr/local/bin/containerd-shim $DEST/ - fi - ) -fi From bf2f93474320a1b43abcbad87b8a7fcd963232c0 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 22 Mar 2016 12:23:17 -0700 Subject: [PATCH 2/3] Copy containerd binaries in tgz Signed-off-by: Michael Crosby Upstream-commit: aca7e73a69c13ec0e64cc60a9ebfeb92aca3d9a6 Component: engine --- components/engine/hack/make/tgz | 1 + 1 file changed, 1 insertion(+) diff --git a/components/engine/hack/make/tgz b/components/engine/hack/make/tgz index a512b832d2..19f391ef51 100644 --- a/components/engine/hack/make/tgz +++ b/components/engine/hack/make/tgz @@ -22,6 +22,7 @@ for d in "$CROSS/"*/*; do mkdir -p "$DEST/build/usr/local/bin" cp -L "$d/$BINARY_FULLNAME" "$DEST/build/usr/local/bin/docker$BINARY_EXTENSION" + copy_containerd "$DEST/build/usr/local/bin/" tar --numeric-owner --owner 0 -C "$DEST/build" -czf "$TGZ" usr From 8c7ac04699f9a206cca4868311502a90b3f1716b Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 22 Mar 2016 14:12:29 -0700 Subject: [PATCH 3/3] Export GOOS and GOARCH in subprocess for tgz Signed-off-by: Michael Crosby Upstream-commit: 5ff66748daecb9674b22983b84ac95c76e04ed00 Component: engine --- components/engine/hack/make.sh | 10 ++++++---- components/engine/hack/make/binary | 2 +- components/engine/hack/make/gccgo | 2 +- components/engine/hack/make/tgz | 6 ++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/components/engine/hack/make.sh b/components/engine/hack/make.sh index 950b426a77..e1ea573e12 100755 --- a/components/engine/hack/make.sh +++ b/components/engine/hack/make.sh @@ -302,10 +302,12 @@ copy_containerd() { cp /usr/local/bin/ctr "$dir/" cp /usr/local/bin/containerd "$dir/" cp /usr/local/bin/containerd-shim "$dir/" - hash_files "$dir/runc" - hash_files "$dir/ctr" - hash_files "$dir/containerd" - hash_files "$dir/containerd-shim" + if [ "$2" == "hash" ]; then + hash_files "$dir/runc" + hash_files "$dir/ctr" + hash_files "$dir/containerd" + hash_files "$dir/containerd-shim" + fi fi ) fi diff --git a/components/engine/hack/make/binary b/components/engine/hack/make/binary index 119c38342e..378af761be 100644 --- a/components/engine/hack/make/binary +++ b/components/engine/hack/make/binary @@ -61,5 +61,5 @@ go build \ echo "Created binary: $DEST/$BINARY_FULLNAME" ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION" -copy_containerd "$DEST" +copy_containerd "$DEST" "hash" hash_files "$DEST/$BINARY_FULLNAME" diff --git a/components/engine/hack/make/gccgo b/components/engine/hack/make/gccgo index f7a1530235..9da203ff79 100644 --- a/components/engine/hack/make/gccgo +++ b/components/engine/hack/make/gccgo @@ -26,5 +26,5 @@ go build -compiler=gccgo \ echo "Created binary: $DEST/$BINARY_FULLNAME" ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION" -copy_containerd "$DEST" +copy_containerd "$DEST" "hash" hash_files "$DEST/$BINARY_FULLNAME" diff --git a/components/engine/hack/make/tgz b/components/engine/hack/make/tgz index 19f391ef51..93a69cbe53 100644 --- a/components/engine/hack/make/tgz +++ b/components/engine/hack/make/tgz @@ -9,9 +9,10 @@ if [ ! -d "$CROSS/linux/amd64" ]; then false fi +( for d in "$CROSS/"*/*; do - GOARCH="$(basename "$d")" - GOOS="$(basename "$(dirname "$d")")" + export GOARCH="$(basename "$d")" + export GOOS="$(basename "$(dirname "$d")")" BINARY_NAME="docker-$VERSION" BINARY_EXTENSION="$(export GOOS && binary_extension)" BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" @@ -32,3 +33,4 @@ for d in "$CROSS/"*/*; do echo "Created tgz: $TGZ" done +)