diff --git a/www-apps/gitlabhq/Manifest b/www-apps/gitlabhq/Manifest index e46036f..1999264 100644 --- a/www-apps/gitlabhq/Manifest +++ b/www-apps/gitlabhq/Manifest @@ -41,6 +41,8 @@ AUX gitlabhq-7.0.0-ldap-custom-mapping.patch 2708 SHA256 8592744ba8b373b2e89c76d AUX gitlabhq-7.1.1-fix-gemfile.patch 2184 SHA256 9ba304baa5a17f1b0637fe243f551ddcc22cf32c3e82b7dc5b1a5cc0c5fc5876 SHA512 db8757874f136fc6a1d138feadbad6f8dfc773446f969b76a4715901dac02c04c978133ef3e9218b9c4a3d0173f53c0d14608ae123ee300a803529cbf232a1d1 WHIRLPOOL 27adf9392f3f1cbc6288afc1aabc174850a689f47f015c9d638b62769607e6e4f5ebe8bcb3811ee189ceeddef7c5bca384b322d15c0008b8867887f26d6188e2 AUX gitlabhq-7.1.1-fix-project-name-regex.patch 638 SHA256 9f3dfcdc4365422037ecc8854b10e2cf96f4fb9508a6d5214b16c3545ca1353b SHA512 4606eade95b75e31eb791d793e3571c4e998c2d451e1f92ce70fba06e3a29c74a17f2fedba24ded4dbdc6db3da87960890552869fd8790caed26ff6fbb201717 WHIRLPOOL 6470de727d060556cc1413ac23f3c3198035f3cd7b05a291f7dedfcd9071a5afecca57c15f7387a84d9c1830118e47fae4fc72ba2f2e67c346bf18c4dae09865 AUX gitlabhq-7.6.2-fix-gemfile.patch 2402 SHA256 9abfdff94da0fe5b6db4d740688af179b93cf56c1ecb915c12bc0a5440295c4b SHA512 ce948a768a0803794e102b062fcdfc7569879f3ac649a1cc86f222053810dc758dbecc41834d06a1f6a3e5e03cf36dcb368e24a47401dfac7f6b8c5197706359 WHIRLPOOL ac7696de8bd143dec22cf3e31807249bd1bb58424edeb8de7745afffa8007ecefd577ce11dfe5de2080d87ab19eb7198ddd2d89f06eb96b5e4c70e2476594f27 +AUX gitlabhq-7.7.1-fix-gemfile.patch 2322 SHA256 0ae2e911fdd2b8c4902222b19efb73d12178c40a9e17a8c98b272ae7378782ab SHA512 d1c4f79325bfe4ec71befe209264339baa61c3028e884318d718a4115eaa866d594e88b5f6b222beb0746cf7e07e92012b3097bb287da01df025d1ed7fad5987 WHIRLPOOL 253e496a91453f90ab640ccb03bc02f2e1ee9a439a3278a6d21feb36d87518d7b834c7f2a012ad14c2bbc42b36817f7d8a093940f91a2d913bf7913191193a7a +AUX gitlabhq-7.7.1-fix-project-name-regex.patch 715 SHA256 b026094b1f910226ddef2365d55d555ba6ebb99c17abc1eceb3906a101bf9f1b SHA512 041eb436089508266a572ec97d5c2d934747f1937fedb81bc18b9a85ace663cd0628d409e037e78d7381c8e968b9913121e09ca152fa35a7b372642b93643cdf WHIRLPOOL d548d403201be0068027dc73b63870845c6c109ee820af4495ed9969165a0fa39a837c0343fe2686a297f845dcc7306fa71fd98ff4941ccf584842d1046748b9 DIST gitlabhq-6.7.5.tar.gz 10229484 SHA256 547ed2807cccf08c11450a9df035dad8db66ab9f9d693db29e3aa1ee65edbae0 SHA512 a90c0cd3954bf20ece9e98626216a42afcb0cc07e0cb23874ab2065757805ac38a8dcf4e93d804a33caeecaf2c6e94d8566f5700cd4161ef9a0aaac089b9ded8 WHIRLPOOL 4d8f5ff3a1245c5e13fc3ff8f819160017dd4dba9f6a48c0f851272da5c97f45162d3e53f327002f1ecde7f31dd5f392bed8503b1b306d913bf63827777cdbcd DIST gitlabhq-6.8.2.tar.gz 10558471 SHA256 db9400d5ffadd3564bbee6e388c90d7f4c8f88450e67213aad11df2d137534ec SHA512 0f57c6bb3b9e89a5bbf7ae4c774e54480518f185f2e50270a7dd921eb2a2322f3e6866ca70741582fad4f99b372ba025fbab15108c291d53ebf04cfaec2f9b75 WHIRLPOOL 73ebd0fb0faef7afd48398ec4e73c8f4175f3dc2a9450ae391b4d3a66b54e0d77f901f518738eb98cc267691559094d4ebecd4c0a7c18fa671c3a1aee4dfe4d2 DIST gitlabhq-6.9.2.tar.gz 10566288 SHA256 2c01b223c3e889c7a45d3815f352c0546a337286d395e4d49df5ecedc1a57dc0 SHA512 b51b4e261666c14f782ce7edbbda24b6d32bb080c5444249f5c38e5233398b30f50a17cc8cbee18d75e57ba11ec3deeab4ffd1a6d6257c1858f8fe63e5138e54 WHIRLPOOL a3b9a8149fab69443b769aa145eb2c9a99bfc9f4a080edf0a6bd46c4771247b6f1c729bf5185e63bf63a02d654145362b7c8e9fefef6f0cdf1f4f30a32cf9dcb @@ -56,6 +58,7 @@ DIST gitlabhq-7.4.3.tar.gz 4189957 SHA256 e03092298526bafb65336a14944570083f96e9 DIST gitlabhq-7.5.1.tar.gz 4221894 SHA256 cbaef29b55c35b1428fb4678be76500e7f0c292aa72314fa457d94c61fb5e00d SHA512 fc99100aab666819c06df96fc7979cb108a42249d811482c64473a51ec38e89d325346a4e069666a9130cff9eab21a470e68724cbe53d135bf4dc3b52a6b8930 WHIRLPOOL d86887f196cdc8d2690ff0a788c70994b7192d39b89d47c63a8b0baad8102c22efac3b3dc6556eefba7bb5cb12aaad347e5adb7d9a5a591fd8ca1d7de3a5b493 DIST gitlabhq-7.5.3.tar.gz 4222058 SHA256 533afcf5b9a0683d2f920a436e552af8d8e953c78d03f150cfb8dcfa0da3112d SHA512 18e9d5ee9d39c8e11101d370228b8edd38ccbfc1b7d768977f3cdd575604d7f72f897484749f9d74988b91f8195c0b9452a47a6f83acb6a7890d4aac9dd9f1a7 WHIRLPOOL 0bf347b12c2d2b5d4bf4bbcd0ff790bccfa100d0ff818a77e0843e3ff1ce87a627cd541bd7e5d8160f0954477809c8539ac1c309c3bcbc0e0b517ad3f30193de DIST gitlabhq-7.6.2.tar.gz 4238734 SHA256 bc8f92dacca6be48c7a34b60a727e0755a44742500164c131dde7b88bedb71f0 SHA512 ecff2159536c72c82e34aadaaa02e2ee29ec494e7caf132665139622dcb6ba94af15295a0a8bbdeb550a9c2777284cd67cf57b7940b49da98e288a48577ba1b0 WHIRLPOOL 8b4fa295e82c9d61cc0c9a0e5e84b65ac2528f4afacada065e37214234b98d6aee90abe9d1599b8827e459f5ad503fccbab00f1d7528b89735f1617f4d55507c +DIST gitlabhq-7.7.1.tar.gz 4438938 SHA256 b3399006bb7b89c1622bee52562bff4ab9681fe4c31c127858c39dfb720e1bb1 SHA512 378ba79ad7d191895fc54b3f99ca2ff1e871e07a4557a0dab3b03f3815dfe6fec069f47da58573ad21acb25ed5d7efb249b79c65655c7607db0f9c4f6a2597bb WHIRLPOOL f87d3a8aeac0a3a6dce39806e5e2df7c9a852578627a1ee5875625795044cbe655fff1ffb7635d7cedda662b55c87959cd14f3e9f2e74e075e72a288c5ad4850 EBUILD gitlabhq-6.7.5.ebuild 10973 SHA256 d74d454bd9972f15d21a3454e39a78ab042ccb3444cbbedb25da01d40335361b SHA512 b5494ee857055022da0803277d6a8b84d1fa1d9af66a853eedafdd3fa4993dfe4a66962581234333b16f41b6d605cfe6a207a4d2706c90d921fbc54474deb296 WHIRLPOOL 03026c7b7029c8bc7d5e5ad05c38e4b507be6c4f36b488753120d7d0849522a9e557c5b04adcac4c22eced0fbc1432fd16e7447198092b6691ccc529147d9dcf EBUILD gitlabhq-6.8.2.ebuild 10595 SHA256 24317d99bb9d0e220c11a37709b1b701b9cd7bf7b9fe3adead666c531569dcf0 SHA512 2f3f5e38b33edfdff35f3888e694984e97d897d7c64c0aa6cc35149d253e7211560dbd918b12e891c0d1d009241e53e255a2a3be91beb5a3954d148c4554315e WHIRLPOOL 4dca44d6e271ec14252e3a4690e6736d64133d3d115ec19b77d37cb5a2a3d3a46e9820dae48df5d7fa79dd0ca9c6b178b9dca85811bc0e78b7964580b0696b59 EBUILD gitlabhq-6.9.2.ebuild 10616 SHA256 4221acadb5ac65ca3d662a2a560ff6343e04e0ca14dbd1b5bdd8f6a07812f7be SHA512 161c587d219c0dfd54b92805f7378aa7b1750bb25e632a16b67e3d24b28fab95f8f4272d685dfc70f1d7bfb15449a208fbb8b343dd8f902d8855034ed7f855d1 WHIRLPOOL effe560de13a29de88bf42aa927ddc2781373722a0e9a83ebef8942b0128208e35658a6b43d1bdc2d6e2b80c43b836dc8cc431f5d38912c201c789f70076e245 @@ -73,3 +76,4 @@ EBUILD gitlabhq-7.5.1.ebuild 10904 SHA256 821abc6ca9c2b87f18aa3279068ead6c25ed5d EBUILD gitlabhq-7.5.3-r1.ebuild 10907 SHA256 3c8b8cabc75968beda5a351b746ab53c7e644d16c437bc54af51fd62283a1917 SHA512 e42b3605ab405a798467713f723ddff553ecef81b2f16baad9bd93653da15fb23e47aa7f28d5cc93eaabf3e8eeb70201dc6f8ae6192b42da82be0a754e54704d WHIRLPOOL eae1bb4dc43c178f61fd8fe5784c1e02f385969dc7237ce9c140774266f4a583f911617014602c1e72c0f8f525edc7b6e620c748045419640f0f0bdc8dc6f0d3 EBUILD gitlabhq-7.5.3.ebuild 10904 SHA256 821abc6ca9c2b87f18aa3279068ead6c25ed5d652a0ac725dc5c53a6eb9baf08 SHA512 f0ff1487b022ed7884a4883b4e0fe36229918a3c93ea24ed315da7eda8cbc664974444e4efb7275e26008c5ef75e872d0fe1f76eda43d7aaa2223649faf5d554 WHIRLPOOL a20c720e9ad3a440b89d09df0a02dfef4f63cfab2102a69da20e5f38925daf97f8a8d339e4c9d997e0f0a05b9f71ad3932d6cdc20e6561696d2286bb7d510589 EBUILD gitlabhq-7.6.2.ebuild 10911 SHA256 f0fe0342c47c7e0d6ae10e080f56198c752454bddbe8910092124c290c40e716 SHA512 34ae28951cb92b6c01e21c421a156ffd35c45b75f3e4d4701e46da71f13a921fc291c146ee3436e39d68898ae4ee107aa558d63429aa4f96344502654e8c6ee9 WHIRLPOOL 3a43aa3d336ba926a4d9703b96472eddcadf55bc966e65fcf3eca8ee0070effcc0920a18c4f376f1292c64dcbceccd6733c6010ab03db3dfc98f25d0da5b7c6c +EBUILD gitlabhq-7.7.1.ebuild 10904 SHA256 f9e77cfebae0862b9c5077622e53672aaaea9f5907ad246c937996abc393321a SHA512 3dee148099c831a3a37d1b73b425c55034eeb17e14f3e3f5fdccabd21e773f1ee4eb70361c2d85e1b9ae90aeba294df6e6f0d0598bec06776e4f300e806b1320 WHIRLPOOL 836b1ee166421e3bf4537fadf9dd5f4104b1322824770f987575550de9f2b811c3897759f0434817ca4825281828bcf71316d1396b8820ecee32e54f9a8b8196 diff --git a/www-apps/gitlabhq/files/gitlabhq-7.7.1-fix-gemfile.patch b/www-apps/gitlabhq/files/gitlabhq-7.7.1-fix-gemfile.patch new file mode 100644 index 0000000..8fa62a7 --- /dev/null +++ b/www-apps/gitlabhq/files/gitlabhq-7.7.1-fix-gemfile.patch @@ -0,0 +1,97 @@ +diff --git a/Gemfile b/Gemfile +index b403e85..03f48ed 100644 +--- a/Gemfile ++++ b/Gemfile +@@ -160,6 +160,10 @@ gem "underscore-rails", "~> 1.4.4" + # Sanitize user input + gem "sanitize", '~> 2.0' + ++# The newer revision of charlock_holmes that is finally fixed to ++# be compatible with Gentoo ++gem "charlock_holmes", git: "https://github.com/brianmario/charlock_holmes.git", ref: "dde194609b3513b0d2369ce8f916ae52566154b4" ++ + # Protect against bruteforcing + gem "rack-attack" + +@@ -259,7 +263,6 @@ end + + group :production do + gem "gitlab_meta", '7.0' +- gem "therubyracer" + end + + gem "newrelic_rpm" +diff --git a/Gemfile.lock b/Gemfile.lock +index c6aa35a..531a483 100644 +--- a/Gemfile.lock ++++ b/Gemfile.lock +@@ -1,3 +1,10 @@ ++GIT ++ remote: https://github.com/brianmario/charlock_holmes.git ++ revision: dde194609b3513b0d2369ce8f916ae52566154b4 ++ ref: dde194609b3513b0d2369ce8f916ae52566154b4 ++ specs: ++ charlock_holmes (0.6.9.4) ++ + GEM + remote: https://rubygems.org/ + specs: +@@ -64,7 +71,6 @@ GEM + json (>= 1.7) + celluloid (0.15.2) + timers (~> 1.1.0) +- charlock_holmes (0.6.9.4) + cliver (0.3.2) + code_analyzer (0.4.3) + sexp_processor +@@ -285,7 +291,6 @@ GEM + addressable (~> 2.3) + letter_opener (1.1.2) + launchy (~> 2.2) +- libv8 (3.16.14.7) + listen (2.3.1) + celluloid (>= 0.15.2) + rb-fsevent (>= 0.9.3) +@@ -439,7 +444,6 @@ GEM + redis-store (~> 1.1.0) + redis-store (1.1.4) + redis (>= 2.2) +- ref (1.0.5) + request_store (1.0.5) + require_all (1.3.2) + rest-client (1.6.7) +@@ -541,9 +545,6 @@ GEM + term-ansicolor (1.2.2) + tins (~> 0.8) + test_after_commit (0.2.2) +- therubyracer (0.12.0) +- libv8 (~> 3.16.14.0) +- ref + thin (1.6.1) + daemons (>= 1.0.9) + eventmachine (>= 1.0.0) +@@ -552,7 +553,7 @@ GEM + thread_safe (0.3.4) + tilt (1.4.1) + timers (1.1.0) +- timfel-krb5-auth (0.8) ++ timfel-krb5-auth (0.8.3) + tinder (1.9.3) + eventmachine (~> 1.0) + faraday (~> 0.8) +@@ -623,6 +624,7 @@ DEPENDENCIES + browser + capybara (~> 2.2.1) + carrierwave ++ charlock_holmes! + coffee-rails + colored + coveralls +@@ -724,7 +726,6 @@ DEPENDENCIES + stamp + state_machine + test_after_commit +- therubyracer + thin + tinder (~> 1.9.2) + turbolinks diff --git a/www-apps/gitlabhq/files/gitlabhq-7.7.1-fix-project-name-regex.patch b/www-apps/gitlabhq/files/gitlabhq-7.7.1-fix-project-name-regex.patch new file mode 100644 index 0000000..0ec5299 --- /dev/null +++ b/www-apps/gitlabhq/files/gitlabhq-7.7.1-fix-project-name-regex.patch @@ -0,0 +1,26 @@ +diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb +index cf6e260..5657566 100644 +--- a/lib/gitlab/regex.rb ++++ b/lib/gitlab/regex.rb +@@ -1,3 +1,5 @@ ++# encoding: utf-8 ++ + module Gitlab + module Regex + extend self +@@ -11,12 +13,12 @@ module Gitlab + end + + def project_name_regex +- /\A[a-zA-Z0-9_.][a-zA-Z0-9_\-\. ]*\z/ ++ /\A[\p{Word}_.][\p{Word}_\-:\. ]*\z/ + end + + def project_regex_message +- "can contain only letters, digits, '_', '-' and '.' and space. " \ +- "It must start with letter, digit or '_'." ++ "can contain only letters, digits, '_', '-', ':' and '.' and space. " \ ++ "It must start with letter, digit, '.' or '_'." + end + + def name_regex diff --git a/www-apps/gitlabhq/gitlabhq-7.7.1.ebuild b/www-apps/gitlabhq/gitlabhq-7.7.1.ebuild new file mode 100644 index 0000000..7a65ce0 --- /dev/null +++ b/www-apps/gitlabhq/gitlabhq-7.7.1.ebuild @@ -0,0 +1,368 @@ +# 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" +#RUBY_S="${PN}-7.4.0" + +RESTRICT="mirror" + +LICENSE="MIT" +SLOT="6" +KEYWORDS="~amd64 ~x86" +IUSE="mysql +postgres +unicorn systemd" + +## 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 ) + virtual/krb5 + virtual/pkgconfig" +DEPEND="${GEMS_DEPEND} + >=dev-vcs/gitlab-shell-2.4.1 + dev-vcs/git" +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-project-name-regex: +# Allow project name to contain non-ASCII characters. +# +# fix-sendmail-config: +# Fix default settings to work with ssmtp that doesn't know '-t' argument. +# +RUBY_PATCHES=( + "${P}-fix-gemfile.patch" + "${P}-fix-project-name-regex.patch" + "${PN}-6.0.2-fix-sendmail-config.patch" + "${PN}-7.0.0-email-custom-reply_to.patch" +) + +MY_NAME="gitlab" +MY_USER="git" # should be same as in gitlab-shell + +DEST_DIR="/opt/${MY_NAME}-${SLOT}" +CONF_DIR="/etc/${MY_NAME}-${SLOT}" +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:).*|/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; 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} + + ## 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-6.init + + cp "${FILESDIR}/${rcscript}" "${T}" || die + sed -i \ + -e "s|@USER@|${MY_USER}|" \ + -e "s|@SLOT@|${SLOT}|" \ + -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}-${SLOT}" + 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 $@" +}