added ebuilds for www-apps/gitlab{hq,-ci}-7.14.1. this version requires ruby21.

This commit is contained in:
Manuel Friedli 2015-09-01 13:51:19 +02:00
parent 5747cf3ff7
commit b8b7b97ed0
4 changed files with 679 additions and 0 deletions

View File

@ -6,6 +6,7 @@ DIST gitlab-ci-7.13.1.tar.gz 754531 SHA256 5b0b05503c7d38ff35c5ccd6bbe81be97460e
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
DIST gitlab-ci-7.13.5.tar.gz 754582 SHA256 2318640561cca55d0dc54db6dcbe1320628438c42e3a4e23015168e2150d5444 SHA512 cf0f7a586e83872b483a29522cd8143ccd9cbecba99e5c1c9842d4a29434e04a607e20238fdec523d515ac7a905b160a12c15598d838eb27e2f8bacdca9b52b3 WHIRLPOOL 29f73a3f9c02e66d04e9b257ce18d3250b51e96df2ad7d0bc61979dd9bf0179e594d9c39a02a39fb8564fc923cb8592a967152dadd20597dfbe536dfe6291520
DIST gitlab-ci-7.14.1.tar.gz 1103265 SHA256 4f856217ac395d296395f42943dc1b3561a49df4a43635860a204a1b3a8b763c SHA512 85283ddacdb4bfec60a479793d0380aa0db542e642c37a64b7eff6153e99105e1e26f11990bd767a996eb8d1deffe243c8eaa59ecd942cd5b37c85e940b3113b WHIRLPOOL c60506ea1a3399215fa2a39af55728d340054ef45f1886e57e110703a93a3fb8b6fb9d5cea1bb34ad112a58fad1d84c03e6b3c243a089cec08a7e2cd0c450c15
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
@ -13,3 +14,4 @@ EBUILD gitlab-ci-7.13.1.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b
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
EBUILD gitlab-ci-7.13.5.ebuild 8552 SHA256 5a398564d49986ca891a6c3f62cfc08d31b4b56d96f71c9d89f333f582f9f967 SHA512 9f4aa8569954e28e9081262560192e224d4a1bf80ca73dca6349d0b08f14218e7841d516b9a0d93dca2923e7a49e0093a5d397a224f7e417cf5d65ff498e74f3 WHIRLPOOL 8d27bb147d1f858259ff2b9bd208c7a05bad8cb2057ce5ee56462fb4a9fb2eb9c417ca344cfd66a9a715aeec429988c34ca4dd9495bf1f6529082d3ba509d358
EBUILD gitlab-ci-7.14.1.ebuild 8545 SHA256 1aa8d73cb86eaf49d1d9e540d1b842ca823e1e2634312611b2cf0caf92536556 SHA512 c2b3e4c17bebcbae5c98db6458099bba05f881772a322893e06797592001a49178bc8f2a2c970a8d2276f3be568c288f821b640470581a0b1b8067c9fbae897a WHIRLPOOL 0dcbd3385b7c75d78afc4329231ec1a5a4e593a7aa9f8a1aad38ac82b281e2ea6c135fdff2a9be90ace9af0c4927fdbc4c2d5253c1c34e85e3e389c7e46f7dec

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="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

@ -13,6 +13,7 @@ DIST gitlabhq-7.13.1.tar.gz 6364607 SHA256 ee1d57ae4daf78cd27603f9c53a20481b18cb
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
DIST gitlabhq-7.13.5.tar.gz 6350133 SHA256 d49e8812b84c3411fe5d246822e5c6fd3fd755e1605ef3a143daf4863ac56d61 SHA512 4df9969c0983ba069c242cf52d495abe5f6f687072c31922240cc046192f8b16a09b45249ffd7ea49bc601537d8f96c5ae6c7cc545f4a62ba1f75b92c9dae672 WHIRLPOOL 95a24c0e3525f052998b38f426348b5b23a9b9317ef2ee5cf193fcc96547047a30c29857af5bfcc9c067a4e936148924a31d64c37aeb0fb0f295e9e0bede6ed8
DIST gitlabhq-7.14.1.tar.gz 6393565 SHA256 a906fb35aaff415e0ca6ff053fecf6c97c0a9a2afc3a2da7b45b8bbb61aca75a SHA512 09912a4da7d64f0a6f26935e4ef73108908822ff0239fabbe36631f27389a02153ec4b116c0624336460971d5bd3f1e1c33214068e4513a86bd39cd29422ff70 WHIRLPOOL 9600dcad2d52a5494a44078dce46a00353134b8b727430ac264713489d982d4bb57d9e8a156cf86f3d297d8d6fe66f8aa3ea4d39e7b50b4a7f7ac3cadfcd62a0
EBUILD gitlabhq-7.11.4.ebuild 11217 SHA256 7c477ab21bc72ba0ebd9f2279cb168b30756b171ac5b0469c6225d7fb46f86ef SHA512 502c220cbb551d6fa66ce773ace9e4d7ef3f4a70bcd79bfbd535ccfa1845571b3d1ee8fd60dca086c24f58f573bda4ffd91583896d25dbd592f598a7cde182e5 WHIRLPOOL f35ae007f5c12521d983f18847182ce097af595052c7598e4667b2606c901cab46fe46e13b5e2c7bd83960dd9538c4753ffbb1bde71ec60230d98cf9a3423f63
EBUILD gitlabhq-7.12.1.ebuild 10845 SHA256 0d70e40a3ba00e3d073ba5c0c0af3ad29b6a2acb0304406fc05ee80ee7783333 SHA512 6fccf6a9cb8047896d97153e2e64da6200f3cbb7ba9428eae11a2b8c0b05bc3c97363c3c306a649528c56efabfdc1771ab3b5daee840da5c1b7a522697f9b243 WHIRLPOOL 0b4088bcd4fe62ff84ff159a34560e49b761c060ad60da9726e7261f8a88ff0336f0403fb160a995254c64322fb40b35ab5378d593f6a15f89e45c10a6645984
EBUILD gitlabhq-7.12.2.ebuild 10845 SHA256 0d70e40a3ba00e3d073ba5c0c0af3ad29b6a2acb0304406fc05ee80ee7783333 SHA512 6fccf6a9cb8047896d97153e2e64da6200f3cbb7ba9428eae11a2b8c0b05bc3c97363c3c306a649528c56efabfdc1771ab3b5daee840da5c1b7a522697f9b243 WHIRLPOOL 0b4088bcd4fe62ff84ff159a34560e49b761c060ad60da9726e7261f8a88ff0336f0403fb160a995254c64322fb40b35ab5378d593f6a15f89e45c10a6645984
@ -20,3 +21,4 @@ EBUILD gitlabhq-7.13.1.ebuild 10844 SHA256 8abfb869da634a1741bc913f9a62067f4d557
EBUILD gitlabhq-7.13.2.ebuild 10852 SHA256 03c4884a314b7bc4e50959ebdc04e844a845477e01bfae59a96c1c21a12bed43 SHA512 c19fd85ae870961620c592a3138997f08cc97f346b7d528820d735df4430dea04baca58bfbb5522c6a880bb7a4b05b60e82e2dd9f6ec40d8562a036d34a323a5 WHIRLPOOL 93b8600cb228e429831fb3c61d57dba204605b02f9048b7b89158268abe146e56b9185cd911c1ba9422214495e89eea39eadab1a8a97dce657ba9221352e23a2
EBUILD gitlabhq-7.13.4.ebuild 11040 SHA256 7c92176dfe88c544de7f9ffa2fb4ca848ff567a55feee25e70c1a267c00f51d8 SHA512 62cf7b697be431e09f1c4e3e0df3f31be1dab098a508f1cce295cf814143baaf39d240039d7db0370d7e74f5388066abd25b6d4ca5e9976daa25fbcc5f95fc6d WHIRLPOOL 561406c358fb868bed26a989915a6bd6987a318f23e5d5ec06e9ed6d920b7a796819290bdfeb4608394afc21d10c28176c7754bcf19692933ba22a845287b86a
EBUILD gitlabhq-7.13.5.ebuild 11040 SHA256 7c92176dfe88c544de7f9ffa2fb4ca848ff567a55feee25e70c1a267c00f51d8 SHA512 62cf7b697be431e09f1c4e3e0df3f31be1dab098a508f1cce295cf814143baaf39d240039d7db0370d7e74f5388066abd25b6d4ca5e9976daa25fbcc5f95fc6d WHIRLPOOL 561406c358fb868bed26a989915a6bd6987a318f23e5d5ec06e9ed6d920b7a796819290bdfeb4608394afc21d10c28176c7754bcf19692933ba22a845287b86a
EBUILD gitlabhq-7.14.1.ebuild 11048 SHA256 f8d88a0100407e3b3cf45f014be6b6d31c9f0dde308bb8ce8e8b1748f6684dc3 SHA512 cefce1845875f482b7bdbc09847129418218986b4bdb1e6199f2a045dd4ecc65632e5183c3a85c4866600f7deb955f508ba79531a25c644950770b8c83891c23 WHIRLPOOL 808c168bd64e159b56ed2c7422f0fa85a9610b5fb8283f946eed1e11e118032f163695b1093c911868c864dd4aa6840d8e38eda20cdc4a037e7898063d602e52

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="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* )"
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,archive_repo,system_hook,project_web_hook,gitlab_shell,incoming_email,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 $@"
}