Browse code

Create a bundle for the install script to support other domains

For the CS Engine we need to have an install script like OSS does, but
the locations are all different, as is the GPG key used. This is
accomplished here by slightly altering the script itself and adding a
simple 'sed' based bundle for make.sh.

This install script is used in to change the URLs instead of sed in
release.sh.

Signed-off-by: Mike Dougherty <mike.dougherty@docker.com>

Mike Dougherty authored on 2016/01/07 07:25:39
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
... ...
@@ -161,11 +164,13 @@ do_install() {
161 161
 	fi
162 162
 
163 163
 	# check to see which repo they are trying to install from
164
-	repo='main'
165
-	if [ "https://test.docker.com/" = "$url" ]; then
166
-		repo='testing'
167
-	elif [ "https://experimental.docker.com/" = "$url" ]; then
168
-		repo='experimental'
164
+	if [ -z "$repo" ]; then
165
+		repo='main'
166
+		if [ "https://test.docker.com/" = "$url" ]; then
167
+			repo='testing'
168
+		elif [ "https://experimental.docker.com/" = "$url" ]; then
169
+			repo='experimental'
170
+		fi
169 171
 	fi
170 172
 
171 173
 	# perform some very rudimentary platform detection
... ...
@@ -370,9 +375,9 @@ do_install() {
370 370
 			fi
371 371
 			(
372 372
 			set -x
373
-			$sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D"
373
+			$sh_c "apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys ${gpg_fingerprint}"
374 374
 			$sh_c "mkdir -p /etc/apt/sources.list.d"
375
-			$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"
375
+			$sh_c "echo deb [arch=$(dpkg --print-architecture)] ${apt_url}/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list"
376 376
 			$sh_c 'sleep 3; apt-get update; apt-get install -y -q docker-engine'
377 377
 			)
378 378
 			echo_docker_as_nonroot
... ...
@@ -383,10 +388,10 @@ do_install() {
383 383
 			$sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
384 384
 			[docker-${repo}-repo]
385 385
 			name=Docker ${repo} Repository
386
-			baseurl=https://yum.dockerproject.org/repo/${repo}/${lsb_dist}/${dist_version}
386
+			baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version}
387 387
 			enabled=1
388 388
 			gpgcheck=1
389
-			gpgkey=https://yum.dockerproject.org/gpg
389
+			gpgkey=${yum_url}/gpg
390 390
 			EOF
391 391
 			if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "22" ]; then
392 392
 				(
393 393
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() {