2013-01-16 12:02:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
echo "updating dependencies"
|
|
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
|
|
# 'target' is the output directory
|
|
|
|
|
rm -rf $DIR/target
|
|
|
|
|
mkdir $DIR/target
|
|
|
|
|
mkdir $DIR/target/deb
|
2013-09-16 03:19:10 +00:00
|
|
|
|
2013-09-16 04:27:14 +00:00
|
|
|
# default build number to 1 if not found
|
|
|
|
|
if [ -z "$BUILD_NUMBER" ]; then
|
|
|
|
|
BUILD_NUMBER="1"
|
|
|
|
|
fi
|
|
|
|
|
|
2013-09-18 20:35:20 +00:00
|
|
|
GEM_VERSION="0.1.${BUILD_NUMBER}"
|
2013-09-16 03:19:10 +00:00
|
|
|
# copy needed gems to cache so they'll be bundled up in the debian
|
|
|
|
|
mkdir -p vendor/cache
|
|
|
|
|
cp ../db/target/ruby_package/jam_db-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy jam-db gem"; exit 1; }
|
|
|
|
|
cp ../pb/target/ruby/jampb/jampb-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy jam-pb gem"; exit 1; }
|
|
|
|
|
cp ../ruby/jam_ruby-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy jam-ruby gem"; exit 1; }
|
|
|
|
|
|
2013-01-16 12:02:09 +00:00
|
|
|
# put all dependencies into vendor/bundle
|
2014-01-14 22:55:34 +00:00
|
|
|
#rm -rf vendor/bundle -- let jenkins config 'wipe workspace' decide this
|
2013-01-16 12:02:09 +00:00
|
|
|
rm Gemfile.lock # if we don't want versions to float, pin it in the Gemfile, not count on Gemfile.lock
|
|
|
|
|
bundle install --path vendor/bundle
|
2014-02-02 20:03:31 +00:00
|
|
|
#bundle update
|
2013-01-16 12:02:09 +00:00
|
|
|
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: updated dependencies"
|
|
|
|
|
else
|
|
|
|
|
echo "could not update dependencies"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -z $SKIP_TESTS ]; then
|
|
|
|
|
|
|
|
|
|
echo "running rspec tests"
|
|
|
|
|
bundle exec rspec
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: ran rspec tests"
|
|
|
|
|
else
|
|
|
|
|
echo "running rspec tests failed."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -n "$PACKAGE" ]; then
|
|
|
|
|
|
|
|
|
|
if [ -z "$BUILD_NUMBER" ]; then
|
|
|
|
|
echo "BUILD NUMBER is not defined"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2013-08-29 13:49:47 +00:00
|
|
|
cat > lib/jam_admin/version.rb << EOF
|
|
|
|
|
module JamAdmin
|
2013-08-29 13:48:54 +00:00
|
|
|
VERSION = "0.1.$BUILD_NUMBER"
|
|
|
|
|
end
|
|
|
|
|
EOF
|
|
|
|
|
|
2013-09-16 17:03:26 +00:00
|
|
|
echo "$BUILD_NUMBER" > BUILD_NUMBER
|
2013-08-29 13:48:54 +00:00
|
|
|
|
2013-01-16 12:02:09 +00:00
|
|
|
type -P dpkg-architecture > /dev/null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
ARCH=`dpkg-architecture -qDEB_HOST_ARCH`
|
|
|
|
|
else
|
|
|
|
|
echo "WARN: unable to determine architecture."
|
|
|
|
|
ARCH=`all`
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
# cache all gems local, and tell bundle to use local gems only
|
2014-02-02 20:03:31 +00:00
|
|
|
#bundle install --path vendor/bundle --local
|
2013-01-16 12:02:09 +00:00
|
|
|
# prepare production acssets
|
|
|
|
|
rm -rf $DIR/public/assets
|
2015-07-15 17:12:29 +00:00
|
|
|
bundle exec rake assets:precompile RAILS_ENV=production
|
2013-01-16 12:02:09 +00:00
|
|
|
|
|
|
|
|
# create debian using fpm
|
2013-09-16 17:03:26 +00:00
|
|
|
bundle exec fpm -s dir -t deb -p target/deb/jam-admin_0.1.${BUILD_NUMBER}_${ARCH}.deb -n "jam-admin" -v "0.1.$BUILD_NUMBER" --prefix /var/lib/jam-admin --after-install $DIR/script/package/post-install.sh --before-install $DIR/script/package/pre-install.sh --before-remove $DIR/script/package/pre-uninstall.sh --after-remove $DIR/script/package/post-uninstall.sh Gemfile .bundle config Rakefile script config.ru lib public vendor app BUILD_NUMBER
|
2013-01-16 12:02:09 +00:00
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "build complete"
|
|
|
|
|
|