From 53a6b7eafef138c884bd2f50163f4dc4b983d336 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sat, 27 May 2017 13:39:34 +0200 Subject: [PATCH] www-apps/gitlab-ce: add ebuild for gitlab-ce 9.2.2 Package-Manager: Portage-2.3.5, Repoman-2.3.1 --- www-apps/gitlab-ce/Manifest | 3 + .../03-gitlab-ce-9.2.2-database.yml.patch | 102 +++++ www-apps/gitlab-ce/gitlab-ce-9.2.2.ebuild | 427 ++++++++++++++++++ 3 files changed, 532 insertions(+) create mode 100644 www-apps/gitlab-ce/files/03-gitlab-ce-9.2.2-database.yml.patch create mode 100644 www-apps/gitlab-ce/gitlab-ce-9.2.2.ebuild diff --git a/www-apps/gitlab-ce/Manifest b/www-apps/gitlab-ce/Manifest index 1f15d91..d2ba883 100644 --- a/www-apps/gitlab-ce/Manifest +++ b/www-apps/gitlab-ce/Manifest @@ -3,6 +3,7 @@ AUX 02-gitlab-ce-8.11.0-fix-redis-config-path.patch 423 SHA256 4878d37082c7e5c0a AUX 02-gitlab-ce-9.0.0-fix-redis-config-path.patch 423 SHA256 9de3711c1f06a0561001166f2a44b4c1dc5fa3fa57a5230eb1dcc2b5d394449c SHA512 ae89fa3c6fde777e844e777862415450787ebf83653435cea329d66810c5805d2126d41cb1ce40b15c42371543bc182a59305b8b1b6a7433121340a625300370 WHIRLPOOL d97962907bb1fc610ebc52665a6ce51f40ee932e7ac715279f3c0554f2880a7b220ecbac2c4c97bd4d3dac22b9a025aa729805221ed5e6d15f04f6cd8e210d22 AUX 03-gitlab-ce-8.14.0-database.yml.patch 2172 SHA256 8435bf632aab03057342d5d6d75f016b006da00157c0cce2661416b752f8b75d SHA512 048aa5877ef30e702727b917cf7fb6bd534c497a7c24ab55640635598af293b0567bb9f356c4b91d55291341ced50847909f117f46d3fc9962c2f7a0f7b6bfb9 WHIRLPOOL 87b62f5e326211c2ff9001742a04b71bd94b21f4851778a513f7e1981da193dc16718559be42a0ba21aaa0c2f5b65a2571bc20174c063aa13e6436f0b422f057 AUX 03-gitlab-ce-8.17.0-database.yml.patch 2238 SHA256 c5ec9e8a11fb60a7749b9f8cf553949e78aacf9a8233b39c4986980851196c8e SHA512 1668e2c1d00ef485d2bc5af8d343c9be19f291a627d0041d42b268ec1ad8aedecba99336998e6b1b3ac2f4cd617556d17ab5f1f11f95d696205e3d10d6b74e1c WHIRLPOOL c91a6604f050113c9f584d7bf34ebe660263beb88879382873952d6b1b136ad5b576b813bf9f2f66ee49d6656fb1d24437dca395c2574bd7dab07cd1a3a36a99 +AUX 03-gitlab-ce-9.2.2-database.yml.patch 2342 SHA256 870cddca799897d249773d0b0e58d30b1290475e3c313faa6bbc307c73f80d4b SHA512 257ff2cf3bd090dd08a8f03baa6c06d130313bf46b21ac61a606aaa0f0cf1eaacd3ad231761989448e4dc28aeda01b03192290314582db002c32c65eed4134aa WHIRLPOOL 94d95a9e6d15d48c6e786521b04eb43b12a003feae0a464122f51cdf2a5215b2c025134373842a6633d0adf73ceea1db9fb32e36236391bdf9e750565f908591 AUX 04-gitlab-ce-8.12.7-fix-check-task.patch 917 SHA256 e1adffbd59a418d5e14cbd51ae14d5c1f0364af759c77b6cb485079e0233e90f SHA512 226c3892768dc526dbc9f109aaecdee1eb27c0acb5060ba6db8222410c500336ebcf7184437228480da04ce5de149a14bbb5c1471aed853a280d7f371f271d88 WHIRLPOOL 3ec22dc4d12b5025bddfccdea27a816aca1f818d5138b3dc9a6362e56ec4cd14e5c38c76b64b468f3797e0d2718d38aad4f910abf3f3328a7983832babb7f231 AUX 05-gitlab-ce-8.12.7-replace-sys-filesystem.patch 2387 SHA256 dd0e9987ed4bb3a9c73c6aee1d89434afc51ff663fef2ee4ac93adf1b73b944a SHA512 afa82fb8c8d57633c99373f31678760fa6ecca5e459a9059f5b460b458d1dbf3230108a6b4f394780c26a697881c9b2319f15804cb8d04ad3139127e7c0f4ff8 WHIRLPOOL 90ce708f8cde0a4bcaef9fc002ca00b97a1211559bcabf5481ec71c608bc5b772ecd518ff07a8d626a27e4b21c0f0f51fa37a65503e79664ececd78d5f19e87b AUX 05-gitlab-ce-8.16.0-replace-sys-filesystem.patch 2379 SHA256 cf5e0ea55c99996744422312a46914a8e54b6ab68ac5e67abda444e1170bcd4b SHA512 eb5ea3a9f040c3df64bd8ebb20ed873fb6af17322867c0f5714e3d9ad5ac26b79e9ffaaa4720617513123b651ceccedeb992b64c87b9b945338614c9eeec1468 WHIRLPOOL 2591c1d439447f3e08fe413ab8127b9945f8e4813480093af1da796675903bbb2b8a2205bd1480d383402ef861c348cfa0bd45305e7c1fa20458bfd6b6b327a5 @@ -23,6 +24,7 @@ DIST gitlab-ce-9.0.1.tar.gz 26350693 SHA256 94549d69650383347256b9f3f0c11f200e0e DIST gitlab-ce-9.0.2.tar.gz 26349628 SHA256 2b8913a1ed5f49c59314ce1aa5874d917d38c3c663a981aac3374ced8a123629 SHA512 563450eb22dc2eb7d8aec52b7fb2ec58339bf59f0b46e59fa2a98ff8e2634d95948b9872afc1e64bff840985ed15b8efd588661f075c27cdb984c125ea41624e WHIRLPOOL 3660dde5cadb279f48d2c43e4fb3ba47b7d7a07c38e25940d55b8cb8bf4d750ca97088db73d1f808b3ff5ef8b3867d45ec0289e1ff1e0c5e362994ed38fc9eb9 DIST gitlab-ce-9.0.7.tar.gz 26358937 SHA256 e70d1f3926f3b7e872353da2d21a7a6b44ed51a3b145e237f4768f8190eaeb08 SHA512 c3f28ef81eb546727f895d92a120e1e459b8eceb1c1068888ec9972444355c02d441bd8d85c360e684f0389b0c6f2ffae57a69a220639fa9ffe7f8c63730daad WHIRLPOOL 04380783f5074fcfe905b129e6e457da44e9dbd1d6d43d70309ea0f55fa8f916af28f52460dc68b1b588feb8d99b8ba543e52bffdee93f3115efa3473c8728ce DIST gitlab-ce-9.1.4.tar.gz 30512187 SHA256 36e5e41c89e215ec4b25c4129a9a47878b1e4e6104c54b0cdf8981d3f39f070a SHA512 d29f2d805c14cc98f0851c4877e91ab6785bbe487341b2bf3392ee293bc683bf00dd455e400d2c3a27b8dc0a6ffa020768cbd11ec9ee029b5f0f2ccfcbfb3a4e WHIRLPOOL a05f4c66c20df274d42ea3c76491fd7ba28561ffe4f7fc97c542bd79c54bbea09646be3f7a8d5b896023e6cd1e4e13ad40915f58e91519e04dedc8939f2a405e +DIST gitlab-ce-9.2.2.tar.gz 30969181 SHA256 6d8a1ab6c808c53bccc2c3f3b4dc052cf9e8e7d1a47d5c83ef799afad5304815 SHA512 c047d8f471e360abe913bccde07a8604153dbe064df69a5797ab5f82f4aa7f7191f5ba26444d846364518a8575a48c5be6111df4516f961b714257d58c5ca730 WHIRLPOOL 246b24d44b8654ff9ad1750c930f8a885c0db1c579b28944e71f6aa9c081b940b8f3fa418d0bb7c42fcf517b1837e4782ea5388000be262d29aa703b086316c2 EBUILD gitlab-ce-8.15.8.ebuild 11986 SHA256 6c86e66d4b568b88dd44ec52401e25c33b2d5e61d9a76e77180320d40ef57132 SHA512 91e1dc1cd8b9b77ea039e7e194b06c44900511b9e7787a714faec14746f96da6d00aa66bd16763732c468d8a46815e29fe761349a0a0d712db21bd4a12d31e06 WHIRLPOOL 50923df1fdda85abf7c7984a49d73d6486628439612de18ec3914274f3a053ce98ffbffec0f6ca9f2f9ba1ca9491467de0762d2d4a31ea480f32eb68222c79f9 EBUILD gitlab-ce-8.16.8.ebuild 11986 SHA256 0d5bdaf00e45fd5f48af3873cf4c9782d038338e8aa0e3a5a6fdb00ae868f771 SHA512 973a44e9d631203bf33596cfd5be1c999bbbff1ce25ff0cddd2707e59c9d98321c5efe0bbc2d62995b7b4f32c7a75b43f4bb4b3cfb10e25a64eaef5319b8ddf2 WHIRLPOOL 367b66c83a8a9356d5b76a2a03f1bd8e38714f8d7c4228d9b2f019f6ec63bff66be93c2ce657c43ae970bc693ed94fdd5b2e32488222dcae0cacbfcc15b3cb1b EBUILD gitlab-ce-8.17.4.ebuild 12932 SHA256 17cb7cc858d71085d69e6ccca5b3802244e4db92bb5092e0717b53f21564e50b SHA512 3ee082772b29b6efbd90870bf92bdf9bd2ca8821bdba724574a2c58b39e5acbc5fa8bfa4463c1ab350f5633c8f821f2f7a90952b765aacf7ff381bb7ce77b9b7 WHIRLPOOL dded31fed93b7c2a553a6a8cc07a883302a76df85d804b03ae6dfce6be447b090c54f639d9894c6d56819c409b32a8ccd1280a054ec48120b2eb58ea0890c731 @@ -31,6 +33,7 @@ EBUILD gitlab-ce-9.0.1-r1.ebuild 13087 SHA256 4dda1de15a8fb05d2fc5b97a99113fe93b EBUILD gitlab-ce-9.0.2.ebuild 13087 SHA256 f8705f07c62a4988b10b1c83ddb743032d1838f24b562a0f69df72ba690ed1f3 SHA512 c0cf1b1228e5499c7643811f80db010dce67d20da5aefd6a40ef2a537bb4ed7b589e8f878307a06ec1fb8d053a3e2ea00a97c66a7edb6e4845f92b493fad9b82 WHIRLPOOL 2df17352ea8ea15fbb74a10b1941b369d642f65453d10599d599925cc46d5f71e9a6149dc56acf15a501750228dc1eecceeb19d72890f3835a514c891f84dcc6 EBUILD gitlab-ce-9.0.7.ebuild 13087 SHA256 68f0d2d7c8cde9b07bb280bb2f6b6d3fea4de6791571f27aaf619853940d2d30 SHA512 21545e878a2f60d082b132256fb09c72a5cc1d252115f448770432fd98becc5aeef42281f00fa55642a1a0866f41f107903b33160e52c61bc4c6d7811f5a06fe WHIRLPOOL 6ad81da17812721b94e8fcfc2328a24355a1f777d067ff2f557f0928ea2f4af55f0edb8587b8fe004f5481254cd72a520a7a77a6a601afc12315d8d37773f5c8 EBUILD gitlab-ce-9.1.4.ebuild 13214 SHA256 72983da6d39625c6263e066dd4b965418e8396e3acd68fedd5ed5961e09c274b SHA512 b1b7ee8e9ccb9ee672467ef69ef74ccde04381b5135c8652d5bb030581f64e8881e31c274bcc865dac608185c5922d639f2c500b05dfdb40edbe462b337667e2 WHIRLPOOL 01554bbced8a3255ec0439c9e5352e4bf4e963daa3df36d3ac90bf6acded983c0d44bcb10fd40006b3c1ebb9a94c170b7efd63adef8272eb936954e3f344e7b2 +EBUILD gitlab-ce-9.2.2.ebuild 13276 SHA256 47d906938442e48c8c42a78bc83e058c6263502a24ef9f78af7c245bbc2ace26 SHA512 f52e7b9e371eb016ea04b572255a79221e6956db23599e064c079f73dc6484e11ee8267b4114dd70f3a195bba6aae5e69f6b88649c0fce4337560706a0f8ef82 WHIRLPOOL 0ae0ef9fc5fc062e14d4a5f3464868c288ba3effab5599e907306633a2e3ce2b9c24e3be1ff2b54d2d7d0d367f65553478e75f3d51b0eaf5d6e4a59a11a3a2c6 EBUILD gitlab-ce-9999.ebuild 13029 SHA256 b4a010ff86baa4f2a7cf1349e74f49e763b88bb675f01acdbaf16c204597859d SHA512 6cdfdbf27a3ccec276ce06c25dc5a76cba6fb25f807650f5e2e5ed600fd03e487a60de3481719c53fffb43d3f7d2a0e8258a41dd0e461be1e82252eb59105372 WHIRLPOOL 0994bab6308ac1c466e17d53b7057f51e472b4b5cc0ca1d91b11217d0caf9448d3a69d769732c2acb4194f3eb5a94b8bb3c98441ec99ca94066900c7fe5e85ac MISC ChangeLog 17848 SHA256 d57ce2fbafb6a62a30a4bf02feff9c37f33b94f8158f6b50c87053d8422307b2 SHA512 3b83ca4c32949ff08d1d59131388f3f59497c7831c5b09d1fd10a36445f1c383dbf04e91ddeff6c9b6c5131578450afb354b03819ddba80f7249b0ddd0b4f2e9 WHIRLPOOL d5ab8749e2c7d6a18adf2d63a7c7a69b40d93357d3e5714f131ec7cacca6008ca41f23a2c2bb8ece1ba10aaebf47b5f1363a2c4a29bbbe45672d06904e82f614 MISC metadata.xml 801 SHA256 3dc7486a12903f47f65968d524c93500ba30a4a09fa57e5a9dacf356509b44bb SHA512 e132754b72e64246531fa883400a0cf1a473ac5a6a49623db58ccf118a038b7cf37df03d9550f37b4a25f9ddbb1dcc5652ec9a4f2259d8e3ce202692c4025f41 WHIRLPOOL e9d961681fd790008eaf80fa07ce2c55a00a58f2e920d759793783ca8c8f508602a777e94c0cb65fe87c7dbef0cabdf26e4f4082584421097d939cbab20c4ac6 diff --git a/www-apps/gitlab-ce/files/03-gitlab-ce-9.2.2-database.yml.patch b/www-apps/gitlab-ce/files/03-gitlab-ce-9.2.2-database.yml.patch new file mode 100644 index 0000000..b4b2c8c --- /dev/null +++ b/www-apps/gitlab-ce/files/03-gitlab-ce-9.2.2-database.yml.patch @@ -0,0 +1,102 @@ +diff --git a/config/database.yml.mysql b/config/database.yml.mysql +index db1b712..a3b5ecc 100644 +--- a/config/database.yml.mysql ++++ b/config/database.yml.mysql +@@ -3,42 +3,12 @@ + # + production: + adapter: mysql2 +- encoding: utf8 +- collation: utf8_general_ci ++ encoding: utf8mb4 ++ collation: utf8mb4_general_ci + reconnect: false +- database: gitlabhq_production ++ database: gitlab + pool: 10 + username: git + password: "secure password" + # host: localhost +- # socket: /tmp/mysql.sock +- +-# +-# Development specific +-# +-development: +- adapter: mysql2 +- encoding: utf8 +- collation: utf8_general_ci +- reconnect: false +- database: gitlabhq_development +- pool: 5 +- username: root +- password: "secure password" +- # host: localhost +- # socket: /tmp/mysql.sock +- +-# Warning: The database defined as "test" will be erased and +-# re-generated from your development database when you run "rake". +-# Do not set this db to the same as development or production. +-test: &test +- adapter: mysql2 +- encoding: utf8mb4 +- collation: utf8mb4_general_ci +- reconnect: false +- database: gitlabhq_test +- pool: 5 +- username: root +- password: +- # host: localhost +- # socket: /tmp/mysql.sock ++ # socket: /run/mysqld/mysqld.sock +diff --git a/config/database.yml.postgresql b/config/database.yml.postgresql +index c517a4c..28f7993 100644 +--- a/config/database.yml.postgresql ++++ b/config/database.yml.postgresql +@@ -4,45 +4,9 @@ + production: + adapter: postgresql + encoding: unicode +- database: gitlabhq_production ++ database: gitlab + pool: 10 + # username: git + # password: + # host: localhost + # port: 5432 +- +-# +-# Development specific +-# +-development: +- adapter: postgresql +- encoding: unicode +- database: gitlabhq_development +- pool: 5 +- username: postgres +- password: +- # host: localhost +- +-# +-# Staging specific +-# +-staging: +- adapter: postgresql +- encoding: unicode +- database: gitlabhq_staging +- pool: 5 +- username: postgres +- password: +- # host: localhost +- +-# Warning: The database defined as "test" will be erased and +-# re-generated from your development database when you run "rake". +-# Do not set this db to the same as development or production. +-test: &test +- adapter: postgresql +- encoding: unicode +- database: gitlabhq_test +- pool: 5 +- username: postgres +- password: +- # host: localhost diff --git a/www-apps/gitlab-ce/gitlab-ce-9.2.2.ebuild b/www-apps/gitlab-ce/gitlab-ce-9.2.2.ebuild new file mode 100644 index 0000000..218940f --- /dev/null +++ b/www-apps/gitlab-ce/gitlab-ce-9.2.2.ebuild @@ -0,0 +1,427 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +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="ruby23" + +inherit eutils ruby-ng user systemd + +MY_PV="v${PV/_/-}" +MY_GIT_COMMIT="cbde95c281af5cdd6b4dee3bdb1bdb360eb71d2c" + +# Gitaly is optional in Gitlab 9.2, and it is not yet supported by this +# ebuild. But the version declaration is already here. +GITALY_VERSION="0.10.0" +GITLAB_PAGES_VERSION="0.4.2" +GITLAB_SHELL_VERSION="5.0.4" +GITLAB_WORKHORSE_VERSION="2.0.0" + +DESCRIPTION="GitLab is a free project and repository management application" +HOMEPAGE="https://about.gitlab.com/" +SRC_URI="https://gitlab.com/gitlab-org/${PN}/repository/archive.tar.gz?ref=${MY_PV} -> ${P}.tar.gz" +RUBY_S="${PN}-${MY_PV}-${MY_GIT_COMMIT}" + +RESTRICT="mirror" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~x86 ~arm64" +IUSE="kerberos mysql +postgres +unicorn systemd pages -gitaly 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/ragel + >=net-libs/nodejs-4.3.0 + >=sys-apps/yarn-0.17.0 + postgres? ( >=dev-db/postgresql-9.1:* ) + mysql? ( virtual/mysql ) + kerberos? ( virtual/krb5 )" +CDEPEND=" + dev-util/cmake + virtual/pkgconfig" +COMMON_DEPEND=" + ${GEMS_DEPEND} + ~dev-vcs/gitlab-shell-${GITLAB_SHELL_VERSION} + >=dev-vcs/git-2.8.4 + ~www-servers/gitlab-workhorse-${GITLAB_WORKHORSE_VERSION} + kerberos? ( !app-crypt/heimdal ) + rugged_use_system_libraries? ( net-libs/http-parser dev-libs/libgit2:0/24 ) + pages? ( ~www-servers/gitlab-pages-${GITLAB_PAGES_VERSION} ) + gitaly? ( ~www-servers/gitaly-${GITALY_VERSION} )" +DEPEND=" + ${CDEPEND} + ${COMMON_DEPEND}" +RDEPEND=" + ${COMMON_DEPEND} + >=dev-db/redis-2.8 + virtual/mta + systemd? ( sys-apps/systemd:0= )" +# required bundler >= 1.14.2 +ruby_add_bdepend " + virtual/rubygems + >=dev-ruby/bundler-1.13.7" + +# +# fix-sendmail-config: +# Fix default settings to work with ssmtp that doesn't know '-t' argument. +# fix-redis-config-path: +# Point to the absolute location of redis_config.rb +# +RUBY_PATCHES=( + "01-${PN}-8.7.5-fix-sendmail-config.patch" + "02-${PN}-9.0.0-fix-redis-config-path.patch" + "03-${PN}-9.2.2-database.yml.patch" + "04-${PN}-8.12.7-fix-check-task.patch" + "05-${PN}-9.0.0-replace-sys-filesystem.patch" + "06-${PN}-8.17.0-fix-webpack-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}" + +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} + + 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" + + einfo "Cleaning old gems ..." + ${RUBY} /usr/bin/bundle clean + + # clean gems cache + rm -Rf vendor/bundle/ruby/*/cache + rm -Rf vendor/bundle/ruby/*/bundler/gems/charlock_holmes-dde194609b35/.git + + ## RC script ## + + if use systemd ; then + ewarn "Beware: systemd support has not been tested, use at your own risk!" + systemd_newunit "${FILESDIR}/gitlab-8.13.0-sidekiq.service" "gitlab-sidekiq.service" + systemd_dounit "${FILESDIR}/gitlab-unicorn.service" + systemd_dounit "${FILESDIR}/gitlab-workhorse.service" + systemd_dounit "${FILESDIR}/gitlab-mailroom.service" + systemd_dotmpfilesd "${FILESDIR}/gitlab.conf" + else + local rcscript=gitlab-8.13.3-sidekiq.init + use unicorn && rcscript=gitlab-8.13.3-unicorn.init + + cp "${FILESDIR}/${rcscript}" "${T}" || die + sed -i \ + -e "s|@USER@|${MY_USER}|" \ + -e "s|@GITLAB_BASE@|${dest}|" \ + -e "s|@LOGS_DIR@|${logs}|" \ + "${T}/${rcscript}" \ + || die "failed to filter ${rcscript}" + + newinitd "${T}/${rcscript}" "${MY_NAME}" + fi + + # fix permissions + fowners -R ${MY_USER}:${MY_USER} ${dest} ${temp} ${logs} +} + +pkg_postinst() { + elog "If this is an update from a previous version, stop your GitLab" + elog "instance and issue the following command to perform all required" + elog "migrations:" + elog " emerge --config \"=${CATEGORY}/${PF}\"" + elog "PLEASE NOTE: It's HIGHLY recommended to backup your database" + elog "before running the config phase. Run these commands (as root):" + elog + elog " cd /opt/gitlab" + elog " sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production" + elog + elog "If this was a fresh install, follow these steps:" + 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 initialize the environment:" + elog " emerge --config \"=${CATEGORY}/${PF}\"" + elog " Note: Do not forget to start Redis server first!" + 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." + if use postgres; then + elog "Please note: As of GitLab 8.6, users of PostgreSQL need to enable the" + elog "`pg_trgm` extension by running the following command as a PostgreSQL" + elog "super user for *every* GitLab database:" + elog " CREATE EXTENSION IF NOT EXISTS pg_trgm;" + elog "For details, see the documentation at the GitLab website." + fi + if use mysql ; then + ewarn "PLEASE also read this document about needed migrations on MySQL:" + ewarn "https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/database_mysql.md" + ewarn "Failing to follow those instructions may make the config phase fail!" + fi +} + +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}/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 + + su -l ${MY_USER} -c "git config --global repack.writeBitmaps true" + + # determine whether this is an update or a fresh install. we do this by + # checking whether the ${DEST_DIR}/.git directory exists or not + # + if [ -d "${DEST_DIR}/.git" ]; then + local update=true + else + local update=false + fi + + ## Initialize app ## + + local RAILS_ENV="production" + local RUBY=${RUBY:-/usr/bin/ruby} + local BUNDLE="${RUBY} /usr/bin/bundle" + + # FIXME: this line existed in older ebuilds, but the variable is + # never used. what was it for!? + # local dbname="$(ryaml ${CONF_DIR}/database.yml production database)" + + if [ "${update}" = 'true' ]; then + einfo "Migrating database ..." + exec_rake db:migrate + + # https://github.com/gitlabhq/gitlabhq/issues/5311#issuecomment-31656496 + einfo "Migrating iids ..." + exec_rake migrate_iids + + einfo "Installing npm modules ..." + exec_rake yarn:install +# exec_yarn install + + einfo "Cleaning old precompiled assets ..." + exec_rake gitlab:assets:clean + + einfo "Cleaning cache ..." + exec_rake cache:clear + else + # 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 + + einfo "Initializing database ..." + exec_rake gitlab:setup + + einfo "Installing npm modules ..." + exec_rake yarn:install +# exec_yarn install + fi + + einfo "Precompiling assests ..." + exec_rake gitlab:assets:compile + + 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 + elog + elog "If you want to make sure that the install/upgrade was successful, start" + elog "Gitlab now and then run these commands (as root):" + elog + elog " cd /opt/gitlab" + elog " sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production" + elog " sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production" + elog + if ! use systemd ; then + elog "You may also run" + elog " /etc/init.d/gitlab check" + elog " for convenience." + 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} NODE_ENV=${RAILS_ENV}" + + echo " ${command}" + su -l ${MY_USER} -c " + export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; export NODE_PATH=${DEST_DIR}/node_modules + cd ${DEST_DIR} + ${command}" \ + || die "failed to run rake $@" +} + +#exec_yarn() { +# local command="yarn $@ --${RAILS_ENV}" +# +# echo " ${command}" +# su -l ${MY_USER} -c " +# export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; export NODE_PATH=${DEST_DIR}/node_modules +# cd ${DEST_DIR} +# ${command}" \ +# || die "failed to run yarn $@" +#}