This repository has been archived by the owner on Jan 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathupdate.sh
executable file
·103 lines (90 loc) · 2.42 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
set -eo pipefail
cd "$(readlink -f "$(dirname "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
get_part() {
dir="$1"
shift
part="$1"
shift
if [ -f "$dir/$part" ]; then
cat "$dir/$part"
return 0
fi
if [ -f "$part" ]; then
cat "$part"
return 0
fi
if [ $# -gt 0 ]; then
echo "$1"
return 0
fi
return 1
}
repo="$(get_part . repo '')"
if [ "$repo" ]; then
if [[ "$repo" != */* ]]; then
user="$(docker info | awk '/^Username:/ { print $2 }')"
if [ "$user" ]; then
repo="$user/$repo"
fi
fi
fi
for version in "${versions[@]}"; do
dir="$(readlink -f "$version")"
variant="$(get_part "$dir" variant 'minbase')"
components="$(get_part "$dir" components 'main')"
include="$(get_part "$dir" include '')"
suite="$(get_part "$dir" suite "$version")"
mirror="$(get_part "$dir" mirror '')"
script="$(get_part "$dir" script '')"
args=( -d "$dir" debootstrap )
[ -z "$variant" ] || args+=( --variant="$variant" )
[ -z "$components" ] || args+=( --components="$components" )
[ -z "$include" ] || args+=( --include="$include" )
debootstrapVersion="$(debootstrap --version)"
debootstrapVersion="${debootstrapVersion##* }"
if dpkg --compare-versions "$debootstrapVersion" '>=' '1.0.69'; then
args+=( --force-check-gpg )
fi
args+=( "$suite" )
if [ "$mirror" ]; then
args+=( "$mirror" )
if [ "$script" ]; then
args+=( "$script" )
fi
fi
mkimage="$(readlink -f "${MKIMAGE:-"mkimage.sh"}")"
{
echo "$(basename "$mkimage") ${args[*]/"$dir"/.}"
echo
echo 'https://github.com/docker/docker/blob/master/contrib/mkimage.sh'
} > "$dir/build-command.txt"
sudo nice ionice -c 3 "$mkimage" "${args[@]}" 2>&1 | tee "$dir/build.log"
sudo chown -R "$(id -u):$(id -g)" "$dir"
if [ "$repo" ]; then
( set -x && docker build -t "${repo}:${suite}" "$dir" )
if [ "$suite" != "$version" ]; then
( set -x && docker tag -f "${repo}:${suite}" "${repo}:${version}" )
fi
docker run -it --rm "${repo}:${suite}" bash -xc '
cat /etc/apt/sources.list
echo
cat /etc/os-release 2>/dev/null
echo
cat /etc/lsb-release 2>/dev/null
echo
cat /etc/debian_version 2>/dev/null
true
'
docker run --rm "${repo}:${suite}" dpkg-query -f '${Package}\t${Version}\n' -W > "$dir/build.manifest"
fi
done
latest="$(get_part . latest '')"
if [ "$latest" ]; then
( set -x && docker tag -f "${repo}:${latest}" "${repo}:latest" )
fi