Merge pull request #12376 from Mic92/refactor-hack

Refactor shellscripts
This commit is contained in:
Jessie Frazelle
2015-04-22 12:12:44 -07:00
21 changed files with 100 additions and 99 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
set -e
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
go build \
@@ -30,4 +30,4 @@ else
fi
# 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 -2
View File
@@ -2,7 +2,7 @@
set -e
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
go build --compiler=gccgo \
@@ -28,4 +28,4 @@ else
fi
# 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 -2
View File
@@ -2,8 +2,8 @@
for pidFile in $(find "$DEST" -name docker.pid); do
pid=$(set -x; cat "$pidFile")
( set -x; kill $pid )
if ! wait $pid; then
( set -x; kill "$pid" )
if ! wait "$pid"; then
echo >&2 "warning: PID $pid from $pidFile had a nonzero exit code"
fi
done
+1 -1
View File
@@ -11,7 +11,7 @@ if [[ "$(uname -s)" == CYGWIN* ]]; then
DEST=$(cygpath -mw $DEST)
fi
source "$(dirname "$BASH_SOURCE")/.go-autogen"
source "${MAKEDIR}/.go-autogen"
go build \
-o "$DEST/$BINARY_FULLNAME" \
+2 -2
View File
@@ -5,7 +5,7 @@ DEST=$1
# 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
# integration-daemon-stop to make sure we kill the daemon and don't hang,
@@ -76,7 +76,7 @@ DEST=$1
# clean up after ourselves
rm -f Dockerfile.build
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
source "${MAKEDIR}/.integration-daemon-stop"
[ -z "$didFail" ] # "set -e" ftw
) 2>&1 | tee -a $DEST/test.log
+1 -1
View File
@@ -28,6 +28,6 @@ for platform in $DOCKER_CROSSPLATFORMS; do
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
fi
source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform"
source "${MAKEDIR}/binary" "$DEST/$platform"
)
done
+2 -2
View File
@@ -4,7 +4,7 @@ set -e
DEST=$1
if [ -z "$DOCKER_CLIENTONLY" ]; then
source "$(dirname "$BASH_SOURCE")/.dockerinit"
source "${MAKEDIR}/.dockerinit"
hash_files "$DEST/dockerinit-$VERSION"
else
@@ -18,5 +18,5 @@ fi
export LDFLAGS_STATIC_DOCKER=''
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
source "$(dirname "$BASH_SOURCE")/binary"
source "${MAKEDIR}/binary"
)
+2 -2
View File
@@ -4,7 +4,7 @@ set -e
DEST=$1
if [ -z "$DOCKER_CLIENTONLY" ]; then
source "$(dirname "$BASH_SOURCE")/.dockerinit-gccgo"
source "${MAKEDIR}/.dockerinit-gccgo"
hash_files "$DEST/dockerinit-$VERSION"
else
@@ -19,5 +19,5 @@ fi
export LDFLAGS_STATIC_DOCKER=''
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
source "$(dirname "$BASH_SOURCE")/gccgo"
source "${MAKEDIR}/gccgo"
)
+1 -1
View File
@@ -6,7 +6,7 @@ BINARY_NAME="docker-$VERSION"
BINARY_EXTENSION="$(binary_extension)"
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
source "$(dirname "$BASH_SOURCE")/.go-autogen"
source "${MAKEDIR}/.go-autogen"
if [[ "${BUILDFLAGS[@]}" =~ 'netgo ' ]]; then
EXTLDFLAGS_STATIC_DOCKER+=' -lnetgo'
+2 -2
View File
@@ -5,7 +5,7 @@ DEST=$1
# 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
# integration-daemon-stop to make sure we kill the daemon and don't hang,
@@ -24,7 +24,7 @@ DEST=$1
didFail=1
fi
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
source "${MAKEDIR}/.integration-daemon-stop"
[ -z "$didFail" ] # "set -e" ftw
) 2>&1 | tee -a $DEST/test.log
+2 -2
View File
@@ -5,7 +5,7 @@ DEST=$1
INIT=$DEST/../dynbinary/dockerinit-$VERSION
[ -x "$INIT" ] || {
source "$(dirname "$BASH_SOURCE")/.dockerinit"
source "${MAKEDIR}/.dockerinit"
INIT="$DEST/dockerinit"
}
export TEST_DOCKERINIT_PATH="$INIT"
@@ -22,4 +22,4 @@ bundle_test_integration() {
# spews when it is given packages that aren't used
bundle_test_integration 2>&1 \
| grep --line-buffered -v '^warning: no packages being tested depend on ' \
| tee -a $DEST/test.log
| tee -a "$DEST/test.log"
+6 -6
View File
@@ -9,23 +9,23 @@ bundle_test_integration_cli() {
# 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
# integration-daemon-stop to make sure we kill the daemon and don't hang,
# even and especially on test failures
didFail=
if ! {
source "$(dirname "$BASH_SOURCE")/.ensure-frozen-images"
source "$(dirname "$BASH_SOURCE")/.ensure-httpserver"
source "$(dirname "$BASH_SOURCE")/.ensure-emptyfs"
source "${MAKEDIR}/.ensure-frozen-images"
source "${MAKEDIR}/.ensure-httpserver"
source "${MAKEDIR}/.ensure-emptyfs"
bundle_test_integration_cli
}; then
didFail=1
fi
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
source "${MAKEDIR}/.integration-daemon-stop"
[ -z "$didFail" ] # "set -e" ftw
) 2>&1 | tee -a $DEST/test.log
) 2>&1 | tee -a "$DEST/test.log"
+3 -3
View File
@@ -39,12 +39,12 @@ bundle_test_unit() {
mkdir -p "$HOME/.parallel"
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"
else
# aww, no "parallel" available - fall back to boring
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!
done
fi
@@ -85,4 +85,4 @@ go_run_test_dir() {
fi
}
bundle_test_unit 2>&1 | tee -a $DEST/test.log
bundle_test_unit 2>&1 | tee -a "$DEST/test.log"
+30 -30
View File
@@ -40,26 +40,26 @@ bundle_ubuntu() {
DIR=$DEST/build
# Include our udev rules
mkdir -p $DIR/etc/udev/rules.d
cp contrib/udev/80-docker.rules $DIR/etc/udev/rules.d/
mkdir -p "$DIR/etc/udev/rules.d"
cp contrib/udev/80-docker.rules "$DIR/etc/udev/rules.d/"
# Include our init scripts
mkdir -p $DIR/etc/init
cp contrib/init/upstart/docker.conf $DIR/etc/init/
mkdir -p $DIR/etc/init.d
cp contrib/init/sysvinit-debian/docker $DIR/etc/init.d/
mkdir -p $DIR/etc/default
cp contrib/init/sysvinit-debian/docker.default $DIR/etc/default/docker
mkdir -p $DIR/lib/systemd/system
cp contrib/init/systemd/docker.{service,socket} $DIR/lib/systemd/system/
mkdir -p "$DIR/etc/init"
cp contrib/init/upstart/docker.conf "$DIR/etc/init/"
mkdir -p "$DIR/etc/init.d"
cp contrib/init/sysvinit-debian/docker "$DIR/etc/init.d/"
mkdir -p "$DIR/etc/default"
cp contrib/init/sysvinit-debian/docker.default "$DIR/etc/default/docker"
mkdir -p "$DIR/lib/systemd/system"
cp contrib/init/systemd/docker.{service,socket} "$DIR/lib/systemd/system/"
# Include contributed completions
mkdir -p $DIR/etc/bash_completion.d
cp contrib/completion/bash/docker $DIR/etc/bash_completion.d/
mkdir -p $DIR/usr/share/zsh/vendor-completions
cp contrib/completion/zsh/_docker $DIR/usr/share/zsh/vendor-completions/
mkdir -p $DIR/etc/fish/completions
cp contrib/completion/fish/docker.fish $DIR/etc/fish/completions/
mkdir -p "$DIR/etc/bash_completion.d"
cp contrib/completion/bash/docker "$DIR/etc/bash_completion.d/"
mkdir -p "$DIR/usr/share/zsh/vendor-completions"
cp contrib/completion/zsh/_docker "$DIR/usr/share/zsh/vendor-completions/"
mkdir -p "$DIR/etc/fish/completions"
cp contrib/completion/fish/docker.fish "$DIR/etc/fish/completions/"
# Include contributed man pages
docs/man/md2man-all.sh -q
@@ -76,11 +76,11 @@ bundle_ubuntu() {
# Copy the binary
# This will fail if the binary bundle hasn't been built
mkdir -p $DIR/usr/bin
cp $DEST/../binary/docker-$VERSION $DIR/usr/bin/docker
mkdir -p "$DIR/usr/bin"
cp "$DEST/../binary/docker-$VERSION" "$DIR/usr/bin/docker"
# Generate postinst/prerm/postrm scripts
cat > $DEST/postinst <<'EOF'
cat > "$DEST/postinst" <<'EOF'
#!/bin/sh
set -e
set -u
@@ -104,7 +104,7 @@ service docker $_dh_action 2>/dev/null || true
#DEBHELPER#
EOF
cat > $DEST/prerm <<'EOF'
cat > "$DEST/prerm" <<'EOF'
#!/bin/sh
set -e
set -u
@@ -113,7 +113,7 @@ service docker stop 2>/dev/null || true
#DEBHELPER#
EOF
cat > $DEST/postrm <<'EOF'
cat > "$DEST/postrm" <<'EOF'
#!/bin/sh
set -e
set -u
@@ -131,18 +131,18 @@ fi
#DEBHELPER#
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
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
cd $DEST
cd "$DEST"
# create lxc-docker-VERSION package
fpm -s dir -C $DIR \
--name lxc-docker-$VERSION --version "$PKGVERSION" \
--after-install $DEST/postinst \
--before-remove $DEST/prerm \
--after-remove $DEST/postrm \
fpm -s dir -C "$DIR" \
--name "lxc-docker-$VERSION" --version "$PKGVERSION" \
--after-install "$DEST/postinst" \
--before-remove "$DEST/prerm" \
--after-remove "$DEST/postrm" \
--architecture "$PACKAGE_ARCHITECTURE" \
--prefix / \
--depends iptables \
@@ -184,8 +184,8 @@ EOF
)
# clean up after ourselves so we have a clean output directory
rm $DEST/postinst $DEST/prerm $DEST/postrm
rm -r $DIR
rm "$DEST/postinst" "$DEST/prerm" "$DEST/postrm"
rm -r "$DIR"
}
bundle_ubuntu
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/.validate"
source "${MAKEDIR}/.validate"
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/.validate"
source "${MAKEDIR}/.validate"
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/.validate"
source "${MAKEDIR}/.validate"
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true) )
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/.validate"
source "${MAKEDIR}/.validate"
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )