2013-10-22 14:33:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
set -e
|
|
|
|
|
2013-10-24 20:14:54 +00:00
|
|
|
. ./exports.sh
|
|
|
|
|
2013-10-28 16:27:35 +00:00
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: $0 <version>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-10-28 16:16:29 +00:00
|
|
|
admin_dir=/tmp/influx_admin_interface
|
2013-10-28 16:27:35 +00:00
|
|
|
influxdb_version=$1
|
2013-10-24 20:55:56 +00:00
|
|
|
rm -rf packages
|
|
|
|
mkdir packages
|
|
|
|
|
|
|
|
function setup_rvm {
|
|
|
|
# Load RVM into a shell session *as a function*
|
|
|
|
if [ -s "$HOME/.rvm/scripts/rvm" ]; then
|
|
|
|
# First try to load from a user install
|
|
|
|
source "$HOME/.rvm/scripts/rvm"
|
|
|
|
elif [ -s "/usr/local/rvm/scripts/rvm" ]; then
|
|
|
|
# Then try to load from a root install
|
|
|
|
source "/usr/local/rvm/scripts/rvm"
|
|
|
|
else
|
|
|
|
printf "ERROR: An RVM installation was not found.\n"
|
|
|
|
fi
|
2013-10-28 16:16:29 +00:00
|
|
|
rvm use --create 1.9.3@influxdb
|
|
|
|
gem install bundler
|
2013-10-24 20:55:56 +00:00
|
|
|
gem install fpm
|
|
|
|
}
|
|
|
|
|
2013-10-28 16:16:29 +00:00
|
|
|
function package_admin_interface {
|
|
|
|
[ -d $admin_dir ] || git clone https://github.com/influxdb/influxdb-js.git $admin_dir
|
|
|
|
rvm rvmrc trust /tmp/influx_admin_interface/.rvmrc
|
|
|
|
pushd $admin_dir
|
|
|
|
git checkout .
|
|
|
|
git pull --rebase
|
|
|
|
|
|
|
|
bundle install
|
|
|
|
bundle exec middleman build
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
function package_files {
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: $0 architecture"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf build
|
|
|
|
mkdir build
|
|
|
|
|
2013-10-28 16:16:29 +00:00
|
|
|
package_admin_interface
|
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
mv server build/influxdb
|
|
|
|
|
|
|
|
cp config.json.sample build/config.json
|
|
|
|
|
2013-10-28 16:16:29 +00:00
|
|
|
# cp -R src/admin/site/ build/admin/
|
|
|
|
mkdir build/admin
|
|
|
|
cp -R $admin_dir/build/* build/admin/
|
2013-10-24 20:55:56 +00:00
|
|
|
|
2013-10-26 16:42:03 +00:00
|
|
|
cp -R scripts/ build/
|
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
tar_file=influxdb-$influxdb_version.$1.tar.gz
|
|
|
|
|
|
|
|
tar -czf $tar_file build/*
|
|
|
|
|
|
|
|
mv $tar_file packages/
|
|
|
|
}
|
|
|
|
|
|
|
|
function build_packages {
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: $0 architecture"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $1 == "386" ]; then
|
|
|
|
rpm_args="setarch i386"
|
|
|
|
deb_args="-a i386"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf out_rpm
|
|
|
|
mkdir -p out_rpm/opt/influxdb/versions/$influxdb_version
|
|
|
|
cp -r build/* out_rpm/opt/influxdb/versions/$influxdb_version
|
|
|
|
pushd out_rpm
|
2013-10-26 16:42:03 +00:00
|
|
|
$rpm_args fpm -s dir -t rpm --after-install ../scripts/post_install.sh -n influxdb -v $influxdb_version . || exit $?
|
2013-10-24 20:55:56 +00:00
|
|
|
mv *.rpm ../packages/
|
2013-10-26 16:42:03 +00:00
|
|
|
fpm -s dir -t deb $deb_args --after-install ../scripts/post_install.sh -n influxdb -v $influxdb_version . || exit $?
|
2013-10-24 20:55:56 +00:00
|
|
|
mv *.deb ../packages/
|
|
|
|
popd
|
|
|
|
}
|
2013-10-22 14:33:20 +00:00
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
function setup_version {
|
|
|
|
echo "Changing version from dev to $influxdb_version"
|
2013-10-26 16:24:59 +00:00
|
|
|
sha1=`git rev-list --max-count=1 HEAD`
|
|
|
|
sed -i.bak -e "s/var version = \"dev\"/var version = \"$influxdb_version\"/" -e "s/var gitSha = \"\"/var gitSha = \"$sha1\"/" src/server/server.go
|
2013-10-26 16:42:03 +00:00
|
|
|
sed -i.bak -e "s/REPLACE_VERSION/$influxdb_version/" scripts/post_install.sh
|
2013-10-24 20:55:56 +00:00
|
|
|
}
|
2013-10-22 14:33:20 +00:00
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
function revert_version {
|
2013-10-26 16:42:03 +00:00
|
|
|
if [ -e src/server/server.go.bak ]; then
|
|
|
|
rm src/server/server.go
|
|
|
|
mv src/server/server.go.bak src/server/server.go
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e scripts/post_install.sh ]; then
|
|
|
|
rm scripts/post_install.sh
|
|
|
|
mv scripts/post_install.sh.bak scripts/post_install.sh
|
2013-10-24 20:55:56 +00:00
|
|
|
fi
|
2013-10-22 14:33:20 +00:00
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
echo "Changed version back to dev"
|
|
|
|
}
|
2013-10-22 14:33:20 +00:00
|
|
|
|
2013-10-24 20:55:56 +00:00
|
|
|
setup_rvm
|
|
|
|
setup_version
|
|
|
|
UPDATE=on ./build.sh && package_files amd64 && build_packages amd64
|
|
|
|
revert_version
|
2013-10-28 16:30:43 +00:00
|
|
|
[ $on_linux == yes ] && CGO_ENABLED=1 GOARCH=386 UPDATE=on ./build.sh && package_files 386 && build_packages 386
|