1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
#!/bin/sh
#
# Automate package uploading to bintray.com.
#
# Run in the top-level of a tree, ensuring .bintrayrc is available with
# valid user setting (username, email, apikey, distro, gpgphrase).
sudo=`which sudo` # can be cleared via .bintrayrc
topdir=`pwd`
quit()
{
echo $*
exit 1
}
[ -e "${topdir}/VERSION.pcp" ] || quit "Not a PCP git tree, missing VERSION.pcp"
[ -e "${topdir}/.bintrayrc" ] || quit "Tree is unconfigured, missing .bintrayrc"
. ${topdir}/.bintrayrc
. ${topdir}/VERSION.pcp
version=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION}
buildversion=${version}-${PACKAGE_BUILD}
[ -z "${user}" ] && quit "user is not configured (via .bintrayrc)"
[ -z "${email}" ] && quit "email is not configured (via .bintrayrc)"
[ -z "${apikey}" ] && quit "apikey is not configured (via .bintrayrc)"
[ -z "${gpgpass}" ] && quit "passphrase is not configured (via .bintrayrc)"
pkg_upload()
{
distro="$1"; file="$2"; vers="$3"
url="https://api.bintray.com/content/pcp/${distro}/${file}"
echo "Uploading ${file} to:" && echo " ${url}"
curl \
-T ${file} -u ${user}:${apikey} \
-H "X-GPG-PASSPHRASE: ${gpgpass}" \
-H "X-Bintray-Publish: 1" \
"${url};bt_package=pcp;bt_version=${vers};publish=1"
echo
}
deb_upload()
{
distro="$1"; file="$2"; vers="$3"; arch="$4"
deb="deb_distribution=${distro};deb_component=main;deb_architecture=${arch}"
url="https://api.bintray.com/content/pcp/${distro}/${file}"
echo "Uploading ${file} to:" && echo " ${url}"
curl \
-T ${file} -u ${user}:${apikey} \
-H "X-GPG-PASSPHRASE: ${gpgpass}" \
-H "X-Bintray-Debian-Distribution: ${distro}" \
-H "X-Bintray-Debian-Component: main" \
-H "X-Bintray-Publish: 1" \
"${url};${deb};bt_package=pcp;bt_version=${vers};publish=1"
echo
}
sign_repository()
{
repo="$1"; vers="$2"
url="https://api.bintray.com/gpg/pcp/${repo}/pcp/versions/${vers}"
echo "Signing version ${repo}/${version} via:" && echo " ${url}"
curl -X POST -H "X-GPG-PASSPHRASE: ${gpgpass}" -u ${user}:${apikey} \
"${url};bt_package=pcp;bt_version=${vers};publish=1"
url="https://api.bintray.com/calc_metadata/pcp/${repo}"
echo "Signing repository ${repo} via:" && echo " ${url}"
curl -X POST -H "X-GPG-PASSPHRASE: ${gpgpass}" -u ${user}:${apikey} "${url}"
}
container_upload()
{
path="$1"; file="$2"; vers="$3"
docker login -u ${user} -p ${apikey} -e ${email} pcp-docker-pcp.bintray.io
$sudo docker tag ${path} \
pcp-docker-pcp.bintray.io/${path}:${vers}
docker push pcp-docker-pcp.bintray.io/${path}:${vers}
}
verify_asset()
{
file="$1"; prev="$2"
test -f "${file}" || return 1
# batch mode - if we said yes already, say yes again
test "X${prev}" = "Xyes" && return 0
echo -n "Found ${file}, upload? (y/N) "
read yesno
test "X${yesno}" = "Xy" -o "X${yesno}" = "XY" && return 0
return 1
}
# Source
cd ${topdir}/build/tar 2>/dev/null && \
verify_asset pcp-${version}.src.tar.gz && \
pkg_upload source pcp-${version}.src.tar.gz ${version}
# Mac OS X
cd ${topdir}/pcp-${version}/build/mac 2>/dev/null && \
verify_asset pcp-${buildversion}.dmg && \
pkg_upload macosx pcp-${buildversion}.dmg ${version}
# Windows
cd ${topdir}/pcp-${version}/build/win 2>/dev/null && \
verify_asset pcp-${buildversion}.msi && \
pkg_upload windows pcp-${buildversion}.msi ${version}
# Solaris
cd ${topdir}/pcp-${version}/build/sun 2>/dev/null && \
verify_asset pcp-${version} && \
pkg_upload solaris11 pcp-${version} ${version}
# Docker images
if cd ${topdir}/pcp-${version}/build/containers 2>/dev/null
then
previous=no
for image in *
do
[ -d ${image} ] || continue
cd ${topdir}/pcp-${version}/build/containers/${image}
verify_asset ${image}.tgz ${previous} && \
previous=yes && \
container_upload ${image} ${image}.tgz ${version}
done
fi
# RPM packages
if cd ${topdir}/pcp-${version}/build/rpm 2>/dev/null
then
# $distro is something like "el7"
[ -z "${distro}" ] && quit "distro is not configured (via .bintrayrc)"
previous=no
srcrpm=`echo *.src.rpm`
for rpm in *.rpm
do
[ "${rpm}" = "${srcrpm}" ] && continue
verify_asset ${rpm} ${previous} && \
previous=yes && \
pkg_upload ${distro} ${rpm} ${version}
done
[ $previous = yes ] && sign_repository ${distro} ${version}
fi
# DEB packages
if cd ${topdir}/build/deb 2>/dev/null
then
# $distro is something like "wheezy", $arch is like "amd64" or "i386"
[ -z "${distro}" ] && quit "distro is not configured (via .bintrayrc)"
[ -z "${arch}" ] && quit "arch is not configured (via .bintrayrc)"
previous=no
for deb in *.deb *.tar.gz
do
verify_asset ${deb} ${previous} && \
previous=yes && \
deb_upload ${distro} ${deb} ${version} ${arch}
done
[ $previous = yes ] && sign_repository ${distro} ${version}
fi
|