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:
Akihiro Suda 2020-03-03 12:27:49 +09:00
parent eb484fcb67
commit 3cf82748dd
50 changed files with 513 additions and 441 deletions

View file

@ -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 || {
@ -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,7 +200,7 @@ 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
@ -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
@ -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

View file

@ -22,7 +22,7 @@ errexit() {
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
@ -41,12 +41,13 @@ bundle_files(){
fi fi
} }
control_docker(){ control_docker() {
m=$1; op=$2 m=$1
op=$2
# NOTE: `docker-machine ssh $m sh -c "foo bar"` does not work # NOTE: `docker-machine ssh $m sh -c "foo bar"` does not work
# (but `docker-machine ssh $m sh -c "foo\ bar"` works) # (but `docker-machine ssh $m sh -c "foo\ bar"` works)
# Anyway we avoid using `sh -c` here for avoiding confusion # Anyway we avoid using `sh -c` here for avoiding confusion
cat <<EOF | docker-machine ssh $m sudo sh 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,14 +61,16 @@ 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
shift
files=$@
echo "$m: detecting docker" echo "$m: detecting docker"
prefix=$(detect_prefix $m) prefix=$(detect_prefix $m)
echo "$m: detected docker on $prefix" echo "$m: detected docker on $prefix"
@ -82,14 +85,15 @@ install_to(){
echo "$m: done" 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
machines=$@
check_prereq check_prereq
files=$(bundle_files) files=$(bundle_files)
echo "Files to be installed:" echo "Files to be installed:"
@ -101,7 +105,10 @@ case "$1" in
done done
status=0 status=0
for pid in ${pids[@]}; do for pid in ${pids[@]}; do
wait $pid || { status=$?; echo "background process $pid failed with exit status $status"; } wait $pid || {
status=$?
echo "background process $pid failed with exit status $status"
}
done done
exit $status exit $status
;; ;;

View file

@ -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"

View file

@ -78,7 +78,7 @@ 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)
@ -96,10 +96,10 @@ 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

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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
@ -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

View file

@ -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 $?

View file

@ -20,12 +20,12 @@ 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"
@ -33,8 +33,8 @@ case "$1" in
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"

View file

@ -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() {

View file

@ -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
} }
@ -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

View file

@ -5,7 +5,7 @@
set -e set -e
die () { die() {
echo >&2 "$@" echo >&2 "$@"
exit 1 exit 1
} }

View file

@ -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.
@ -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,8 +127,7 @@ 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

View file

@ -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,8 +56,7 @@ 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
@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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"/*
)

View file

@ -16,31 +16,31 @@ 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.):
@ -68,7 +68,7 @@ function template() {
} }
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}"

View file

@ -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.

View file

@ -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
} }

View file

@ -6,7 +6,7 @@ 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

View file

@ -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" "$@"
} }

View file

@ -38,9 +38,9 @@ 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 case "$(go env GOOS)/$(go env GOARCH)" in
windows/amd64) windows/amd64)
@ -49,7 +49,7 @@ if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARC
;; ;;
linux/arm) linux/arm)
case "${GOARM}" in case "${GOARM}" in
5|"") 5 | "")
export CC="${CC:-arm-linux-gnueabi-gcc}" export CC="${CC:-arm-linux-gnueabi-gcc}"
export CGO_ENABLED=1 export CGO_ENABLED=1
;; ;;
@ -68,20 +68,20 @@ if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARC
export CGO_ENABLED=1 export CGO_ENABLED=1
;; ;;
esac esac
fi fi
# -buildmode=pie is not supported on Windows and Linux on mips.
case "$(go env GOOS)/$(go env GOARCH)" in
windows/* | linux/mips*) ;;
# -buildmode=pie is not supported on Windows and Linux on mips.
case "$(go env GOOS)/$(go env GOARCH)" in
windows/*|linux/mips*)
;;
*) *)
BUILDFLAGS+=( "-buildmode=pie" ) BUILDFLAGS+=("-buildmode=pie")
;; ;;
esac esac
echo "Building: $DEST/$BINARY_FULLNAME" echo "Building: $DEST/$BINARY_FULLNAME"
echo "GOOS=\"${GOOS}\" GOARCH=\"${GOARCH}\" GOARM=\"${GOARM}\"" echo "GOOS=\"${GOOS}\" GOARCH=\"${GOARCH}\" GOARM=\"${GOARM}\""
go build \ go build \
-o "$DEST/$BINARY_FULLNAME" \ -o "$DEST/$BINARY_FULLNAME" \
"${BUILDFLAGS[@]}" \ "${BUILDFLAGS[@]}" \
-ldflags " -ldflags "

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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"
@ -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
} }

View file

@ -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"

View file

@ -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"
) )

View file

@ -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"

View file

@ -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}"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
;; ;;