added ebuilds and patches for gitlabhq 6.7.5 and 6.8.2 and cleaned up patch files for 6.6.5.

This commit is contained in:
Manuel Friedli 2014-05-19 13:22:58 +02:00
parent 38af1e988e
commit 717334d1bf
9 changed files with 937 additions and 33 deletions

View file

@ -24,8 +24,14 @@ AUX gitlabhq-6.5.1-fix-project-name-regex.patch 997 SHA256 a9e321bf7a986d86dbb87
AUX gitlabhq-6.5.1-ldap-custom-mapping.patch 3276 SHA256 d335fc980a891a7a24cbb96ec7a4109bb3fc3a89ebc8c797d787e69fff74e7d2 SHA512 7cb523db97986eb94d0feda7be0eb8f400b9df744f25a44a783925059ae97671400bebfbe75b6d803640e4eb828abea193dcde26a2e6d5f103dc9d0913772365 WHIRLPOOL 76d81fd7075bb6dd52b622c6f2147393dd5fcf8e42addb82e9431a019c445f5703a77f31db71a62e05561eb05be8195bf05da0be83cd20db57659a057f7b0481
AUX gitlabhq-6.6.5-email-custom-reply_to.patch 1617 SHA256 320405e34892d5fc3f1e6ccc9ed043623e540b0d2daa18184c01a038d3bb558c SHA512 5117743fd42dafa2ebf107b9c25ca0d5b79e02aa987cfc9380aef6270ab5417db69b2d59740fd59d4d828a128d1ae4cb26eef895387e89cabb3581c855ef9254 WHIRLPOOL 4634491c9611b97e0d2203b3656ef3ceb175b21c0cad0bb564ac728884cc983a39f5a68f84b9a387c60e36524e8c58efcc563f6590527e768b68b3218c84c762
AUX gitlabhq-6.6.5-fix-gemfile.patch 2161 SHA256 7f1f6fef287a00a0f794ad31a81cced87a5ac6a31e79e27be6530f92d66a2598 SHA512 24bb78ea36886764911af7825c0ade796dbd24ee99ee19e418d4478bc4d4dcbdb4ffcfd63b615a842a320234c4e6b0b851094abdd0c5be0a5cd80308a00d380a WHIRLPOOL 6345e2ec96c52f79545f21fb330e8517925c04f162dc2cbad959c1eb59fd65e89be4cc45d1510ef662e43a26541e840e02742adb9474569a44e80771df773d7f
AUX gitlabhq-6.6.5-fix-ldap-dn-case.patch 649 SHA256 37b217c56ccbed79a13e7d657572433c307867d62aa8e21c7ab1c537733b0d4f SHA512 99508485b83c21a9ba70b5d65ed082baf2fca1f6542d4118f24de841dc1eb35f9639ab5afcf46342043d9fc8b7c76e5ae7e8d749c7faa0263de91213415a22c1 WHIRLPOOL cb41be068a5b727e22ee917741dbd71ff363efc003502d37956a08fe741b57ab7507b066b784229c6b5a9691c884971ab138de3457e58c5d8ad619b770e31c27
AUX gitlabhq-6.6.5-fix-project-name-regex.patch 997 SHA256 a9e321bf7a986d86dbb87f1af3360ce71d60de5a9d6d3e23b12e469240ecd8bd SHA512 d0883c30b1d542e20908c8efa46cacab337fc70e902894a01707468b033be88ce6af865d78d5bc8830c74fbca55fc1c70286a4a95b9b6c82f06f0d0720e40b35 WHIRLPOOL 16f89f870d5b317015f08e415db323baac6f99ad789c7555f16c37ca918a9706c05b4ff527661d8399814fc7847895f5079a621d98c8c427da59deaaa2a3bd89
AUX gitlabhq-6.6.5-ldap-custom-mapping.patch 3052 SHA256 64e47278393ba4442037bb684a44c1538e671683cfaa9dfcb9bf61e5265da03a SHA512 f1e9ad71e4b95e6cb4f56179d1a9f92b5a2b7c59a425f4c9620c3bb6cd68c9bd2ae4e443f8a29d84455b029d99ba248517b44b1b8e9ddeeca249a6e749bf095f WHIRLPOOL c2045af7b8b766a3e154a1a8fa83a469df4111b352973533f902c16abfeee161d1f4cf88861847f64dad36e39ca65a796598e9d75ddad5a8e9f160707af349a3
AUX gitlabhq-6.7.5-email-custom-reply_to.patch 1628 SHA256 0a5e1043a453395cc552626072677b6ad6de843980d3f480f6b98469c2f7ccc2 SHA512 7fe754dcfb3e8fb15daad059b4582dcbefb61da2bd12fe73ec5eee4b77ac9a2116e25365fbb3503b76f6048ae707230333a5439a63b59f946e2da37a8cecf92e WHIRLPOOL fca02b390e5edee5a58538f620fc7f5ff7632dcfd3d2b31befc4dcd46338e2345db337ee888dc2b6d7d456bcb426d44989a8a01f4176ac05491712012bc98b23
AUX gitlabhq-6.7.5-fix-project-name-regex.patch 1148 SHA256 bb0e175e56412aaef647fb0a3cc31f0e1dfdc12983d4195ab9375b2ecd929c46 SHA512 7b9db9068edbf99c9226fecf4ac3154110481a7b69020ee05d1318ee6f4105d53c45ca14317f917825c9769d317a8815830638a371fd8f5d6af031b361bef65a WHIRLPOOL 0c333f523230ec49089017087dce328e79e646efeaec5c9520f541775d717c45cabf3173199405b55b836285d0fa9c27764f250eb7f19fe4f1909514caf879e9
AUX gitlabhq-6.8.2-fix-gemfile.patch 2073 SHA256 6cccaba8d4483e4e8390ec518e474e2137985d490163cfcc0cef090fc80e0277 SHA512 75c21c7c5103d13009427739d591a268b7d9d43add0a3d0c2f3188a054c0963a4b525c024664732ad6ff5429adddfde49d98b74285a0de21c351143692839b73 WHIRLPOOL 4ec488ae566c5781eff17cead6c83002ef4a5055c02f3bf07ed8955985a8e3b7fe61fd4b5b116e4cb74787fb4b3f9caa820a9c67b297c007eed7f0be2d461261
AUX gitlabhq-6.8.2-ldap-custom-mapping.patch 2579 SHA256 82aaae2c64554e9c00dfb8f1d66884512f509752c74b03fe430d3ba7e7a5c18d SHA512 82e1900473b96d0067b477f76fae7445dc000a520bebe0f9cbdd7e02063b146005aa63594f508e3a592e89b04ac26b425b8a186bbd474b538c918d74c6abb9a7 WHIRLPOOL 953ddf4b70a9caf29afeaee50939c3bc3ec4a4f53cb484f50f151e7a8d6ab2d03303deb4c26c931fa836fa84b5935522630ffed7d266fcd9cb6982a6148e6882
DIST gitlabhq-6.6.5.tar.gz 10240388 SHA256 70c2c50ab903b7173ccbb32d2c7f3db9a89a4a005d5515ef9ed5d935193dca2e SHA512 38d2395eabb4607b40798de0c6e9aa7fb6ecfe482b6f7d1a5cc2350c1cf04d939ae2487834d159419d01c24e82b818920f7b1999df444cb473c99d9fc40244da WHIRLPOOL ce684cac1ca27ae51f25277cba1c62fa389150ccd83ae83d5d91a17cf4e183e8af7928431000924f0dcb03505045cad850a05e6b2ac4fa001a488e73a4b09971
EBUILD gitlabhq-6.6.5.ebuild 10772 SHA256 b28fabaa399d478468740c6567dc5fb6403039ecf63fb10dd4d3947b3bdb5b4f SHA512 fef43df379af3200d023d06b8e3c7a8118e3c464e6a910ec8b16882a8a39e027a1082f4f604384282fe0a64a64f5f79f27f87636e8150ed6c5ef355c8d4581a2 WHIRLPOOL 8d1775f01638a55f407ed8590606675962544887500ce46f73b81cd383817bdbc27a510e6bfed0426bbaa8b0deea76cdafc08844e4b58929815f1e2dfc8ca861
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
EBUILD gitlabhq-6.6.5.ebuild 10786 SHA256 7aba88de5bc37d19161828401d39385dcd96914b50f7504dad5068aa966b2a73 SHA512 7284a4b0aad4f2b2fc0373c4348c846e2a59a3227d4defbb1e1fc17a71fdf5f4a7aa7f5a58528110bec0325ec544fa8490ed1c9b7d359db5ea060df64895382d WHIRLPOOL 79b1d4c9fe08d150f58709642951ee8ae49313a660ceaeeb8af6b23b6a70730fbe517fe3ca1466d11d5f95e56f1d597d66517601ef40b1414b99e08168ba53ba
EBUILD gitlabhq-6.7.5.ebuild 10795 SHA256 d5da5a477f75068f41ac54bbc73f53a46a2f6263d816d9496409184d329bda46 SHA512 f39c8e85a087a484b25f5a3fadb29dd03022859982b3ce15bb2728256e1902ac58d3557cbac89eaf89edaa340326812d61adb4f077b92fe183c28872e727d435 WHIRLPOOL ab59badccc1097d198aaf05a287530dba6efaa7b46c8004cf87e3f9937cddd56ff717405b8481603d257a9898d293fd5be3eeddce9d4e90d802689b2b1923597
EBUILD gitlabhq-6.8.2.ebuild 10757 SHA256 d9f45ba9b148ef9d8808f5a2f5f8308816b1f6e9d24219e14e29bd1ed3b8caa8 SHA512 df482e32e0af3df65b65f25e1309e8eb304dad82ea040881907350cd3a5fee10588f1dc1af8633a794bd67a1f78bc13393e10f346c204eb1dd200b03dad6a90d WHIRLPOOL c54ff371a8aa1f2d215eeed3566c0699dcc34c44c346c19a93a65ada8eec0a3dfc51e9e49b60dc9771c95be6a250cdee63967fff34c2c1093bef598838f58aec

View file

@ -1,20 +0,0 @@
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb
index 59f0fa6..8afd64f 100644
--- a/lib/gitlab/ldap/user.rb
+++ b/lib/gitlab/ldap/user.rb
@@ -83,8 +83,14 @@ module Gitlab
private
+ # Override superclass method to use our case-insensitive find_by_uid
+ def find_by_uid_and_provider
+ find_by_uid(uid)
+ end
+
def find_by_uid(uid)
- model.where(provider: provider, extern_uid: uid).last
+ # LDAP distinguished name is case-insensitive
+ model.where("provider = ? and lower(extern_uid) = ?", provider, uid.downcase).last
end
def provider

View file

@ -0,0 +1,33 @@
--- app/mailers/notify.rb.orig 2014-05-19 12:22:50.840000000 +0200
+++ app/mailers/notify.rb 2014-05-19 12:23:35.660000000 +0200
@@ -16,7 +16,7 @@
default_url_options[:script_name] = Gitlab.config.gitlab.relative_url_root
default from: Proc.new { default_sender_address.format }
- default reply_to: "noreply@#{Gitlab.config.gitlab.host}"
+ default reply_to: Gitlab.config.gitlab.email_reply_to
# Just send email with 2 seconds delay
def self.delay
--- config/gitlab.yml.example.orig 2014-05-19 12:23:45.640000000 +0200
+++ config/gitlab.yml.example 2014-05-19 12:24:07.340000000 +0200
@@ -37,6 +37,9 @@
# Email address used in the "From" field in mails sent by GitLab
email_from: gitlab@localhost
+ # Email address used in the "Reply-To" field in mails send by GitLab (default: no-reply@<host>)
+ email_reply_to: no-reply@localhost
+
# Email address of your support contact (default: same as email_from)
support_email: support@localhost
--- config/initializers/1_settings.rb.orig 2014-05-19 12:24:14.520000000 +0200
+++ config/initializers/1_settings.rb 2014-05-19 12:24:44.010000000 +0200
@@ -78,6 +78,7 @@
Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || ''
Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
+Settings.gitlab['email_reply_to'] ||= "no-reply@#{Settings.gitlab.host}"
Settings.gitlab['support_email'] ||= Settings.gitlab.email_from
Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)
Settings.gitlab['user'] ||= 'git'

View file

@ -1,5 +1,5 @@
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
--- lib/gitlab/regex.rb.orig 2014-05-19 12:17:42.210000000 +0200
+++ lib/gitlab/regex.rb 2014-05-19 12:18:56.920000000 +0200
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
@ -10,14 +10,14 @@
end
def project_name_regex
- /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/
+ /\A\p{Word}[\p{Word}\-:\. ]*\z/
- /\A[a-zA-Z0-9_][a-zA-Z0-9_\-\. ]*\z/
+ /\A[\p{Word}_][\p{Word}_\-:\. ]*\z/
end
def name_regex
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -85,7 +85,7 @@
--- app/models/project.rb.orig 2014-05-19 12:19:44.700000000 +0200
+++ app/models/project.rb 2014-05-19 12:20:16.050000000 +0200
@@ -84,7 +84,7 @@
validates :description, length: { maximum: 2000 }, allow_blank: true
validates :name, presence: true, length: { within: 0..255 },
format: { with: Gitlab::Regex.project_name_regex,

View file

@ -0,0 +1,84 @@
--- Gemfile.orig 2014-05-19 13:04:44.700000000 +0200
+++ Gemfile 2014-05-19 13:05:44.400000000 +0200
@@ -142,6 +142,10 @@
# 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"
@@ -151,7 +155,6 @@
gem "sass-rails", '~> 4.0.2'
gem "coffee-rails"
gem "uglifier"
-gem "therubyracer"
gem 'turbolinks'
gem 'jquery-turbolinks'
--- Gemfile.lock.orig 2014-05-19 13:06:11.660000000 +0200
+++ Gemfile.lock 2014-05-19 13:08:38.440000000 +0200
@@ -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:
@@ -60,7 +67,6 @@
json (>= 1.7)
celluloid (0.15.2)
timers (~> 1.1.0)
- charlock_holmes (0.6.9.4)
cliver (0.2.2)
code_analyzer (0.4.3)
sexp_processor
@@ -267,7 +273,6 @@
addressable (~> 2.3)
letter_opener (1.1.2)
launchy (~> 2.2)
- libv8 (3.16.14.3)
listen (2.3.1)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
@@ -402,7 +407,6 @@
redis-store (~> 1.1.0)
redis-store (1.1.4)
redis (>= 2.2)
- ref (1.0.5)
require_all (1.3.2)
rest-client (1.6.7)
mime-types (>= 1.16)
@@ -496,9 +500,6 @@
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)
@@ -567,6 +568,7 @@
bootstrap-sass (~> 3.0)
capybara
carrierwave
+ charlock_holmes!
coffee-rails
colored
coveralls
@@ -654,7 +656,6 @@
stamp
state_machine
test_after_commit
- therubyracer
thin
tinder (~> 1.9.2)
turbolinks

View file

@ -0,0 +1,76 @@
--- Gemfile.orig 2014-05-19 13:15:25.830000000 +0200
+++ Gemfile 2014-05-19 13:16:01.020000000 +0200
@@ -36,7 +36,8 @@
gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
# LDAP Auth
-gem 'gitlab_omniauth-ldap', '1.0.4', require: "omniauth-ldap"
+# Patched for attributes mapping customization
+gem 'gitlab_omniauth-ldap', '1.0.4', require: 'omniauth-ldap', git: 'https://github.com/jirutka/omniauth-ldap.git', ref: 'b55852bfc9b46ecf790a2c5526386702350eab89'
# Git Wiki
gem 'gollum-lib', '~> 3.0.0'
--- Gemfile.lock.orig 2014-05-19 13:16:34.160000000 +0200
+++ Gemfile.lock 2014-05-19 13:17:44.500000000 +0200
@@ -5,6 +5,17 @@
specs:
charlock_holmes (0.6.9.4)
+ GIT
+ remote: https://github.com/jirutka/omniauth-ldap.git
+ revision: b55852bfc9b46ecf790a2c5526386702350eab89
+ ref: b55852bfc9b46ecf790a2c5526386702350eab89
+ specs:
+ gitlab_omniauth-ldap (1.0.4)
+ net-ldap (~> 0.3.1)
+ omniauth (~> 1.0)
+ pyu-ruby-sasl (~> 0.0.3.1)
+ rubyntlm (~> 0.1.1)
+
GEM
remote: https://rubygems.org/
specs:
@@ -186,11 +197,6 @@
gitlab-linguist (~> 3.0)
rugged (~> 0.19.0)
gitlab_meta (6.0)
- gitlab_omniauth-ldap (1.0.4)
- net-ldap (~> 0.3.1)
- omniauth (~> 1.0)
- pyu-ruby-sasl (~> 0.0.3.1)
- rubyntlm (~> 0.1.1)
gollum-lib (3.0.0)
github-markup (~> 1.1.0)
gitlab-grit (~> 2.6.5)
@@ -593,7 +599,7 @@
gitlab_emoji (~> 0.0.1.1)
gitlab_git (~> 5.8)
gitlab_meta (= 6.0)
- gitlab_omniauth-ldap (= 1.0.4)
+ gitlab_omniauth-ldap (= 1.0.4)!
gollum-lib (~> 3.0.0)
gon (~> 5.0.0)
grape (~> 0.6.1)
--- config/gitlab.yml.example.orig 2014-05-19 13:18:03.400000000 +0200
+++ config/gitlab.yml.example 2014-05-19 13:18:45.740000000 +0200
@@ -135,6 +135,10 @@
method: 'ssl' # "tls" or "ssl" or "plain"
bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
password: '_the_password_of_the_bind_user'
+ mapping:
+ username: 'uid'
+ name: 'cn'
+ email: 'mail'
# If allow_username_or_email_login is enabled, GitLab will ignore everything
# after the first '@' in the LDAP username submitted by the user on login.
#
--- config/initializers/devise.rb.orig 2014-05-19 13:19:23.120000000 +0200
+++ config/initializers/devise.rb 2014-05-19 13:19:43.170000000 +0200
@@ -223,6 +223,7 @@
method: Gitlab.config.ldap['method'],
bind_dn: Gitlab.config.ldap['bind_dn'],
password: Gitlab.config.ldap['password'],
+ mapping: Gitlab.config.ldap['mapping'],
name_proc: email_stripping_proc
end

View file

@ -4,7 +4,7 @@
EAPI="5"
# Mainteiner notes:
# 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
@ -68,9 +68,9 @@ ruby_add_bdepend "
#
RUBY_PATCHES=(
"${P}-fix-gemfile.patch"
"${P}-fix-project-name-regex.patch"
"${PN}-6.5.1-fix-project-name-regex.patch"
"${PN}-6.0.2-fix-sendmail-config.patch"
"${P}-fix-ldap-dn-case.patch"
"${PN}-6.5.1-fix-ldap-dn-case.patch"
"${P}-ldap-custom-mapping.patch"
"${P}-email-custom-reply_to.patch"
)

View file

@ -0,0 +1,363 @@
# 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="ruby19 ruby20"
PYTHON_DEPEND="2:2.7"
inherit eutils python ruby-ng user
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"
RESTRICT="mirror"
LICENSE="MIT"
SLOT="6"
KEYWORDS="amd64 x86"
IUSE="mysql +postgres +unicorn"
## Gems dependencies:
# charlock_holmes dev-libs/icu
# grape, capybara dev-libs/libxml2, dev-libs/libxslt
# json dev-util/ragel
# pygments.rb python 2.7+
# execjs net-libs/nodejs, or any other JS runtime
# pg dev-db/postgresql-base
# mysql virtual/mysql
#
GEMS_DEPEND="
dev-libs/icu
dev-libs/libxml2
dev-libs/libxslt
dev-util/ragel
net-libs/nodejs
postgres? ( dev-db/postgresql-base )
mysql? ( virtual/mysql )"
DEPEND="${GEMS_DEPEND}
>=dev-vcs/gitlab-shell-1.9.1
dev-vcs/git"
RDEPEND="${DEPEND}
dev-db/redis
virtual/mta"
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=(
"${PN}-6.6.5-fix-gemfile.patch"
"${P}-fix-project-name-regex.patch"
"${PN}-6.0.2-fix-sendmail-config.patch"
"${PN}-6.5.1-fix-ldap-dn-case.patch"
"${PN}-6.6.5-ldap-custom-mapping.patch"
"${P}-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://github.com/gitlabhq/gitlabhq/blob/v${PV}/script/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 zzet's stupid migration which expetcs that users are so foolish
# to run GitLab with PostgreSQL's superuser...
rm db/migrate/20121009205010_postgres_create_integer_cast.rb
# remove useless files
rm -r lib/support/{deploy,init.d}
rm -r script/{background_jobs,web}
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}
fperms +x script/{rails,check}
## RC script ##
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}"
}
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 $@"
}

View file

@ -0,0 +1,362 @@
# 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="ruby19 ruby20"
PYTHON_DEPEND="2:2.7"
inherit eutils python ruby-ng user
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"
RESTRICT="mirror"
LICENSE="MIT"
SLOT="6"
KEYWORDS="amd64 x86"
IUSE="mysql +postgres +unicorn"
## Gems dependencies:
# charlock_holmes dev-libs/icu
# grape, capybara dev-libs/libxml2, dev-libs/libxslt
# json dev-util/ragel
# pygments.rb python 2.7+
# execjs net-libs/nodejs, or any other JS runtime
# pg dev-db/postgresql-base
# mysql virtual/mysql
#
GEMS_DEPEND="
dev-libs/icu
dev-libs/libxml2
dev-libs/libxslt
dev-util/ragel
net-libs/nodejs
postgres? ( dev-db/postgresql-base )
mysql? ( virtual/mysql )"
DEPEND="${GEMS_DEPEND}
>=dev-vcs/gitlab-shell-1.9.1
dev-vcs/git"
RDEPEND="${DEPEND}
dev-db/redis
virtual/mta"
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"
"${PN}-6.7.5-fix-project-name-regex.patch"
"${PN}-6.0.2-fix-sendmail-config.patch"
"${P}-ldap-custom-mapping.patch"
"${PN}-6.7.5-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://github.com/gitlabhq/gitlabhq/blob/v${PV}/script/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 zzet's stupid migration which expetcs that users are so foolish
# to run GitLab with PostgreSQL's superuser...
rm db/migrate/20121009205010_postgres_create_integer_cast.rb
# remove useless files
rm -r lib/support/{deploy,init.d}
rm -r script/{background_jobs,web}
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}
fperms +x script/{rails,check}
## RC script ##
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}"
}
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 $@"
}