added ebuilds for gitlab{hq,-c1}-7.13.4.

NOTE: gitlabhq-7.13.4 now supports the new use flag "rugged_use_system_libraries", which will use installed libraries for building the rugged gem, hopefully avoiding some build errors under certain cirumstances.
This commit is contained in:
Manuel Friedli 2015-08-13 14:22:12 +02:00
parent 024ab59e91
commit e411cd969c
4 changed files with 679 additions and 0 deletions

View file

@ -4,8 +4,10 @@ DIST gitlab-ci-7.12.1.tar.gz 741319 SHA256 20bcacb1b51b50feac3bed510fc6bfe120f0a
DIST gitlab-ci-7.12.2.tar.gz 741122 SHA256 d1e7f4b106a48d53a54942a2b543dd08097402bab3e379ef9daeecd9790e26f6 SHA512 a1197ba30d4bee985554cd54efefd46d278a22071a52cd2c367934f274bc268af5f42960c268792e8aa09f481f40fe6a6da640f69f63cae7c778af2c778bc86c WHIRLPOOL 57338dc79edfaeec0702cd75f74c2d89bf2cb6f41657a4aa1e36dd5427648783dcfad2c7ee534fd9fb8d20e1991dd3f7cef15234f7e96600f4c89cc2eb5dec62
DIST gitlab-ci-7.13.1.tar.gz 754531 SHA256 5b0b05503c7d38ff35c5ccd6bbe81be97460e060ee78b541804dcc8e18ffa319 SHA512 36faebfbd86333d518bee91d33498f6bb850a0e9987a462e5d66ae1d4cdea463e871f505943474aab9cf9e455bf0c4621379f51f1736adc5c6104f4e8d0cf1a3 WHIRLPOOL 34b27c1a71b14681d35e2e62faa7d93bea169daf2612f875250dd5b30ebaab5deba6f4d2d8a23da1db84d85fb1477188d33a658b60f76c30736b318840d5f99a
DIST gitlab-ci-7.13.2.tar.gz 754524 SHA256 769521038aec08f9cffb87381e83a46c02d24bd6a94132cf7111a905002673f8 SHA512 9ff28524923ffea7ec7b218c58ac3c5e1141e6f22b9f92b78da86d5e2ed9aadd72fd82693c5b35a1bab9c21706fd1336f7063c0cf50bb6b0fa1a562a5cdebd8e WHIRLPOOL d4ac82c93707b0ff23bffaf28fa3bb2397a891b732f6419dcef097c03b158ca7d40472acdeffb3d160c0b637492904c1171eb2ff8e4acdb7f51e298aa46ce4c8
DIST gitlab-ci-7.13.4.tar.gz 754607 SHA256 041ccd2f6a72d0501085b6141f3131f246e4b98ae22eadf6c651405736a4112d SHA512 49fc134a03408b7d60600a2bca4053d2c63bf7257afdd4b5d8133615c8c5eda3638fac7f4682a204f058ac04bd0c849f1c951eba38111f6abd287be6fea017ff WHIRLPOOL 576cdccc308c1ace7fb88c5371816a10864631c58f4713b9a669ffc81e15b75906e202d17a40e349d9d023cb8628246fb66a1483149e77bbac14f39045fc6d0b
EBUILD gitlab-ci-7.11.4.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b56d96f71c9d89f333f582f9f967 SHA512 9f4aa8569954e28e9081262560192e224d4a1bf80ca73dca6349d0b08f14218e7841d516b9a0d93dca2923e7a49e0093a5d397a224f7e417cf5d65ff498e74f3 WHIRLPOOL 8d27bb147d1f858259ff2b9bd208c7a05bad8cb2057ce5ee56462fb4a9fb2eb9c417ca344cfd66a9a715aeec429988c34ca4dd9495bf1f6529082d3ba509d358
EBUILD gitlab-ci-7.12.1.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b56d96f71c9d89f333f582f9f967 SHA512 9f4aa8569954e28e9081262560192e224d4a1bf80ca73dca6349d0b08f14218e7841d516b9a0d93dca2923e7a49e0093a5d397a224f7e417cf5d65ff498e74f3 WHIRLPOOL 8d27bb147d1f858259ff2b9bd208c7a05bad8cb2057ce5ee56462fb4a9fb2eb9c417ca344cfd66a9a715aeec429988c34ca4dd9495bf1f6529082d3ba509d358
EBUILD gitlab-ci-7.12.2.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b56d96f71c9d89f333f582f9f967 SHA512 9f4aa8569954e28e9081262560192e224d4a1bf80ca73dca6349d0b08f14218e7841d516b9a0d93dca2923e7a49e0093a5d397a224f7e417cf5d65ff498e74f3 WHIRLPOOL 8d27bb147d1f858259ff2b9bd208c7a05bad8cb2057ce5ee56462fb4a9fb2eb9c417ca344cfd66a9a715aeec429988c34ca4dd9495bf1f6529082d3ba509d358
EBUILD gitlab-ci-7.13.1.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b56d96f71c9d89f333f582f9f967 SHA512 9f4aa8569954e28e9081262560192e224d4a1bf80ca73dca6349d0b08f14218e7841d516b9a0d93dca2923e7a49e0093a5d397a224f7e417cf5d65ff498e74f3 WHIRLPOOL 8d27bb147d1f858259ff2b9bd208c7a05bad8cb2057ce5ee56462fb4a9fb2eb9c417ca344cfd66a9a715aeec429988c34ca4dd9495bf1f6529082d3ba509d358
EBUILD gitlab-ci-7.13.2.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b56d96f71c9d89f333f582f9f967 SHA512 9f4aa8569954e28e9081262560192e224d4a1bf80ca73dca6349d0b08f14218e7841d516b9a0d93dca2923e7a49e0093a5d397a224f7e417cf5d65ff498e74f3 WHIRLPOOL 8d27bb147d1f858259ff2b9bd208c7a05bad8cb2057ce5ee56462fb4a9fb2eb9c417ca344cfd66a9a715aeec429988c34ca4dd9495bf1f6529082d3ba509d358
EBUILD gitlab-ci-7.13.4.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b56d96f71c9d89f333f582f9f967 SHA512 9f4aa8569954e28e9081262560192e224d4a1bf80ca73dca6349d0b08f14218e7841d516b9a0d93dca2923e7a49e0093a5d397a224f7e417cf5d65ff498e74f3 WHIRLPOOL 8d27bb147d1f858259ff2b9bd208c7a05bad8cb2057ce5ee56462fb4a9fb2eb9c417ca344cfd66a9a715aeec429988c34ca4dd9495bf1f6529082d3ba509d358

View file

@ -0,0 +1,309 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="5"
# Maintainer notes:
# - This ebuild uses Bundler to download and install all gems in deployment mode
# (i.e. into isolated directory inside application). That's not Gentoo way how
# it should be done, but GitLab has too many dependencies that it will be too
# difficult to maintain them via ebuilds.
#
USE_RUBY="ruby20 ruby21"
PYTHON_DEPEND="2:2.7"
inherit eutils python ruby-ng user
DESCRIPTION="GitLab CI is a continuous integration server that is tightly integrated with GitLab"
HOMEPAGE="https://gitlab.com/gitlab-org/gitlab-ci"
SRC_URI="https://github.com/gitlabhq/gitlab-ci/archive/v${PV}.tar.gz -> ${P}.tar.gz"
RESTRICT="mirror"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="mysql +postgres"
## Gems dependencies:
# charlock_holmes dev-libs/icu
# grape, capybara dev-libs/libxml2, dev-libs/libxslt
# pg dev-db/postgresql
# mysql virtual/mysql
#
GEMS_DEPEND="
dev-libs/icu
dev-libs/libxml2
dev-libs/libxslt
postgres? ( dev-db/postgresql )
mysql? ( virtual/mysql )"
DEPEND="${GEMS_DEPEND}
dev-vcs/git"
RDEPEND="${DEPEND}
dev-db/redis
virtual/mta"
ruby_add_bdepend "
virtual/rubygems
>=dev-ruby/bundler-1.0"
# no patches needed so far ...
#RUBY_PATCHES=(
#)
MY_NAME="gitlab-ci"
MY_USER="gitlab_ci"
DEST_DIR="/opt/${MY_NAME}"
CONF_DIR="/etc/${MY_NAME}"
LOGS_DIR="/var/log/${MY_NAME}"
TEMP_DIR="/var/tmp/${MY_NAME}"
RUN_DIR="/run/${MY_NAME}"
# When updating ebuild to newer version, check list of the queues in
# https://gitlab.com/gitlab-org/gitlab-ci/blob/v${PV}/script/background_jobs
SIDEKIQ_QUEUES="runner,common,default"
pkg_setup() {
enewgroup gitlab_ci
enewuser gitlab_ci -1 /bin/bash ${DEST_DIR} "gitlab_ci,cron,redis"
}
all_ruby_prepare() {
# fix paths
sed -i -E \
-e "s|redis://redis.example.com:6379|unix:/run/redis/redis.sock|" \
config/resque.yml.example || die "failed to filter resque.yml.example"
sed -i -E \
-e "s|/home/gitlab_ci/gitlab-ci/tmp/(pids\|sockets)|${RUN_DIR}|" \
-e "s|/home/gitlab_ci/gitlab-ci/log|${LOGS_DIR}|" \
-e "s|/home/gitlab_ci/gitlab-ci|${DEST_DIR}|" \
config/unicorn.rb.example || die "failed to filter unicorn.rb.example"
sed -i \
-e "s|/home/gitlab_ci/gitlab-ci/tmp/sockets|${RUN_DIR}|" \
-e "s|/home/gitlab_ci/gitlab-ci/public|${DEST_DIR}/public|" \
lib/support/nginx/gitlab_ci || die "failed to filter nginx/gitlab_ci"
# modify default database settings for PostgreSQL
sed -i -E \
-e 's|(username:).*|\1 gitlab|' \
-e 's|(password:).*|\1 gitlab|' \
-e 's|(socket:).*|/run/postgresql/.s.PGSQL.5432|' \
config/database.yml.postgresql \
|| die "failed to filter database.yml.postgresql"
# modify default database settings for MySQL
sed -i -E \
-e "s|/tmp/mysql.sock|/run/mysqld/mysqld.sock|" \
config/database.yml.mysql || die "failed to filter database.yml.mysql"
# rename config files
mv config/application.yml.example config/application.yml
mv config/unicorn.rb.example config/unicorn.rb
local dbconf=config/database.yml
if use postgres && ! use mysql; then
mv ${dbconf}.postgresql ${dbconf}
rm ${dbconf}.mysql
elif use mysql && ! use postgres; then
mv ${dbconf}.mysql ${dbconf}
rm ${dbconf}.postgresql
fi
# remove useless files
rm -r lib/support/init.d
}
all_ruby_install() {
local dest=${DEST_DIR}
local conf=${CONF_DIR}
local logs=${LOGS_DIR}
local temp=${TEMP_DIR}
local runs=${RUN_DIR}
# prepare directories
diropts -m750
dodir ${logs} ${temp}
diropts -m755
dodir ${conf} ${dest}/public/uploads
dosym ${temp} ${dest}/tmp
dosym ${logs} ${dest}/log
# install configs
insinto ${conf}
doins -r config/*
dosym ${conf} ${dest}/config
echo 'export RAILS_ENV=production' > "${D}/${dest}/.profile"
# remove needless dirs
rm -Rf config tmp log
# install the rest files
# using cp 'cause doins is slow
cp -Rl * "${D}/${dest}"/
# install logrotate config
dodir /etc/logrotate.d
cat > "${D}/etc/logrotate.d/${MY_NAME}" <<-EOF
${logs}/*.log {
missingok
delaycompress
compress
copytruncate
}
EOF
## Install gems via bundler ##
cd "${D}/${dest}"
local without="development test aws"
local flag; for flag in mysql postgres; do
without+="$(use $flag || echo ' '$flag)"
done
local bundle_args="--deployment ${without:+--without ${without}}"
einfo "Running bundle install ${bundle_args} ..."
${RUBY} /usr/bin/bundle install ${bundle_args} || die "bundler failed"
# clean gems cache
rm -Rf vendor/bundle/ruby/*/cache
# fix permissions
fowners -R ${MY_USER}:${MY_USER} ${dest} ${temp} ${logs}
fowners ${MY_USER}:${MY_USER} ${conf}/database.yml
fperms 640 ${conf}/database.yml
## RC script ##
local rcscript=gitlab-ci-unicorn.init
cp "${FILESDIR}/${rcscript}" "${T}" || die
sed -i \
-e "s|@USER@|${MY_USER}|" \
-e "s|@GITLAB_CI_BASE@|${dest}|" \
-e "s|@LOGS_DIR@|${logs}|" \
-e "s|@RUN_DIR@|${runs}|" \
-e "s|@QUEUES@|${SIDEKIQ_QUEUES}|" \
"${T}/${rcscript}" \
|| die "failed to filter ${rcscript}"
newinitd "${T}/${rcscript}" "${MY_NAME}"
}
pkg_postinst() {
elog
elog "1. Configure your GitLab CI's settings in ${CONF_DIR}/application.yml."
elog
elog "2. Configure your database settings in ${CONF_DIR}/database.yml"
elog " for \"production\" environment."
elog
elog "3. Adjust the webserver settings in ${CONF_DIR}/unicorn.rb"
elog
elog "4. Then you should create a database for your GitLab CI instance, if you"
elog "haven't done so already."
elog
if use postgres; then
elog "If you have local PostgreSQL running, just copy&run:"
elog " su postgres"
elog " psql -c \"CREATE ROLE gitlab_ci PASSWORD 'gitlab_ci' \\"
elog " NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;\""
elog " createdb -E UTF-8 -O gitlab_ci gitlab_ci_production"
elog " Note: You should change your password to something more random..."
elog
fi
elog "4. Finally execute the following command to initlize environment:"
elog " emerge --config \"=${CATEGORY}/${PF}\""
elog " Note: Do not forget to start Redis server first!"
elog
elog "If this is an update from previous version, it's HIGHLY recommended"
elog "to backup your database before running the config phase!"
}
pkg_config() {
einfo "Checking configuration files"
if [ ! -r "${CONF_DIR}/database.yml" ]; then
eerror "Copy ${CONF_DIR}/database.yml.* to"
eerror "${CONF_DIR}/database.yml and edit this file in order to configure your"
eerror "database settings for \"production\" environment."; die
fi
local email_from="$(ryaml ${CONF_DIR}/application.yml production gitlab_ci email_from)"
local gitlab_ci_home="$(egethome ${MY_USER})"
# configure Git global settings
if [ ! -e "${gitlab_ci_home}/.gitconfig" ]; then
einfo "Setting git user"
su -l ${MY_USER} -c "
git config --global user.email '${email_from}';
git config --global user.name 'GitLab CI'" \
|| die "failed to setup git name and email"
fi
if [ ! -d "${DEST_DIR}/.git" ]; then
# create dummy git repo as workaround for
# https://github.com/bundler/bundler/issues/2039
einfo "Initializing dummy git repository to avoid false errors from bundler"
su -l ${MY_USER} -c "
cd ${DEST_DIR}
git init
git add README.md
git commit -m 'Dummy repository'" >/dev/null
fi
## Initialize app ##
local RAILS_ENV="production"
local RUBY=${RUBY:-/usr/bin/ruby}
local BUNDLE="${RUBY} /usr/bin/bundle"
local dbname="$(ryaml ${CONF_DIR}/database.yml production database)"
if [ -f "${DEST_DIR}/.secret" ]; then
local update=true
einfo "Migrating database ..."
exec_rake db:migrate
else
local update=false
einfo "Initializing database ..."
exec_rake setup
einfo "Setting up cron schedules ..."
exec_rake whenever -w
fi
if [ "${update}" = 'true' ]; then
ewarn
ewarn "This configuration script runs only common migration tasks."
ewarn "Please read guides on"
ewarn " https://gitlab.com/gitlab-org/gitlab-ci/tree/v${PV}/doc/update"
ewarn "for any additional migration tasks specific to your previous GitLab CI"
ewarn "version."
fi
}
ryaml() {
ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
}
exec_rake() {
local command="${BUNDLE} exec rake $@ RAILS_ENV=${RAILS_ENV}"
echo " ${command}"
su -l ${MY_USER} -c "
export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8
cd ${DEST_DIR}
${command}" \
|| die "failed to run rake $@"
}

View file

@ -11,8 +11,10 @@ DIST gitlabhq-7.12.1.tar.gz 6095871 SHA256 ed14b4e81c548d0e56b2c872db76f3e9fa5a9
DIST gitlabhq-7.12.2.tar.gz 6096090 SHA256 270f0c5a03a1e7ddb7cf7556f2b13c81c1def54ef90f8919419ffa3fa0c95e05 SHA512 b1996a88e6aadfbfcaef21953db914667cfe59c090be6f6dc1b14c69e1afae2c23baae1e5af06fa2bd8a38ab86b225d7c931d1ae9c18def7e0eafe291c5e96a1 WHIRLPOOL f365922e9532e42d8553e7073ed226b4d177afe3ff9597cbd11b37615028b2e046b25fb41ed80ea0cdc086348accdb633c1f3aedb56908d2ba987b9af27f4b60
DIST gitlabhq-7.13.1.tar.gz 6364607 SHA256 ee1d57ae4daf78cd27603f9c53a20481b18cb6e0e2afad1cd73f91007d4f363d SHA512 8b2225344977b9804db54022546dc204da6ff3030253db3cc92a57ea041e916776f6de9fc99a36ebde909fd7063d0e97e6ac8377b6f957d0d67abe1481f431e2 WHIRLPOOL 3d43121c6091d95d07e07d45ba83aa3e16b0450408fae626c49543e353354687301a58603a1ffd279ab5897dbeac250457093bca9a9a787d3495ab47399a7ddd
DIST gitlabhq-7.13.2.tar.gz 6346829 SHA256 1f1b798dad393e6a6ba5497447af743b11c60866933c276304f5c3ce81795353 SHA512 58fbed4f32ff2351a90b42609cdb0907465456248e6ac39c25f1dda57fe6b0a39e42af46a973f03f1d36fbb5c62028cbe316627776bf0dc5892cfec432ada27b WHIRLPOOL 471e45674c15892233153f45da30177fa0791194524f7b10b2c0c135a5fe5895f6d89907be5a2292f38f218584b04bb7b570335d4db2319bd0c53357781b6ad3
DIST gitlabhq-7.13.4.tar.gz 6350001 SHA256 4d6c653d7f2535f909f5783511da54b57c8a3a79966dfd923d43119ccf9b1c4a SHA512 ec4fa8ab4e8e853d515253ac2482756e4ecc8d5727a64f1644c427153e7cba78ef8cdc2d9214329207976c6d62c76993938cf8d114754c93e609f435768c6f99 WHIRLPOOL 839ca10a2cd638490cd8090fb1f7c41ab8066f97ce7c8f1eafa1e60cb4a37734070bb5a636000ae43d775905df34ed36c7c8cb0902af335dc070c8e166ea3630
EBUILD gitlabhq-7.11.4.ebuild 11204 SHA256 628ea499dbe687ff9d086139a3f9df78551926507fa592c255d8b777de5b1a80 SHA512 89eec325b45024c95794ccae2d7498754d894d1d514c064dc41e1b757a96141f6489c7f394c54112604e53c21df5b178246f28eb3afccc15b5fbdc06fb691ca1 WHIRLPOOL 263f97a5f992a21b6dc64182cceb8598339406e8a8ada4954729989716ea80a47618e4596c58c3d34f9f9e86b3ec0de19047f3b249a8f59b29eca1370057a0a5
EBUILD gitlabhq-7.12.1.ebuild 10832 SHA256 e0528cb58c30189ccb6de155ea6812ec5166f2361dba25c105681ca111c9d9c5 SHA512 36cdc8aabe4fe25cd68d9138598ec0e3f6cca8a6d6d82981a645419abfa729c1b88afd7377dbbff97eebd1686cd9aac280113227516734b882ccd6fb54d9da7e WHIRLPOOL 7c0446ec2c0f08596d4182e41f895a160ebef3151a39d17d81c68e4cb18ab65b0aba84b972df8f4378f29db4c381151485270ad2c158cd8270154feb08968eda
EBUILD gitlabhq-7.12.2.ebuild 10832 SHA256 e0528cb58c30189ccb6de155ea6812ec5166f2361dba25c105681ca111c9d9c5 SHA512 36cdc8aabe4fe25cd68d9138598ec0e3f6cca8a6d6d82981a645419abfa729c1b88afd7377dbbff97eebd1686cd9aac280113227516734b882ccd6fb54d9da7e WHIRLPOOL 7c0446ec2c0f08596d4182e41f895a160ebef3151a39d17d81c68e4cb18ab65b0aba84b972df8f4378f29db4c381151485270ad2c158cd8270154feb08968eda
EBUILD gitlabhq-7.13.1.ebuild 10831 SHA256 c6ab27d9a22e3648161b11d722940abd44729ad051eefd59894c01d55aece8a5 SHA512 3b8800099bea40594d048fb99f5ff8bb261814d744497c49af45382eb2e812a1c7c647e97f02ecf61f953245345abb9318f0489a2a1a3be70cbec42c6838ef49 WHIRLPOOL aad3e5547a634ae2da8ef290719f1a3e069f49d3074f72ea291bd341131c7c4fdc5dc96e8c98c266678f291327a199f79ac884b1a3f6171a1684c21e0a4d3011
EBUILD gitlabhq-7.13.2.ebuild 10839 SHA256 48835c96e66b030dbca438044a3f9dec651ae7784b9d413b2daf06d1a97407f7 SHA512 e8cbb370f443868a3ef436daeefd9baed47bb11af46f6d85d257bd0d4447598493abb98279c2ed4f0c984ba85cdde7c26a2ae723a55de53fbad18f52fcd7f882 WHIRLPOOL d57f7ea1cad689b319a3bab541deb5dee18218f9d2073367eb3d6b801423e919d0c666e98dc029e295a0f259d1a74e3cabfeef7a706822ee0f903ce82d6dabf8
EBUILD gitlabhq-7.13.4.ebuild 11029 SHA256 86082710ac6452eaf2c695b057bf19e095b337b74071c85bc7c3bad5e34e80e6 SHA512 4bd2b77e766c226786c970d73ca0d447f03fa5c5351db0cb1518f6bc315b5d3fe0bbb1fb6f0e66f35c49ad9bb90c8e2e4d6c330292251969e5ea74769541a9d8 WHIRLPOOL 67c897e22a2dc2774ad668d0891d223f0de4bdd4a87516e4245027a5d3d9d6328c196a2d652de55082ac08b7183d8240860cf3698cb6895cf06fad0adc3def08

View file

@ -0,0 +1,366 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="5"
# Maintainer notes:
# - This ebuild uses Bundler to download and install all gems in deployment mode
# (i.e. into isolated directory inside application). That's not Gentoo way how
# it should be done, but GitLab has too many dependencies that it will be too
# difficult to maintain them via ebuilds.
#
USE_RUBY="ruby20 ruby21"
PYTHON_DEPEND="2:2.7"
inherit eutils python ruby-ng user systemd
DESCRIPTION="GitLab is a free project and repository management application"
HOMEPAGE="https://github.com/gitlabhq/gitlabhq"
SRC_URI="https://github.com/gitlabhq/gitlabhq/archive/v${PV}.tar.gz -> ${P}.tar.gz"
#SRC_URI="https://github.com/gitlabhq/gitlabhq/archive/v7.11.0.rc2.tar.gz -> ${P}.tar.gz"
#RUBY_S="${PN}-7.11.0"
RESTRICT="mirror"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="kerberos mysql +postgres +unicorn systemd rugged_use_system_libraries"
## Gems dependencies:
# charlock_holmes dev-libs/icu
# grape, capybara dev-libs/libxml2, dev-libs/libxslt
# rugged dev-util/cmake, virtual/pkgconfig
# json dev-util/ragel
# pygments.rb python 2.7+
# execjs net-libs/nodejs, or any other JS runtime
# pg dev-db/postgresql
# mysql virtual/mysql
#
GEMS_DEPEND="
dev-libs/icu
dev-libs/libxml2
dev-libs/libxslt
dev-util/cmake
dev-util/ragel
net-libs/nodejs
postgres? ( dev-db/postgresql )
mysql? ( virtual/mysql )
kerberos? ( virtual/krb5 )
virtual/pkgconfig"
DEPEND="${GEMS_DEPEND}
>=dev-vcs/gitlab-shell-2.6.3
dev-vcs/git
kerberos? ( !app-crypt/heimdal )
rugged_use_system_libraries? ( net-libs/http-parser >=dev-libs/libgit2-0.22.0 )"
RDEPEND="${DEPEND}
dev-db/redis
virtual/mta
systemd? ( sys-apps/systemd:0= )"
ruby_add_bdepend "
virtual/rubygems
>=dev-ruby/bundler-1.0"
#
# fix-gemfile:
# Remove therubyracer that doesn't compile well on Gentoo (we're using
# nodejs instead that is faster and better). Also replace broken
# charlock_holmes version with fixed one.
#
# fix-sendmail-config:
# Fix default settings to work with ssmtp that doesn't know '-t' argument.
#
RUBY_PATCHES=(
"${PN}-7.13.1-fix-gemfile.patch"
"${PN}-fix-sendmail-config.patch"
)
MY_NAME="gitlab"
MY_USER="git" # should be same as in gitlab-shell
DEST_DIR="/opt/${MY_NAME}"
CONF_DIR="/etc/${MY_NAME}"
LOGS_DIR="/var/log/${MY_NAME}"
TEMP_DIR="/var/tmp/${MY_NAME}"
# When updating ebuild to newer version, check list of the queues in
# https://gitlab.com/gitlab-org/gitlab-ce/blob/v${PV}/bin/background_jobs
SIDEKIQ_QUEUES="post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default"
all_ruby_prepare() {
# fix paths
local satellites_path="${TEMP_DIR}/repo_satellites"
local repos_path=/var/lib/git/repositories
local shell_path=/usr/share/gitlab-shell
sed -i -E \
-e "/satellites:$/,/\w:$/ s|(\s*path:\s).*|\1${satellites_path}/|" \
-e "/gitlab_shell:$/,/\w:$/ s|(\s*path:\s).*|\1${shell_path}/|" \
-e "/gitlab_shell:$/,/\w:$/ s|(\s*repos_path:\s).*|\1${repos_path}/|" \
-e "/gitlab_shell:$/,/\w:$/ s|(\s*hooks_path:\s).*|\1${shell_path}/hooks/|" \
config/gitlab.yml.example || die "failed to filter gitlab.yml.example"
local run_path=/run/${MY_NAME}
sed -i -E \
-e "s|/home/git/gitlab/tmp/(pids\|sockets)|${run_path}|" \
-e "s|/home/git/gitlab/log|${LOGS_DIR}|" \
-e "s|/home/git/gitlab|${DEST_DIR}|" \
config/unicorn.rb.example || die "failed to filter unicorn.rb.example"
sed -i \
-e "s|/home/git/gitlab/tmp/sockets|${run_path}|" \
lib/support/nginx/gitlab || die "failed to filter nginx/gitlab"
# modify default database settings for PostgreSQL
sed -i -E \
-e 's|(username:).*|\1 gitlab|' \
-e 's|(password:).*|\1 gitlab|' \
-e 's|(socket:).*|\1 /run/postgresql/.s.PGSQL.5432|' \
config/database.yml.postgresql \
|| die "failed to filter database.yml.postgresql"
# rename config files
mv config/gitlab.yml.example config/gitlab.yml
mv config/unicorn.rb.example config/unicorn.rb
local dbconf=config/database.yml
if use postgres && ! use mysql; then
mv ${dbconf}.postgresql ${dbconf}
rm ${dbconf}.mysql
elif use mysql && ! use postgres; then
mv ${dbconf}.mysql ${dbconf}
rm ${dbconf}.postgresql
fi
# remove useless files
rm -r lib/support/{deploy,init.d}
use unicorn || rm config/unicorn.rb
}
all_ruby_install() {
local dest=${DEST_DIR}
local conf=${CONF_DIR}
local logs=${LOGS_DIR}
local temp=${TEMP_DIR}
# prepare directories
diropts -m750
dodir ${logs} ${temp} ${temp}/repo_satellites
diropts -m755
dodir ${conf} ${dest}/public/uploads
dosym ${temp} ${dest}/tmp
dosym ${logs} ${dest}/log
# install configs
insinto ${conf}
doins -r config/*
dosym ${conf} ${dest}/config
echo 'export RAILS_ENV=production' > "${D}/${dest}/.profile"
# remove needless dirs
rm -Rf config tmp log
# install the rest files
# using cp 'cause doins is slow
cp -Rl * "${D}/${dest}"/
# install logrotate config
dodir /etc/logrotate.d
cat > "${D}/etc/logrotate.d/${MY_NAME}" <<-EOF
${logs}/*.log {
missingok
delaycompress
compress
copytruncate
}
EOF
## Install gems via bundler ##
cd "${D}/${dest}"
local without="development test aws"
local flag; for flag in mysql postgres unicorn kerberos; do
without+="$(use $flag || echo ' '$flag)"
done
local bundle_args="--deployment ${without:+--without ${without}}"
use "rugged_use_system_libraries" && export RUGGED_USE_SYSTEM_LIBRARIES="YES"
einfo "Running bundle install ${bundle_args} ..."
${RUBY} /usr/bin/bundle install ${bundle_args} || die "bundler failed"
# clean gems cache
rm -Rf vendor/bundle/ruby/*/cache
# fix permissions
fowners -R ${MY_USER}:${MY_USER} ${dest} ${temp} ${logs}
## RC script ##
if use systemd ; then
ewarn "Beware: systemd support has not been tested, use at your own risk!"
systemd_dounit "${FILESDIR}/gitlab-sidekiq.service"
systemd_dounit "${FILESDIR}/gitlab-unicorn.service"
systemd_dotmpfilesd "${FILESDIR}/gitlab.conf"
else
local rcscript=gitlab-sidekiq.init
use unicorn && rcscript=gitlab-unicorn.init
cp "${FILESDIR}/${rcscript}" "${T}" || die
sed -i \
-e "s|@USER@|${MY_USER}|" \
-e "s|@GITLAB_BASE@|${dest}|" \
-e "s|@LOGS_DIR@|${logs}|" \
-e "s|@QUEUES@|${SIDEKIQ_QUEUES}|" \
"${T}/${rcscript}" \
|| die "failed to filter ${rcscript}"
newinitd "${T}/${rcscript}" "${MY_NAME}"
fi
}
pkg_postinst() {
elog
elog "1. Configure your GitLab's settings in ${CONF_DIR}/gitlab.yml."
elog
elog "2. Configure your database settings in ${CONF_DIR}/database.yml"
elog " for \"production\" environment."
elog
elog "3. Then you should create a database for your GitLab instance, if you"
elog "haven't done so already."
elog
if use postgres; then
elog "If you have local PostgreSQL running, just copy&run:"
elog " su postgres"
elog " psql -c \"CREATE ROLE gitlab PASSWORD 'gitlab' \\"
elog " NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;\""
elog " createdb -E UTF-8 -O gitlab gitlabhq_production"
elog " Note: You should change your password to something more random..."
elog
fi
elog "4. Finally execute the following command to initlize environment:"
elog " emerge --config \"=${CATEGORY}/${PF}\""
elog " Note: Do not forget to start Redis server first!"
elog
elog "If this is an update from previous version, it's HIGHLY recommended"
elog "to backup your database before running the config phase!"
elog
elog "If you're running GitLab behind an SSL proxy such as nginx or Apache and"
elog "you can't login after the upgrade, be sure to read the section about the"
elog "verification of the CSRF token in GitLab's trouble-shooting guide at"
elog "http://goo.gl/5XGRGv."
}
pkg_config() {
local shell_conf='/etc/gitlab-shell.yml'
einfo "Checking configuration files"
if [ ! -r "${CONF_DIR}/database.yml" ]; then
eerror "Copy ${CONF_DIR}/database.yml.* to"
eerror "${CONF_DIR}/database.yml and edit this file in order to configure your"
eerror "database settings for \"production\" environment."; die
fi
# check gitlab-shell configuration
if [ -r ${shell_conf} ]; then
local shell_repos_path="$(ryaml ${shell_conf} repos_path)"
local gitlab_repos_path="$(ryaml ${CONF_DIR}/gitlab.yml \
production gitlab_shell repos_path)"
if [ ! "${shell_repos_path}" -ef "${gitlab_repos_path}" ]; then
eerror "repos_path in ${CONF_DIR}/gitlab.yml and ${shell_conf}"
eerror "must points to the same location! Fix the repos_path location and"
eerror "run this again."; die
fi
else
ewarn "GitLab Shell checks skipped, could not find config file at"
ewarn "${shell_conf}. Make sure that you have gitlab-shell properly"
ewarn "installed and that repos_path is the same as in GitLab."
fi
local email_from="$(ryaml ${CONF_DIR}/gitlab.yml production gitlab email_from)"
local git_home="$(egethome ${MY_USER})"
# configure Git global settings
if [ ! -e "${git_home}/.gitconfig" ]; then
einfo "Setting git user"
su -l ${MY_USER} -c "
git config --global user.email '${email_from}';
git config --global user.name 'GitLab'" \
|| die "failed to setup git name and email"
fi
if [ ! -d "${DEST_DIR}/.git" ]; then
# create dummy git repo as workaround for
# https://github.com/bundler/bundler/issues/2039
einfo "Initializing dummy git repository to avoid false errors from bundler"
su -l ${MY_USER} -c "
cd ${DEST_DIR}
git init
git add README.md
git commit -m 'Dummy repository'" >/dev/null
fi
## Initialize app ##
local RAILS_ENV="production"
local RUBY=${RUBY:-/usr/bin/ruby}
local BUNDLE="${RUBY} /usr/bin/bundle"
local dbname="$(ryaml ${CONF_DIR}/database.yml production database)"
if [ -f "${DEST_DIR}/.secret" ]; then
local update=true
einfo "Migrating database ..."
exec_rake db:migrate
# https://github.com/gitlabhq/gitlabhq/issues/5311#issuecomment-31656496
einfo "Migrating iids ..."
exec_rake migrate_iids
einfo "Cleaning old precompiled assets ..."
exec_rake assets:clean
einfo "Cleaning cache ..."
exec_rake cache:clear
else
local update=false
einfo "Initializing database ..."
exec_rake gitlab:setup
fi
einfo "Precompiling assests ..."
exec_rake assets:precompile
if [ "${update}" = 'true' ]; then
ewarn
ewarn "This configuration script runs only common migration tasks."
ewarn "Please read guides on"
ewarn " https://github.com/gitlabhq/gitlabhq/blob/master/doc/update/"
ewarn "for any additional migration tasks specific to your previous GitLab"
ewarn "version."
fi
}
ryaml() {
ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
}
exec_rake() {
local command="${BUNDLE} exec rake $@ RAILS_ENV=${RAILS_ENV}"
echo " ${command}"
su -l ${MY_USER} -c "
export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8
cd ${DEST_DIR}
${command}" \
|| die "failed to run rake $@"
}