зеркало из https://github.com/microsoft/docker.git
Merge pull request #12376 from Mic92/refactor-hack
Refactor shellscripts
This commit is contained in:
Коммит
e3e1c2be42
|
@ -60,7 +60,7 @@ for HIER in $(cut -d: -f2 /proc/1/cgroup); do
|
||||||
|
|
||||||
mkdir -p "$CGROUP/$HIER"
|
mkdir -p "$CGROUP/$HIER"
|
||||||
|
|
||||||
if ! mountpoint -q $CGROUP/$HIER; then
|
if ! mountpoint -q "$CGROUP/$HIER"; then
|
||||||
mount -n -t cgroup -o "$OHIER" cgroup "$CGROUP/$HIER"
|
mount -n -t cgroup -o "$OHIER" cgroup "$CGROUP/$HIER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
19
hack/make.sh
19
hack/make.sh
|
@ -24,10 +24,12 @@ set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
export DOCKER_PKG='github.com/docker/docker'
|
export DOCKER_PKG='github.com/docker/docker'
|
||||||
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
export MAKEDIR="$SCRIPTDIR/make"
|
||||||
|
|
||||||
# We're a nice, sexy, little shell script, and people might try to run us;
|
# We're a nice, sexy, little shell script, and people might try to run us;
|
||||||
# but really, they shouldn't. We want to be in a container!
|
# but really, they shouldn't. We want to be in a container!
|
||||||
if [ "$(pwd)" != "/go/src/$DOCKER_PKG" ] || [ -z "$DOCKER_CROSSPLATFORMS" ]; then
|
if [ "$PWD" != "/go/src/$DOCKER_PKG" ] || [ -z "$DOCKER_CROSSPLATFORMS" ]; then
|
||||||
{
|
{
|
||||||
echo "# WARNING! I don't seem to be running in the Docker container."
|
echo "# WARNING! I don't seem to be running in the Docker container."
|
||||||
echo "# The result of this command might be an incorrect build, and will not be"
|
echo "# The result of this command might be an incorrect build, and will not be"
|
||||||
|
@ -62,7 +64,7 @@ DEFAULT_BUNDLES=(
|
||||||
ubuntu
|
ubuntu
|
||||||
)
|
)
|
||||||
|
|
||||||
VERSION=$(cat ./VERSION)
|
VERSION=$(< ./VERSION)
|
||||||
if command -v git &> /dev/null && git rev-parse &> /dev/null; then
|
if command -v git &> /dev/null && git rev-parse &> /dev/null; then
|
||||||
GITCOMMIT=$(git rev-parse --short HEAD)
|
GITCOMMIT=$(git rev-parse --short HEAD)
|
||||||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
||||||
|
@ -82,7 +84,7 @@ if [ "$AUTO_GOPATH" ]; then
|
||||||
rm -rf .gopath
|
rm -rf .gopath
|
||||||
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
|
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
|
||||||
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
|
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
|
||||||
export GOPATH="$(pwd)/.gopath:$(pwd)/vendor"
|
export GOPATH="${PWD}/.gopath:${PWD}/vendor"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! "$GOPATH" ]; then
|
if [ ! "$GOPATH" ]; then
|
||||||
|
@ -110,7 +112,7 @@ fi
|
||||||
# Use these flags when compiling the tests and final binary
|
# Use these flags when compiling the tests and final binary
|
||||||
|
|
||||||
IAMSTATIC='true'
|
IAMSTATIC='true'
|
||||||
source "$(dirname "$BASH_SOURCE")/make/.go-autogen"
|
source "$SCRIPTDIR/make/.go-autogen"
|
||||||
LDFLAGS='-w'
|
LDFLAGS='-w'
|
||||||
|
|
||||||
LDFLAGS_STATIC='-linkmode external'
|
LDFLAGS_STATIC='-linkmode external'
|
||||||
|
@ -251,7 +253,7 @@ bundle() {
|
||||||
bundlescript=$1
|
bundlescript=$1
|
||||||
bundle=$(basename $bundlescript)
|
bundle=$(basename $bundlescript)
|
||||||
echo "---> Making bundle: $bundle (in bundles/$VERSION/$bundle)"
|
echo "---> Making bundle: $bundle (in bundles/$VERSION/$bundle)"
|
||||||
mkdir -p bundles/$VERSION/$bundle
|
mkdir -p "bundles/$VERSION/$bundle"
|
||||||
source "$bundlescript" "$(pwd)/bundles/$VERSION/$bundle"
|
source "$bundlescript" "$(pwd)/bundles/$VERSION/$bundle"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,23 +263,22 @@ main() {
|
||||||
mkdir -p bundles
|
mkdir -p bundles
|
||||||
if [ -e "bundles/$VERSION" ]; then
|
if [ -e "bundles/$VERSION" ]; then
|
||||||
echo "bundles/$VERSION already exists. Removing."
|
echo "bundles/$VERSION already exists. Removing."
|
||||||
rm -fr bundles/$VERSION && mkdir bundles/$VERSION || exit 1
|
rm -fr "bundles/$VERSION" && mkdir "bundles/$VERSION" || exit 1
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(go env GOHOSTOS)" != 'windows' ]; then
|
if [ "$(go env GOHOSTOS)" != 'windows' ]; then
|
||||||
# Windows and symlinks don't get along well
|
# Windows and symlinks don't get along well
|
||||||
ln -sfT $VERSION bundles/latest
|
ln -sfT "$VERSION" bundles/latest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
bundles=(${DEFAULT_BUNDLES[@]})
|
bundles=(${DEFAULT_BUNDLES[@]})
|
||||||
else
|
else
|
||||||
bundles=($@)
|
bundles=($@)
|
||||||
fi
|
fi
|
||||||
for bundle in ${bundles[@]}; do
|
for bundle in ${bundles[@]}; do
|
||||||
bundle $SCRIPTDIR/make/$bundle
|
bundle "$SCRIPTDIR/make/$bundle"
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
IAMSTATIC="true"
|
IAMSTATIC="true"
|
||||||
source "$(dirname "$BASH_SOURCE")/.go-autogen"
|
source "${MAKEDIR}/.go-autogen"
|
||||||
|
|
||||||
# dockerinit still needs to be a static binary, even if docker is dynamic
|
# dockerinit still needs to be a static binary, even if docker is dynamic
|
||||||
go build \
|
go build \
|
||||||
|
@ -30,4 +30,4 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
|
# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
|
||||||
export DOCKER_INITSHA1="$($sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"
|
export DOCKER_INITSHA1=$($sha1sum "$DEST/dockerinit-$VERSION" | cut -d' ' -f1)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
IAMSTATIC="true"
|
IAMSTATIC="true"
|
||||||
source "$(dirname "$BASH_SOURCE")/.go-autogen"
|
source "${MAKEDIR}/.go-autogen"
|
||||||
|
|
||||||
# dockerinit still needs to be a static binary, even if docker is dynamic
|
# dockerinit still needs to be a static binary, even if docker is dynamic
|
||||||
go build --compiler=gccgo \
|
go build --compiler=gccgo \
|
||||||
|
@ -28,4 +28,4 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
|
# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
|
||||||
export DOCKER_INITSHA1="$($sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"
|
export DOCKER_INITSHA1=$($sha1sum "$DEST/dockerinit-$VERSION" | cut -d' ' -f1)
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
for pidFile in $(find "$DEST" -name docker.pid); do
|
for pidFile in $(find "$DEST" -name docker.pid); do
|
||||||
pid=$(set -x; cat "$pidFile")
|
pid=$(set -x; cat "$pidFile")
|
||||||
( set -x; kill $pid )
|
( set -x; kill "$pid" )
|
||||||
if ! wait $pid; then
|
if ! wait "$pid"; then
|
||||||
echo >&2 "warning: PID $pid from $pidFile had a nonzero exit code"
|
echo >&2 "warning: PID $pid from $pidFile had a nonzero exit code"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -11,7 +11,7 @@ if [[ "$(uname -s)" == CYGWIN* ]]; then
|
||||||
DEST=$(cygpath -mw $DEST)
|
DEST=$(cygpath -mw $DEST)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.go-autogen"
|
source "${MAKEDIR}/.go-autogen"
|
||||||
|
|
||||||
go build \
|
go build \
|
||||||
-o "$DEST/$BINARY_FULLNAME" \
|
-o "$DEST/$BINARY_FULLNAME" \
|
||||||
|
|
|
@ -5,7 +5,7 @@ DEST=$1
|
||||||
|
|
||||||
# subshell so that we can export PATH without breaking other things
|
# subshell so that we can export PATH without breaking other things
|
||||||
(
|
(
|
||||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
|
source "${MAKEDIR}/.integration-daemon-start"
|
||||||
|
|
||||||
# we need to wrap up everything in between integration-daemon-start and
|
# we need to wrap up everything in between integration-daemon-start and
|
||||||
# integration-daemon-stop to make sure we kill the daemon and don't hang,
|
# integration-daemon-stop to make sure we kill the daemon and don't hang,
|
||||||
|
@ -76,7 +76,7 @@ DEST=$1
|
||||||
# clean up after ourselves
|
# clean up after ourselves
|
||||||
rm -f Dockerfile.build
|
rm -f Dockerfile.build
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
|
source "${MAKEDIR}/.integration-daemon-stop"
|
||||||
|
|
||||||
[ -z "$didFail" ] # "set -e" ftw
|
[ -z "$didFail" ] # "set -e" ftw
|
||||||
) 2>&1 | tee -a $DEST/test.log
|
) 2>&1 | tee -a $DEST/test.log
|
||||||
|
|
|
@ -28,6 +28,6 @@ for platform in $DOCKER_CROSSPLATFORMS; do
|
||||||
export LDFLAGS_STATIC_DOCKER="" # we just need a simple client for these platforms
|
export LDFLAGS_STATIC_DOCKER="" # we just need a simple client for these platforms
|
||||||
export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" ) # remove the "daemon" build tag from platforms that aren't supported
|
export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" ) # remove the "daemon" build tag from platforms that aren't supported
|
||||||
fi
|
fi
|
||||||
source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform"
|
source "${MAKEDIR}/binary" "$DEST/$platform"
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|
|
@ -4,7 +4,7 @@ set -e
|
||||||
DEST=$1
|
DEST=$1
|
||||||
|
|
||||||
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
||||||
source "$(dirname "$BASH_SOURCE")/.dockerinit"
|
source "${MAKEDIR}/.dockerinit"
|
||||||
|
|
||||||
hash_files "$DEST/dockerinit-$VERSION"
|
hash_files "$DEST/dockerinit-$VERSION"
|
||||||
else
|
else
|
||||||
|
@ -18,5 +18,5 @@ fi
|
||||||
export LDFLAGS_STATIC_DOCKER=''
|
export LDFLAGS_STATIC_DOCKER=''
|
||||||
export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
|
export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
|
||||||
export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
|
export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
|
||||||
source "$(dirname "$BASH_SOURCE")/binary"
|
source "${MAKEDIR}/binary"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ set -e
|
||||||
DEST=$1
|
DEST=$1
|
||||||
|
|
||||||
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
||||||
source "$(dirname "$BASH_SOURCE")/.dockerinit-gccgo"
|
source "${MAKEDIR}/.dockerinit-gccgo"
|
||||||
|
|
||||||
hash_files "$DEST/dockerinit-$VERSION"
|
hash_files "$DEST/dockerinit-$VERSION"
|
||||||
else
|
else
|
||||||
|
@ -19,5 +19,5 @@ fi
|
||||||
export LDFLAGS_STATIC_DOCKER=''
|
export LDFLAGS_STATIC_DOCKER=''
|
||||||
export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
|
export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
|
||||||
export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
|
export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
|
||||||
source "$(dirname "$BASH_SOURCE")/gccgo"
|
source "${MAKEDIR}/gccgo"
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,7 +6,7 @@ BINARY_NAME="docker-$VERSION"
|
||||||
BINARY_EXTENSION="$(binary_extension)"
|
BINARY_EXTENSION="$(binary_extension)"
|
||||||
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.go-autogen"
|
source "${MAKEDIR}/.go-autogen"
|
||||||
|
|
||||||
if [[ "${BUILDFLAGS[@]}" =~ 'netgo ' ]]; then
|
if [[ "${BUILDFLAGS[@]}" =~ 'netgo ' ]]; then
|
||||||
EXTLDFLAGS_STATIC_DOCKER+=' -lnetgo'
|
EXTLDFLAGS_STATIC_DOCKER+=' -lnetgo'
|
||||||
|
|
|
@ -5,7 +5,7 @@ DEST=$1
|
||||||
|
|
||||||
# subshell so that we can export PATH without breaking other things
|
# subshell so that we can export PATH without breaking other things
|
||||||
(
|
(
|
||||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
|
source "${MAKEDIR}/.integration-daemon-start"
|
||||||
|
|
||||||
# we need to wrap up everything in between integration-daemon-start and
|
# we need to wrap up everything in between integration-daemon-start and
|
||||||
# integration-daemon-stop to make sure we kill the daemon and don't hang,
|
# integration-daemon-stop to make sure we kill the daemon and don't hang,
|
||||||
|
@ -24,7 +24,7 @@ DEST=$1
|
||||||
didFail=1
|
didFail=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
|
source "${MAKEDIR}/.integration-daemon-stop"
|
||||||
|
|
||||||
[ -z "$didFail" ] # "set -e" ftw
|
[ -z "$didFail" ] # "set -e" ftw
|
||||||
) 2>&1 | tee -a $DEST/test.log
|
) 2>&1 | tee -a $DEST/test.log
|
||||||
|
|
|
@ -5,7 +5,7 @@ DEST=$1
|
||||||
|
|
||||||
INIT=$DEST/../dynbinary/dockerinit-$VERSION
|
INIT=$DEST/../dynbinary/dockerinit-$VERSION
|
||||||
[ -x "$INIT" ] || {
|
[ -x "$INIT" ] || {
|
||||||
source "$(dirname "$BASH_SOURCE")/.dockerinit"
|
source "${MAKEDIR}/.dockerinit"
|
||||||
INIT="$DEST/dockerinit"
|
INIT="$DEST/dockerinit"
|
||||||
}
|
}
|
||||||
export TEST_DOCKERINIT_PATH="$INIT"
|
export TEST_DOCKERINIT_PATH="$INIT"
|
||||||
|
@ -22,4 +22,4 @@ bundle_test_integration() {
|
||||||
# spews when it is given packages that aren't used
|
# spews when it is given packages that aren't used
|
||||||
bundle_test_integration 2>&1 \
|
bundle_test_integration 2>&1 \
|
||||||
| grep --line-buffered -v '^warning: no packages being tested depend on ' \
|
| grep --line-buffered -v '^warning: no packages being tested depend on ' \
|
||||||
| tee -a $DEST/test.log
|
| tee -a "$DEST/test.log"
|
||||||
|
|
|
@ -9,23 +9,23 @@ bundle_test_integration_cli() {
|
||||||
|
|
||||||
# subshell so that we can export PATH without breaking other things
|
# subshell so that we can export PATH without breaking other things
|
||||||
(
|
(
|
||||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
|
source "${MAKEDIR}/.integration-daemon-start"
|
||||||
|
|
||||||
# we need to wrap up everything in between integration-daemon-start and
|
# we need to wrap up everything in between integration-daemon-start and
|
||||||
# integration-daemon-stop to make sure we kill the daemon and don't hang,
|
# integration-daemon-stop to make sure we kill the daemon and don't hang,
|
||||||
# even and especially on test failures
|
# even and especially on test failures
|
||||||
didFail=
|
didFail=
|
||||||
if ! {
|
if ! {
|
||||||
source "$(dirname "$BASH_SOURCE")/.ensure-frozen-images"
|
source "${MAKEDIR}/.ensure-frozen-images"
|
||||||
source "$(dirname "$BASH_SOURCE")/.ensure-httpserver"
|
source "${MAKEDIR}/.ensure-httpserver"
|
||||||
source "$(dirname "$BASH_SOURCE")/.ensure-emptyfs"
|
source "${MAKEDIR}/.ensure-emptyfs"
|
||||||
|
|
||||||
bundle_test_integration_cli
|
bundle_test_integration_cli
|
||||||
}; then
|
}; then
|
||||||
didFail=1
|
didFail=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
|
source "${MAKEDIR}/.integration-daemon-stop"
|
||||||
|
|
||||||
[ -z "$didFail" ] # "set -e" ftw
|
[ -z "$didFail" ] # "set -e" ftw
|
||||||
) 2>&1 | tee -a $DEST/test.log
|
) 2>&1 | tee -a "$DEST/test.log"
|
||||||
|
|
|
@ -39,12 +39,12 @@ bundle_test_unit() {
|
||||||
mkdir -p "$HOME/.parallel"
|
mkdir -p "$HOME/.parallel"
|
||||||
touch "$HOME/.parallel/ignored_vars"
|
touch "$HOME/.parallel/ignored_vars"
|
||||||
|
|
||||||
echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir"
|
echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ "${MAKEDIR}/.go-compile-test-dir"
|
||||||
rm -rf "$HOME"
|
rm -rf "$HOME"
|
||||||
else
|
else
|
||||||
# aww, no "parallel" available - fall back to boring
|
# aww, no "parallel" available - fall back to boring
|
||||||
for test_dir in $TESTDIRS; do
|
for test_dir in $TESTDIRS; do
|
||||||
"$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" || true
|
"${MAKEDIR}/.go-compile-test-dir" "$test_dir" || true
|
||||||
# don't let one directory that fails to build tank _all_ our tests!
|
# don't let one directory that fails to build tank _all_ our tests!
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -85,4 +85,4 @@ go_run_test_dir() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle_test_unit 2>&1 | tee -a $DEST/test.log
|
bundle_test_unit 2>&1 | tee -a "$DEST/test.log"
|
||||||
|
|
|
@ -40,26 +40,26 @@ bundle_ubuntu() {
|
||||||
DIR=$DEST/build
|
DIR=$DEST/build
|
||||||
|
|
||||||
# Include our udev rules
|
# Include our udev rules
|
||||||
mkdir -p $DIR/etc/udev/rules.d
|
mkdir -p "$DIR/etc/udev/rules.d"
|
||||||
cp contrib/udev/80-docker.rules $DIR/etc/udev/rules.d/
|
cp contrib/udev/80-docker.rules "$DIR/etc/udev/rules.d/"
|
||||||
|
|
||||||
# Include our init scripts
|
# Include our init scripts
|
||||||
mkdir -p $DIR/etc/init
|
mkdir -p "$DIR/etc/init"
|
||||||
cp contrib/init/upstart/docker.conf $DIR/etc/init/
|
cp contrib/init/upstart/docker.conf "$DIR/etc/init/"
|
||||||
mkdir -p $DIR/etc/init.d
|
mkdir -p "$DIR/etc/init.d"
|
||||||
cp contrib/init/sysvinit-debian/docker $DIR/etc/init.d/
|
cp contrib/init/sysvinit-debian/docker "$DIR/etc/init.d/"
|
||||||
mkdir -p $DIR/etc/default
|
mkdir -p "$DIR/etc/default"
|
||||||
cp contrib/init/sysvinit-debian/docker.default $DIR/etc/default/docker
|
cp contrib/init/sysvinit-debian/docker.default "$DIR/etc/default/docker"
|
||||||
mkdir -p $DIR/lib/systemd/system
|
mkdir -p "$DIR/lib/systemd/system"
|
||||||
cp contrib/init/systemd/docker.{service,socket} $DIR/lib/systemd/system/
|
cp contrib/init/systemd/docker.{service,socket} "$DIR/lib/systemd/system/"
|
||||||
|
|
||||||
# Include contributed completions
|
# Include contributed completions
|
||||||
mkdir -p $DIR/etc/bash_completion.d
|
mkdir -p "$DIR/etc/bash_completion.d"
|
||||||
cp contrib/completion/bash/docker $DIR/etc/bash_completion.d/
|
cp contrib/completion/bash/docker "$DIR/etc/bash_completion.d/"
|
||||||
mkdir -p $DIR/usr/share/zsh/vendor-completions
|
mkdir -p "$DIR/usr/share/zsh/vendor-completions"
|
||||||
cp contrib/completion/zsh/_docker $DIR/usr/share/zsh/vendor-completions/
|
cp contrib/completion/zsh/_docker "$DIR/usr/share/zsh/vendor-completions/"
|
||||||
mkdir -p $DIR/etc/fish/completions
|
mkdir -p "$DIR/etc/fish/completions"
|
||||||
cp contrib/completion/fish/docker.fish $DIR/etc/fish/completions/
|
cp contrib/completion/fish/docker.fish "$DIR/etc/fish/completions/"
|
||||||
|
|
||||||
# Include contributed man pages
|
# Include contributed man pages
|
||||||
docs/man/md2man-all.sh -q
|
docs/man/md2man-all.sh -q
|
||||||
|
@ -76,11 +76,11 @@ bundle_ubuntu() {
|
||||||
|
|
||||||
# Copy the binary
|
# Copy the binary
|
||||||
# This will fail if the binary bundle hasn't been built
|
# This will fail if the binary bundle hasn't been built
|
||||||
mkdir -p $DIR/usr/bin
|
mkdir -p "$DIR/usr/bin"
|
||||||
cp $DEST/../binary/docker-$VERSION $DIR/usr/bin/docker
|
cp "$DEST/../binary/docker-$VERSION" "$DIR/usr/bin/docker"
|
||||||
|
|
||||||
# Generate postinst/prerm/postrm scripts
|
# Generate postinst/prerm/postrm scripts
|
||||||
cat > $DEST/postinst <<'EOF'
|
cat > "$DEST/postinst" <<'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
|
@ -104,7 +104,7 @@ service docker $_dh_action 2>/dev/null || true
|
||||||
|
|
||||||
#DEBHELPER#
|
#DEBHELPER#
|
||||||
EOF
|
EOF
|
||||||
cat > $DEST/prerm <<'EOF'
|
cat > "$DEST/prerm" <<'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
|
@ -113,7 +113,7 @@ service docker stop 2>/dev/null || true
|
||||||
|
|
||||||
#DEBHELPER#
|
#DEBHELPER#
|
||||||
EOF
|
EOF
|
||||||
cat > $DEST/postrm <<'EOF'
|
cat > "$DEST/postrm" <<'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
|
@ -131,18 +131,18 @@ fi
|
||||||
#DEBHELPER#
|
#DEBHELPER#
|
||||||
EOF
|
EOF
|
||||||
# TODO swaths of these were borrowed from debhelper's auto-inserted stuff, because we're still using fpm - we need to use debhelper instead, and somehow reconcile Ubuntu that way
|
# TODO swaths of these were borrowed from debhelper's auto-inserted stuff, because we're still using fpm - we need to use debhelper instead, and somehow reconcile Ubuntu that way
|
||||||
chmod +x $DEST/postinst $DEST/prerm $DEST/postrm
|
chmod +x "$DEST/postinst" "$DEST/prerm" "$DEST/postrm"
|
||||||
|
|
||||||
(
|
(
|
||||||
# switch directories so we create *.deb in the right folder
|
# switch directories so we create *.deb in the right folder
|
||||||
cd $DEST
|
cd "$DEST"
|
||||||
|
|
||||||
# create lxc-docker-VERSION package
|
# create lxc-docker-VERSION package
|
||||||
fpm -s dir -C $DIR \
|
fpm -s dir -C "$DIR" \
|
||||||
--name lxc-docker-$VERSION --version "$PKGVERSION" \
|
--name "lxc-docker-$VERSION" --version "$PKGVERSION" \
|
||||||
--after-install $DEST/postinst \
|
--after-install "$DEST/postinst" \
|
||||||
--before-remove $DEST/prerm \
|
--before-remove "$DEST/prerm" \
|
||||||
--after-remove $DEST/postrm \
|
--after-remove "$DEST/postrm" \
|
||||||
--architecture "$PACKAGE_ARCHITECTURE" \
|
--architecture "$PACKAGE_ARCHITECTURE" \
|
||||||
--prefix / \
|
--prefix / \
|
||||||
--depends iptables \
|
--depends iptables \
|
||||||
|
@ -184,8 +184,8 @@ EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
# clean up after ourselves so we have a clean output directory
|
# clean up after ourselves so we have a clean output directory
|
||||||
rm $DEST/postinst $DEST/prerm $DEST/postrm
|
rm "$DEST/postinst" "$DEST/prerm" "$DEST/postrm"
|
||||||
rm -r $DIR
|
rm -r "$DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle_ubuntu
|
bundle_ubuntu
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
source "${MAKEDIR}/.validate"
|
||||||
|
|
||||||
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
||||||
dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
|
dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
source "${MAKEDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
source "${MAKEDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) )
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) )
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
source "${MAKEDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
||||||
|
|
|
@ -60,7 +60,7 @@ if [ "$1" != '--release-regardless-of-test-failure' ]; then
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION=$(cat VERSION)
|
VERSION=$(< VERSION)
|
||||||
BUCKET=$AWS_S3_BUCKET
|
BUCKET=$AWS_S3_BUCKET
|
||||||
|
|
||||||
# These are the 2 keys we've used to sign the deb's
|
# These are the 2 keys we've used to sign the deb's
|
||||||
|
@ -71,23 +71,23 @@ BUCKET=$AWS_S3_BUCKET
|
||||||
|
|
||||||
setup_s3() {
|
setup_s3() {
|
||||||
# Try creating the bucket. Ignore errors (it might already exist).
|
# Try creating the bucket. Ignore errors (it might already exist).
|
||||||
s3cmd mb s3://$BUCKET 2>/dev/null || true
|
s3cmd mb "s3://$BUCKET" 2>/dev/null || true
|
||||||
# Check access to the bucket.
|
# Check access to the bucket.
|
||||||
# s3cmd has no useful exit status, so we cannot check that.
|
# s3cmd has no useful exit status, so we cannot check that.
|
||||||
# Instead, we check if it outputs anything on standard output.
|
# Instead, we check if it outputs anything on standard output.
|
||||||
# (When there are problems, it uses standard error instead.)
|
# (When there are problems, it uses standard error instead.)
|
||||||
s3cmd info s3://$BUCKET | grep -q .
|
s3cmd info "s3://$BUCKET" | grep -q .
|
||||||
# Make the bucket accessible through website endpoints.
|
# Make the bucket accessible through website endpoints.
|
||||||
s3cmd ws-create --ws-index index --ws-error error s3://$BUCKET
|
s3cmd ws-create --ws-index index --ws-error error "s3://$BUCKET"
|
||||||
}
|
}
|
||||||
|
|
||||||
# write_to_s3 uploads the contents of standard input to the specified S3 url.
|
# write_to_s3 uploads the contents of standard input to the specified S3 url.
|
||||||
write_to_s3() {
|
write_to_s3() {
|
||||||
DEST=$1
|
DEST=$1
|
||||||
F=`mktemp`
|
F=`mktemp`
|
||||||
cat > $F
|
cat > "$F"
|
||||||
s3cmd --acl-public --mime-type='text/plain' put $F $DEST
|
s3cmd --acl-public --mime-type='text/plain' put "$F" "$DEST"
|
||||||
rm -f $F
|
rm -f "$F"
|
||||||
}
|
}
|
||||||
|
|
||||||
s3_url() {
|
s3_url() {
|
||||||
|
@ -246,20 +246,20 @@ release_build() {
|
||||||
# 1. A full APT repository is published at $BUCKET/ubuntu/
|
# 1. A full APT repository is published at $BUCKET/ubuntu/
|
||||||
# 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/index
|
# 2. Instructions for using the APT repository are uploaded at $BUCKET/ubuntu/index
|
||||||
release_ubuntu() {
|
release_ubuntu() {
|
||||||
[ -e bundles/$VERSION/ubuntu ] || {
|
[ -e "bundles/$VERSION/ubuntu" ] || {
|
||||||
echo >&2 './hack/make.sh must be run before release_ubuntu'
|
echo >&2 './hack/make.sh must be run before release_ubuntu'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Sign our packages
|
# Sign our packages
|
||||||
dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \
|
dpkg-sig -g "--passphrase $GPG_PASSPHRASE" -k releasedocker \
|
||||||
--sign builder bundles/$VERSION/ubuntu/*.deb
|
--sign builder "bundles/$VERSION/ubuntu/"*.deb
|
||||||
|
|
||||||
# Setup the APT repo
|
# Setup the APT repo
|
||||||
APTDIR=bundles/$VERSION/ubuntu/apt
|
APTDIR=bundles/$VERSION/ubuntu/apt
|
||||||
mkdir -p $APTDIR/conf $APTDIR/db
|
mkdir -p "$APTDIR/conf" "$APTDIR/db"
|
||||||
s3cmd sync s3://$BUCKET/ubuntu/db/ $APTDIR/db/ || true
|
s3cmd sync "s3://$BUCKET/ubuntu/db/" "$APTDIR/db/" || true
|
||||||
cat > $APTDIR/conf/distributions <<EOF
|
cat > "$APTDIR/conf/distributions" <<EOF
|
||||||
Codename: docker
|
Codename: docker
|
||||||
Components: main
|
Components: main
|
||||||
Architectures: amd64 i386
|
Architectures: amd64 i386
|
||||||
|
@ -267,19 +267,19 @@ EOF
|
||||||
|
|
||||||
# Add the DEB package to the APT repo
|
# Add the DEB package to the APT repo
|
||||||
DEBFILE=bundles/$VERSION/ubuntu/lxc-docker*.deb
|
DEBFILE=bundles/$VERSION/ubuntu/lxc-docker*.deb
|
||||||
reprepro -b $APTDIR includedeb docker $DEBFILE
|
reprepro -b "$APTDIR" includedeb docker "$DEBFILE"
|
||||||
|
|
||||||
# Sign
|
# Sign
|
||||||
for F in $(find $APTDIR -name Release); do
|
for F in $(find $APTDIR -name Release); do
|
||||||
gpg -u releasedocker --passphrase $GPG_PASSPHRASE \
|
gpg -u releasedocker --passphrase "$GPG_PASSPHRASE" \
|
||||||
--armor --sign --detach-sign \
|
--armor --sign --detach-sign \
|
||||||
--output $F.gpg $F
|
--output "$F.gpg" "$F"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Upload keys
|
# Upload keys
|
||||||
s3cmd sync $HOME/.gnupg/ s3://$BUCKET/ubuntu/.gnupg/
|
s3cmd sync "$HOME/.gnupg/" "s3://$BUCKET/ubuntu/.gnupg/"
|
||||||
gpg --armor --export releasedocker > bundles/$VERSION/ubuntu/gpg
|
gpg --armor --export releasedocker > "bundles/$VERSION/ubuntu/gpg"
|
||||||
s3cmd --acl-public put bundles/$VERSION/ubuntu/gpg s3://$BUCKET/gpg
|
s3cmd --acl-public put "bundles/$VERSION/ubuntu/gpg" "s3://$BUCKET/gpg"
|
||||||
|
|
||||||
local gpgFingerprint=36A1D7869245C8950F966E92D8576A8BA88D21E9
|
local gpgFingerprint=36A1D7869245C8950F966E92D8576A8BA88D21E9
|
||||||
if [[ $BUCKET == test* ]]; then
|
if [[ $BUCKET == test* ]]; then
|
||||||
|
@ -287,7 +287,7 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Upload repo
|
# Upload repo
|
||||||
s3cmd --acl-public sync $APTDIR/ s3://$BUCKET/ubuntu/
|
s3cmd --acl-public sync "$APTDIR/" "s3://$BUCKET/ubuntu/"
|
||||||
cat <<EOF | write_to_s3 s3://$BUCKET/ubuntu/index
|
cat <<EOF | write_to_s3 s3://$BUCKET/ubuntu/index
|
||||||
# Check that HTTPS transport is available to APT
|
# Check that HTTPS transport is available to APT
|
||||||
if [ ! -e /usr/lib/apt/methods/https ]; then
|
if [ ! -e /usr/lib/apt/methods/https ]; then
|
||||||
|
@ -312,14 +312,14 @@ EOF
|
||||||
|
|
||||||
# Add redirect at /ubuntu/info for URL-backwards-compatibility
|
# Add redirect at /ubuntu/info for URL-backwards-compatibility
|
||||||
rm -rf /tmp/emptyfile && touch /tmp/emptyfile
|
rm -rf /tmp/emptyfile && touch /tmp/emptyfile
|
||||||
s3cmd --acl-public --add-header='x-amz-website-redirect-location:/ubuntu/' --mime-type='text/plain' put /tmp/emptyfile s3://$BUCKET/ubuntu/info
|
s3cmd --acl-public --add-header='x-amz-website-redirect-location:/ubuntu/' --mime-type='text/plain' put /tmp/emptyfile "s3://$BUCKET/ubuntu/info"
|
||||||
|
|
||||||
echo "APT repository uploaded. Instructions available at $(s3_url)/ubuntu"
|
echo "APT repository uploaded. Instructions available at $(s3_url)/ubuntu"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Upload binaries and tgz files to S3
|
# Upload binaries and tgz files to S3
|
||||||
release_binaries() {
|
release_binaries() {
|
||||||
[ -e bundles/$VERSION/cross/linux/amd64/docker-$VERSION ] || {
|
[ -e "bundles/$VERSION/cross/linux/amd64/docker-$VERSION" ] || {
|
||||||
echo >&2 './hack/make.sh must be run before release_binaries'
|
echo >&2 './hack/make.sh must be run before release_binaries'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -341,29 +341,29 @@ EOF
|
||||||
|
|
||||||
# Add redirect at /builds/info for URL-backwards-compatibility
|
# Add redirect at /builds/info for URL-backwards-compatibility
|
||||||
rm -rf /tmp/emptyfile && touch /tmp/emptyfile
|
rm -rf /tmp/emptyfile && touch /tmp/emptyfile
|
||||||
s3cmd --acl-public --add-header='x-amz-website-redirect-location:/builds/' --mime-type='text/plain' put /tmp/emptyfile s3://$BUCKET/builds/info
|
s3cmd --acl-public --add-header='x-amz-website-redirect-location:/builds/' --mime-type='text/plain' put /tmp/emptyfile "s3://$BUCKET/builds/info"
|
||||||
|
|
||||||
if [ -z "$NOLATEST" ]; then
|
if [ -z "$NOLATEST" ]; then
|
||||||
echo "Advertising $VERSION on $BUCKET as most recent version"
|
echo "Advertising $VERSION on $BUCKET as most recent version"
|
||||||
echo $VERSION | write_to_s3 s3://$BUCKET/latest
|
echo "$VERSION" | write_to_s3 "s3://$BUCKET/latest"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Upload the index script
|
# Upload the index script
|
||||||
release_index() {
|
release_index() {
|
||||||
sed "s,url='https://get.docker.com/',url='$(s3_url)/'," hack/install.sh | write_to_s3 s3://$BUCKET/index
|
sed "s,url='https://get.docker.com/',url='$(s3_url)/'," hack/install.sh | write_to_s3 "s3://$BUCKET/index"
|
||||||
}
|
}
|
||||||
|
|
||||||
release_test() {
|
release_test() {
|
||||||
if [ -e "bundles/$VERSION/test" ]; then
|
if [ -e "bundles/$VERSION/test" ]; then
|
||||||
s3cmd --acl-public sync bundles/$VERSION/test/ s3://$BUCKET/test/
|
s3cmd --acl-public sync "bundles/$VERSION/test/" "s3://$BUCKET/test/"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_gpg() {
|
setup_gpg() {
|
||||||
# Make sure that we have our keys
|
# Make sure that we have our keys
|
||||||
mkdir -p $HOME/.gnupg/
|
mkdir -p "$HOME/.gnupg/"
|
||||||
s3cmd sync s3://$BUCKET/ubuntu/.gnupg/ $HOME/.gnupg/ || true
|
s3cmd sync "s3://$BUCKET/ubuntu/.gnupg/" "$HOME/.gnupg/" || true
|
||||||
gpg --list-keys releasedocker >/dev/null || {
|
gpg --list-keys releasedocker >/dev/null || {
|
||||||
gpg --gen-key --batch <<EOF
|
gpg --gen-key --batch <<EOF
|
||||||
Key-Type: RSA
|
Key-Type: RSA
|
||||||
|
|
Загрузка…
Ссылка в новой задаче