Browse code

Merge pull request #19146 from mikedougherty/cs-105-download-script

Create a bundle for the install script to support other domains

Jess Frazelle authored on 2016/01/23 02:25:24
Showing 3 changed files
... ...
@@ -23,7 +23,10 @@ set -e
23 23
 #     s3cmd put --acl-public -P hack/install.sh s3://get.docker.com/index
24 24
 #
25 25
 
26
-url='https://get.docker.com/'
26
+url="https://get.docker.com/"
27
+apt_url="https://apt.dockerproject.org"
28
+yum_url="https://yum.dockerproject.org"
29
+gpg_fingerprint="58118E89F3A912897C070ADBF76221572C52609D"
27 30
 
28 31
 command_exists() {
29 32
 	command -v "$@" > /dev/null 2>&1
... ...
@@ -200,11 +203,13 @@ do_install() {
200 200
 	fi
201 201
 
202 202
 	# check to see which repo they are trying to install from
203
-	repo='main'
204
-	if [ "https://test.docker.com/" = "$url" ]; then
205
-		repo='testing'
206
-	elif [ "https://experimental.docker.com/" = "$url" ]; then
207
-		repo='experimental'
203
+	if [ -z "$repo" ]; then
204
+		repo='main'
205
+		if [ "https://test.docker.com/" = "$url" ]; then
206
+			repo='testing'
207
+		elif [ "https://experimental.docker.com/" = "$url" ]; then
208
+			repo='experimental'
209
+		fi
208 210
 	fi
209 211
 
210 212
 	# perform some very rudimentary platform detection
... ...
@@ -409,9 +414,9 @@ do_install() {
409 409
 			fi
410 410
 			(
411 411
 			set -x
412
-			$sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D"
412
+			$sh_c "apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys ${gpg_fingerprint}"
413 413
 			$sh_c "mkdir -p /etc/apt/sources.list.d"
414
-			$sh_c "echo deb [arch=$(dpkg --print-architecture)] https://apt.dockerproject.org/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list"
414
+			$sh_c "echo deb [arch=$(dpkg --print-architecture)] ${apt_url}/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list"
415 415
 			$sh_c 'sleep 3; apt-get update; apt-get install -y -q docker-engine'
416 416
 			)
417 417
 			echo_docker_as_nonroot
... ...
@@ -422,10 +427,10 @@ do_install() {
422 422
 			$sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
423 423
 			[docker-${repo}-repo]
424 424
 			name=Docker ${repo} Repository
425
-			baseurl=https://yum.dockerproject.org/repo/${repo}/${lsb_dist}/${dist_version}
425
+			baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version}
426 426
 			enabled=1
427 427
 			gpgcheck=1
428
-			gpgkey=https://yum.dockerproject.org/gpg
428
+			gpgkey=${yum_url}/gpg
429 429
 			EOF
430 430
 			if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "22" ]; then
431 431
 				(
432 432
new file mode 100644
... ...
@@ -0,0 +1,63 @@
0
+#!/bin/bash
1
+set -e
2
+
3
+# This script modifies the install.sh script for domains and keys other than
4
+# those used by the primary opensource releases.
5
+#
6
+# You can provide `url`, `yum_url`, `apt_url` and optionally `gpg_fingerprint`
7
+# or `GPG_KEYID` as environment variables, or the defaults for open source are used.
8
+#
9
+# The lower-case variables are substituted into install.sh.
10
+#
11
+# gpg_fingerprint and GPG_KEYID are optional, defaulting to the opensource release
12
+# key ("releasedocker"). Other GPG_KEYIDs will require you to mount a volume with
13
+# the correct contents to /root/.gnupg.
14
+#
15
+# It outputs the modified `install.sh` file to $DOCKER_RELEASE_DIR (default: $DEST)
16
+#
17
+# Example usage:
18
+#
19
+# docker run \
20
+# --rm \
21
+# --privileged \
22
+# -e "GPG_KEYID=deadbeef" \
23
+# -e "GNUPGHOME=/root/.gnupg" \
24
+# -v $HOME/.gnupg:/root/.gnupg \
25
+# -v $(pwd):/go/src/github.com/docker/docker/bundles \
26
+# "$IMAGE_DOCKER" \
27
+# hack/make.sh install-script
28
+
29
+: ${DOCKER_RELEASE_DIR:=$DEST}
30
+: ${GPG_KEYID:=releasedocker}
31
+
32
+DEFAULT_URL="https://get.docker.com/"
33
+DEFAULT_APT_URL="https://apt.dockerproject.org"
34
+DEFAULT_YUM_URL="https://yum.dockerproject.org"
35
+DEFAULT_GPG_FINGERPRINT="58118E89F3A912897C070ADBF76221572C52609D"
36
+
37
+: ${url:=$DEFAULT_URL}
38
+: ${apt_url:=$DEFAULT_APT_URL}
39
+: ${yum_url:=$DEFAULT_YUM_URL}
40
+if [[ "$GPG_KEYID" == "releasedocker" ]] ; then
41
+	: ${gpg_fingerprint:=$DEFAULT_GPG_FINGERPRINT}
42
+fi
43
+
44
+DEST_FILE="$DOCKER_RELEASE_DIR/install.sh"
45
+
46
+bundle_install_script() {
47
+	mkdir -p "$DOCKER_RELEASE_DIR"
48
+
49
+	if [[ -z "$gpg_fingerprint" ]] ; then
50
+		# NOTE: if no key matching key is in /root/.gnupg, this will fail
51
+		gpg_fingerprint=$(gpg --with-fingerprint -k "$GPG_KEYID" | grep "Key fingerprint" | awk -F "=" '{print $2};' | tr -d ' ')
52
+	fi
53
+
54
+	cp hack/install.sh "$DEST_FILE"
55
+	sed -i.bak 's#^url=".*"$#url="'"$url"'"#' "$DEST_FILE"
56
+	sed -i.bak 's#^apt_url=".*"$#apt_url="'"$apt_url"'"#' "$DEST_FILE"
57
+	sed -i.bak 's#^yum_url=".*"$#yum_url="'"$yum_url"'"#' "$DEST_FILE"
58
+	sed -i.bak 's#^gpg_fingerprint=".*"$#gpg_fingerprint="'"$gpg_fingerprint"'"#' "$DEST_FILE"
59
+	rm "${DEST_FILE}.bak"
60
+}
61
+
62
+bundle_install_script
... ...
@@ -289,7 +289,8 @@ EOF
289 289
 # Upload the index script
290 290
 release_index() {
291 291
 	echo "Releasing index"
292
-	sed "s,url='https://get.docker.com/',url='$(s3_url)/'," hack/install.sh | write_to_s3 "s3://$BUCKET_PATH/index"
292
+	url="$(s3_url)" hack/make.sh install-script
293
+	write_to_s3 "s3://$BUCKET_PATH/index" < "bundles/$VERSION/install-script/install.sh"
293 294
 }
294 295
 
295 296
 release_test() {