From 79881f8a02f6ac896dfd3b08e66d9b3878551b02 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 23 Feb 2015 13:32:27 +0100 Subject: [PATCH] added ebuild for www-apps/gitlabhq-7.8.0 and required patches --- www-apps/gitlabhq/Manifest | 4 + ...gitlabhq-7.8.0-email-custom-reply_to.patch | 39 ++ .../files/gitlabhq-7.8.0-fix-gemfile.patch | 88 +++++ www-apps/gitlabhq/gitlabhq-7.8.0.ebuild | 368 ++++++++++++++++++ 4 files changed, 499 insertions(+) create mode 100644 www-apps/gitlabhq/files/gitlabhq-7.8.0-email-custom-reply_to.patch create mode 100644 www-apps/gitlabhq/files/gitlabhq-7.8.0-fix-gemfile.patch create mode 100644 www-apps/gitlabhq/gitlabhq-7.8.0.ebuild diff --git a/www-apps/gitlabhq/Manifest b/www-apps/gitlabhq/Manifest index 3d0d2f0..91eb4c5 100644 --- a/www-apps/gitlabhq/Manifest +++ b/www-apps/gitlabhq/Manifest @@ -43,6 +43,8 @@ AUX gitlabhq-7.1.1-fix-project-name-regex.patch 638 SHA256 9f3dfcdc4365422037ecc 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 +AUX gitlabhq-7.8.0-email-custom-reply_to.patch 1853 SHA256 ccf123b164fa323a212bb2b53104e0dc8d1bd0ecbc0a0dc3b41fa58740ba6779 SHA512 67b4f4624bd7fe91b78b28b2265f7166110611fe2a32ded733aff65291e7562af4bd3b0d3345a45991a537486eda4606cd82347b907b09c6ff47d55d40969227 WHIRLPOOL 678716e8dfa794055a7d4827a7f1e9bc67475738ed7308d5cc28a7661a99acf927cb91a59dd01055cdbde9690bb3dc10b87c53569351267dea2e86117140af5e +AUX gitlabhq-7.8.0-fix-gemfile.patch 2123 SHA256 935a72dd9cdbb12de6c95ca5e3fba066b5fcf368830f9e4c7ce4466feab20400 SHA512 70960437b1e5e5054ee28134104a1cabdf95ac6a7f034f755f97eb859d526662ab9e6313fd1c72b6838c308df5173a0d08896f137f8f737c6c0a6e7b7f54bfc3 WHIRLPOOL 8d7cbc26934f2d0e993c75565a17992c3c44a7ab51e6154bf7a91667e0e1c5837cb6546730bea882772b042c6353459f20e59a9a95d56d130f6db8ce4d2d1123 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 @@ -60,6 +62,7 @@ DIST gitlabhq-7.5.3.tar.gz 4222058 SHA256 533afcf5b9a0683d2f920a436e552af8d8e953 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 DIST gitlabhq-7.7.2.tar.gz 4439065 SHA256 7c99367be815d231ba4b349a7f0a3d2470ae13ac2910d01d085f46890961b714 SHA512 5853d7989e75c03b7f8df24378bf25d9b49ffc858f6421f809bfcc11177905d9706307d048b880316331c74c79914a3ebdd032682414c76ac6b082e3813be074 WHIRLPOOL eb56dadcda422cfccf263f838ec225359ed9490a3c34df8a3d4a9b1f08ad98900374d81214217f27132b29d104b5102ec3d95f0c6bc10a8eca7088f9e5c9bbbd +DIST gitlabhq-7.8.0.tar.gz 5303213 SHA256 a7b3836b1071ee58f986197b08c3d91fc85524a5ce3050f7ef6697088850a242 SHA512 fff5240f8286a3d084ac158a262ab1c285c1b685769e1a707e0317e67fd0c27205970c51338589a59c8192eb4a87c7e43b2ecbbaa5da8f5f243024f364285983 WHIRLPOOL bd8ed138b888ab46ecfa172045e79520db5f48ce95b119a1af752db4988ee62c73be753773d4cc5dea4fd029d4bf6a78293291e050a7b1e2776b0a84deff2357 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 @@ -79,3 +82,4 @@ EBUILD gitlabhq-7.5.3.ebuild 10904 SHA256 821abc6ca9c2b87f18aa3279068ead6c25ed5d EBUILD gitlabhq-7.6.2.ebuild 10911 SHA256 f0fe0342c47c7e0d6ae10e080f56198c752454bddbe8910092124c290c40e716 SHA512 34ae28951cb92b6c01e21c421a156ffd35c45b75f3e4d4701e46da71f13a921fc291c146ee3436e39d68898ae4ee107aa558d63429aa4f96344502654e8c6ee9 WHIRLPOOL 3a43aa3d336ba926a4d9703b96472eddcadf55bc966e65fcf3eca8ee0070effcc0920a18c4f376f1292c64dcbceccd6733c6010ab03db3dfc98f25d0da5b7c6c EBUILD gitlabhq-7.7.1.ebuild 10903 SHA256 0251aaec752e74b586353559889f21f031531dd84ffd741e562e4974727e54f7 SHA512 3c54ca69e6797853c1292c4727cb6cefe6428d9a74d09014570215f120e2a3194ab8578570f1ba767545e0510056bbeff6708e743a066467782aa566bed3bfdb WHIRLPOOL f25960e6a3b6f966c9b62e00356baf91474f58cab42fb9598a937ef503830752f62b998e865250708a89f4974c4e4df9c1afc5a3749159f25765cf5945e9e332 EBUILD gitlabhq-7.7.2.ebuild 10918 SHA256 834ea3aa7a6ce103040a8c2938327c43b1479aa7cebc00030e0852bf31b6aa45 SHA512 2a7070ae80aadeab5809bd9634b97603929624264af804720fea2b9c1ecb11f7d1a9b3e6a49d75666f55d041fcd884d0ceb517ab081658bed9fe56678d0dac3f WHIRLPOOL 25d9aa4bfe0bb9feda5c90c3ea7c2ad7eea8e363a1b7761d4757fb58f6edb9966a87158a501bbf7576da91364b5716e897598eddfa8d05442bf8cfb4c22583f6 +EBUILD gitlabhq-7.8.0.ebuild 10904 SHA256 fd965128e305c5194e2ee1ad38779f486764e936f66b2bc9eaf99cd90299709e SHA512 cb7d057c9b1f211c789f10a425b704177137f3f5f7796b287fdbedd0d6784159a27f561e9edd34c294a605d0a4a64504ab6707a20b78aea8b7c38d86267b78e1 WHIRLPOOL 8f44295e40f6d6a5e24c24e3e352fb07c0ff50c211614bc4bad6d2bcc8d237c0748ef6fcc889a7fdf7cc656244e76004a43ea5799e4a43b47e7017ab202a951b diff --git a/www-apps/gitlabhq/files/gitlabhq-7.8.0-email-custom-reply_to.patch b/www-apps/gitlabhq/files/gitlabhq-7.8.0-email-custom-reply_to.patch new file mode 100644 index 0000000..c21590e --- /dev/null +++ b/www-apps/gitlabhq/files/gitlabhq-7.8.0-email-custom-reply_to.patch @@ -0,0 +1,39 @@ +diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb +index 46ead62..d4ee6bb 100644 +--- a/app/mailers/notify.rb ++++ b/app/mailers/notify.rb +@@ -19,7 +19,7 @@ class Notify < ActionMailer::Base + 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 +diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example +index 044b1f6..5ff344e 100644 +--- a/config/gitlab.yml.example ++++ b/config/gitlab.yml.example +@@ -44,6 +44,9 @@ production: &base + # Email address used in the "From" field in mails sent by GitLab + email_from: example@example.com + ++ # Email address used in the "Reply-To" field in mails send by GitLab (default: no-reply@) ++ email_reply_to: no-reply@example.com ++ + # Email server smtp settings are in config/initializers/smtp_settings.rb.sample + + # default_can_create_group: false # default: true +diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb +index 6a8bbb8..de5c8f8 100644 +--- a/config/initializers/1_settings.rb ++++ b/config/initializers/1_settings.rb +@@ -102,6 +102,7 @@ Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || '' + Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http" + Settings.gitlab['email_enabled'] ||= true if Settings.gitlab['email_enabled'].nil? + Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}" ++Settings.gitlab['email_reply_to'] ||= "no-reply@#{Settings.gitlab.host}" + Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) + Settings.gitlab['user'] ||= 'git' + Settings.gitlab['user_home'] ||= begin diff --git a/www-apps/gitlabhq/files/gitlabhq-7.8.0-fix-gemfile.patch b/www-apps/gitlabhq/files/gitlabhq-7.8.0-fix-gemfile.patch new file mode 100644 index 0000000..431825c --- /dev/null +++ b/www-apps/gitlabhq/files/gitlabhq-7.8.0-fix-gemfile.patch @@ -0,0 +1,88 @@ +diff --git a/Gemfile b/Gemfile +index c3d8299..f1c9da6 100644 +--- a/Gemfile ++++ b/Gemfile +@@ -167,6 +167,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" + +@@ -265,7 +269,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 3283da4..ae2518f 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: +@@ -74,7 +81,6 @@ GEM + json (>= 1.7) + celluloid (0.16.0) + timers (~> 4.0.0) +- charlock_holmes (0.6.9.4) + cliver (0.3.2) + coderay (1.1.0) + coercible (1.0.0) +@@ -297,7 +303,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) +@@ -453,7 +458,6 @@ GEM + redis-store (~> 1.1.0) + redis-store (1.1.4) + redis (>= 2.2) +- ref (1.0.5) + request_store (1.0.5) + rest-client (1.6.7) + mime-types (>= 1.16) +@@ -564,9 +568,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) +@@ -649,6 +650,7 @@ DEPENDENCIES + cal-heatmap-rails (~> 0.0.1) + capybara (~> 2.2.1) + carrierwave ++ charlock_holmes! + coffee-rails + colored + coveralls +@@ -752,7 +754,6 @@ DEPENDENCIES + stamp + state_machine + test_after_commit +- therubyracer + thin + tinder (~> 1.9.2) + turbolinks diff --git a/www-apps/gitlabhq/gitlabhq-7.8.0.ebuild b/www-apps/gitlabhq/gitlabhq-7.8.0.ebuild new file mode 100644 index 0000000..539159e --- /dev/null +++ b/www-apps/gitlabhq/gitlabhq-7.8.0.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.3 + 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" + "${PN}-7.7.1-fix-project-name-regex.patch" + "${PN}-6.0.2-fix-sendmail-config.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://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 $@" +}