github.com/duglin/docker@v1.13.1/hack/make/install-script (about)

     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