run shfmt
git grep --name-only '^#!' | egrep -v '(vendor|\.go|Jenkinsfile)' | xargs shfmt -w -bn -ci -sr Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
eb484fcb67
commit
3cf82748dd
50 changed files with 513 additions and 441 deletions
|
@ -43,7 +43,7 @@ is_set_as_module() {
|
||||||
color() {
|
color() {
|
||||||
local codes=()
|
local codes=()
|
||||||
if [ "$1" = 'bold' ]; then
|
if [ "$1" = 'bold' ]; then
|
||||||
codes=( "${codes[@]}" '1' )
|
codes=("${codes[@]}" '1')
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
|
@ -60,7 +60,7 @@ color() {
|
||||||
white) code=37 ;;
|
white) code=37 ;;
|
||||||
esac
|
esac
|
||||||
if [ "$code" ]; then
|
if [ "$code" ]; then
|
||||||
codes=( "${codes[@]}" "$code" )
|
codes=("${codes[@]}" "$code")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
local IFS=';'
|
local IFS=';'
|
||||||
|
@ -98,12 +98,13 @@ check_flag() {
|
||||||
|
|
||||||
check_flags() {
|
check_flags() {
|
||||||
for flag in "$@"; do
|
for flag in "$@"; do
|
||||||
echo -n "- "; check_flag "$flag"
|
echo -n "- "
|
||||||
|
check_flag "$flag"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
check_command() {
|
check_command() {
|
||||||
if command -v "$1" >/dev/null 2>&1; then
|
if command -v "$1" > /dev/null 2>&1; then
|
||||||
wrap_good "$1 command" 'available'
|
wrap_good "$1 command" 'available'
|
||||||
else
|
else
|
||||||
wrap_bad "$1 command" 'missing'
|
wrap_bad "$1 command" 'missing'
|
||||||
|
@ -121,7 +122,7 @@ check_device() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_distro_userns() {
|
check_distro_userns() {
|
||||||
source /etc/os-release 2>/dev/null || /bin/true
|
source /etc/os-release 2> /dev/null || /bin/true
|
||||||
if [[ "${ID}" =~ ^(centos|rhel)$ && "${VERSION_ID}" =~ ^7 ]]; then
|
if [[ "${ID}" =~ ^(centos|rhel)$ && "${VERSION_ID}" =~ ^7 ]]; then
|
||||||
# this is a CentOS7 or RHEL7 system
|
# this is a CentOS7 or RHEL7 system
|
||||||
grep -q "user_namespace.enable=1" /proc/cmdline || {
|
grep -q "user_namespace.enable=1" /proc/cmdline || {
|
||||||
|
@ -156,7 +157,7 @@ echo 'Generally Necessary:'
|
||||||
echo -n '- '
|
echo -n '- '
|
||||||
cgroupSubsystemDir="$(awk '/[, ](cpu|cpuacct|cpuset|devices|freezer|memory)[, ]/ && $3 == "cgroup" { print $2 }' /proc/mounts | head -n1)"
|
cgroupSubsystemDir="$(awk '/[, ](cpu|cpuacct|cpuset|devices|freezer|memory)[, ]/ && $3 == "cgroup" { print $2 }' /proc/mounts | head -n1)"
|
||||||
cgroupDir="$(dirname "$cgroupSubsystemDir")"
|
cgroupDir="$(dirname "$cgroupSubsystemDir")"
|
||||||
if [ -d "$cgroupDir/cpu" ] || [ -d "$cgroupDir/cpuacct" ] || [ -d "$cgroupDir/cpuset" ] || [ -d "$cgroupDir/devices" ] || [ -d "$cgroupDir/freezer" ] || [ -d "$cgroupDir/memory" ]; then
|
if [ -d "$cgroupDir/cpu" ] || [ -d "$cgroupDir/cpuacct" ] || [ -d "$cgroupDir/cpuset" ] || [ -d "$cgroupDir/devices" ] || [ -d "$cgroupDir/freezer" ] || [ -d "$cgroupDir/memory" ]; then
|
||||||
echo "$(wrap_good 'cgroup hierarchy' 'properly mounted') [$cgroupDir]"
|
echo "$(wrap_good 'cgroup hierarchy' 'properly mounted') [$cgroupDir]"
|
||||||
else
|
else
|
||||||
if [ "$cgroupSubsystemDir" ]; then
|
if [ "$cgroupSubsystemDir" ]; then
|
||||||
|
@ -168,7 +169,7 @@ else
|
||||||
echo " $(wrap_color '(see https://github.com/tianon/cgroupfs-mount)' yellow)"
|
echo " $(wrap_color '(see https://github.com/tianon/cgroupfs-mount)' yellow)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
|
if [ "$(cat /sys/module/apparmor/parameters/enabled 2> /dev/null)" = 'Y' ]; then
|
||||||
echo -n '- '
|
echo -n '- '
|
||||||
if command -v apparmor_parser &> /dev/null; then
|
if command -v apparmor_parser &> /dev/null; then
|
||||||
wrap_good 'apparmor' 'enabled and tools installed'
|
wrap_good 'apparmor' 'enabled and tools installed'
|
||||||
|
@ -199,8 +200,8 @@ flags=(
|
||||||
POSIX_MQUEUE
|
POSIX_MQUEUE
|
||||||
)
|
)
|
||||||
check_flags "${flags[@]}"
|
check_flags "${flags[@]}"
|
||||||
if [ "$kernelMajor" -lt 4 ] || ( [ "$kernelMajor" -eq 4 ] && [ "$kernelMinor" -lt 8 ] ); then
|
if [ "$kernelMajor" -lt 4 ] || ([ "$kernelMajor" -eq 4 ] && [ "$kernelMinor" -lt 8 ]); then
|
||||||
check_flags DEVPTS_MULTIPLE_INSTANCES
|
check_flags DEVPTS_MULTIPLE_INSTANCES
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -228,12 +229,15 @@ echo 'Optional Features:'
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
if is_set LEGACY_VSYSCALL_NATIVE; then
|
if is_set LEGACY_VSYSCALL_NATIVE; then
|
||||||
echo -n "- "; wrap_bad "CONFIG_LEGACY_VSYSCALL_NATIVE" 'enabled'
|
echo -n "- "
|
||||||
|
wrap_bad "CONFIG_LEGACY_VSYSCALL_NATIVE" 'enabled'
|
||||||
echo " $(wrap_color '(dangerous, provides an ASLR-bypassing target with usable ROP gadgets.)' bold black)"
|
echo " $(wrap_color '(dangerous, provides an ASLR-bypassing target with usable ROP gadgets.)' bold black)"
|
||||||
elif is_set LEGACY_VSYSCALL_EMULATE; then
|
elif is_set LEGACY_VSYSCALL_EMULATE; then
|
||||||
echo -n "- "; wrap_good "CONFIG_LEGACY_VSYSCALL_EMULATE" 'enabled'
|
echo -n "- "
|
||||||
|
wrap_good "CONFIG_LEGACY_VSYSCALL_EMULATE" 'enabled'
|
||||||
elif is_set LEGACY_VSYSCALL_NONE; then
|
elif is_set LEGACY_VSYSCALL_NONE; then
|
||||||
echo -n "- "; wrap_bad "CONFIG_LEGACY_VSYSCALL_NONE" 'enabled'
|
echo -n "- "
|
||||||
|
wrap_bad "CONFIG_LEGACY_VSYSCALL_NONE" 'enabled'
|
||||||
echo " $(wrap_color '(containers using eglibc <= 2.13 will not work. Switch to' bold black)"
|
echo " $(wrap_color '(containers using eglibc <= 2.13 will not work. Switch to' bold black)"
|
||||||
echo " $(wrap_color ' "CONFIG_VSYSCALL_[NATIVE|EMULATE]" or use "vsyscall=[native|emulate]"' bold black)"
|
echo " $(wrap_color ' "CONFIG_VSYSCALL_[NATIVE|EMULATE]" or use "vsyscall=[native|emulate]"' bold black)"
|
||||||
echo " $(wrap_color ' on kernel command line. Note that this will disable ASLR for the,' bold black)"
|
echo " $(wrap_color ' on kernel command line. Note that this will disable ASLR for the,' bold black)"
|
||||||
|
@ -245,15 +249,15 @@ echo 'Optional Features:'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$kernelMajor" -lt 4 ] || ( [ "$kernelMajor" -eq 4 ] && [ "$kernelMinor" -le 5 ] ); then
|
if [ "$kernelMajor" -lt 4 ] || ([ "$kernelMajor" -eq 4 ] && [ "$kernelMinor" -le 5 ]); then
|
||||||
check_flags MEMCG_KMEM
|
check_flags MEMCG_KMEM
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$kernelMajor" -lt 3 ] || ( [ "$kernelMajor" -eq 3 ] && [ "$kernelMinor" -le 18 ] ); then
|
if [ "$kernelMajor" -lt 3 ] || ([ "$kernelMajor" -eq 3 ] && [ "$kernelMinor" -le 18 ]); then
|
||||||
check_flags RESOURCE_COUNTERS
|
check_flags RESOURCE_COUNTERS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$kernelMajor" -lt 3 ] || ( [ "$kernelMajor" -eq 3 ] && [ "$kernelMinor" -le 13 ] ); then
|
if [ "$kernelMajor" -lt 3 ] || ([ "$kernelMajor" -eq 3 ] && [ "$kernelMinor" -le 13 ]); then
|
||||||
netprio=NETPRIO_CGROUP
|
netprio=NETPRIO_CGROUP
|
||||||
else
|
else
|
||||||
netprio=CGROUP_NET_PRIO
|
netprio=CGROUP_NET_PRIO
|
||||||
|
@ -270,7 +274,7 @@ flags=(
|
||||||
IP_VS_NFCT
|
IP_VS_NFCT
|
||||||
IP_VS_PROTO_TCP
|
IP_VS_PROTO_TCP
|
||||||
IP_VS_PROTO_UDP
|
IP_VS_PROTO_UDP
|
||||||
IP_VS_RR
|
IP_VS_RR
|
||||||
)
|
)
|
||||||
check_flags "${flags[@]}"
|
check_flags "${flags[@]}"
|
||||||
|
|
||||||
|
@ -295,7 +299,7 @@ echo " - \"$(wrap_color 'overlay' blue)\":"
|
||||||
check_flags VXLAN BRIDGE_VLAN_FILTERING | sed 's/^/ /'
|
check_flags VXLAN BRIDGE_VLAN_FILTERING | sed 's/^/ /'
|
||||||
echo ' Optional (for encrypted networks):'
|
echo ' Optional (for encrypted networks):'
|
||||||
check_flags CRYPTO CRYPTO_AEAD CRYPTO_GCM CRYPTO_SEQIV CRYPTO_GHASH \
|
check_flags CRYPTO CRYPTO_AEAD CRYPTO_GCM CRYPTO_SEQIV CRYPTO_GHASH \
|
||||||
XFRM XFRM_USER XFRM_ALGO INET_ESP INET_XFRM_MODE_TRANSPORT | sed 's/^/ /'
|
XFRM XFRM_USER XFRM_ALGO INET_ESP INET_XFRM_MODE_TRANSPORT | sed 's/^/ /'
|
||||||
echo " - \"$(wrap_color 'ipvlan' blue)\":"
|
echo " - \"$(wrap_color 'ipvlan' blue)\":"
|
||||||
check_flags IPVLAN | sed 's/^/ /'
|
check_flags IPVLAN | sed 's/^/ /'
|
||||||
echo " - \"$(wrap_color 'macvlan' blue)\":"
|
echo " - \"$(wrap_color 'macvlan' blue)\":"
|
||||||
|
@ -334,9 +338,12 @@ check_flags OVERLAY_FS | sed 's/^/ /'
|
||||||
EXITCODE=0
|
EXITCODE=0
|
||||||
|
|
||||||
echo " - \"$(wrap_color 'zfs' blue)\":"
|
echo " - \"$(wrap_color 'zfs' blue)\":"
|
||||||
echo -n " - "; check_device /dev/zfs
|
echo -n " - "
|
||||||
echo -n " - "; check_command zfs
|
check_device /dev/zfs
|
||||||
echo -n " - "; check_command zpool
|
echo -n " - "
|
||||||
|
check_command zfs
|
||||||
|
echo -n " - "
|
||||||
|
check_command zpool
|
||||||
[ "$EXITCODE" = 0 ] && STORAGE=0
|
[ "$EXITCODE" = 0 ] && STORAGE=0
|
||||||
EXITCODE=0
|
EXITCODE=0
|
||||||
|
|
||||||
|
@ -345,8 +352,7 @@ EXITCODE=$CODE
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
check_limit_over()
|
check_limit_over() {
|
||||||
{
|
|
||||||
if [ "$(cat "$1")" -le "$2" ]; then
|
if [ "$(cat "$1")" -le "$2" ]; then
|
||||||
wrap_bad "- $1" "$(cat "$1")"
|
wrap_bad "- $1" "$(cat "$1")"
|
||||||
wrap_color " This should be set to at least $2, for example set: sysctl -w kernel/keys/root_maxkeys=1000000" bold black
|
wrap_color " This should be set to at least $2, for example set: sysctl -w kernel/keys/root_maxkeys=1000000" bold black
|
||||||
|
|
|
@ -16,37 +16,38 @@ set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
errexit() {
|
errexit() {
|
||||||
echo "$1"
|
echo "$1"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
BUNDLE="bundles/$(cat VERSION)"
|
BUNDLE="bundles/$(cat VERSION)"
|
||||||
|
|
||||||
bundle_files(){
|
bundle_files() {
|
||||||
# prefer dynbinary if exists
|
# prefer dynbinary if exists
|
||||||
for f in dockerd docker-proxy; do
|
for f in dockerd docker-proxy; do
|
||||||
if [ -d $BUNDLE/dynbinary-daemon ]; then
|
if [ -d $BUNDLE/dynbinary-daemon ]; then
|
||||||
echo $BUNDLE/dynbinary-daemon/$f
|
echo $BUNDLE/dynbinary-daemon/$f
|
||||||
|
else
|
||||||
|
echo $BUNDLE/binary-daemon/$f
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for f in containerd ctr containerd-shim docker-init runc; do
|
||||||
|
echo $BUNDLE/binary-daemon/$f
|
||||||
|
done
|
||||||
|
if [ -d $BUNDLE/dynbinary-client ]; then
|
||||||
|
echo $BUNDLE/dynbinary-client/docker
|
||||||
else
|
else
|
||||||
echo $BUNDLE/binary-daemon/$f
|
echo $BUNDLE/binary-client/docker
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
for f in containerd ctr containerd-shim docker-init runc; do
|
|
||||||
echo $BUNDLE/binary-daemon/$f
|
|
||||||
done
|
|
||||||
if [ -d $BUNDLE/dynbinary-client ]; then
|
|
||||||
echo $BUNDLE/dynbinary-client/docker
|
|
||||||
else
|
|
||||||
echo $BUNDLE/binary-client/docker
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
control_docker(){
|
control_docker() {
|
||||||
m=$1; op=$2
|
m=$1
|
||||||
# NOTE: `docker-machine ssh $m sh -c "foo bar"` does not work
|
op=$2
|
||||||
# (but `docker-machine ssh $m sh -c "foo\ bar"` works)
|
# NOTE: `docker-machine ssh $m sh -c "foo bar"` does not work
|
||||||
# Anyway we avoid using `sh -c` here for avoiding confusion
|
# (but `docker-machine ssh $m sh -c "foo\ bar"` works)
|
||||||
cat <<EOF | docker-machine ssh $m sudo sh
|
# Anyway we avoid using `sh -c` here for avoiding confusion
|
||||||
|
cat << EOF | docker-machine ssh $m sudo sh
|
||||||
if command -v systemctl > /dev/null; then
|
if command -v systemctl > /dev/null; then
|
||||||
systemctl $op docker
|
systemctl $op docker
|
||||||
elif command -v service > /dev/null; then
|
elif command -v service > /dev/null; then
|
||||||
|
@ -60,52 +61,58 @@ fi
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
detect_prefix(){
|
detect_prefix() {
|
||||||
m=$1
|
m=$1
|
||||||
script='dirname $(dirname $(which dockerd))'
|
script='dirname $(dirname $(which dockerd))'
|
||||||
echo $script | docker-machine ssh $m sh
|
echo $script | docker-machine ssh $m sh
|
||||||
}
|
}
|
||||||
|
|
||||||
install_to(){
|
install_to() {
|
||||||
m=$1; shift; files=$@
|
m=$1
|
||||||
echo "$m: detecting docker"
|
shift
|
||||||
prefix=$(detect_prefix $m)
|
files=$@
|
||||||
echo "$m: detected docker on $prefix"
|
echo "$m: detecting docker"
|
||||||
echo "$m: stopping docker"
|
prefix=$(detect_prefix $m)
|
||||||
control_docker $m stop
|
echo "$m: detected docker on $prefix"
|
||||||
echo "$m: installing docker"
|
echo "$m: stopping docker"
|
||||||
# NOTE: GNU tar is required because we use --transform here
|
control_docker $m stop
|
||||||
# TODO: compression (should not be default)
|
echo "$m: installing docker"
|
||||||
tar ch --transform 's/.*\///' $files | docker-machine ssh $m sudo tar Cx $prefix/bin
|
# NOTE: GNU tar is required because we use --transform here
|
||||||
echo "$m: starting docker"
|
# TODO: compression (should not be default)
|
||||||
control_docker $m start
|
tar ch --transform 's/.*\///' $files | docker-machine ssh $m sudo tar Cx $prefix/bin
|
||||||
echo "$m: done"
|
echo "$m: starting docker"
|
||||||
|
control_docker $m start
|
||||||
|
echo "$m: done"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_prereq(){
|
check_prereq() {
|
||||||
command -v docker-machine > /dev/null || errexit "docker-machine not installed"
|
command -v docker-machine > /dev/null || errexit "docker-machine not installed"
|
||||||
( tar --version | grep GNU > /dev/null ) || errexit "GNU tar not installed"
|
(tar --version | grep GNU > /dev/null) || errexit "GNU tar not installed"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"install")
|
"install")
|
||||||
shift; machines=$@
|
shift
|
||||||
check_prereq
|
machines=$@
|
||||||
files=$(bundle_files)
|
check_prereq
|
||||||
echo "Files to be installed:"
|
files=$(bundle_files)
|
||||||
for f in $files; do echo $f; done
|
echo "Files to be installed:"
|
||||||
pids=()
|
for f in $files; do echo $f; done
|
||||||
for m in $machines; do
|
pids=()
|
||||||
install_to $m $files &
|
for m in $machines; do
|
||||||
pids+=($!)
|
install_to $m $files &
|
||||||
done
|
pids+=($!)
|
||||||
status=0
|
done
|
||||||
for pid in ${pids[@]}; do
|
status=0
|
||||||
wait $pid || { status=$?; echo "background process $pid failed with exit status $status"; }
|
for pid in ${pids[@]}; do
|
||||||
done
|
wait $pid || {
|
||||||
exit $status
|
status=$?
|
||||||
;;
|
echo "background process $pid failed with exit status $status"
|
||||||
*)
|
}
|
||||||
errexit "Usage: $0 install MACHINES"
|
done
|
||||||
;;
|
exit $status
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
errexit "Usage: $0 install MACHINES"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -25,7 +25,7 @@ fi
|
||||||
|
|
||||||
rootlesskit=""
|
rootlesskit=""
|
||||||
for f in docker-rootlesskit rootlesskit; do
|
for f in docker-rootlesskit rootlesskit; do
|
||||||
if which $f >/dev/null 2>&1; then
|
if which $f > /dev/null 2>&1; then
|
||||||
rootlesskit=$f
|
rootlesskit=$f
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -43,7 +43,7 @@ fi
|
||||||
net=$DOCKERD_ROOTLESS_ROOTLESSKIT_NET
|
net=$DOCKERD_ROOTLESS_ROOTLESSKIT_NET
|
||||||
mtu=$DOCKERD_ROOTLESS_ROOTLESSKIT_MTU
|
mtu=$DOCKERD_ROOTLESS_ROOTLESSKIT_MTU
|
||||||
if [ -z $net ]; then
|
if [ -z $net ]; then
|
||||||
if which slirp4netns >/dev/null 2>&1; then
|
if which slirp4netns > /dev/null 2>&1; then
|
||||||
if slirp4netns --help | grep -- --disable-host-loopback; then
|
if slirp4netns --help | grep -- --disable-host-loopback; then
|
||||||
net=slirp4netns
|
net=slirp4netns
|
||||||
if [ -z $mtu ]; then
|
if [ -z $mtu ]; then
|
||||||
|
@ -54,7 +54,7 @@ if [ -z $net ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z $net ]; then
|
if [ -z $net ]; then
|
||||||
if which vpnkit >/dev/null 2>&1; then
|
if which vpnkit > /dev/null 2>&1; then
|
||||||
net=vpnkit
|
net=vpnkit
|
||||||
else
|
else
|
||||||
echo "Either slirp4netns (v0.3+) or vpnkit needs to be installed"
|
echo "Either slirp4netns (v0.3+) or vpnkit needs to be installed"
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if ! command -v qemu-nbd &> /dev/null; then
|
if ! command -v qemu-nbd &> /dev/null; then
|
||||||
echo >&2 'error: "qemu-nbd" not found!'
|
echo >&2 'error: "qemu-nbd" not found!'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Convert disk image to docker image"
|
echo "Convert disk image to docker image"
|
||||||
echo ""
|
echo ""
|
||||||
echo "usage: $0 image-name disk-image-file [ base-image ]"
|
echo "usage: $0 image-name disk-image-file [ base-image ]"
|
||||||
echo " ie: $0 cirros:0.3.3 cirros-0.3.3-x86_64-disk.img"
|
echo " ie: $0 cirros:0.3.3 cirros-0.3.3-x86_64-disk.img"
|
||||||
echo " $0 ubuntu:cloud ubuntu-14.04-server-cloudimg-amd64-disk1.img ubuntu:14.04"
|
echo " $0 ubuntu:cloud ubuntu-14.04-server-cloudimg-amd64-disk1.img ubuntu:14.04"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$#" -lt 2 ]; then
|
if [ "$#" -lt 2 ]; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CURDIR=$(pwd)
|
CURDIR=$(pwd)
|
||||||
|
@ -24,7 +24,7 @@ CURDIR=$(pwd)
|
||||||
image_name="${1%:*}"
|
image_name="${1%:*}"
|
||||||
image_tag="${1#*:}"
|
image_tag="${1#*:}"
|
||||||
if [ "$image_tag" == "$1" ]; then
|
if [ "$image_tag" == "$1" ]; then
|
||||||
image_tag="latest"
|
image_tag="latest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
disk_image_file="$2"
|
disk_image_file="$2"
|
||||||
|
@ -35,10 +35,10 @@ block_device=/dev/nbd0
|
||||||
builddir=$(mktemp -d)
|
builddir=$(mktemp -d)
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
umount "$builddir/disk_image" || true
|
umount "$builddir/disk_image" || true
|
||||||
umount "$builddir/workdir" || true
|
umount "$builddir/workdir" || true
|
||||||
qemu-nbd -d $block_device &> /dev/null || true
|
qemu-nbd -d $block_device &> /dev/null || true
|
||||||
rm -rf $builddir
|
rm -rf $builddir
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
@ -55,18 +55,18 @@ base_image_mounts=""
|
||||||
|
|
||||||
# Unpack base image
|
# Unpack base image
|
||||||
if [ -n "$docker_base_image" ]; then
|
if [ -n "$docker_base_image" ]; then
|
||||||
mkdir -p "$builddir/base"
|
mkdir -p "$builddir/base"
|
||||||
docker pull "$docker_base_image"
|
docker pull "$docker_base_image"
|
||||||
docker save "$docker_base_image" | tar -xC "$builddir/base"
|
docker save "$docker_base_image" | tar -xC "$builddir/base"
|
||||||
|
|
||||||
image_id=$(docker inspect -f "{{.Id}}" "$docker_base_image")
|
image_id=$(docker inspect -f "{{.Id}}" "$docker_base_image")
|
||||||
while [ -n "$image_id" ]; do
|
while [ -n "$image_id" ]; do
|
||||||
mkdir -p "$builddir/base/$image_id/layer"
|
mkdir -p "$builddir/base/$image_id/layer"
|
||||||
tar -xf "$builddir/base/$image_id/layer.tar" -C "$builddir/base/$image_id/layer"
|
tar -xf "$builddir/base/$image_id/layer.tar" -C "$builddir/base/$image_id/layer"
|
||||||
|
|
||||||
base_image_mounts="${base_image_mounts}:$builddir/base/$image_id/layer=ro+wh"
|
base_image_mounts="${base_image_mounts}:$builddir/base/$image_id/layer=ro+wh"
|
||||||
image_id=$(docker inspect -f "{{.Parent}}" "$image_id")
|
image_id=$(docker inspect -f "{{.Parent}}" "$image_id")
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mount work directory
|
# Mount work directory
|
||||||
|
@ -75,20 +75,20 @@ mount -t aufs -o "br=$builddir/diff=rw${base_image_mounts},dio,xino=/dev/shm/auf
|
||||||
# Update files
|
# Update files
|
||||||
cd $builddir
|
cd $builddir
|
||||||
LC_ALL=C diff -rq disk_image workdir \
|
LC_ALL=C diff -rq disk_image workdir \
|
||||||
| sed -re "s|Only in workdir(.*?): |DEL \1/|g;s|Only in disk_image(.*?): |ADD \1/|g;s|Files disk_image/(.+) and workdir/(.+) differ|UPDATE /\1|g" \
|
| sed -re "s|Only in workdir(.*?): |DEL \1/|g;s|Only in disk_image(.*?): |ADD \1/|g;s|Files disk_image/(.+) and workdir/(.+) differ|UPDATE /\1|g" \
|
||||||
| while read action entry; do
|
| while read action entry; do
|
||||||
case "$action" in
|
case "$action" in
|
||||||
ADD|UPDATE)
|
ADD | UPDATE)
|
||||||
cp -a "disk_image$entry" "workdir$entry"
|
cp -a "disk_image$entry" "workdir$entry"
|
||||||
;;
|
;;
|
||||||
DEL)
|
DEL)
|
||||||
rm -rf "workdir$entry"
|
rm -rf "workdir$entry"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error: unknown diff line: $action $entry" >&2
|
echo "Error: unknown diff line: $action $entry" >&2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Pack new image
|
# Pack new image
|
||||||
new_image_id="$(for i in $(seq 1 32); do printf "%02x" $(($RANDOM % 256)); done)"
|
new_image_id="$(for i in $(seq 1 32); do printf "%02x" $(($RANDOM % 256)); done)"
|
||||||
|
@ -96,15 +96,15 @@ mkdir -p $builddir/result/$new_image_id
|
||||||
cd diff
|
cd diff
|
||||||
tar -cf $builddir/result/$new_image_id/layer.tar *
|
tar -cf $builddir/result/$new_image_id/layer.tar *
|
||||||
echo "1.0" > $builddir/result/$new_image_id/VERSION
|
echo "1.0" > $builddir/result/$new_image_id/VERSION
|
||||||
cat > $builddir/result/$new_image_id/json <<-EOS
|
cat > $builddir/result/$new_image_id/json <<- EOS
|
||||||
{ "docker_version": "1.4.1"
|
{ "docker_version": "1.4.1"
|
||||||
, "id": "$new_image_id"
|
, "id": "$new_image_id"
|
||||||
, "created": "$(date -u +%Y-%m-%dT%H:%M:%S.%NZ)"
|
, "created": "$(date -u +%Y-%m-%dT%H:%M:%S.%NZ)"
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
if [ -n "$docker_base_image" ]; then
|
if [ -n "$docker_base_image" ]; then
|
||||||
image_id=$(docker inspect -f "{{.Id}}" "$docker_base_image")
|
image_id=$(docker inspect -f "{{.Id}}" "$docker_base_image")
|
||||||
echo ", \"parent\": \"$image_id\"" >> $builddir/result/$new_image_id/json
|
echo ", \"parent\": \"$image_id\"" >> $builddir/result/$new_image_id/json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "}" >> $builddir/result/$new_image_id/json
|
echo "}" >> $builddir/result/$new_image_id/json
|
||||||
|
|
|
@ -59,13 +59,13 @@ while [ $# -gt 0 ]; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS=','
|
IFS=','
|
||||||
ancestry=( ${ancestryJson//[\[\] \"]/} )
|
ancestry=(${ancestryJson//[\[\] \"]/})
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ -s "$dir/tags-$imageFile.tmp" ]; then
|
if [ -s "$dir/tags-$imageFile.tmp" ]; then
|
||||||
echo -n ', ' >> "$dir/tags-$imageFile.tmp"
|
echo -n ', ' >> "$dir/tags-$imageFile.tmp"
|
||||||
else
|
else
|
||||||
images=( "${images[@]}" "$image" )
|
images=("${images[@]}" "$image")
|
||||||
fi
|
fi
|
||||||
echo -n '"'"$tag"'": "'"$imageId"'"' >> "$dir/tags-$imageFile.tmp"
|
echo -n '"'"$tag"'": "'"$imageId"'"' >> "$dir/tags-$imageFile.tmp"
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,15 @@ authService='registry.docker.io'
|
||||||
|
|
||||||
# https://github.com/moby/moby/issues/33700
|
# https://github.com/moby/moby/issues/33700
|
||||||
fetch_blob() {
|
fetch_blob() {
|
||||||
local token="$1"; shift
|
local token="$1"
|
||||||
local image="$1"; shift
|
shift
|
||||||
local digest="$1"; shift
|
local image="$1"
|
||||||
local targetFile="$1"; shift
|
shift
|
||||||
local curlArgs=( "$@" )
|
local digest="$1"
|
||||||
|
shift
|
||||||
|
local targetFile="$1"
|
||||||
|
shift
|
||||||
|
local curlArgs=("$@")
|
||||||
|
|
||||||
local curlHeaders="$(
|
local curlHeaders="$(
|
||||||
curl -S "${curlArgs[@]}" \
|
curl -S "${curlArgs[@]}" \
|
||||||
|
@ -63,7 +67,7 @@ fetch_blob() {
|
||||||
-D-
|
-D-
|
||||||
)"
|
)"
|
||||||
curlHeaders="$(echo "$curlHeaders" | tr -d '\r')"
|
curlHeaders="$(echo "$curlHeaders" | tr -d '\r')"
|
||||||
if grep -qE "^HTTP/[0-9].[0-9] 3" <<<"$curlHeaders"; then
|
if grep -qE "^HTTP/[0-9].[0-9] 3" <<< "$curlHeaders"; then
|
||||||
rm -f "$targetFile"
|
rm -f "$targetFile"
|
||||||
|
|
||||||
local blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')"
|
local blobRedirect="$(echo "$curlHeaders" | awk -F ': ' 'tolower($1) == "location" { print $2; exit }')"
|
||||||
|
@ -81,7 +85,8 @@ fetch_blob() {
|
||||||
|
|
||||||
# handle 'application/vnd.docker.distribution.manifest.v2+json' manifest
|
# handle 'application/vnd.docker.distribution.manifest.v2+json' manifest
|
||||||
handle_single_manifest_v2() {
|
handle_single_manifest_v2() {
|
||||||
local manifestJson="$1"; shift
|
local manifestJson="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
local configDigest="$(echo "$manifestJson" | jq --raw-output '.config.digest')"
|
local configDigest="$(echo "$manifestJson" | jq --raw-output '.config.digest')"
|
||||||
local imageId="${configDigest#*:}" # strip off "sha256:"
|
local imageId="${configDigest#*:}" # strip off "sha256:"
|
||||||
|
@ -91,7 +96,7 @@ handle_single_manifest_v2() {
|
||||||
|
|
||||||
local layersFs="$(echo "$manifestJson" | jq --raw-output --compact-output '.layers[]')"
|
local layersFs="$(echo "$manifestJson" | jq --raw-output --compact-output '.layers[]')"
|
||||||
local IFS="$newlineIFS"
|
local IFS="$newlineIFS"
|
||||||
local layers=( $layersFs )
|
local layers=($layersFs)
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
echo "Downloading '$imageIdentifier' (${#layers[@]} layers)..."
|
echo "Downloading '$imageIdentifier' (${#layers[@]} layers)..."
|
||||||
|
@ -116,7 +121,7 @@ handle_single_manifest_v2() {
|
||||||
local parentJson="$(printf ', parent: "%s"' "$parentId")"
|
local parentJson="$(printf ', parent: "%s"' "$parentId")"
|
||||||
local addJson="$(printf '{ id: "%s"%s }' "$layerId" "${parentId:+$parentJson}")"
|
local addJson="$(printf '{ id: "%s"%s }' "$layerId" "${parentId:+$parentJson}")"
|
||||||
# this starter JSON is taken directly from Docker's own "docker save" output for unimportant layers
|
# this starter JSON is taken directly from Docker's own "docker save" output for unimportant layers
|
||||||
jq "$addJson + ." > "$dir/$layerId/json" <<-'EOJSON'
|
jq "$addJson + ." > "$dir/$layerId/json" <<- 'EOJSON'
|
||||||
{
|
{
|
||||||
"created": "0001-01-01T00:00:00Z",
|
"created": "0001-01-01T00:00:00Z",
|
||||||
"container_config": {
|
"container_config": {
|
||||||
|
@ -145,7 +150,7 @@ handle_single_manifest_v2() {
|
||||||
case "$layerMediaType" in
|
case "$layerMediaType" in
|
||||||
application/vnd.docker.image.rootfs.diff.tar.gzip)
|
application/vnd.docker.image.rootfs.diff.tar.gzip)
|
||||||
local layerTar="$layerId/layer.tar"
|
local layerTar="$layerId/layer.tar"
|
||||||
layerFiles=( "${layerFiles[@]}" "$layerTar" )
|
layerFiles=("${layerFiles[@]}" "$layerTar")
|
||||||
# TODO figure out why "-C -" doesn't work here
|
# TODO figure out why "-C -" doesn't work here
|
||||||
# "curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume."
|
# "curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume."
|
||||||
# "HTTP/1.1 416 Requested Range Not Satisfiable"
|
# "HTTP/1.1 416 Requested Range Not Satisfiable"
|
||||||
|
@ -179,7 +184,7 @@ handle_single_manifest_v2() {
|
||||||
Layers: '"$(echo '[]' | jq --raw-output ".$(for layerFile in "${layerFiles[@]}"; do echo " + [ \"$layerFile\" ]"; done)")"'
|
Layers: '"$(echo '[]' | jq --raw-output ".$(for layerFile in "${layerFiles[@]}"; do echo " + [ \"$layerFile\" ]"; done)")"'
|
||||||
}'
|
}'
|
||||||
)"
|
)"
|
||||||
manifestJsonEntries=( "${manifestJsonEntries[@]}" "$manifestJsonEntry" )
|
manifestJsonEntries=("${manifestJsonEntries[@]}" "$manifestJsonEntry")
|
||||||
}
|
}
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
|
@ -227,7 +232,7 @@ while [ $# -gt 0 ]; do
|
||||||
application/vnd.docker.distribution.manifest.list.v2+json)
|
application/vnd.docker.distribution.manifest.list.v2+json)
|
||||||
layersFs="$(echo "$manifestJson" | jq --raw-output --compact-output '.manifests[]')"
|
layersFs="$(echo "$manifestJson" | jq --raw-output --compact-output '.manifests[]')"
|
||||||
IFS="$newlineIFS"
|
IFS="$newlineIFS"
|
||||||
layers=( $layersFs )
|
layers=($layersFs)
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
found=""
|
found=""
|
||||||
|
@ -273,7 +278,7 @@ while [ $# -gt 0 ]; do
|
||||||
|
|
||||||
layersFs="$(echo "$manifestJson" | jq --raw-output '.fsLayers | .[] | .blobSum')"
|
layersFs="$(echo "$manifestJson" | jq --raw-output '.fsLayers | .[] | .blobSum')"
|
||||||
IFS="$newlineIFS"
|
IFS="$newlineIFS"
|
||||||
layers=( $layersFs )
|
layers=($layersFs)
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
history="$(echo "$manifestJson" | jq '.history | [.[] | .v1Compatibility]')"
|
history="$(echo "$manifestJson" | jq '.history | [.[] | .v1Compatibility]')"
|
||||||
|
@ -314,7 +319,7 @@ while [ $# -gt 0 ]; do
|
||||||
if [ -s "$dir/tags-$imageFile.tmp" ]; then
|
if [ -s "$dir/tags-$imageFile.tmp" ]; then
|
||||||
echo -n ', ' >> "$dir/tags-$imageFile.tmp"
|
echo -n ', ' >> "$dir/tags-$imageFile.tmp"
|
||||||
else
|
else
|
||||||
images=( "${images[@]}" "$image" )
|
images=("${images[@]}" "$image")
|
||||||
fi
|
fi
|
||||||
echo -n '"'"$tag"'": "'"$imageId"'"' >> "$dir/tags-$imageFile.tmp"
|
echo -n '"'"$tag"'": "'"$imageId"'"' >> "$dir/tags-$imageFile.tmp"
|
||||||
done
|
done
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
# $> ./generate_aliases <mailmap_file> > aliases
|
# $> ./generate_aliases <mailmap_file> > aliases
|
||||||
#
|
#
|
||||||
|
|
||||||
cat $1 | \
|
cat $1 \
|
||||||
grep -v '^#' | \
|
| grep -v '^#' \
|
||||||
sed 's/^[^<]*<\([^>]*\)>/\1/' | \
|
| sed 's/^[^<]*<\([^>]*\)>/\1/' \
|
||||||
grep '<.*>' | sed -e 's/[<>]/ /g' | \
|
| grep '<.*>' | sed -e 's/[<>]/ /g' \
|
||||||
awk '{if ($3 != "") { print $3" "$1 } else {print $2" "$1}}' | \
|
| awk '{if ($3 != "") { print $3" "$1 } else {print $2" "$1}}' \
|
||||||
sort | uniq
|
| sort | uniq
|
||||||
|
|
|
@ -22,7 +22,7 @@ start_pre() {
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
ebegin "Reloading ${RC_SVCNAME}"
|
ebegin "Reloading ${RC_SVCNAME}"
|
||||||
start-stop-daemon --signal HUP --pidfile "${pidfile}"
|
start-stop-daemon --signal HUP --pidfile "${pidfile}"
|
||||||
eend $? "Failed to stop ${RC_SVCNAME}"
|
eend $? "Failed to stop ${RC_SVCNAME}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ fi
|
||||||
|
|
||||||
check_init() {
|
check_init() {
|
||||||
# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly)
|
# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly)
|
||||||
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
|
if [ -x /sbin/initctl ] && /sbin/initctl version 2> /dev/null | grep -q upstart; then
|
||||||
log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
|
log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -85,7 +85,7 @@ cgroupfs_mount() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
check_init
|
check_init
|
||||||
|
|
||||||
fail_unless_root
|
fail_unless_root
|
||||||
|
|
||||||
cgroupfs_mount
|
cgroupfs_mount
|
||||||
|
@ -110,9 +110,9 @@ case "$1" in
|
||||||
--pidfile "$DOCKER_SSD_PIDFILE" \
|
--pidfile "$DOCKER_SSD_PIDFILE" \
|
||||||
--make-pidfile \
|
--make-pidfile \
|
||||||
-- \
|
-- \
|
||||||
-p "$DOCKER_PIDFILE" \
|
-p "$DOCKER_PIDFILE" \
|
||||||
$DOCKER_OPTS \
|
$DOCKER_OPTS \
|
||||||
>> "$DOCKER_LOGFILE" 2>&1
|
>> "$DOCKER_LOGFILE" 2>&1
|
||||||
log_end_msg $?
|
log_end_msg $?
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ case "$1" in
|
||||||
restart)
|
restart)
|
||||||
check_init
|
check_init
|
||||||
fail_unless_root
|
fail_unless_root
|
||||||
docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
|
docker_pid=$(cat "$DOCKER_SSD_PIDFILE" 2> /dev/null)
|
||||||
[ -n "$docker_pid" ] \
|
[ -n "$docker_pid" ] \
|
||||||
&& ps -p $docker_pid > /dev/null 2>&1 \
|
&& ps -p $docker_pid > /dev/null 2>&1 \
|
||||||
&& $0 stop
|
&& $0 stop
|
||||||
|
|
|
@ -109,10 +109,9 @@ rh_status() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rh_status_q() {
|
rh_status_q() {
|
||||||
rh_status >/dev/null 2>&1
|
rh_status > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
check_for_cleanup() {
|
check_for_cleanup() {
|
||||||
if [ -f ${pidfile} ]; then
|
if [ -f ${pidfile} ]; then
|
||||||
/bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
|
/bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
|
||||||
|
@ -141,13 +140,14 @@ case "$1" in
|
||||||
status)
|
status)
|
||||||
rh_status
|
rh_status
|
||||||
;;
|
;;
|
||||||
condrestart|try-restart)
|
condrestart | try-restart)
|
||||||
rh_status_q || exit 0
|
rh_status_q || exit 0
|
||||||
restart
|
restart
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||||
exit 2
|
exit 2
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
|
|
@ -20,26 +20,26 @@ DATABASE_KEY="$DATABASE/com.docker.driver.amd64-linux/bundle"
|
||||||
[ -d "$DATABASE" ] || errexit "Docker for Mac must be installed for this script"
|
[ -d "$DATABASE" ] || errexit "Docker for Mac must be installed for this script"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"install")
|
"install")
|
||||||
[ -d "$BUNDLE" ] || errexit "cannot find bundle $BUNDLE"
|
[ -d "$BUNDLE" ] || errexit "cannot find bundle $BUNDLE"
|
||||||
[ -e "$CLIENT_PATH" ] || errexit "you need to run make cross first"
|
[ -e "$CLIENT_PATH" ] || errexit "you need to run make cross first"
|
||||||
[ -e "$BUNDLE/binary-daemon/dockerd" ] || errexit "you need to build binaries first"
|
[ -e "$BUNDLE/binary-daemon/dockerd" ] || errexit "you need to build binaries first"
|
||||||
[ -f "$BUNDLE/binary-client/docker" ] || errexit "you need to build binaries first"
|
[ -f "$BUNDLE/binary-client/docker" ] || errexit "you need to build binaries first"
|
||||||
git -C "$DATABASE" reset --hard >/dev/null
|
git -C "$DATABASE" reset --hard > /dev/null
|
||||||
echo "$BUNDLE_PATH" > "$DATABASE_KEY"
|
echo "$BUNDLE_PATH" > "$DATABASE_KEY"
|
||||||
git -C "$DATABASE" add "$DATABASE_KEY"
|
git -C "$DATABASE" add "$DATABASE_KEY"
|
||||||
git -C "$DATABASE" commit -m "update bundle to $BUNDLE_PATH"
|
git -C "$DATABASE" commit -m "update bundle to $BUNDLE_PATH"
|
||||||
rm -f /usr/local/bin/docker
|
rm -f /usr/local/bin/docker
|
||||||
cp "$CLIENT_PATH" /usr/local/bin
|
cp "$CLIENT_PATH" /usr/local/bin
|
||||||
echo "Bundle installed. Restart Docker to use. To uninstall, reset Docker to factory defaults."
|
echo "Bundle installed. Restart Docker to use. To uninstall, reset Docker to factory defaults."
|
||||||
;;
|
;;
|
||||||
"undo")
|
"undo")
|
||||||
git -C "$DATABASE" reset --hard >/dev/null
|
git -C "$DATABASE" reset --hard > /dev/null
|
||||||
[ -f "$DATABASE_KEY" ] || errexit "bundle not set"
|
[ -f "$DATABASE_KEY" ] || errexit "bundle not set"
|
||||||
git -C "$DATABASE" rm "$DATABASE_KEY"
|
git -C "$DATABASE" rm "$DATABASE_KEY"
|
||||||
git -C "$DATABASE" commit -m "remove bundle"
|
git -C "$DATABASE" commit -m "remove bundle"
|
||||||
rm -f /usr/local/bin/docker
|
rm -f /usr/local/bin/docker
|
||||||
ln -s "$HOME/Library/Group Containers/group.com.docker/bin/docker" /usr/local/bin
|
ln -s "$HOME/Library/Group Containers/group.com.docker/bin/docker" /usr/local/bin
|
||||||
echo "Bundle removed. Using dev versions may cause issues, a reset to factory defaults is recommended."
|
echo "Bundle removed. Using dev versions may cause issues, a reset to factory defaults is recommended."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -19,13 +19,13 @@ tmp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
apkv() {
|
apkv() {
|
||||||
curl -sSL $MAINREPO/$ARCH/APKINDEX.tar.gz | tar -Oxz |
|
curl -sSL $MAINREPO/$ARCH/APKINDEX.tar.gz | tar -Oxz \
|
||||||
grep --text '^P:apk-tools-static$' -A1 | tail -n1 | cut -d: -f2
|
| grep --text '^P:apk-tools-static$' -A1 | tail -n1 | cut -d: -f2
|
||||||
}
|
}
|
||||||
|
|
||||||
getapk() {
|
getapk() {
|
||||||
curl -sSL $MAINREPO/$ARCH/apk-tools-static-$(apkv).apk |
|
curl -sSL $MAINREPO/$ARCH/apk-tools-static-$(apkv).apk \
|
||||||
tar -xz -C $TMP sbin/apk.static
|
| tar -xz -C $TMP sbin/apk.static
|
||||||
}
|
}
|
||||||
|
|
||||||
mkbase() {
|
mkbase() {
|
||||||
|
|
|
@ -7,12 +7,12 @@ set -e
|
||||||
# reset umask to default
|
# reset umask to default
|
||||||
umask 022
|
umask 022
|
||||||
|
|
||||||
hash pacstrap &>/dev/null || {
|
hash pacstrap &> /dev/null || {
|
||||||
echo "Could not find pacstrap. Run pacman -S arch-install-scripts"
|
echo "Could not find pacstrap. Run pacman -S arch-install-scripts"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
hash expect &>/dev/null || {
|
hash expect &> /dev/null || {
|
||||||
echo "Could not find expect. Run pacman -S expect"
|
echo "Could not find expect. Run pacman -S expect"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ PKGIGNORE=(
|
||||||
|
|
||||||
PKGREMOVE=(
|
PKGREMOVE=(
|
||||||
gawk
|
gawk
|
||||||
haveged
|
haveged
|
||||||
less
|
less
|
||||||
linux-libre
|
linux-libre
|
||||||
linux-libre-firmware
|
linux-libre-firmware
|
||||||
|
@ -79,7 +79,7 @@ PKGREMOVE="${PKGREMOVE[*]}"
|
||||||
arch="$(uname -m)"
|
arch="$(uname -m)"
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
armv*)
|
armv*)
|
||||||
if pacman -Q archlinuxarm-keyring >/dev/null 2>&1; then
|
if pacman -Q archlinuxarm-keyring > /dev/null 2>&1; then
|
||||||
pacman-key --init
|
pacman-key --init
|
||||||
pacman-key --populate archlinuxarm
|
pacman-key --populate archlinuxarm
|
||||||
else
|
else
|
||||||
|
@ -107,7 +107,7 @@ esac
|
||||||
|
|
||||||
export PACMAN_MIRRORLIST
|
export PACMAN_MIRRORLIST
|
||||||
|
|
||||||
expect <<EOF
|
expect << EOF
|
||||||
set send_slow {1 .1}
|
set send_slow {1 .1}
|
||||||
proc send {ignore arg} {
|
proc send {ignore arg} {
|
||||||
sleep .1
|
sleep .1
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
die () {
|
die() {
|
||||||
echo >&2 "$@"
|
echo >&2 "$@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$#" -eq 1 ] || die "1 argument(s) required, $# provided. Usage: ./mkimage-crux.sh /path/to/iso"
|
[ "$#" -eq 1 ] || die "1 argument(s) required, $# provided. Usage: ./mkimage-crux.sh /path/to/iso"
|
||||||
|
@ -33,15 +33,15 @@ export PATH="$TMP/usr/bin:$PATH"
|
||||||
mkdir -p $ROOTFS/var/lib/pkg
|
mkdir -p $ROOTFS/var/lib/pkg
|
||||||
touch $ROOTFS/var/lib/pkg/db
|
touch $ROOTFS/var/lib/pkg/db
|
||||||
for pkg in $CRUX/crux/core/*; do
|
for pkg in $CRUX/crux/core/*; do
|
||||||
pkgadd -r $ROOTFS $pkg
|
pkgadd -r $ROOTFS $pkg
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove agetty and inittab config
|
# Remove agetty and inittab config
|
||||||
if (grep agetty ${ROOTFS}/etc/inittab 2>&1 > /dev/null); then
|
if (grep agetty ${ROOTFS}/etc/inittab 2>&1 > /dev/null); then
|
||||||
echo "Removing agetty from /etc/inittab ..."
|
echo "Removing agetty from /etc/inittab ..."
|
||||||
chroot ${ROOTFS} sed -i -e "/agetty/d" /etc/inittab
|
chroot ${ROOTFS} sed -i -e "/agetty/d" /etc/inittab
|
||||||
chroot ${ROOTFS} sed -i -e "/shutdown/d" /etc/inittab
|
chroot ${ROOTFS} sed -i -e "/shutdown/d" /etc/inittab
|
||||||
chroot ${ROOTFS} sed -i -e "/^$/N;/^\n$/d" /etc/inittab
|
chroot ${ROOTFS} sed -i -e "/^$/N;/^\n$/d" /etc/inittab
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove kernel source
|
# Remove kernel source
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOOPTS
|
cat << EOOPTS
|
||||||
$(basename $0) [OPTIONS] <name>
|
$(basename $0) [OPTIONS] <name>
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-p "<packages>" The list of packages to install in the container.
|
-p "<packages>" The list of packages to install in the container.
|
||||||
|
@ -21,7 +21,7 @@ OPTIONS:
|
||||||
-t <tag> Specify Tag information.
|
-t <tag> Specify Tag information.
|
||||||
default is reffered at /etc/{redhat,system}-release
|
default is reffered at /etc/{redhat,system}-release
|
||||||
EOOPTS
|
EOOPTS
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# option defaults
|
# option defaults
|
||||||
|
@ -35,38 +35,38 @@ install_groups=()
|
||||||
install_packages=()
|
install_packages=()
|
||||||
version=
|
version=
|
||||||
while getopts ":y:p:g:t:h" opt; do
|
while getopts ":y:p:g:t:h" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
y)
|
y)
|
||||||
yum_config=$OPTARG
|
yum_config=$OPTARG
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
install_packages+=("$OPTARG")
|
install_packages+=("$OPTARG")
|
||||||
;;
|
;;
|
||||||
g)
|
g)
|
||||||
install_groups+=("$OPTARG")
|
install_groups+=("$OPTARG")
|
||||||
;;
|
;;
|
||||||
t)
|
t)
|
||||||
version="$OPTARG"
|
version="$OPTARG"
|
||||||
;;
|
;;
|
||||||
\?)
|
\?)
|
||||||
echo "Invalid option: -$OPTARG"
|
echo "Invalid option: -$OPTARG"
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
name=$1
|
name=$1
|
||||||
|
|
||||||
if [[ -z $name ]]; then
|
if [[ -z $name ]]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# default to Core group if not specified otherwise
|
# default to Core group if not specified otherwise
|
||||||
if [ ${#install_groups[*]} -eq 0 ]; then
|
if [ ${#install_groups[*]} -eq 0 ]; then
|
||||||
install_groups=('Core')
|
install_groups=('Core')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
target=$(mktemp -d --tmpdir $(basename $0).XXXXXX)
|
target=$(mktemp -d --tmpdir $(basename $0).XXXXXX)
|
||||||
|
@ -91,21 +91,19 @@ if [ -d /etc/yum/vars ]; then
|
||||||
cp -a /etc/yum/vars "$target"/etc/yum/
|
cp -a /etc/yum/vars "$target"/etc/yum/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$install_groups" ]];
|
if [[ -n "$install_groups" ]]; then
|
||||||
then
|
yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \
|
||||||
yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \
|
--setopt=group_package_types=mandatory -y groupinstall "${install_groups[@]}"
|
||||||
--setopt=group_package_types=mandatory -y groupinstall "${install_groups[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$install_packages" ]];
|
if [[ -n "$install_packages" ]]; then
|
||||||
then
|
yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \
|
||||||
yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \
|
--setopt=group_package_types=mandatory -y install "${install_packages[@]}"
|
||||||
--setopt=group_package_types=mandatory -y install "${install_packages[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
yum -c "$yum_config" --installroot="$target" -y clean all
|
yum -c "$yum_config" --installroot="$target" -y clean all
|
||||||
|
|
||||||
cat > "$target"/etc/sysconfig/network <<EOF
|
cat > "$target"/etc/sysconfig/network << EOF
|
||||||
NETWORKING=yes
|
NETWORKING=yes
|
||||||
HOSTNAME=localhost.localdomain
|
HOSTNAME=localhost.localdomain
|
||||||
EOF
|
EOF
|
||||||
|
@ -129,18 +127,17 @@ rm -rf "$target"/etc/ld.so.cache "$target"/var/cache/ldconfig
|
||||||
mkdir -p --mode=0755 "$target"/var/cache/ldconfig
|
mkdir -p --mode=0755 "$target"/var/cache/ldconfig
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
if [ -z "$version" ]; then
|
||||||
for file in "$target"/etc/{redhat,system}-release
|
for file in "$target"/etc/{redhat,system}-release; do
|
||||||
do
|
if [ -r "$file" ]; then
|
||||||
if [ -r "$file" ]; then
|
version="$(sed 's/^[^0-9\]*\([0-9.]\+\).*$/\1/' "$file")"
|
||||||
version="$(sed 's/^[^0-9\]*\([0-9.]\+\).*$/\1/' "$file")"
|
break
|
||||||
break
|
fi
|
||||||
fi
|
done
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
if [ -z "$version" ]; then
|
||||||
echo >&2 "warning: cannot autodetect OS version, using '$name' as tag"
|
echo >&2 "warning: cannot autodetect OS version, using '$name' as tag"
|
||||||
version=$name
|
version=$name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tar --numeric-owner -c -C "$target" . | docker import - $name:$version
|
tar --numeric-owner -c -C "$target" . | docker import - $name:$version
|
||||||
|
|
|
@ -28,12 +28,27 @@ tag=
|
||||||
compression="auto"
|
compression="auto"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-d|--dir) dir="$2" ; shift 2 ;;
|
-d | --dir)
|
||||||
-t|--tag) tag="$2" ; shift 2 ;;
|
dir="$2"
|
||||||
--compression) compression="$2" ; shift 2 ;;
|
shift 2
|
||||||
--no-compression) compression="none" ; shift 1 ;;
|
;;
|
||||||
-h|--help) usage ;;
|
-t | --tag)
|
||||||
--) shift ; break ;;
|
tag="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--compression)
|
||||||
|
compression="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--no-compression)
|
||||||
|
compression="none"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
-h | --help) usage ;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -41,9 +56,8 @@ script="$1"
|
||||||
[ "$script" ] || usage
|
[ "$script" ] || usage
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ "$compression" == 'auto' ] || [ -z "$compression" ]
|
if [ "$compression" == 'auto' ] || [ -z "$compression" ]; then
|
||||||
then
|
compression='xz'
|
||||||
compression='xz'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ "$compression" == 'none' ] && compression=''
|
[ "$compression" == 'none' ] && compression=''
|
||||||
|
@ -68,7 +82,10 @@ if [ -z "$dir" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rootfsDir="$dir/rootfs"
|
rootfsDir="$dir/rootfs"
|
||||||
( set -x; mkdir -p "$rootfsDir" )
|
(
|
||||||
|
set -x
|
||||||
|
mkdir -p "$rootfsDir"
|
||||||
|
)
|
||||||
|
|
||||||
# pass all remaining arguments to $script
|
# pass all remaining arguments to $script
|
||||||
"$scriptDir/$script" "$rootfsDir" "$@"
|
"$scriptDir/$script" "$rootfsDir" "$@"
|
||||||
|
@ -79,7 +96,7 @@ mkdir -p "$rootfsDir/dev" "$rootfsDir/proc"
|
||||||
|
|
||||||
# make sure /etc/resolv.conf has something useful in it
|
# make sure /etc/resolv.conf has something useful in it
|
||||||
mkdir -p "$rootfsDir/etc"
|
mkdir -p "$rootfsDir/etc"
|
||||||
cat > "$rootfsDir/etc/resolv.conf" <<'EOF'
|
cat > "$rootfsDir/etc/resolv.conf" << 'EOF'
|
||||||
nameserver 8.8.8.8
|
nameserver 8.8.8.8
|
||||||
nameserver 8.8.4.4
|
nameserver 8.8.4.4
|
||||||
EOF
|
EOF
|
||||||
|
@ -93,7 +110,7 @@ touch "$tarFile"
|
||||||
)
|
)
|
||||||
|
|
||||||
echo >&2 "+ cat > '$dir/Dockerfile'"
|
echo >&2 "+ cat > '$dir/Dockerfile'"
|
||||||
cat > "$dir/Dockerfile" <<EOF
|
cat > "$dir/Dockerfile" << EOF
|
||||||
FROM scratch
|
FROM scratch
|
||||||
ADD $(basename "$tarFile") /
|
ADD $(basename "$tarFile") /
|
||||||
EOF
|
EOF
|
||||||
|
@ -101,20 +118,35 @@ EOF
|
||||||
# if our generated image has a decent shell, let's set a default command
|
# if our generated image has a decent shell, let's set a default command
|
||||||
for shell in /bin/bash /usr/bin/fish /usr/bin/zsh /bin/sh; do
|
for shell in /bin/bash /usr/bin/fish /usr/bin/zsh /bin/sh; do
|
||||||
if [ -x "$rootfsDir/$shell" ]; then
|
if [ -x "$rootfsDir/$shell" ]; then
|
||||||
( set -x; echo 'CMD ["'"$shell"'"]' >> "$dir/Dockerfile" )
|
(
|
||||||
|
set -x
|
||||||
|
echo 'CMD ["'"$shell"'"]' >> "$dir/Dockerfile"
|
||||||
|
)
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
( set -x; rm -rf "$rootfsDir" )
|
(
|
||||||
|
set -x
|
||||||
|
rm -rf "$rootfsDir"
|
||||||
|
)
|
||||||
|
|
||||||
if [ "$tag" ]; then
|
if [ "$tag" ]; then
|
||||||
( set -x; docker build -t "$tag" "$dir" )
|
(
|
||||||
|
set -x
|
||||||
|
docker build -t "$tag" "$dir"
|
||||||
|
)
|
||||||
elif [ "$delDir" ]; then
|
elif [ "$delDir" ]; then
|
||||||
# if we didn't specify a tag and we're going to delete our dir, let's just build an untagged image so that we did _something_
|
# if we didn't specify a tag and we're going to delete our dir, let's just build an untagged image so that we did _something_
|
||||||
( set -x; docker build "$dir" )
|
(
|
||||||
|
set -x
|
||||||
|
docker build "$dir"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$delDir" ]; then
|
if [ "$delDir" ]; then
|
||||||
( set -x; rm -rf "$dir" )
|
(
|
||||||
|
set -x
|
||||||
|
rm -rf "$dir"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,7 +4,7 @@ set -e
|
||||||
rootfsDir="$1"
|
rootfsDir="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
busybox="$(which busybox 2>/dev/null || true)"
|
busybox="$(which busybox 2> /dev/null || true)"
|
||||||
if [ -z "$busybox" ]; then
|
if [ -z "$busybox" ]; then
|
||||||
echo >&2 'error: busybox: not found'
|
echo >&2 'error: busybox: not found'
|
||||||
echo >&2 ' install it with your distribution "busybox-static" package'
|
echo >&2 ' install it with your distribution "busybox-static" package'
|
||||||
|
@ -24,7 +24,7 @@ cp "$busybox" "$rootfsDir/bin/busybox"
|
||||||
cd "$rootfsDir"
|
cd "$rootfsDir"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
modules=( $(bin/busybox --list-modules) )
|
modules=($(bin/busybox --list-modules))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
for module in "${modules[@]}"; do
|
for module in "${modules[@]}"; do
|
||||||
|
|
|
@ -22,7 +22,7 @@ shift
|
||||||
|
|
||||||
before=()
|
before=()
|
||||||
while [ $# -gt 0 ] && [[ "$1" == -* ]]; do
|
while [ $# -gt 0 ] && [[ "$1" == -* ]]; do
|
||||||
before+=( "$1" )
|
before+=("$1")
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ rootfs_chroot() {
|
||||||
|
|
||||||
# prevent init scripts from running during install/update
|
# prevent init scripts from running during install/update
|
||||||
echo >&2 "+ echo exit 101 > '$rootfsDir/usr/sbin/policy-rc.d'"
|
echo >&2 "+ echo exit 101 > '$rootfsDir/usr/sbin/policy-rc.d'"
|
||||||
cat > "$rootfsDir/usr/sbin/policy-rc.d" <<-'EOF'
|
cat > "$rootfsDir/usr/sbin/policy-rc.d" <<- 'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# For most Docker users, "apt-get install" only happens during "docker build",
|
# For most Docker users, "apt-get install" only happens during "docker build",
|
||||||
|
@ -82,7 +82,10 @@ chmod +x "$rootfsDir/usr/sbin/policy-rc.d"
|
||||||
)
|
)
|
||||||
|
|
||||||
# shrink a little, since apt makes us cache-fat (wheezy: ~157.5MB vs ~120MB)
|
# shrink a little, since apt makes us cache-fat (wheezy: ~157.5MB vs ~120MB)
|
||||||
( set -x; rootfs_chroot apt-get clean )
|
(
|
||||||
|
set -x
|
||||||
|
rootfs_chroot apt-get clean
|
||||||
|
)
|
||||||
|
|
||||||
# this file is one APT creates to make sure we don't "autoremove" our currently
|
# this file is one APT creates to make sure we don't "autoremove" our currently
|
||||||
# in-use kernel, which doesn't really apply to debootstraps/Docker images that
|
# in-use kernel, which doesn't really apply to debootstraps/Docker images that
|
||||||
|
@ -93,7 +96,7 @@ rm -f "$rootfsDir/etc/apt/apt.conf.d/01autoremove-kernels"
|
||||||
if strings "$rootfsDir/usr/bin/dpkg" | grep -q unsafe-io; then
|
if strings "$rootfsDir/usr/bin/dpkg" | grep -q unsafe-io; then
|
||||||
# force dpkg not to call sync() after package extraction (speeding up installs)
|
# force dpkg not to call sync() after package extraction (speeding up installs)
|
||||||
echo >&2 "+ echo force-unsafe-io > '$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup'"
|
echo >&2 "+ echo force-unsafe-io > '$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup'"
|
||||||
cat > "$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup" <<-'EOF'
|
cat > "$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup" <<- 'EOF'
|
||||||
# For most Docker users, package installs happen during "docker build", which
|
# For most Docker users, package installs happen during "docker build", which
|
||||||
# doesn't survive power loss and gets restarted clean afterwards anyhow, so
|
# doesn't survive power loss and gets restarted clean afterwards anyhow, so
|
||||||
# this minor tweak gives us a nice speedup (much nicer on spinning disks,
|
# this minor tweak gives us a nice speedup (much nicer on spinning disks,
|
||||||
|
@ -107,7 +110,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
|
||||||
# _keep_ us lean by effectively running "apt-get clean" after every install
|
# _keep_ us lean by effectively running "apt-get clean" after every install
|
||||||
aptGetClean='"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true";'
|
aptGetClean='"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true";'
|
||||||
echo >&2 "+ cat > '$rootfsDir/etc/apt/apt.conf.d/docker-clean'"
|
echo >&2 "+ cat > '$rootfsDir/etc/apt/apt.conf.d/docker-clean'"
|
||||||
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-clean" <<-EOF
|
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-clean" <<- EOF
|
||||||
# Since for most Docker users, package installs happen in "docker build" steps,
|
# Since for most Docker users, package installs happen in "docker build" steps,
|
||||||
# they essentially become individual layers due to the way Docker handles
|
# they essentially become individual layers due to the way Docker handles
|
||||||
# layering, especially using CoW filesystems. What this means for us is that
|
# layering, especially using CoW filesystems. What this means for us is that
|
||||||
|
@ -131,7 +134,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
|
||||||
|
|
||||||
# remove apt-cache translations for fast "apt-get update"
|
# remove apt-cache translations for fast "apt-get update"
|
||||||
echo >&2 "+ echo Acquire::Languages 'none' > '$rootfsDir/etc/apt/apt.conf.d/docker-no-languages'"
|
echo >&2 "+ echo Acquire::Languages 'none' > '$rootfsDir/etc/apt/apt.conf.d/docker-no-languages'"
|
||||||
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-no-languages" <<-'EOF'
|
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-no-languages" <<- 'EOF'
|
||||||
# In Docker, we don't often need the "Translations" files, so we're just wasting
|
# In Docker, we don't often need the "Translations" files, so we're just wasting
|
||||||
# time and space by downloading them, and this inhibits that. For users that do
|
# time and space by downloading them, and this inhibits that. For users that do
|
||||||
# need them, it's a simple matter to delete this file and "apt-get update". :)
|
# need them, it's a simple matter to delete this file and "apt-get update". :)
|
||||||
|
@ -140,7 +143,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo >&2 "+ echo Acquire::GzipIndexes 'true' > '$rootfsDir/etc/apt/apt.conf.d/docker-gzip-indexes'"
|
echo >&2 "+ echo Acquire::GzipIndexes 'true' > '$rootfsDir/etc/apt/apt.conf.d/docker-gzip-indexes'"
|
||||||
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-gzip-indexes" <<-'EOF'
|
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-gzip-indexes" <<- 'EOF'
|
||||||
# Since Docker users using "RUN apt-get update && apt-get install -y ..." in
|
# Since Docker users using "RUN apt-get update && apt-get install -y ..." in
|
||||||
# their Dockerfiles don't go delete the lists files afterwards, we want them to
|
# their Dockerfiles don't go delete the lists files afterwards, we want them to
|
||||||
# be as small as possible on-disk, so we explicitly request "gz" versions and
|
# be as small as possible on-disk, so we explicitly request "gz" versions and
|
||||||
|
@ -156,7 +159,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
|
||||||
|
|
||||||
# update "autoremove" configuration to be aggressive about removing suggests deps that weren't manually installed
|
# update "autoremove" configuration to be aggressive about removing suggests deps that weren't manually installed
|
||||||
echo >&2 "+ echo Apt::AutoRemove::SuggestsImportant 'false' > '$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests'"
|
echo >&2 "+ echo Apt::AutoRemove::SuggestsImportant 'false' > '$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests'"
|
||||||
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests" <<-'EOF'
|
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests" <<- 'EOF'
|
||||||
# Since Docker users are looking for the smallest possible final images, the
|
# Since Docker users are looking for the smallest possible final images, the
|
||||||
# following emerges as a very common pattern:
|
# following emerges as a very common pattern:
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,18 @@ installversion=
|
||||||
mirror=
|
mirror=
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-v|--version) installversion="$2" ; shift 2 ;;
|
-v | --version)
|
||||||
-m|--mirror) mirror="$2" ; shift 2 ;;
|
installversion="$2"
|
||||||
--) shift ; break ;;
|
shift 2
|
||||||
|
;;
|
||||||
|
-m | --mirror)
|
||||||
|
mirror="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,10 @@ echo "Nuking $dir ..."
|
||||||
echo ' (if this is wrong, press Ctrl+C NOW!)'
|
echo ' (if this is wrong, press Ctrl+C NOW!)'
|
||||||
echo
|
echo
|
||||||
|
|
||||||
( set -x; sleep 10 )
|
(
|
||||||
|
set -x
|
||||||
|
sleep 10
|
||||||
|
)
|
||||||
echo
|
echo
|
||||||
|
|
||||||
dir_in_dir() {
|
dir_in_dir() {
|
||||||
|
@ -45,7 +48,10 @@ dir_in_dir() {
|
||||||
for mount in $(awk '{ print $5 }' /proc/self/mountinfo); do
|
for mount in $(awk '{ print $5 }' /proc/self/mountinfo); do
|
||||||
mount="$(readlink -f "$mount" || true)"
|
mount="$(readlink -f "$mount" || true)"
|
||||||
if [ "$dir" != "$mount" ] && dir_in_dir "$mount" "$dir"; then
|
if [ "$dir" != "$mount" ] && dir_in_dir "$mount" "$dir"; then
|
||||||
( set -x; umount -f "$mount" )
|
(
|
||||||
|
set -x
|
||||||
|
umount -f "$mount"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -55,10 +61,17 @@ if command -v btrfs > /dev/null 2>&1; then
|
||||||
# Source: http://stackoverflow.com/a/32865333
|
# Source: http://stackoverflow.com/a/32865333
|
||||||
for subvol in $(find "$dir" -type d -inum 256 | sort -r); do
|
for subvol in $(find "$dir" -type d -inum 256 | sort -r); do
|
||||||
if [ "$dir" != "$subvol" ]; then
|
if [ "$dir" != "$subvol" ]; then
|
||||||
( set -x; btrfs subvolume delete "$subvol" )
|
(
|
||||||
|
set -x
|
||||||
|
btrfs subvolume delete "$subvol"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# finally, DESTROY ALL THINGS
|
# finally, DESTROY ALL THINGS
|
||||||
( shopt -s dotglob; set -x; rm -rf "$dir"/* )
|
(
|
||||||
|
shopt -s dotglob
|
||||||
|
set -x
|
||||||
|
rm -rf "$dir"/*
|
||||||
|
)
|
||||||
|
|
|
@ -16,59 +16,59 @@ function urlencode() {
|
||||||
# urlencode <string>
|
# urlencode <string>
|
||||||
|
|
||||||
local length="${#1}"
|
local length="${#1}"
|
||||||
for (( i = 0; i < length; i++ )); do
|
for ((i = 0; i < length; i++)); do
|
||||||
local c="${1:i:1}"
|
local c="${1:i:1}"
|
||||||
case $c in
|
case $c in
|
||||||
[a-zA-Z0-9.~_-]) printf "$c" ;;
|
[a-zA-Z0-9.~_-]) printf "$c" ;;
|
||||||
*) printf '%%%02X' "'$c"
|
*) printf '%%%02X' "'$c" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function template() {
|
function template() {
|
||||||
# this should always match the template from CONTRIBUTING.md
|
# this should always match the template from CONTRIBUTING.md
|
||||||
cat <<- EOM
|
cat <<- EOM
|
||||||
Description of problem:
|
Description of problem:
|
||||||
|
|
||||||
|
|
||||||
\`docker version\`:
|
\`docker version\`:
|
||||||
`${DOCKER_COMMAND} -D version`
|
$(${DOCKER_COMMAND} -D version)
|
||||||
|
|
||||||
|
|
||||||
\`docker info\`:
|
\`docker info\`:
|
||||||
`${DOCKER_COMMAND} -D info`
|
$(${DOCKER_COMMAND} -D info)
|
||||||
|
|
||||||
|
|
||||||
\`uname -a\`:
|
\`uname -a\`:
|
||||||
`uname -a`
|
$(uname -a)
|
||||||
|
|
||||||
|
|
||||||
Environment details (AWS, VirtualBox, physical, etc.):
|
Environment details (AWS, VirtualBox, physical, etc.):
|
||||||
|
|
||||||
|
|
||||||
How reproducible:
|
How reproducible:
|
||||||
|
|
||||||
|
|
||||||
Steps to Reproduce:
|
Steps to Reproduce:
|
||||||
1.
|
1.
|
||||||
2.
|
2.
|
||||||
3.
|
3.
|
||||||
|
|
||||||
|
|
||||||
Actual Results:
|
Actual Results:
|
||||||
|
|
||||||
|
|
||||||
Expected Results:
|
Expected Results:
|
||||||
|
|
||||||
|
|
||||||
Additional info:
|
Additional info:
|
||||||
|
|
||||||
|
|
||||||
EOM
|
EOM
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_issue_url() {
|
function format_issue_url() {
|
||||||
if [ ${#@} -ne 2 ] ; then
|
if [ ${#@} -ne 2 ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
local issue_name=$(urlencode "${DOCKER_ISSUE_NAME_PREFIX}${1}")
|
local issue_name=$(urlencode "${DOCKER_ISSUE_NAME_PREFIX}${1}")
|
||||||
|
@ -76,7 +76,6 @@ function format_issue_url() {
|
||||||
echo "${DOCKER_ISSUE_URL}?title=${issue_name}&body=${issue_body}"
|
echo "${DOCKER_ISSUE_URL}?title=${issue_name}&body=${issue_body}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo -ne "Do you use \`sudo\` to call docker? [y|N]: "
|
echo -ne "Do you use \`sudo\` to call docker? [y|N]: "
|
||||||
read -r -n 1 use_sudo
|
read -r -n 1 use_sudo
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -91,7 +90,7 @@ echo ""
|
||||||
|
|
||||||
issue_url=$(format_issue_url "${issue_title}" "$(template)")
|
issue_url=$(format_issue_url "${issue_title}" "$(template)")
|
||||||
|
|
||||||
if which xdg-open 2>/dev/null >/dev/null ; then
|
if which xdg-open 2> /dev/null > /dev/null; then
|
||||||
echo -ne "Would like to launch this report in your browser? [Y|n]: "
|
echo -ne "Would like to launch this report in your browser? [Y|n]: "
|
||||||
read -r -n 1 launch_now
|
read -r -n 1 launch_now
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -102,4 +101,3 @@ if which xdg-open 2>/dev/null >/dev/null ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "If you would like to manually open the url, you can open this link if your browser: ${issue_url}"
|
echo "If you would like to manually open the url, you can open this link if your browser: ${issue_url}"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
# containerd is also pinned in vendor.conf. When updating the binary
|
# containerd is also pinned in vendor.conf. When updating the binary
|
||||||
# version you may also need to update the vendor version to pick up bug
|
# version you may also need to update the vendor version to pick up bug
|
||||||
# fixes or new APIs.
|
# fixes or new APIs.
|
||||||
|
|
|
@ -34,5 +34,3 @@ _install_proxy() {
|
||||||
git checkout -q "$LIBNETWORK_COMMIT"
|
git checkout -q "$LIBNETWORK_COMMIT"
|
||||||
go build ${BUILD_MODE} -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
|
go build ${BUILD_MODE} -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
|
|
||||||
install_rootlesskit() {
|
install_rootlesskit() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"dynamic")
|
"dynamic")
|
||||||
install_rootlesskit_dynamic
|
install_rootlesskit_dynamic
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
_install_rootlesskit
|
_install_rootlesskit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo 'Usage: $0 [dynamic]'
|
echo 'Usage: $0 [dynamic]'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.."
|
||||||
# see also ".mailmap" for how email addresses and names are deduplicated
|
# see also ".mailmap" for how email addresses and names are deduplicated
|
||||||
|
|
||||||
{
|
{
|
||||||
cat <<-'EOH'
|
cat <<- 'EOH'
|
||||||
# This file lists all individuals having contributed content to the repository.
|
# This file lists all individuals having contributed content to the repository.
|
||||||
# For how it is generated, see `hack/generate-authors.sh`.
|
# For how it is generated, see `hack/generate-authors.sh`.
|
||||||
EOH
|
EOH
|
||||||
echo
|
echo
|
||||||
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
|
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
|
||||||
|
|
24
hack/make.sh
24
hack/make.sh
|
@ -24,7 +24,7 @@ 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 SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
export MAKEDIR="$SCRIPTDIR/make"
|
export MAKEDIR="$SCRIPTDIR/make"
|
||||||
export PKG_CONFIG=${PKG_CONFIG:-pkg-config}
|
export PKG_CONFIG=${PKG_CONFIG:-pkg-config}
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ echo
|
||||||
DEFAULT_BUNDLES=(
|
DEFAULT_BUNDLES=(
|
||||||
binary-daemon
|
binary-daemon
|
||||||
dynbinary
|
dynbinary
|
||||||
|
\
|
||||||
test-integration
|
test-integration
|
||||||
test-docker-py
|
test-docker-py
|
||||||
|
\
|
||||||
cross
|
cross
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ add_buildtag() {
|
||||||
[[ " $DOCKER_BUILDTAGS" == *" $1_"* ]] || DOCKER_BUILDTAGS+=" $1_$2"
|
[[ " $DOCKER_BUILDTAGS" == *" $1_"* ]] || DOCKER_BUILDTAGS+=" $1_$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ${PKG_CONFIG} 'libsystemd >= 209' 2> /dev/null ; then
|
if ${PKG_CONFIG} 'libsystemd >= 209' 2> /dev/null; then
|
||||||
DOCKER_BUILDTAGS+=" journald"
|
DOCKER_BUILDTAGS+=" journald"
|
||||||
elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null ; then
|
elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null; then
|
||||||
DOCKER_BUILDTAGS+=" journald journald_compat"
|
DOCKER_BUILDTAGS+=" journald journald_compat"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -95,10 +95,11 @@ fi
|
||||||
# functionality. We favour libdm_dlsym_deferred_remove over
|
# functionality. We favour libdm_dlsym_deferred_remove over
|
||||||
# libdm_no_deferred_remove in dynamic cases because the binary could be shipped
|
# libdm_no_deferred_remove in dynamic cases because the binary could be shipped
|
||||||
# with a newer libdevmapper than the one it was built with.
|
# with a newer libdevmapper than the one it was built with.
|
||||||
if \
|
if
|
||||||
command -v gcc &> /dev/null \
|
command -v gcc &> /dev/null \
|
||||||
&& ! ( echo -e '#include <libdevmapper.h>\nint main() { dm_task_deferred_remove(NULL); }'| gcc -xc - -o /dev/null $(pkg-config --libs devmapper) &> /dev/null ) \
|
&& ! (echo -e '#include <libdevmapper.h>\nint main() { dm_task_deferred_remove(NULL); }' | gcc -xc - -o /dev/null $(pkg-config --libs devmapper) &> /dev/null) \
|
||||||
; then
|
;
|
||||||
|
then
|
||||||
add_buildtag libdm dlsym_deferred_remove
|
add_buildtag libdm dlsym_deferred_remove
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -113,10 +114,10 @@ LDFLAGS_STATIC=''
|
||||||
EXTLDFLAGS_STATIC='-static'
|
EXTLDFLAGS_STATIC='-static'
|
||||||
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
|
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
|
||||||
# with options like -race.
|
# with options like -race.
|
||||||
ORIG_BUILDFLAGS=( -tags "netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
|
ORIG_BUILDFLAGS=(-tags "netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo)
|
||||||
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
|
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
|
||||||
|
|
||||||
BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )
|
BUILDFLAGS=(${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}")
|
||||||
|
|
||||||
LDFLAGS_STATIC_DOCKER="
|
LDFLAGS_STATIC_DOCKER="
|
||||||
$LDFLAGS_STATIC
|
$LDFLAGS_STATIC
|
||||||
|
@ -134,7 +135,8 @@ if [ "$(uname -s)" = 'FreeBSD' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bundle() {
|
bundle() {
|
||||||
local bundle="$1"; shift
|
local bundle="$1"
|
||||||
|
shift
|
||||||
echo "---> Making bundle: $(basename "$bundle") (in $DEST)"
|
echo "---> Making bundle: $(basename "$bundle") (in $DEST)"
|
||||||
source "$SCRIPTDIR/make/$bundle" "$@"
|
source "$SCRIPTDIR/make/$bundle" "$@"
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,58 +38,58 @@ hash_files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
export GOGC=${DOCKER_BUILD_GOGC:-1000}
|
export GOGC=${DOCKER_BUILD_GOGC:-1000}
|
||||||
|
|
||||||
if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
|
if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
|
||||||
# must be cross-compiling!
|
# must be cross-compiling!
|
||||||
|
case "$(go env GOOS)/$(go env GOARCH)" in
|
||||||
|
windows/amd64)
|
||||||
|
export CC="${CC:-x86_64-w64-mingw32-gcc}"
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
;;
|
||||||
|
linux/arm)
|
||||||
|
case "${GOARM}" in
|
||||||
|
5 | "")
|
||||||
|
export CC="${CC:-arm-linux-gnueabi-gcc}"
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
;;
|
||||||
|
7)
|
||||||
|
export CC="${CC:-arm-linux-gnueabihf-gcc}"
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
linux/arm64)
|
||||||
|
export CC="${CC:-aarch64-linux-gnu-gcc}"
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
;;
|
||||||
|
linux/amd64)
|
||||||
|
export CC="${CC:-x86_64-linux-gnu-gcc}"
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -buildmode=pie is not supported on Windows and Linux on mips.
|
||||||
case "$(go env GOOS)/$(go env GOARCH)" in
|
case "$(go env GOOS)/$(go env GOARCH)" in
|
||||||
windows/amd64)
|
windows/* | linux/mips*) ;;
|
||||||
export CC="${CC:-x86_64-w64-mingw32-gcc}"
|
|
||||||
export CGO_ENABLED=1
|
*)
|
||||||
;;
|
BUILDFLAGS+=("-buildmode=pie")
|
||||||
linux/arm)
|
|
||||||
case "${GOARM}" in
|
|
||||||
5|"")
|
|
||||||
export CC="${CC:-arm-linux-gnueabi-gcc}"
|
|
||||||
export CGO_ENABLED=1
|
|
||||||
;;
|
|
||||||
7)
|
|
||||||
export CC="${CC:-arm-linux-gnueabihf-gcc}"
|
|
||||||
export CGO_ENABLED=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
linux/arm64)
|
|
||||||
export CC="${CC:-aarch64-linux-gnu-gcc}"
|
|
||||||
export CGO_ENABLED=1
|
|
||||||
;;
|
|
||||||
linux/amd64)
|
|
||||||
export CC="${CC:-x86_64-linux-gnu-gcc}"
|
|
||||||
export CGO_ENABLED=1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
# -buildmode=pie is not supported on Windows and Linux on mips.
|
echo "Building: $DEST/$BINARY_FULLNAME"
|
||||||
case "$(go env GOOS)/$(go env GOARCH)" in
|
echo "GOOS=\"${GOOS}\" GOARCH=\"${GOARCH}\" GOARM=\"${GOARM}\""
|
||||||
windows/*|linux/mips*)
|
go build \
|
||||||
;;
|
-o "$DEST/$BINARY_FULLNAME" \
|
||||||
*)
|
"${BUILDFLAGS[@]}" \
|
||||||
BUILDFLAGS+=( "-buildmode=pie" )
|
-ldflags "
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "Building: $DEST/$BINARY_FULLNAME"
|
|
||||||
echo "GOOS=\"${GOOS}\" GOARCH=\"${GOARCH}\" GOARM=\"${GOARM}\""
|
|
||||||
go build \
|
|
||||||
-o "$DEST/$BINARY_FULLNAME" \
|
|
||||||
"${BUILDFLAGS[@]}" \
|
|
||||||
-ldflags "
|
|
||||||
$LDFLAGS
|
$LDFLAGS
|
||||||
$LDFLAGS_STATIC_DOCKER
|
$LDFLAGS_STATIC_DOCKER
|
||||||
$DOCKER_LDFLAGS
|
$DOCKER_LDFLAGS
|
||||||
" \
|
" \
|
||||||
${GO_PACKAGE}
|
${GO_PACKAGE}
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "Created binary: $DEST/$BINARY_FULLNAME"
|
echo "Created binary: $DEST/$BINARY_FULLNAME"
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
docker-version-osarch() {
|
docker-version-osarch() {
|
||||||
if ! type docker &>/dev/null; then
|
if ! type docker &> /dev/null; then
|
||||||
# docker is not installed
|
# docker is not installed
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
local target="$1" # "Client" or "Server"
|
local target="$1" # "Client" or "Server"
|
||||||
local fmtStr="{{.${target}.Os}}/{{.${target}.Arch}}"
|
local fmtStr="{{.${target}.Os}}/{{.${target}.Arch}}"
|
||||||
if docker version -f "$fmtStr" 2>/dev/null; then
|
if docker version -f "$fmtStr" 2> /dev/null; then
|
||||||
# if "docker version -f" works, let's just use that!
|
# if "docker version -f" works, let's just use that!
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -58,7 +58,7 @@ if [ "$DOCKER_REMAP_ROOT" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# example usage: DOCKER_EXPERIMENTAL=1
|
# example usage: DOCKER_EXPERIMENTAL=1
|
||||||
if [ "$DOCKER_EXPERIMENTAL" ]; then
|
if [ "$DOCKER_EXPERIMENTAL" ]; then
|
||||||
echo >&2 '# DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled! '
|
echo >&2 '# DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled! '
|
||||||
extra_params="$extra_params --experimental"
|
extra_params="$extra_params --experimental"
|
||||||
fi
|
fi
|
||||||
|
@ -88,7 +88,7 @@ if [ -z "$DOCKER_TEST_HOST" ]; then
|
||||||
--userland-proxy="$DOCKER_USERLANDPROXY" \
|
--userland-proxy="$DOCKER_USERLANDPROXY" \
|
||||||
${storage_params} \
|
${storage_params} \
|
||||||
${extra_params} \
|
${extra_params} \
|
||||||
&> "$DEST/docker.log"
|
&> "$DEST/docker.log"
|
||||||
) &
|
) &
|
||||||
else
|
else
|
||||||
export DOCKER_HOST="$DOCKER_TEST_HOST"
|
export DOCKER_HOST="$DOCKER_TEST_HOST"
|
||||||
|
@ -98,7 +98,7 @@ fi
|
||||||
tries=60
|
tries=60
|
||||||
echo "INFO: Waiting for daemon to start..."
|
echo "INFO: Waiting for daemon to start..."
|
||||||
while ! ${TEST_CLIENT_BINARY} version &> /dev/null; do
|
while ! ${TEST_CLIENT_BINARY} version &> /dev/null; do
|
||||||
(( tries-- ))
|
((tries--))
|
||||||
if [ $tries -le 0 ]; then
|
if [ $tries -le 0 ]; then
|
||||||
printf "\n"
|
printf "\n"
|
||||||
if [ -z "$DOCKER_HOST" ]; then
|
if [ -z "$DOCKER_HOST" ]; then
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
if [ ! "$(go env GOOS)" = 'windows' ]; then
|
if [ ! "$(go env GOOS)" = 'windows' ]; then
|
||||||
for pidFile in $(find "$DEST" -name docker.pid); do
|
for pidFile in $(find "$DEST" -name docker.pid); do
|
||||||
pid=$([ -n "$TESTDEBUG" ] && set -x; cat "$pidFile")
|
pid=$(
|
||||||
|
[ -n "$TESTDEBUG" ] && set -x
|
||||||
|
cat "$pidFile"
|
||||||
|
)
|
||||||
(
|
(
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[ -n "$TESTDEBUG" ] && set -x
|
||||||
kill "$pid"
|
kill "$pid"
|
||||||
|
@ -26,7 +29,7 @@ if [ ! "$(go env GOOS)" = 'windows' ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Note this script is not actionable on Windows to Linux CI. Instead the
|
# Note this script is not actionable on Windows to Linux CI. Instead the
|
||||||
# DIND daemon under test is torn down by the Jenkins tear-down script
|
# DIND daemon under test is torn down by the Jenkins tear-down script
|
||||||
echo "INFO: Not stopping daemon on Windows CI"
|
echo "INFO: Not stopping daemon on Windows CI"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -z "${MAKEDIR}" ]; then
|
if [ -z "${MAKEDIR}" ]; then
|
||||||
MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
MAKEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
export MAKEDIR
|
export MAKEDIR
|
||||||
fi
|
fi
|
||||||
source "${MAKEDIR}/.go-autogen"
|
source "${MAKEDIR}/.go-autogen"
|
||||||
|
@ -46,7 +46,7 @@ setup_integration_test_filter() {
|
||||||
|
|
||||||
setup_integration_test_filter
|
setup_integration_test_filter
|
||||||
if [ -z "${TEST_SKIP_INTEGRATION}" ] && [ -z "${TEST_INTEGRATION_DIR}" ]; then
|
if [ -z "${TEST_SKIP_INTEGRATION}" ] && [ -z "${TEST_INTEGRATION_DIR}" ]; then
|
||||||
integration_api_dirs="$(go list -test -f '{{- if ne .ForTest "" -}}{{- .Dir -}}{{- end -}}' ./integration/...)"
|
integration_api_dirs="$(go list -test -f '{{- if ne .ForTest "" -}}{{- .Dir -}}{{- end -}}' ./integration/...)"
|
||||||
else
|
else
|
||||||
integration_api_dirs="${TEST_INTEGRATION_DIR}"
|
integration_api_dirs="${TEST_INTEGRATION_DIR}"
|
||||||
fi
|
fi
|
||||||
|
@ -163,8 +163,8 @@ error_on_leaked_containerd_shims() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
leftovers=$(ps -ax -o pid,cmd |
|
leftovers=$(ps -ax -o pid,cmd \
|
||||||
awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
|
| awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
|
||||||
if [ -n "$leftovers" ]; then
|
if [ -n "$leftovers" ]; then
|
||||||
ps aux
|
ps aux
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
|
@ -190,6 +190,6 @@ set_platform_timeout() {
|
||||||
# - remove last character (usually 'm' from '10m')
|
# - remove last character (usually 'm' from '10m')
|
||||||
# - multiply by testcount
|
# - multiply by testcount
|
||||||
# - add last character back
|
# - add last character back
|
||||||
TIMEOUT=$((${TIMEOUT::-1} * ${TEST_REPEAT}))${TIMEOUT:$((${#TIMEOUT}-1)):1}
|
TIMEOUT=$((${TIMEOUT::-1} * ${TEST_REPEAT}))${TIMEOUT:$((${#TIMEOUT} - 1)):1}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ copy_binaries() {
|
||||||
done
|
done
|
||||||
|
|
||||||
# vpnkit is amd64 only
|
# vpnkit is amd64 only
|
||||||
if command -v "vpnkit.$(uname -m)" 2>&1 >/dev/null; then
|
if command -v "vpnkit.$(uname -m)" 2>&1 > /dev/null; then
|
||||||
cp -f "$(command -v "vpnkit.$(uname -m)")" "$dir/vpnkit"
|
cp -f "$(command -v "vpnkit.$(uname -m)")" "$dir/vpnkit"
|
||||||
if [ "$hash" = "hash" ]; then
|
if [ "$hash" = "hash" ]; then
|
||||||
hash_files "$dir/vpnkit"
|
hash_files "$dir/vpnkit"
|
||||||
|
|
|
@ -4,8 +4,8 @@ set -e
|
||||||
(
|
(
|
||||||
export IAMSTATIC='false'
|
export IAMSTATIC='false'
|
||||||
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[@]/osusergo /}" ) # ditto for osusergo
|
export BUILDFLAGS=("${BUILDFLAGS[@]/osusergo /}") # ditto for osusergo
|
||||||
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 "${MAKEDIR}/.binary"
|
source "${MAKEDIR}/.binary"
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,7 +21,6 @@ if [ -n "$DOCKER_STORAGE_OPTS" ]; then
|
||||||
unset IFS
|
unset IFS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
listen_port=2375
|
listen_port=2375
|
||||||
if [ -n "$DOCKER_PORT" ]; then
|
if [ -n "$DOCKER_PORT" ]; then
|
||||||
IFS=':' read -r -a ports <<< "$DOCKER_PORT"
|
IFS=':' read -r -a ports <<< "$DOCKER_PORT"
|
||||||
|
|
|
@ -37,6 +37,7 @@ source hack/make/.integration-test-helpers
|
||||||
echo "WARN: Skipping test-docker-py: connecting to docker daemon using ${docker_host_scheme} (${DOCKER_HOST}) not supported"
|
echo "WARN: Skipping test-docker-py: connecting to docker daemon using ${docker_host_scheme} (${DOCKER_HOST}) not supported"
|
||||||
bundle .integration-daemon-stop
|
bundle .integration-daemon-stop
|
||||||
return 0
|
return 0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
docker_py_image="docker-sdk-python3:${DOCKER_PY_COMMIT}"
|
docker_py_image="docker-sdk-python3:${DOCKER_PY_COMMIT}"
|
||||||
|
|
|
@ -15,7 +15,7 @@ fi
|
||||||
bundle .integration-daemon-setup
|
bundle .integration-daemon-setup
|
||||||
|
|
||||||
testexit=0
|
testexit=0
|
||||||
( repeat run_test_integration ) || testexit=$?
|
(repeat run_test_integration) || testexit=$?
|
||||||
|
|
||||||
# Always run cleanup, even if the subshell fails
|
# Always run cleanup, even if the subshell fails
|
||||||
bundle .integration-daemon-stop
|
bundle .integration-daemon-stop
|
||||||
|
|
|
@ -3,11 +3,10 @@ set -e -o pipefail
|
||||||
|
|
||||||
source hack/validate/.validate
|
source hack/validate/.validate
|
||||||
|
|
||||||
|
|
||||||
run_integration_flaky() {
|
run_integration_flaky() {
|
||||||
new_tests=$(
|
new_tests=$(
|
||||||
validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' |
|
validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' \
|
||||||
grep -E '^(\+func Test)(.*)(\*testing\.T\))' || true
|
| grep -E '^(\+func Test)(.*)(\*testing\.T\))' || true
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ -z "$new_tests" ]; then
|
if [ -z "$new_tests" ]; then
|
||||||
|
|
|
@ -3,7 +3,7 @@ set -e -u -o pipefail
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
if [ "$ARCH" = "x86_64" ]; then
|
if [ "$ARCH" = "x86_64" ]; then
|
||||||
ARCH="amd64"
|
ARCH="amd64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-${ARCH}}
|
export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-${ARCH}}
|
||||||
|
@ -13,8 +13,9 @@ export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-${ARCH}}
|
||||||
: ${TESTDEBUG:=}
|
: ${TESTDEBUG:=}
|
||||||
|
|
||||||
integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
|
integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
|
||||||
find /tests/integration -type d |
|
find /tests/integration -type d \
|
||||||
grep -vE '(^/tests/integration($|/internal)|/testdata)')"}
|
| grep -vE '(^/tests/integration($|/internal)|/testdata)'
|
||||||
|
)"}
|
||||||
|
|
||||||
run_test_integration() {
|
run_test_integration() {
|
||||||
set_platform_timeout
|
set_platform_timeout
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#
|
#
|
||||||
set -eu -o pipefail
|
set -eu -o pipefail
|
||||||
|
|
||||||
BUILDFLAGS=( -tags 'netgo seccomp libdm_no_deferred_remove' )
|
BUILDFLAGS=(-tags 'netgo seccomp libdm_no_deferred_remove')
|
||||||
TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
|
TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
|
||||||
TESTDIRS="${TESTDIRS:-./...}"
|
TESTDIRS="${TESTDIRS:-./...}"
|
||||||
exclude_paths='/vendor/|/integration'
|
exclude_paths='/vendor/|/integration'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# Run all validation
|
# Run all validation
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
. ${SCRIPTDIR}/default
|
. ${SCRIPTDIR}/default
|
||||||
. ${SCRIPTDIR}/vendor
|
. ${SCRIPTDIR}/vendor
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPTDIR}/.validate"
|
source "${SCRIPTDIR}/.validate"
|
||||||
|
|
||||||
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
|
||||||
|
@ -24,7 +24,7 @@ check_dco() {
|
||||||
if [ ${adds} -eq 0 -a ${dels} -eq 0 ]; then
|
if [ ${adds} -eq 0 -a ${dels} -eq 0 ]; then
|
||||||
echo '0 adds, 0 deletions; nothing to validate! :)'
|
echo '0 adds, 0 deletions; nothing to validate! :)'
|
||||||
else
|
else
|
||||||
commits=( $(validate_log --format='format:%H%n') )
|
commits=($(validate_log --format='format:%H%n'))
|
||||||
badCommits=()
|
badCommits=()
|
||||||
for commit in "${commits[@]}"; do
|
for commit in "${commits[@]}"; do
|
||||||
if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then
|
if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then
|
||||||
|
@ -32,7 +32,7 @@ else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if ! git log -1 --format='format:%B' "$commit" | check_dco; then
|
if ! git log -1 --format='format:%B' "$commit" | check_dco; then
|
||||||
badCommits+=( "$commit" )
|
badCommits+=("$commit")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ${#badCommits[@]} -eq 0 ]; then
|
if [ ${#badCommits[@]} -eq 0 ]; then
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# Run default validation, exclude vendor because it's slow
|
# Run default validation, exclude vendor because it's slow
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
. "${SCRIPTDIR}"/dco
|
. "${SCRIPTDIR}"/dco
|
||||||
. "${SCRIPTDIR}"/default-seccomp
|
. "${SCRIPTDIR}"/default-seccomp
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPTDIR}/.validate"
|
source "${SCRIPTDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) )
|
files=($(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
|
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
|
||||||
# We run 'go generate' and see if we have a diff afterwards
|
# We run 'go generate' and see if we have a diff afterwards
|
||||||
go generate ./profiles/seccomp/ >/dev/null
|
go generate ./profiles/seccomp/ > /dev/null
|
||||||
# Let see if the working directory is clean
|
# Let see if the working directory is clean
|
||||||
diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)"
|
diffs="$(git status --porcelain -- profiles/seccomp 2> /dev/null)"
|
||||||
if [ "$diffs" ]; then
|
if [ "$diffs" ]; then
|
||||||
{
|
{
|
||||||
echo 'The result of go generate ./profiles/seccomp/ differs'
|
echo 'The result of go generate ./profiles/seccomp/ differs'
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Check that no new tests are being added to integration-cli
|
# Check that no new tests are being added to integration-cli
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPTDIR}/.validate"
|
source "${SCRIPTDIR}/.validate"
|
||||||
|
|
||||||
new_tests=$(
|
new_tests=$(
|
||||||
validate_diff --diff-filter=ACMR --unified=0 -- 'integration-cli/*_api_*.go' 'integration-cli/*_cli_*.go' |
|
validate_diff --diff-filter=ACMR --unified=0 -- 'integration-cli/*_api_*.go' 'integration-cli/*_cli_*.go' \
|
||||||
grep -E '^\+func (.*) Test' || true
|
| grep -E '^\+func (.*) Test' || true
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ -n "$new_tests" ]; then
|
if [ -n "$new_tests" ]; then
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
|
|
||||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
# CI platforms differ, so per-platform GOLANGCI_LINT_OPTS can be set
|
# CI platforms differ, so per-platform GOLANGCI_LINT_OPTS can be set
|
||||||
# from a platform-specific Dockerfile, otherwise let's just set
|
# from a platform-specific Dockerfile, otherwise let's just set
|
||||||
|
@ -11,9 +11,9 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
[ -n "${TESTDEBUG}" ] && set -x
|
[ -n "${TESTDEBUG}" ] && set -x
|
||||||
|
|
||||||
# TODO find a way to share this code with hack/make.sh
|
# TODO find a way to share this code with hack/make.sh
|
||||||
if ${PKG_CONFIG} 'libsystemd >= 209' 2> /dev/null ; then
|
if ${PKG_CONFIG} 'libsystemd >= 209' 2> /dev/null; then
|
||||||
DOCKER_BUILDTAGS+=" journald"
|
DOCKER_BUILDTAGS+=" journald"
|
||||||
elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null ; then
|
elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null; then
|
||||||
DOCKER_BUILDTAGS+=" journald journald_compat"
|
DOCKER_BUILDTAGS+=" journald journald_compat"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPTDIR}/.validate"
|
source "${SCRIPTDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'pkg/*.go' || true) )
|
files=($(validate_diff --diff-filter=ACMR --name-only -- 'pkg/*.go' || true))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
badFiles=()
|
badFiles=()
|
||||||
for f in "${files[@]}"; do
|
for f in "${files[@]}"; do
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
badImports=( $(go list -e -f '{{ join .Deps "\n" }}' "$f" | sort -u | grep -vE '^github.com/docker/docker/pkg/' | grep -vE '^github.com/docker/docker/vendor' | grep -E '^github.com/docker/docker' || true) )
|
badImports=($(go list -e -f '{{ join .Deps "\n" }}' "$f" | sort -u | grep -vE '^github.com/docker/docker/pkg/' | grep -vE '^github.com/docker/docker/vendor' | grep -E '^github.com/docker/docker' || true))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
for import in "${badImports[@]}"; do
|
for import in "${badImports[@]}"; do
|
||||||
badFiles+=( "$f imports $import" )
|
badFiles+=("$f imports $import")
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPTDIR}/.validate"
|
source "${SCRIPTDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/swagger.yaml' || true) )
|
files=($(validate_diff --diff-filter=ACMR --name-only -- 'api/swagger.yaml' || true))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
|
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
|
||||||
|
@ -12,7 +12,7 @@ if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
|
||||||
if out=$(swagger validate api/swagger.yaml); then
|
if out=$(swagger validate api/swagger.yaml); then
|
||||||
echo "Congratulations! ${out}"
|
echo "Congratulations! ${out}"
|
||||||
else
|
else
|
||||||
echo "${out}" >&2
|
echo "${out}" >&2
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPTDIR}/.validate"
|
source "${SCRIPTDIR}/.validate"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true) )
|
files=($(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
|
if [ -n "${TEST_FORCE_VALIDATE:-}" ] || [ ${#files[@]} -gt 0 ]; then
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${SCRIPTDIR}/.validate"
|
source "${SCRIPTDIR}/.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))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
badFiles=()
|
badFiles=()
|
||||||
for f in "${files[@]}"; do
|
for f in "${files[@]}"; do
|
||||||
# we use "git show" here to validate that what's committed has valid TOML syntax
|
# we use "git show" here to validate that what's committed has valid TOML syntax
|
||||||
if ! git show "$VALIDATE_HEAD:$f" | tomlv /proc/self/fd/0 ; then
|
if ! git show "$VALIDATE_HEAD:$f" | tomlv /proc/self/fd/0; then
|
||||||
badFiles+=( "$f" )
|
badFiles+=("$f")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ listFile=shell_test_list.json
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"store")
|
"store")
|
||||||
in=$(</dev/stdin)
|
in=$(< /dev/stdin)
|
||||||
server=$(echo "$in" | jq --raw-output ".ServerURL")
|
server=$(echo "$in" | jq --raw-output ".ServerURL")
|
||||||
serverHash=$(echo "$server" | sha1sum - | awk '{print $1}')
|
serverHash=$(echo "$server" | sha1sum - | awk '{print $1}')
|
||||||
|
|
||||||
|
@ -17,34 +17,34 @@ case $1 in
|
||||||
if [[ ! -f $TEMP/$listFile ]]; then
|
if [[ ! -f $TEMP/$listFile ]]; then
|
||||||
echo "{ \"${server}\": \"${username}\" }" > $TEMP/$listFile
|
echo "{ \"${server}\": \"${username}\" }" > $TEMP/$listFile
|
||||||
else
|
else
|
||||||
list=$(<$TEMP/$listFile)
|
list=$(< $TEMP/$listFile)
|
||||||
echo "$list" | jq ". + {\"${server}\": \"${username}\"}" > $TEMP/$listFile
|
echo "$list" | jq ". + {\"${server}\": \"${username}\"}" > $TEMP/$listFile
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"get")
|
"get")
|
||||||
in=$(</dev/stdin)
|
in=$(< /dev/stdin)
|
||||||
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
|
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
|
||||||
if [[ ! -f $TEMP/$serverHash ]]; then
|
if [[ ! -f $TEMP/$serverHash ]]; then
|
||||||
echo "credentials not found in native keychain"
|
echo "credentials not found in native keychain"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
payload=$(<$TEMP/$serverHash)
|
payload=$(< $TEMP/$serverHash)
|
||||||
echo "$payload"
|
echo "$payload"
|
||||||
;;
|
;;
|
||||||
"erase")
|
"erase")
|
||||||
in=$(</dev/stdin)
|
in=$(< /dev/stdin)
|
||||||
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
|
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
|
||||||
rm -f $TEMP/$serverHash
|
rm -f $TEMP/$serverHash
|
||||||
|
|
||||||
# Remove the server from the list
|
# Remove the server from the list
|
||||||
list=$(<$TEMP/$listFile)
|
list=$(< $TEMP/$listFile)
|
||||||
echo "$list" | jq "del(.[\"${in}\"])" > $TEMP/$listFile
|
echo "$list" | jq "del(.[\"${in}\"])" > $TEMP/$listFile
|
||||||
;;
|
;;
|
||||||
"list")
|
"list")
|
||||||
if [[ ! -f $TEMP/$listFile ]]; then
|
if [[ ! -f $TEMP/$listFile ]]; then
|
||||||
echo "{}"
|
echo "{}"
|
||||||
else
|
else
|
||||||
payload=$(<$TEMP/$listFile)
|
payload=$(< $TEMP/$listFile)
|
||||||
echo "$payload"
|
echo "$payload"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue