github.com/shiroyuki/docker@v1.9.0/hack/make/release-rpm (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # This script creates the yum repos for the .rpm files generated by hack/make/build-rpm
     5  #
     6  # The following can then be used as a yum repo:
     7  # 	http://yum.dockerproject.org/repo/$release/$distro/$distro-version
     8  #
     9  # For example:
    10  # 	http://yum.dockerproject.org/repo/main/fedora/22
    11  # 	http://yum.dockerproject.org/repo/testing/centos/6
    12  # 	http://yum.dockerproject.org/repo/experimental/fedora/21
    13  # 	http://yum.dockerproject.org/repo/main/centos/7
    14  #
    15  # ... and so on and so forth for the builds created by hack/make/build-rpm
    16  
    17  : ${DOCKER_RELEASE_DIR:=$DEST}
    18  YUMDIR=$DOCKER_RELEASE_DIR/yum/repo
    19  : ${GPG_KEYID:=releasedocker}
    20  
    21  # manage the repos for each distribution separately
    22  distros=( fedora centos opensuse oraclelinux )
    23  
    24  # get the release
    25  release="main"
    26  
    27  if [[ "$VERSION" == *-rc* ]]; then
    28  	release="testing"
    29  fi
    30  
    31  if [ $DOCKER_EXPERIMENTAL ] || [[ "$VERSION" == *-dev ]] || [ -n "$(git status --porcelain)" ]; then
    32  	release="experimental"
    33  fi
    34  
    35  for distro in "${distros[@]}"; do
    36  	# Setup the yum repo
    37  	REPO=$YUMDIR/$release/$distro
    38  
    39  	for dir in contrib/builder/rpm/$distro-*/; do
    40  		version="$(basename "$dir")"
    41  		suite="${version##*-}"
    42  
    43  		# if the directory does not exist, initialize the yum repo
    44  		if [[ ! -d $REPO/$suite/Packages ]]; then
    45  			mkdir -p "$REPO/$suite/Packages"
    46  
    47  			createrepo --pretty "$REPO/$suite"
    48  		fi
    49  
    50  		# path to rpms
    51  		RPMFILE=( "bundles/$VERSION/build-rpm/$version/RPMS/"*"/docker-engine"*.rpm "bundles/$VERSION/build-rpm/$version/SRPMS/docker-engine"*.rpm )
    52  
    53  		# if we have a $GPG_PASSPHRASE we may as well
    54  		# sign the rpms before adding to repo
    55  		if [ ! -z $GPG_PASSPHRASE ]; then
    56  			# export our key to rpm import
    57  			gpg --armor --export "$GPG_KEYID" > /tmp/gpg
    58  			rpm --import /tmp/gpg
    59  
    60  			# sign the rpms
    61  			echo "yes" | setsid rpm \
    62  				--define "_gpg_name $GPG_KEYID" \
    63  				--define "_signature gpg" \
    64  				--define "__gpg_check_password_cmd /bin/true" \
    65  				--define "__gpg_sign_cmd %{__gpg} gpg --batch --no-armor --passphrase '$GPG_PASSPHRASE' --no-secmem-warning -u '%{_gpg_name}' --sign --detach-sign --output %{__signature_filename} %{__plaintext_filename}" \
    66  				--resign "${RPMFILE[@]}"
    67  		fi
    68  
    69  		# copy the rpms to the packages folder
    70  		cp "${RPMFILE[@]}" "$REPO/$suite/Packages"
    71  
    72  		# update the repo
    73  		createrepo --pretty --update "$REPO/$suite"
    74  	done
    75  done