gitlab-org--gitlab-foss/scripts/prepare_build.sh

50 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
2016-03-09 15:22:25 -05:00
retry() {
2016-06-07 07:06:24 -04:00
if eval "$@"; then
return 0
fi
for i in 2 1; do
sleep 3s
echo "Retrying $i..."
2016-03-09 15:22:25 -05:00
if eval "$@"; then
return 0
fi
done
return 1
}
if [ -f /.dockerenv ] || [ -f ./dockerinit ]; then
mkdir -p vendor/apt
2016-06-07 04:31:02 -04:00
# Install phantomjs package
pushd vendor/apt
2016-08-09 14:25:11 -04:00
PHANTOMJS_FILE="phantomjs-$PHANTOMJS_VERSION-linux-x86_64"
if [ ! -d "$PHANTOMJS_FILE" ]; then
2016-08-15 06:43:23 -04:00
curl -q -L "https://s3.amazonaws.com/gitlab-build-helpers/$PHANTOMJS_FILE.tar.bz2" | tar jx
2016-06-07 04:31:02 -04:00
fi
2016-08-09 14:25:11 -04:00
cp "$PHANTOMJS_FILE/bin/phantomjs" "/usr/bin/"
2016-06-07 04:31:02 -04:00
popd
# Try to install packages
retry 'apt-get update -yqqq; apt-get -o dir::cache::archives="vendor/apt" install -y -qq --force-yes \
libicu-dev libkrb5-dev cmake nodejs postgresql-client mysql-client unzip'
cp config/database.yml.mysql config/database.yml
sed -i 's/username:.*/username: root/g' config/database.yml
sed -i 's/password:.*/password:/g' config/database.yml
sed -i 's/# socket:.*/host: mysql/g' config/database.yml
cp config/resque.yml.example config/resque.yml
sed -i 's/localhost/redis/g' config/resque.yml
2016-09-28 03:16:09 -04:00
export FLAGS=(--path vendor --retry 3 --quiet)
else
export PATH=$HOME/bin:/usr/local/bin:/usr/bin:/bin
cp config/database.yml.mysql config/database.yml
sed "s/username\:.*$/username\: runner/" -i config/database.yml
sed "s/password\:.*$/password\: 'password'/" -i config/database.yml
sed "s/gitlabhq_test/gitlabhq_test_$((RANDOM/5000))/" -i config/database.yml
fi