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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
#!/usr/bin/env bash
#
# Copyright (C) 2017-2019 Alexey Kopytov <akopytov@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# Build packages for a specified architecture and upload them to packagecloud.io
# Expects the following environment variables to be defined:
#
# ARCH - architecture. 'aarch64', 'x86_64 and 'i386' are currently supported
# values. If not set, the script behaves as if it was sequentially
# called with 'x86_64' and 'i386' values
#
# OS/DIST - distribution specification for packpack. When empty (the default)
# use all disitributions available for ARCH
#
# PACKAGECLOUD_TOKEN - packagecloud.io API token
#
# PACKAGECLOUD_USER - packagecloud.io user name, defaults to 'akopytov'
#
# PACKAGECLOUD_REPO - packagecloud.io repository. The default is 'sysbench'
# for releases (i.e. if git HEAD corresponds to a tag),
# and 'sysbench-prereleases' otherwise.
#
# PACKAGECLOUD_EXTRA_ARGS - extra arguments to pass to the package_cloud
# utility. Empty by default. Can be used to pass the
# --skip-errors flag to ignore deploy errors.
#
# PACKPACK_REPO - packpack repository to use. Defaults to akopytov/packpack.
set -eu
PACKAGECLOUD_USER=${PACKAGECLOUD_USER:-"akopytov"}
PACKAGECLOUD_EXTRA_ARGS=${PACKAGECLOUD_EXTRA_ARGS:-}
PACKPACK_REPO=${PACKPACK_REPO:-akopytov/packpack}
distros_x86_64=(
"el 6 x86_64"
"el 7 x86_64"
"el 8 x86_64"
"fedora 29 x86_64"
"fedora 30 x86_64"
"fedora 31 x86_64"
"ubuntu xenial x86_64"
"ubuntu bionic x86_64"
"ubuntu eoan x86_64"
"ubuntu focal x86_64"
"debian jessie x86_64"
"debian stretch x86_64"
"debian buster x86_64"
)
distros_i386=(
"ubuntu xenial i386"
"ubuntu bionic i386"
"ubuntu eoan i386"
"debian jessie i386"
"debian stretch i386"
"debian buster i386"
)
distros_aarch64=(
"el 7 aarch64"
"fedora 29 aarch64"
"fedora 30 aarch64"
"fedora 31 aarch64"
"ubuntu bionic aarch64"
"ubuntu eoan aarch64"
"ubuntu focal aarch64"
"ubuntu xenial aarch64"
"debian jessie aarch64"
"debian stretch aarch64"
"debian buster aarch64"
)
main()
{
if [ ! -r configure.ac ]; then
echo "This script should be executed from the source root directory."
exit 1
fi
if [ -z "${PACKAGECLOUD_TOKEN+x}" ]; then
echo "This script expects PACKAGECLOUD_TOKEN to be defined."
exit 1
fi
if [ ! which package_cloud >/dev/null 2>&1 ]; then
echo "This script requires package_cloud. You can install it by running:"
echo " gem install package_cloud"
fi
if [ ! -d packpack ]; then
git clone https://github.com/${PACKPACK_REPO} packpack
fi
if [ -z "${PACKAGECLOUD_REPO+x}" ]; then
# Upload builds corresponding to release tags to the 'sysbench'
# repository, push other ones to 'sysbench-prereleases'
if ! git describe --long --always >/dev/null 2>&1 ; then
echo "Either run this script from a git repository, or specify "
echo "the packagecloud repository explicitly with PACKAGECLOUD_REPO"
exit 1
fi
local commits=$(git describe --long --always |
sed -n 's/^\([0-9\.]*\)-\([0-9]*\)-\([a-z0-9]*\)/\2/p')
if [ ${commits:-0} = 0 ]; then
export PACKAGECLOUD_REPO=sysbench
# Use short version numbers for release builds
export VERSION=$(git describe)
else
export PACKAGECLOUD_REPO=sysbench-prereleases
fi
fi
declare -a distros
OS=${OS:-}
DIST=${DIST:-}
if [ -n "${OS}" -a -n "${DIST}" ]; then
distros=( "${OS} ${DIST} ${ARCH:-x86_64}" )
elif [ -z "${ARCH+x}" ]; then
distros=("${distros_x86_64[@]}" "${distros_i386[@]}")
else
case "$ARCH" in
x86_64)
distros=( "${distros_x86_64[@]}" )
;;
i386)
distros=( "${distros_i386[@]}" )
;;
aarch64)
distros=( "${distros_aarch64[@]}" )
;;
*)
echo "Invalid ARCH value: $ARCH"
exit 1
;;
esac
fi
export PRODUCT=sysbench
export CHANGELOG_NAME=sysbench
export CHANGELOG_EMAIL=akopytov@gmail.com
for d in "${distros[@]}"; do
echo "*** Building package for $d ***"
local t=( $d )
export OS=${t[0]}
export DIST=${t[1]}
export ARCH=${t[2]}
# Replace "el" with "centos" for packpack, as there is no "el-*" docker
# images for some architectures
local PPOS=${OS/#el/centos}
OS="$PPOS" packpack/packpack
# To avoid name conflicts, deploy source packages only for
# "default", i.e. x86_64 architecture
if [ "${ARCH}" = "x86_64" ]; then
files="$(ls build/*.{rpm,deb,dsc} 2>/dev/null || :)"
else
files="$(ls build/*{[^c].rpm,.deb} 2>/dev/null || :)"
fi
if [ -z "$files" ]; then
echo "No package files to push"
exit 1
fi
echo "Pushing packages to ${PACKAGECLOUD_USER}/${PACKAGECLOUD_REPO}"
for f in $files ; do
echo $f
package_cloud push ${PACKAGECLOUD_EXTRA_ARGS} \
${PACKAGECLOUD_USER}/${PACKAGECLOUD_REPO}/${OS}/${DIST} \
$f
done
OS=${PPOS} packpack/packpack clean
done
}
main
|