2015-06-02 00:21:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script signs the deliverables from release-deb and release-rpm
|
|
|
|
# with a designated GPG key.
|
|
|
|
|
|
|
|
: ${DOCKER_RELEASE_DIR:=$DEST}
|
2015-08-25 19:27:25 +00:00
|
|
|
: ${GPG_KEYID:=releasedocker}
|
2015-06-02 00:21:09 +00:00
|
|
|
APTDIR=$DOCKER_RELEASE_DIR/apt/repo
|
|
|
|
YUMDIR=$DOCKER_RELEASE_DIR/yum/repo
|
|
|
|
|
|
|
|
if [ -z "$GPG_PASSPHRASE" ]; then
|
|
|
|
echo >&2 'you need to set GPG_PASSPHRASE in order to sign artifacts'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $APTDIR ] && [ ! -d $YUMDIR ]; then
|
|
|
|
echo >&2 'release-rpm or release-deb must be run before sign-repos'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
sign_packages(){
|
|
|
|
# sign apt repo metadata
|
|
|
|
if [ -d $APTDIR ]; then
|
|
|
|
# create file with public key
|
2015-08-25 19:27:25 +00:00
|
|
|
gpg --armor --export "$GPG_KEYID" > "$DOCKER_RELEASE_DIR/apt/gpg"
|
2015-06-02 00:21:09 +00:00
|
|
|
|
|
|
|
# sign the repo metadata
|
|
|
|
for F in $(find $APTDIR -name Release); do
|
2015-08-04 19:57:52 +00:00
|
|
|
if test "$F" -nt "$F.gpg" ; then
|
2015-08-25 19:27:25 +00:00
|
|
|
gpg -u "$GPG_KEYID" --passphrase "$GPG_PASSPHRASE" \
|
2015-08-04 19:57:52 +00:00
|
|
|
--armor --sign --detach-sign \
|
|
|
|
--batch --yes \
|
|
|
|
--output "$F.gpg" "$F"
|
|
|
|
fi
|
2015-06-02 00:21:09 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# sign yum repo metadata
|
|
|
|
if [ -d $YUMDIR ]; then
|
|
|
|
# create file with public key
|
2015-08-25 19:27:25 +00:00
|
|
|
gpg --armor --export "$GPG_KEYID" > "$DOCKER_RELEASE_DIR/yum/gpg"
|
2015-06-02 00:21:09 +00:00
|
|
|
|
|
|
|
# sign the repo metadata
|
2015-08-04 19:57:52 +00:00
|
|
|
for F in $(find $YUMDIR -name repomd.xml); do
|
|
|
|
if test "$F" -nt "$F.asc" ; then
|
2015-08-25 19:27:25 +00:00
|
|
|
gpg -u "$GPG_KEYID" --passphrase "$GPG_PASSPHRASE" \
|
2015-08-04 19:57:52 +00:00
|
|
|
--armor --sign --detach-sign \
|
|
|
|
--batch --yes \
|
|
|
|
--output "$F.asc" "$F"
|
|
|
|
fi
|
2015-06-02 00:21:09 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
sign_packages
|