2015-06-29 18:29:50 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-01-22 01:48:15 +00:00
|
|
|
|
2015-01-22 22:56:11 +00:00
|
|
|
###########################################################################
|
|
|
|
# Packaging script which creates debian and RPM packages. It optionally
|
2015-01-28 17:51:54 +00:00
|
|
|
# tags the repo with the given version.
|
|
|
|
#
|
2015-01-28 20:19:00 +00:00
|
|
|
# Requirements: GOPATH must be set. 'fpm' must be on the path, and the AWS
|
|
|
|
# CLI tools must also be installed.
|
|
|
|
#
|
|
|
|
# https://github.com/jordansissel/fpm
|
|
|
|
# http://aws.amazon.com/cli/
|
|
|
|
#
|
|
|
|
# Packaging process: to package a build, simple execute:
|
|
|
|
#
|
|
|
|
# package.sh <version>
|
|
|
|
#
|
|
|
|
# where <version> is the desired version. If generation of a debian and RPM
|
|
|
|
# package is successful, the script will offer to tag the repo using the
|
|
|
|
# supplied version string.
|
|
|
|
#
|
2015-08-31 21:47:42 +00:00
|
|
|
# See package.sh -h for options
|
|
|
|
#
|
2015-01-28 20:19:00 +00:00
|
|
|
# AWS upload: the script will also offer to upload the packages to S3. If
|
|
|
|
# this option is selected, the credentials should be present in the file
|
|
|
|
# ~/aws.conf. The contents should be of the form:
|
|
|
|
#
|
|
|
|
# [default]
|
|
|
|
# aws_access_key_id=<access ID>
|
|
|
|
# aws_secret_access_key=<secret key>
|
|
|
|
# region = us-east-1
|
|
|
|
#
|
|
|
|
# Trim the leading spaces when creating the file. The script will exit if
|
|
|
|
# S3 upload is requested, but this file does not exist.
|
2015-01-22 22:56:11 +00:00
|
|
|
|
2015-06-26 13:33:59 +00:00
|
|
|
[ -z $DEBUG ] || set -x
|
|
|
|
|
2015-01-28 17:43:19 +00:00
|
|
|
AWS_FILE=~/aws.conf
|
2015-01-22 23:31:49 +00:00
|
|
|
|
2015-11-06 16:52:04 +00:00
|
|
|
INSTALL_ROOT_DIR=/usr/bin
|
2015-01-29 22:28:53 +00:00
|
|
|
INFLUXDB_LOG_DIR=/var/log/influxdb
|
2015-11-06 16:52:04 +00:00
|
|
|
INFLUXDB_DATA_DIR=/var/lib/influxdb
|
|
|
|
INFLUXDB_SCRIPT_DIR=/usr/lib/influxdb
|
|
|
|
CONFIG_ROOT_DIR=/etc/influxdb
|
2015-09-08 15:51:00 +00:00
|
|
|
LOGROTATE_DIR=/etc/logrotate.d
|
2015-01-22 01:48:15 +00:00
|
|
|
|
|
|
|
SAMPLE_CONFIGURATION=etc/config.sample.toml
|
2015-01-22 22:39:11 +00:00
|
|
|
INITD_SCRIPT=scripts/init.sh
|
2015-09-09 00:14:03 +00:00
|
|
|
SYSTEMD_SCRIPT=scripts/influxdb.service
|
2015-11-12 19:03:41 +00:00
|
|
|
POSTINSTALL_SCRIPT=scripts/post-install.sh
|
|
|
|
PREINSTALL_SCRIPT=scripts/pre-install.sh
|
|
|
|
POSTUNINSTALL_SCRIPT=scripts/post-uninstall.sh
|
2015-09-08 15:51:00 +00:00
|
|
|
LOGROTATE=scripts/logrotate
|
2015-01-22 01:48:15 +00:00
|
|
|
|
|
|
|
TMP_WORK_DIR=`mktemp -d`
|
|
|
|
POST_INSTALL_PATH=`mktemp`
|
2015-09-17 21:00:10 +00:00
|
|
|
POST_UNINSTALL_PATH=`mktemp`
|
2015-01-22 01:48:15 +00:00
|
|
|
ARCH=`uname -i`
|
2015-01-25 20:13:43 +00:00
|
|
|
LICENSE=MIT
|
|
|
|
URL=influxdb.com
|
|
|
|
MAINTAINER=support@influxdb.com
|
|
|
|
VENDOR=Influxdb
|
2015-10-05 20:51:04 +00:00
|
|
|
DESCRIPTION="Distributed time-series database"
|
2015-05-22 00:49:36 +00:00
|
|
|
|
2015-06-30 14:13:24 +00:00
|
|
|
# Allow path to FPM to be set by environment variables. Some execution contexts
|
|
|
|
# like cron don't have PATH set correctly to pick it up.
|
|
|
|
if [ -z "$FPM" ]; then
|
|
|
|
FPM=`which fpm`
|
|
|
|
fi
|
2015-06-30 13:42:00 +00:00
|
|
|
|
2016-01-10 22:47:43 +00:00
|
|
|
GO_VERSION="go1.4.3"
|
2015-04-10 18:24:26 +00:00
|
|
|
GOPATH_INSTALL=
|
2015-02-25 17:55:12 +00:00
|
|
|
BINS=(
|
|
|
|
influxd
|
|
|
|
influx
|
2015-10-09 18:13:11 +00:00
|
|
|
influx_stress
|
2015-12-26 22:13:54 +00:00
|
|
|
influx_tsm
|
2015-10-09 18:13:11 +00:00
|
|
|
influx_inspect
|
2015-02-25 17:55:12 +00:00
|
|
|
)
|
|
|
|
|
2015-01-22 01:48:15 +00:00
|
|
|
###########################################################################
|
|
|
|
# Helper functions.
|
|
|
|
|
|
|
|
# usage prints simple usage information.
|
|
|
|
usage() {
|
2015-08-31 21:47:42 +00:00
|
|
|
cat << EOF >&2
|
2015-09-15 23:49:02 +00:00
|
|
|
$0 [-h] [-p|-w] [-t <dist>] [-r <number>] <version>
|
|
|
|
|
|
|
|
<version> should be a dotted version such as 0.9.5.
|
|
|
|
|
|
|
|
-r release candidate number, if any.
|
|
|
|
Example: -r 7
|
2015-08-31 21:47:42 +00:00
|
|
|
-p just build packages
|
2015-10-08 04:43:15 +00:00
|
|
|
-x build with race-detection enabled
|
2015-09-01 00:58:45 +00:00
|
|
|
-w build packages for current working directory
|
|
|
|
imply -p
|
2015-08-31 21:47:42 +00:00
|
|
|
-t <dist>
|
|
|
|
build package for <dist>
|
|
|
|
<dist> can be rpm, tar or deb
|
|
|
|
can have multiple -t
|
2015-09-15 23:49:02 +00:00
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
$0 0.9.5 -r 9 # Creates 0.9.5-rc9
|
|
|
|
$0 0.9.4 # Creates 0.9.4
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
EOF
|
2015-01-22 01:48:15 +00:00
|
|
|
cleanup_exit $1
|
|
|
|
}
|
|
|
|
|
2015-09-15 23:49:02 +00:00
|
|
|
# full_version echoes the full version string, given a version and an optiona;l
|
|
|
|
# RC number. If the just the version is present, that is echoed. If the RC is
|
|
|
|
# also provided, then "rc" and the number is concatenated with the version.
|
|
|
|
# For example, 0.9.4rc4 would be returned if version was 0.9.4 and the RC number
|
|
|
|
# was 4.
|
|
|
|
full_version() {
|
|
|
|
version=$1
|
|
|
|
rc=$2
|
|
|
|
if [ -z "$rc" ]; then
|
|
|
|
echo $version
|
|
|
|
else
|
2015-09-28 22:08:01 +00:00
|
|
|
echo ${version}-rc${rc}
|
2015-09-15 23:49:02 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# rpm_release echoes the RPM release or "iteration" given an RC number.
|
|
|
|
rpm_release() {
|
|
|
|
rc=$1
|
|
|
|
if [ -z "$rc" ]; then
|
|
|
|
echo 1
|
|
|
|
else
|
|
|
|
echo 0.1.rc${rc}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-01-22 01:48:15 +00:00
|
|
|
# cleanup_exit removes all resources created during the process and exits with
|
|
|
|
# the supplied returned code.
|
|
|
|
cleanup_exit() {
|
|
|
|
rm -r $TMP_WORK_DIR
|
|
|
|
rm $POST_INSTALL_PATH
|
2015-09-17 21:00:10 +00:00
|
|
|
rm $POST_UNINSTALL_PATH
|
2015-01-22 01:48:15 +00:00
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
2015-06-25 21:27:43 +00:00
|
|
|
# current_branch echos the current git branch.
|
|
|
|
current_branch() {
|
|
|
|
echo `git rev-parse --abbrev-ref HEAD`
|
|
|
|
}
|
|
|
|
|
2015-04-10 18:24:26 +00:00
|
|
|
# check_gopath sanity checks the value of the GOPATH env variable, and determines
|
|
|
|
# the path where build artifacts are installed. GOPATH may be a colon-delimited
|
|
|
|
# list of directories.
|
2015-01-22 01:48:15 +00:00
|
|
|
check_gopath() {
|
|
|
|
[ -z "$GOPATH" ] && echo "GOPATH is not set." && cleanup_exit 1
|
2015-04-10 18:24:26 +00:00
|
|
|
GOPATH_INSTALL=`echo $GOPATH | cut -d ':' -f 1`
|
|
|
|
[ ! -d "$GOPATH_INSTALL" ] && echo "GOPATH_INSTALL is not a directory." && cleanup_exit 1
|
|
|
|
echo "GOPATH ($GOPATH) looks sane, using $GOPATH_INSTALL for installation."
|
2015-01-22 01:48:15 +00:00
|
|
|
}
|
|
|
|
|
2015-04-21 01:14:46 +00:00
|
|
|
check_gvm() {
|
2015-06-24 21:40:03 +00:00
|
|
|
if [ -n "$GOPATH" ]; then
|
|
|
|
existing_gopath=$GOPATH
|
|
|
|
fi
|
|
|
|
|
2015-04-21 17:18:54 +00:00
|
|
|
source $HOME/.gvm/scripts/gvm
|
2015-04-21 01:14:46 +00:00
|
|
|
which gvm
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "gvm not found -- aborting."
|
|
|
|
cleanup_exit $1
|
|
|
|
fi
|
|
|
|
gvm use $GO_VERSION
|
2015-04-21 17:14:26 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2015-04-21 01:14:46 +00:00
|
|
|
echo "gvm cannot find Go version $GO_VERSION -- aborting."
|
|
|
|
cleanup_exit $1
|
|
|
|
fi
|
2015-06-24 21:40:03 +00:00
|
|
|
|
|
|
|
# Keep any existing GOPATH set.
|
|
|
|
if [ -n "$existing_gopath" ]; then
|
2015-06-24 21:47:34 +00:00
|
|
|
GOPATH=$existing_gopath
|
2015-06-24 21:40:03 +00:00
|
|
|
fi
|
2015-04-21 01:14:46 +00:00
|
|
|
}
|
|
|
|
|
2015-01-22 01:48:15 +00:00
|
|
|
# check_clean_tree ensures that no source file is locally modified.
|
|
|
|
check_clean_tree() {
|
|
|
|
modified=$(git ls-files --modified | wc -l)
|
|
|
|
if [ $modified -ne 0 ]; then
|
|
|
|
echo "The source tree is not clean -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
echo "Git tree is clean."
|
|
|
|
}
|
|
|
|
|
|
|
|
# update_tree ensures the tree is in-sync with the repo.
|
|
|
|
update_tree() {
|
2015-07-01 16:16:14 +00:00
|
|
|
git pull origin $TARGET_BRANCH
|
2015-01-22 01:48:15 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to pull latest code -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
git fetch --tags
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to fetch tags -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
echo "Git tree updated successfully."
|
|
|
|
}
|
|
|
|
|
|
|
|
# check_tag_exists checks if the existing release already exists in the tags.
|
|
|
|
check_tag_exists () {
|
|
|
|
version=$1
|
|
|
|
git tag | grep -q "^v$version$"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Proposed version $version already exists as a tag -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# make_dir_tree creates the directory structure within the packages.
|
|
|
|
make_dir_tree() {
|
|
|
|
work_dir=$1
|
|
|
|
version=$2
|
2015-11-06 16:52:04 +00:00
|
|
|
|
|
|
|
mkdir -p $work_dir/$INSTALL_ROOT_DIR
|
|
|
|
mkdir -p $work_dir/$INFLUXDB_SCRIPT_DIR/scripts
|
2015-01-22 01:48:15 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2015-11-06 16:52:04 +00:00
|
|
|
echo "Failed to create script directory -- aborting."
|
2015-01-22 01:48:15 +00:00
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
mkdir -p $work_dir/$CONFIG_ROOT_DIR
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to create configuration directory -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-09-08 15:51:00 +00:00
|
|
|
mkdir -p $work_dir/$LOGROTATE_DIR
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to create logrotate directory -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-01-22 01:48:15 +00:00
|
|
|
}
|
|
|
|
|
2015-01-22 23:50:20 +00:00
|
|
|
# do_build builds the code. The version and commit must be passed in.
|
2015-01-22 01:48:15 +00:00
|
|
|
do_build() {
|
2015-07-01 16:16:14 +00:00
|
|
|
for b in ${BINS[*]}; do
|
|
|
|
rm -f $GOPATH_INSTALL/bin/$b
|
|
|
|
done
|
2015-09-08 15:50:26 +00:00
|
|
|
|
2015-09-01 23:04:25 +00:00
|
|
|
if [ -n "$WORKING_DIR" ]; then
|
2015-09-01 00:58:45 +00:00
|
|
|
STASH=`git stash create -a`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "WARNING: failed to stash uncommited local changes"
|
|
|
|
fi
|
|
|
|
git reset --hard
|
|
|
|
fi
|
2015-09-08 15:50:26 +00:00
|
|
|
|
2015-07-01 16:16:14 +00:00
|
|
|
go get -u -f -d ./...
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "WARNING: failed to 'go get' packages."
|
|
|
|
fi
|
|
|
|
|
|
|
|
git checkout $TARGET_BRANCH # go get switches to master, so ensure we're back.
|
2015-09-08 15:50:26 +00:00
|
|
|
|
2015-09-01 23:04:25 +00:00
|
|
|
if [ -n "$WORKING_DIR" ]; then
|
2015-09-01 00:58:45 +00:00
|
|
|
git stash apply $STASH
|
|
|
|
if [ $? -ne 0 ]; then #and apply previous uncommited local changes
|
|
|
|
echo "WARNING: failed to restore uncommited local changes"
|
|
|
|
fi
|
|
|
|
fi
|
2015-09-08 15:50:26 +00:00
|
|
|
|
2015-01-22 23:50:20 +00:00
|
|
|
version=$1
|
|
|
|
commit=`git rev-parse HEAD`
|
2015-08-12 18:14:25 +00:00
|
|
|
branch=`current_branch`
|
2015-01-22 23:50:20 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Unable to retrieve current commit -- aborting"
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
|
2015-09-25 06:32:47 +00:00
|
|
|
date=`date -u --iso-8601=seconds`
|
2015-12-14 17:54:56 +00:00
|
|
|
go install $RACE -a -ldflags="-X main.version=$version -X main.branch=$branch -X main.commit=$commit -X main.buildTime=$date" ./...
|
2015-01-22 01:48:15 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Build failed, unable to create package -- aborting"
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
echo "Build completed successfully."
|
|
|
|
}
|
|
|
|
|
|
|
|
###########################################################################
|
2015-08-31 21:47:42 +00:00
|
|
|
# Process options
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
case $1 in
|
2015-09-08 15:50:26 +00:00
|
|
|
-h | --help)
|
2015-09-15 18:56:27 +00:00
|
|
|
usage 0
|
|
|
|
;;
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
-p | --packages-only)
|
2015-09-15 18:56:27 +00:00
|
|
|
PACKAGES_ONLY="PACKAGES_ONLY"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
-t | --target)
|
|
|
|
case "$2" in
|
|
|
|
'tar') TAR_WANTED="gz"
|
|
|
|
;;
|
|
|
|
'deb') DEB_WANTED="deb"
|
|
|
|
;;
|
|
|
|
'rpm') RPM_WANTED="rpm"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown target distribution $2"
|
2015-09-01 20:34:32 +00:00
|
|
|
usage 1
|
2015-08-31 21:47:42 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift 2
|
|
|
|
;;
|
2015-09-15 18:56:27 +00:00
|
|
|
|
2015-09-15 23:49:02 +00:00
|
|
|
-r)
|
|
|
|
RC=$2
|
|
|
|
if [ -z "$RC" ]; then
|
|
|
|
echo "RC number required"
|
|
|
|
fi
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2015-10-08 04:43:15 +00:00
|
|
|
-x)
|
|
|
|
RACE="-race"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2015-09-01 00:58:45 +00:00
|
|
|
-w | --working-directory)
|
|
|
|
PACKAGES_ONLY="PACKAGES_ONLY"
|
|
|
|
WORKING_DIR="WORKING_DIR"
|
2015-09-15 18:56:27 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
-*)
|
|
|
|
echo "Unknown option $1"
|
|
|
|
usage 1
|
|
|
|
;;
|
2015-09-15 18:56:27 +00:00
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
?*)
|
|
|
|
if [ -z $VERSION ]; then
|
|
|
|
VERSION=$1
|
|
|
|
shift
|
|
|
|
else
|
2015-09-09 00:14:03 +00:00
|
|
|
echo "$1 : aborting version already set to $VERSION"
|
2015-08-31 21:47:42 +00:00
|
|
|
usage 1
|
|
|
|
fi
|
2015-09-15 23:49:02 +00:00
|
|
|
|
2015-11-06 16:52:04 +00:00
|
|
|
|
|
|
|
echo $VERSION | grep -i '[r|rc]' 2>&1 >/dev/null
|
2015-09-15 23:49:02 +00:00
|
|
|
if [ $? -ne 1 -a -z "$NIGHTLY_BUILD" ]; then
|
|
|
|
echo
|
|
|
|
echo "$VERSION contains reference to RC - specify RC separately"
|
|
|
|
echo
|
|
|
|
usage 1
|
|
|
|
fi
|
2015-08-31 21:47:42 +00:00
|
|
|
;;
|
2015-09-15 18:56:27 +00:00
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
*) break
|
|
|
|
esac
|
|
|
|
done
|
2015-01-22 01:48:15 +00:00
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ -z "$DEB_WANTED$RPM_WANTED$TAR_WANTED" ]; then
|
|
|
|
TAR_WANTED="gz"
|
|
|
|
DEB_WANTED="deb"
|
2015-09-08 15:50:26 +00:00
|
|
|
RPM_WANTED="rpm"
|
2015-01-22 01:48:15 +00:00
|
|
|
fi
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ -z "$VERSION" ]; then
|
|
|
|
echo -e "Missing version"
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# Start the packaging process.
|
|
|
|
|
2015-01-22 01:48:15 +00:00
|
|
|
echo -e "\nStarting package process...\n"
|
|
|
|
|
2015-07-01 16:16:14 +00:00
|
|
|
# Ensure the current is correct.
|
|
|
|
TARGET_BRANCH=`current_branch`
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ -z "$NIGHTLY_BUILD" -a -z "$PACKAGES_ONLY" ]; then
|
2015-07-01 16:16:14 +00:00
|
|
|
echo -n "Current branch is $TARGET_BRANCH. Start packaging this branch? [Y/n] "
|
|
|
|
read response
|
|
|
|
response=`echo $response | tr 'A-Z' 'a-z'`
|
|
|
|
if [ "x$response" == "xn" ]; then
|
|
|
|
echo "Packaging aborted."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-04-21 01:14:46 +00:00
|
|
|
check_gvm
|
2015-01-22 01:48:15 +00:00
|
|
|
check_gopath
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ -z "$NIGHTLY_BUILD" -a -z "$PACKAGES_ONLY" ]; then
|
2015-06-24 22:08:27 +00:00
|
|
|
check_clean_tree
|
|
|
|
update_tree
|
2015-09-15 23:49:02 +00:00
|
|
|
check_tag_exists `full_version $VERSION $RC`
|
2015-06-24 22:08:27 +00:00
|
|
|
fi
|
2015-06-24 23:25:29 +00:00
|
|
|
|
2015-09-15 23:49:02 +00:00
|
|
|
do_build `full_version $VERSION $RC`
|
|
|
|
make_dir_tree $TMP_WORK_DIR `full_version $VERSION $RC`
|
2015-01-22 01:48:15 +00:00
|
|
|
|
2015-01-22 22:20:24 +00:00
|
|
|
###########################################################################
|
2015-01-28 00:25:43 +00:00
|
|
|
# Copy the assets to the installation directories.
|
2015-01-22 22:20:24 +00:00
|
|
|
|
2015-02-25 17:55:12 +00:00
|
|
|
for b in ${BINS[*]}; do
|
2015-11-06 16:52:04 +00:00
|
|
|
cp $GOPATH_INSTALL/bin/$b $TMP_WORK_DIR/$INSTALL_ROOT_DIR/
|
2015-02-25 17:55:12 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2015-11-06 16:52:04 +00:00
|
|
|
echo "Failed to copy binaries to packaging directory ($TMP_WORK_DIR/$INSTALL_ROOT_DIR/) -- aborting."
|
2015-02-25 17:55:12 +00:00
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
done
|
2015-11-06 16:52:04 +00:00
|
|
|
echo "${BINS[*]} copied to $TMP_WORK_DIR/$INSTALL_ROOT_DIR/"
|
2015-01-22 01:48:15 +00:00
|
|
|
|
2015-11-06 16:52:04 +00:00
|
|
|
cp $INITD_SCRIPT $TMP_WORK_DIR/$INFLUXDB_SCRIPT_DIR/$INITD_SCRIPT
|
2015-01-22 22:39:11 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2015-11-06 16:52:04 +00:00
|
|
|
echo "Failed to copy init.d script to packaging directory ($TMP_WORK_DIR/$INFLUXDB_SCRIPT_DIR/) -- aborting."
|
2015-01-22 22:39:11 +00:00
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-11-06 16:52:04 +00:00
|
|
|
echo "$INITD_SCRIPT copied to $TMP_WORK_DIR/$INFLUXDB_SCRIPT_DIR"
|
2015-01-22 22:39:11 +00:00
|
|
|
|
2015-11-06 16:52:04 +00:00
|
|
|
cp $SYSTEMD_SCRIPT $TMP_WORK_DIR/$INFLUXDB_SCRIPT_DIR/$SYSTEMD_SCRIPT
|
2015-09-09 00:14:03 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to copy systemd script to packaging directory -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-11-06 16:52:04 +00:00
|
|
|
echo "$SYSTEMD_SCRIPT copied to $TMP_WORK_DIR/$INFLUXDB_SCRIPT_DIR"
|
2015-09-09 00:14:03 +00:00
|
|
|
|
2015-09-09 07:51:37 +00:00
|
|
|
cp $SAMPLE_CONFIGURATION $TMP_WORK_DIR/$CONFIG_ROOT_DIR/influxdb.conf
|
2015-01-22 01:48:15 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to copy $SAMPLE_CONFIGURATION to packaging directory -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
|
2015-10-14 17:15:48 +00:00
|
|
|
install -m 644 $LOGROTATE $TMP_WORK_DIR/$LOGROTATE_DIR/influxdb
|
2015-09-08 15:51:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to copy logrotate configuration to packaging directory -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
|
2015-01-22 22:20:24 +00:00
|
|
|
###########################################################################
|
|
|
|
# Create the actual packages.
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ -z "$NIGHTLY_BUILD" -a -z "$PACKAGES_ONLY" ]; then
|
2015-09-15 23:49:02 +00:00
|
|
|
echo -n "Commence creation of $ARCH packages, version `full_version $VERSION $RC`? [Y/n] "
|
2015-06-24 22:08:27 +00:00
|
|
|
read response
|
|
|
|
response=`echo $response | tr 'A-Z' 'a-z'`
|
|
|
|
if [ "x$response" == "xn" ]; then
|
|
|
|
echo "Packaging aborted."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-01-22 01:48:15 +00:00
|
|
|
fi
|
|
|
|
|
2015-09-15 23:49:02 +00:00
|
|
|
COMMON_FPM_ARGS="\
|
|
|
|
--log error \
|
|
|
|
-C $TMP_WORK_DIR \
|
|
|
|
--vendor $VENDOR \
|
|
|
|
--url $URL \
|
|
|
|
--license $LICENSE \
|
|
|
|
--maintainer $MAINTAINER \
|
2015-11-12 19:03:41 +00:00
|
|
|
--after-install $POSTINSTALL_SCRIPT \
|
|
|
|
--before-install $PREINSTALL_SCRIPT \
|
|
|
|
--after-remove $POSTUNINSTALL_SCRIPT \
|
2015-10-08 04:43:15 +00:00
|
|
|
--name influxdb${RACE} \
|
2015-09-15 23:49:02 +00:00
|
|
|
--config-files $CONFIG_ROOT_DIR \
|
|
|
|
--config-files $LOGROTATE_DIR"
|
2015-01-22 01:48:15 +00:00
|
|
|
|
2015-09-01 23:04:25 +00:00
|
|
|
if [ -n "$DEB_WANTED" ]; then
|
2015-10-05 20:51:04 +00:00
|
|
|
$FPM -s dir -t deb $deb_args --description "$DESCRIPTION" $COMMON_FPM_ARGS --version `full_version $VERSION $RC` .
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to create Debian package -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
echo "Debian package created successfully."
|
2015-01-22 01:48:15 +00:00
|
|
|
fi
|
|
|
|
|
2015-09-01 23:04:25 +00:00
|
|
|
if [ -n "$TAR_WANTED" ]; then
|
2015-10-08 04:43:15 +00:00
|
|
|
if [ -n "$RACE" ]; then
|
|
|
|
# Tweak race prefix for tarball.
|
|
|
|
race="race_"
|
|
|
|
fi
|
|
|
|
$FPM -s dir -t tar --prefix influxdb_$race`full_version $VERSION $RC`_${ARCH} -p influxdb_$race`full_version $VERSION $RC`_${ARCH}.tar.gz --description "$DESCRIPTION" $COMMON_FPM_ARGS --version `full_version $VERSION $RC ` .
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to create Tar package -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
echo "Tar package created successfully."
|
2015-06-26 14:21:53 +00:00
|
|
|
fi
|
|
|
|
|
2015-09-01 23:04:25 +00:00
|
|
|
if [ -n "$RPM_WANTED" ]; then
|
2015-10-05 20:51:04 +00:00
|
|
|
$rpm_args $FPM -s dir -t rpm --description "$DESCRIPTION" $COMMON_FPM_ARGS --depends coreutils --version $VERSION --iteration `rpm_release $RC` .
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to create RPM package -- aborting."
|
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
echo "RPM package created successfully."
|
2015-08-25 05:22:16 +00:00
|
|
|
fi
|
|
|
|
|
2015-01-22 22:20:24 +00:00
|
|
|
###########################################################################
|
|
|
|
# Offer to tag the repo.
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ -z "$NIGHTLY_BUILD" -a -z "$PACKAGES_ONLY" ]; then
|
2015-09-15 23:49:02 +00:00
|
|
|
echo -n "Tag source tree with v`full_version $VERSION $RC` and push to repo? [y/N] "
|
2015-06-24 22:08:27 +00:00
|
|
|
read response
|
|
|
|
response=`echo $response | tr 'A-Z' 'a-z'`
|
|
|
|
if [ "x$response" == "xy" ]; then
|
2015-09-15 23:49:02 +00:00
|
|
|
echo "Creating tag v`full_version $VERSION $RC` and pushing to repo"
|
|
|
|
git tag v`full_version $VERSION $RC`
|
2015-06-24 22:08:27 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2015-09-15 23:49:02 +00:00
|
|
|
echo "Failed to create tag v`full_version $VERSION $RC` -- aborting"
|
2015-06-24 22:08:27 +00:00
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-09-15 23:49:02 +00:00
|
|
|
echo "Tag v`full_version $VERSION $RC` created"
|
|
|
|
git push origin v`full_version $VERSION $RC`
|
2015-06-24 22:08:27 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2015-09-15 23:49:02 +00:00
|
|
|
echo "Failed to push tag v`full_version $VERSION $RC` to repo -- aborting"
|
2015-06-24 22:08:27 +00:00
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-09-15 23:49:02 +00:00
|
|
|
echo "Tag v`full_version $VERSION $RC` pushed to repo"
|
2015-06-24 22:08:27 +00:00
|
|
|
else
|
2015-09-15 23:49:02 +00:00
|
|
|
echo "Not creating tag v`full_version $VERSION $RC`."
|
2015-01-22 22:20:24 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-01-22 23:31:49 +00:00
|
|
|
###########################################################################
|
|
|
|
# Offer to publish the packages.
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
if [ -z "$NIGHTLY_BUILD" -a -z "$PACKAGES_ONLY" ]; then
|
2015-06-24 22:08:27 +00:00
|
|
|
echo -n "Publish packages to S3? [y/N] "
|
|
|
|
read response
|
|
|
|
response=`echo $response | tr 'A-Z' 'a-z'`
|
|
|
|
fi
|
|
|
|
|
2015-06-24 22:12:30 +00:00
|
|
|
if [ "x$response" == "xy" -o -n "$NIGHTLY_BUILD" ]; then
|
2015-01-22 23:31:49 +00:00
|
|
|
echo "Publishing packages to S3."
|
2015-01-28 17:43:19 +00:00
|
|
|
if [ ! -e "$AWS_FILE" ]; then
|
|
|
|
echo "$AWS_FILE does not exist -- aborting."
|
2015-01-22 23:31:49 +00:00
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
|
|
|
|
2015-08-31 21:47:42 +00:00
|
|
|
for filepath in `ls *.{$DEB_WANTED,$RPM_WANTED,$TAR_WANTED} 2> /dev/null`; do
|
2015-01-22 23:31:49 +00:00
|
|
|
filename=`basename $filepath`
|
2015-11-23 22:49:31 +00:00
|
|
|
sum=`md5sum $filename | cut -d ' ' -f 1`
|
2015-09-15 23:49:02 +00:00
|
|
|
|
2015-06-24 22:44:55 +00:00
|
|
|
if [ -n "$NIGHTLY_BUILD" ]; then
|
2015-09-15 23:49:02 +00:00
|
|
|
# Replace the version string in the filename with "nightly".
|
|
|
|
v=`full_version $VERSION $RC`
|
|
|
|
v_underscored=`echo "$v" | tr - _`
|
|
|
|
v_rpm=$VERSION-`rpm_release $RC`
|
|
|
|
|
|
|
|
# It's ok to run each of these since only 1 will match, leaving
|
|
|
|
# filename untouched otherwise.
|
|
|
|
filename=`echo $filename | sed s/$v/nightly/`
|
|
|
|
filename=`echo $filename | sed s/$v_underscored/nightly/`
|
|
|
|
filename=`echo $filename | sed s/$v_rpm/nightly-1/`
|
2015-06-24 22:44:55 +00:00
|
|
|
fi
|
2015-09-15 23:49:02 +00:00
|
|
|
|
2015-01-28 17:43:19 +00:00
|
|
|
AWS_CONFIG_FILE=$AWS_FILE aws s3 cp $filepath s3://influxdb/$filename --acl public-read --region us-east-1
|
|
|
|
if [ $? -ne 0 ]; then
|
2015-08-31 21:47:42 +00:00
|
|
|
echo "Upload failed ($filename) -- aborting".
|
2015-01-28 17:43:19 +00:00
|
|
|
cleanup_exit 1
|
|
|
|
fi
|
2015-11-20 19:36:19 +00:00
|
|
|
echo "$filename uploaded, MD5 checksum is $sum"
|
2015-01-22 23:31:49 +00:00
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "Not publishing packages to S3."
|
|
|
|
fi
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# All done.
|
|
|
|
|
2015-01-22 22:20:24 +00:00
|
|
|
echo -e "\nPackaging process complete."
|
2015-01-22 01:48:15 +00:00
|
|
|
cleanup_exit 0
|