Skip to content

Commit 51dad11

Browse files
committed
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>
1 parent 18fdbdb commit 51dad11

File tree

3 files changed

+80
-11
lines changed

3 files changed

+80
-11
lines changed

hack/install.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ set -e
2323
# s3cmd put --acl-public -P hack/install.sh s3://get.docker.com/index
2424
#
2525

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

2831
command_exists() {
2932
command -v "$@" > /dev/null 2>&1
@@ -161,11 +164,13 @@ do_install() {
161164
fi
162165

163166
# 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'
167+
if [ -z "$repo" ]; then
168+
repo='main'
169+
if [ "https://test.docker.com/" = "$url" ]; then
170+
repo='testing'
171+
elif [ "https://experimental.docker.com/" = "$url" ]; then
172+
repo='experimental'
173+
fi
169174
fi
170175

171176
# perform some very rudimentary platform detection
@@ -370,9 +375,9 @@ do_install() {
370375
fi
371376
(
372377
set -x
373-
$sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D"
378+
$sh_c "apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys ${gpg_fingerprint}"
374379
$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"
380+
$sh_c "echo deb [arch=$(dpkg --print-architecture)] ${apt_url}/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list"
376381
$sh_c 'sleep 3; apt-get update; apt-get install -y -q docker-engine'
377382
)
378383
echo_docker_as_nonroot
@@ -383,10 +388,10 @@ do_install() {
383388
$sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
384389
[docker-${repo}-repo]
385390
name=Docker ${repo} Repository
386-
baseurl=https://yum.dockerproject.org/repo/${repo}/${lsb_dist}/${dist_version}
391+
baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version}
387392
enabled=1
388393
gpgcheck=1
389-
gpgkey=https://yum.dockerproject.org/gpg
394+
gpgkey=${yum_url}/gpg
390395
EOF
391396
if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "22" ]; then
392397
(

hack/make/install-script

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# This script modifies the install.sh script for domains and keys other than
5+
# those used by the primary opensource releases.
6+
#
7+
# You can provide `url`, `yum_url`, `apt_url` and optionally `gpg_fingerprint`
8+
# or `GPG_KEYID` as environment variables, or the defaults for open source are used.
9+
#
10+
# The lower-case variables are substituted into install.sh.
11+
#
12+
# gpg_fingerprint and GPG_KEYID are optional, defaulting to the opensource release
13+
# key ("releasedocker"). Other GPG_KEYIDs will require you to mount a volume with
14+
# the correct contents to /root/.gnupg.
15+
#
16+
# It outputs the modified `install.sh` file to $DOCKER_RELEASE_DIR (default: $DEST)
17+
#
18+
# Example usage:
19+
#
20+
# docker run \
21+
# --rm \
22+
# --privileged \
23+
# -e "GPG_KEYID=deadbeef" \
24+
# -e "GNUPGHOME=/root/.gnupg" \
25+
# -v $HOME/.gnupg:/root/.gnupg \
26+
# -v $(pwd):/go/src/github.com/docker/docker/bundles \
27+
# "$IMAGE_DOCKER" \
28+
# hack/make.sh install-script
29+
30+
: ${DOCKER_RELEASE_DIR:=$DEST}
31+
: ${GPG_KEYID:=releasedocker}
32+
33+
DEFAULT_URL="https://get.docker.com/"
34+
DEFAULT_APT_URL="https://apt.dockerproject.org"
35+
DEFAULT_YUM_URL="https://yum.dockerproject.org"
36+
DEFAULT_GPG_FINGERPRINT="58118E89F3A912897C070ADBF76221572C52609D"
37+
38+
: ${url:=$DEFAULT_URL}
39+
: ${apt_url:=$DEFAULT_APT_URL}
40+
: ${yum_url:=$DEFAULT_YUM_URL}
41+
if [[ "$GPG_KEYID" == "releasedocker" ]] ; then
42+
: ${gpg_fingerprint:=$DEFAULT_GPG_FINGERPRINT}
43+
fi
44+
45+
DEST_FILE="$DOCKER_RELEASE_DIR/install.sh"
46+
47+
bundle_install_script() {
48+
mkdir -p "$DOCKER_RELEASE_DIR"
49+
50+
if [[ -z "$gpg_fingerprint" ]] ; then
51+
# NOTE: if no key matching key is in /root/.gnupg, this will fail
52+
gpg_fingerprint=$(gpg --with-fingerprint -k "$GPG_KEYID" | grep "Key fingerprint" | awk -F "=" '{print $2};' | tr -d ' ')
53+
fi
54+
55+
cp hack/install.sh "$DEST_FILE"
56+
sed -i.bak 's#^url=".*"$#url="'"$url"'"#' "$DEST_FILE"
57+
sed -i.bak 's#^apt_url=".*"$#apt_url="'"$apt_url"'"#' "$DEST_FILE"
58+
sed -i.bak 's#^yum_url=".*"$#yum_url="'"$yum_url"'"#' "$DEST_FILE"
59+
sed -i.bak 's#^gpg_fingerprint=".*"$#gpg_fingerprint="'"$gpg_fingerprint"'"#' "$DEST_FILE"
60+
rm "${DEST_FILE}.bak"
61+
}
62+
63+
bundle_install_script

hack/release.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ EOF
289289
# Upload the index script
290290
release_index() {
291291
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"
293294
}
294295

295296
release_test() {

0 commit comments

Comments
 (0)