diff --git a/dev-vcs/gitlab-shell/Manifest b/dev-vcs/gitlab-shell/Manifest index b3bdd46..fc792f6 100644 --- a/dev-vcs/gitlab-shell/Manifest +++ b/dev-vcs/gitlab-shell/Manifest @@ -3,7 +3,9 @@ DIST gitlab-shell-2.4.1.tar.gz 21776 SHA256 9b656a8662b1e8d95e30470209c613d6a7b4 DIST gitlab-shell-2.4.3.tar.gz 22930 SHA256 16bdda3a3b2fe933c48f74a79a4e604fd28eb7c8d0baea60177dff19ffd7f7ca SHA512 b2884bf4fb329cd0e82233dfd8712ced193d20edd271a980ddf0c9ce8496ae09d9bd14d927876a1075165733c0ab247ab25239a6769d49cf9845a438fddd864c WHIRLPOOL bdb6dd267d94488eb57c690849d7aa60a0c8502319a4c34af477941bfdb3b905566e70f199f1a1ee929ef3c7fb3d176fdbef0b2d3227d85b01e75be6579e385f DIST gitlab-shell-2.5.4.tar.gz 31787 SHA256 d27d5c5d73724d68af99783f8fc561b9398582188d0ecee4265b310cd41e3a5b SHA512 40d687707a3c65b91f9a7f9db257993618e09d7ad9ceb5636e926690795053f62664ac1a19b90c6aebc0d97c709aa4c6be17fab52a8378a74238168b36c238d5 WHIRLPOOL c89fcada281844d3552ed992f56cb31a2bded8c6e8db6bc564ddb91ae3aa566c2a8493306707c2b726c36de284a308f30e74ffe7a2212db3c58e7578e985e0c2 DIST gitlab-shell-2.6.2.tar.gz 32108 SHA256 4e9885379af546ad50165f3c95110f130f8a4b2bddfae1a746f225df19960826 SHA512 353a25a391ad6818f631437cbd6735491e7ae61e0184f5ee52a69eb9a1f24354fc7c6752896c91dbf7ff6dd5f9df6ae8cb4cb0f022ac3d838fa693aa5244410a WHIRLPOOL c32642442b3a1d0519aa563261cd353ee8bc2cfc115d868a3179f56d947be0fdbbd3bb6bea8a4b2e1077f8de890b430a534f1135b59e2562d06c41ce0b995db0 +DIST gitlab-shell-2.6.3.tar.gz 32152 SHA256 1c5582aa1f5552c2299b186fe12bf1ee5bafcf2bf855ecc193b1ca346d25ae9d SHA512 bac120eef30b7c6c2ee59a0a1063eed3416bc1eaea99df7a61bcb98d2b64528f948944f3daab44af186f9383e740b6746955d2a0425b5e8cebaf0836c853b235 WHIRLPOOL 94b5c3d7ca26601a1bdad19187b2694895ef932b175a1cd3a6295ac3f66f50588120e077c313f7b488ab4ae5b76749c673a4234fee3f85cad82e10c89e2dc436 EBUILD gitlab-shell-2.4.1.ebuild 3501 SHA256 7df2653edb6213906f9c51f96b1516029df2bba7fed1b11468b1029e6b3f17bd SHA512 8b647a6b4513631c385f7d0b84f58f6fc4e29409512bcf7ff6a0f10c8b9cb292afa13f5ff6a1c35898a0a3f207866472f3aee1f85f77796648f1fb055281f3bd WHIRLPOOL 20d1c0545db9a11a99e6d81dfee08f39d08759534178c2fcca2a74146954cdd292bb071e53a876905cb7446bbe699b78ef26d7349611221453cfee644cafb561 EBUILD gitlab-shell-2.4.3.ebuild 3502 SHA256 6c604db35e20522c499f45d5994c421ea08b25313f630af8349441ddae96d757 SHA512 8d492097a53e1314212c263730b5f00f8f53c8d52b1fdc8b6c5d8abed86927f4ff56c2bf04a430dd6aa0b155d4531881d5fbbd7d8948131ec609dc2d7eb41080 WHIRLPOOL 2b491377ffe21cd0706e6c8422e1c5b52530460b08abbc315cb7e172a052f1acfdabc335575b284bd8a9107cc83d4d1411e3afe1294710d4064d14025acf1bb4 EBUILD gitlab-shell-2.5.4.ebuild 3502 SHA256 6c604db35e20522c499f45d5994c421ea08b25313f630af8349441ddae96d757 SHA512 8d492097a53e1314212c263730b5f00f8f53c8d52b1fdc8b6c5d8abed86927f4ff56c2bf04a430dd6aa0b155d4531881d5fbbd7d8948131ec609dc2d7eb41080 WHIRLPOOL 2b491377ffe21cd0706e6c8422e1c5b52530460b08abbc315cb7e172a052f1acfdabc335575b284bd8a9107cc83d4d1411e3afe1294710d4064d14025acf1bb4 EBUILD gitlab-shell-2.6.2.ebuild 3500 SHA256 8de274d1be0c80ad57639ade47a6ca9d4446aed136a8cf75d6d821a3e9c414cf SHA512 10f1720fdcdbf96f95b9c5c5e2d396d49b1012bb7dc41c8cea3d9b9d3add0c7dc9574b47a90790e189e755ca8097c076a92cb279291f7112af1bfe5c6fd15fdd WHIRLPOOL affb0799af07ee36201eb5594296a74eb279d176b1713f6566cec067db5b4749057c5189b291f9fe28d94bb35e1e8e7d5baa6f00915ef9fa220199b3ed2b66c6 +EBUILD gitlab-shell-2.6.3.ebuild 3500 SHA256 8de274d1be0c80ad57639ade47a6ca9d4446aed136a8cf75d6d821a3e9c414cf SHA512 10f1720fdcdbf96f95b9c5c5e2d396d49b1012bb7dc41c8cea3d9b9d3add0c7dc9574b47a90790e189e755ca8097c076a92cb279291f7112af1bfe5c6fd15fdd WHIRLPOOL affb0799af07ee36201eb5594296a74eb279d176b1713f6566cec067db5b4749057c5189b291f9fe28d94bb35e1e8e7d5baa6f00915ef9fa220199b3ed2b66c6 diff --git a/dev-vcs/gitlab-shell/gitlab-shell-2.6.3.ebuild b/dev-vcs/gitlab-shell/gitlab-shell-2.6.3.ebuild new file mode 100644 index 0000000..ef904e0 --- /dev/null +++ b/dev-vcs/gitlab-shell/gitlab-shell-2.6.3.ebuild @@ -0,0 +1,126 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="5" + +USE_RUBY="ruby20 ruby21" + +inherit eutils ruby-ng user + +DESCRIPTION="SSH access and repository management for GitLab" +HOMEPAGE="https://github.com/gitlabhq/gitlab-shell" +SRC_URI="https://github.com/gitlabhq/gitlab-shell/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="" + +DEPEND="" +RDEPEND=" + dev-vcs/git + dev-db/redis + virtual/ssh" +ruby_add_bdepend " + virtual/ruby-ssl" + +MERGE_TYPE="binary" + +RUBY_PATCHES=( + "${PN}-2.0.0-config-paths.patch" +) + +GIT_USER="git" +DEST_DIR="/usr/share/${PN}" +DATA_DIR="/var/lib/git" +LOGS_DIR="/var/log/gitlab" +CONF_FILE="/etc/gitlab-shell.yml" + +pkg_setup() { + enewgroup ${GIT_USER} + enewuser ${GIT_USER} -1 /bin/bash ${DATA_DIR} "${GIT_USER}" + + local git_shell=$(egetshell ${GIT_USER}) + if [ ! ${git_shell} -ef '/bin/bash' ]; then + ewarn "User ${GIT_USER} already exists, but with the shell ${git_shell}." + ewarn "Changing shell to /bin/bash ..." + + usermod -s /bin/bash ${GIT_USER} \ + || die "failed to change login shell for ${GIT_USER}" + fi +} + +all_ruby_prepare() { + # fix paths + sed -i -E \ + -e "s|/home/git|${DATA_DIR}|" \ + -e "s|[\# ]*(log_file: ).*|\1\"${LOGS_DIR}/gitlab-shell.log\"|" \ + config.yml.example || die "failed to filter config.yml.example" + + sed -i \ + -e "s|File\.join(ROOT_PATH, 'config.yml')|'${CONF_FILE}'|" \ + lib/gitlab_config.rb || die "failed to filter gitlab_config.rb" +} + +all_ruby_install() { + # install lib + insinto ${DEST_DIR}; doins -r lib LICENSE README.md VERSION + + # install scripts + exeinto ${DEST_DIR}/bin; doexe bin/* + exeinto ${DEST_DIR}/hooks; doexe hooks/* + exeinto ${DEST_DIR}/support; doexe support/* + + # create symlinks to bin + local name; for name in $(basename -a bin/gitlab-*); do + dosym "${DEST_DIR}/bin/${name}" "/usr/bin/${name}" + done + + insinto $(dirname ${CONF_FILE}) + newins config.yml.example $(basename ${CONF_FILE}) + + # create symlink for .gitlab_shell_secret + einfo "creating symlink for .gitlab_shell_secret" + TOKEN_FILE="${DEST_DIR}/.gitlab_shell_secret" + dosym /opt/gitlab/.gitlab_shell_secret "$TOKEN_FILE" + + # prepare directories + diropts -m750; dodir ${DATA_DIR} + diropts -m770; keepdir ${DATA_DIR}/repositories + diropts -m755; dodir ${LOGS_DIR} + + # GitLab stupidly expects that gitlab-shell is in home of git user... + dosym ${DEST_DIR} ${DATA_DIR}/gitlab-shell + + # fix permissions + fowners -R ${GIT_USER}:${GIT_USER} ${DATA_DIR} ${LOGS_DIR} +} + +pkg_postinst() { + # check git home directory + local git_home=$(egethome ${GIT_USER}) + if [ ! "${git_home}" -ef ${DATA_DIR} ]; then + ewarn "An authorized_keys is configured to be inside ${DATA_DIR}/.ssh," + ewarn "but HOME of ${GIT_USER} user is located in ${git_home}. You must" + ewarn "either change the authorized_keys location in ${CONF_FILE}," + ewarn "or change home directory of ${GIT_USER} user to ${DATA_DIR}" + ewarn "and move ${git_home}/.ssh here." + ewarn + fi + + local auth_dir="${git_home}/.ssh" + + elog "Initializing authorized_keys file in ${auth_dir}" + mkdir -p ${auth_dir} + touch ${auth_dir}/authorized_keys + chmod -R u=rwX,go=- ${auth_dir} + chown -R ${GIT_USER}:${GIT_USER} ${auth_dir} + + elog + elog "GitLab Shell was initialized. Repositories are located in" + elog "${DATA_DIR}/repositories, scripts in ${DEST_DIR}/bin." + elog "All gitlab-* scripts was symlinked to /usr/bin to be on your path." + elog + elog "You should change your gitlab_url in: ${CONF_FILE}." +} diff --git a/www-apps/gitlabhq/Manifest b/www-apps/gitlabhq/Manifest index 4f9187d..638de86 100644 --- a/www-apps/gitlabhq/Manifest +++ b/www-apps/gitlabhq/Manifest @@ -14,12 +14,14 @@ AUX gitlabhq-7.9.3-email-custom-reply_to.patch 1787 SHA256 278b23ce845f39a4342af AUX gitlabhq-7.9.3-fix-gemfile.patch 1456 SHA256 ad7deb355b74a156ef04c031ff45946a4852d273b30c4bae2be5b2cb11d0d683 SHA512 f0535f57338833f734701ab9c64a1a1dc9f7d6e7c634756c18e98bd5c6811876e2cbc7d64bd93297d5717d1d1e4f9213c7982c32770000698dc7a718a7b00155 WHIRLPOOL dfc2083e7c3c7895a01f4e1e588610f542a38a636ce9af1165b5c0fa4301fa91a6b58f24833ab9e754ea3024e48894b6b58ee9e3d2acec6cddcc1ecc515b097b DIST gitlabhq-7.10.3.tar.gz 5690032 SHA256 e0d442b3c2bc4ae19bc0f146bc9ee0c07275616323f3aa9ae68a6021cd9e0e42 SHA512 46c59389aa9d699747cbea4790ef89f38b2d7c9a7b7452369be6eba47a3136c1ea8fa12c8a74a40e6700d83a238fc6aee78c7a22468878417e1f201e4f4e077b WHIRLPOOL 37ade7b0c5e33eb1ca018b461e12bbd83d15d89b0201e17e2857d595fca8f3fa783098fc7e090789a00786a83d7299f3597e664a2cf1fe9ea66690c4c8a325d2 DIST gitlabhq-7.10.4.tar.gz 5690013 SHA256 9b87da87316ac32ce34b4826c1c8baf28b539c2289c62320ca69cf86298cdb5b SHA512 b97da9fa51fada1fb0694440f2e64de13faceed5bc716b83b39505af3e3f4680d8691360afd4c9ada0a0b7ed2c451ccb822eedf386aa39cd54cb8d57fe4e70ca WHIRLPOOL 2a0958df369b01c543402a2ff0377adb9ed6b7f508a879b89907c59614cd83ccdd9b1c952fca88921c933772d63cede2131273d74a920b2e99909e75670da84d +DIST gitlabhq-7.11.0_rc2.tar.gz 5730911 SHA256 7bdaacfcde96a23f8f09abf7e236ad636fa785fb9f72101772896675d4cfcbb0 SHA512 0caa351c594f4bb5000a82b21bb930cb24c51194a5604d6c9e5447c6e79cfdb8d791972e0afbf760e251c108b3f55be513a52d28f4674cc8af7804c925e19cda WHIRLPOOL 9febdb701ffd4050f1fc1d47a83d3a161f4f8d029c4edffdd435e70c75a329aa8a94ab1cd3ddb265d46fb876a12a1955969158d4fb83edaa06e987ec497ee7a9 DIST gitlabhq-7.8.1.tar.gz 5302130 SHA256 4308a945b605caa369c0cafc22fbf7aa9f6cf9143ab200cde86c9c9308849153 SHA512 ac789c6264e599f44e50edf4ff09187293f1d2a7f4fc9460b3f28d5753a4d868247fe68a443e50c2bcbd75871ed7a124f1d49e84565da954c83f36154b4cc302 WHIRLPOOL ceb7f82f86d31264321fec76b5344d908327546ba9c2ceec7ad81cd8eaba7832450459251cd3e52825ae00f926f8d74205681abc8e867f97d44eea195dca4652 DIST gitlabhq-7.8.4.tar.gz 5302883 SHA256 84b2f2ed08aa524bcd85145921b99d176da1ed5210ebd00ef16b65b0c69c0c29 SHA512 35d803754b46b11087665f766279cd5b5fe348ba48cec3d889dc393ffa407f50bf9aea8564fd1f3e5fe1b513eec3a4e4e5032ed9c4f6e47189c59a7a60a515ff WHIRLPOOL d97911ac6cf5dcddffd784ee757846ca11c8134f80f88f9fbbb1ef90a3ed7a189ba00c126686fd34ba8889e0fafa0fe0059c9613ab922a1f155d8bfca5777d53 DIST gitlabhq-7.9.3.tar.gz 5390351 SHA256 265bf36d8560b8cac59a24474dc8addb7854435600589faae2c46f40bc232b18 SHA512 2387ae0228dbb75d5c58bb7240a7a04a7c36edbc994f9aac4d26509b1163e3e65779958f985de11474693ec6a09e0662d8af8a6fd78f13507e1d9ab38a4092d8 WHIRLPOOL 800148f5490c9a559604d47cb4a1733afbc6dd3bc79755b7985152c2514335d0e15ecef5c4a250bcbae821db8d0dbbaf2457e55b9b6abec4068777282b98ea01 DIST gitlabhq-7.9.4.tar.gz 5392634 SHA256 bbc6a0647832f983322ce2c80f3d642354709b32de28f8ba6009c508c3600ece SHA512 2503c32143df3d46bd7abb8956aa3e65d436f02bd993024c5fbd4838f90b746de44f5a78f82572b6d9e312f34e5ae27a4c51706ae9ae315c069cd14519e8d90d WHIRLPOOL 6bd1d8a451693c8906fe32c5705f57aacb59c69c1168d9d7461e7a6665b3ae7326ebaaaa1799af4c4d246fd6a071383eba48729dc4627de6ca75180771aa6db8 EBUILD gitlabhq-7.10.3.ebuild 11280 SHA256 b68816f36f41d7c2771448db041b56c9c12d82b6326856e37c26b0d763463e2a SHA512 f7ad09d20d0c5a9167f5e9118ca56a6ce9b441e5c80d3d83dc5ed43d8809026cb285941747283c0813651a89fc3a0e25d0a1c11ab9efdf282dfeb8349214ae7b WHIRLPOOL 0b34c86392af8607a4a30c3b51dd4ec0816d4af0183e50cbe750105a644c0b6bcfc34454bd78cbdb6a5d358954cf390593778e3f5aa6ad453604f6e4a4722e05 EBUILD gitlabhq-7.10.4.ebuild 11291 SHA256 d9958266f80306ae1961e00f50fd211d3d1b9496686301c1d145ecfcde7b03b1 SHA512 516d140f375ff5b915332555f06d805e4455eebab0cfa33dac2c0e8e1460c9f9611573d5f0604e75416f6ee376870123f3f3c4fc7405badc86a1ecbcfe5c4150 WHIRLPOOL ae0281c20bf798cc09ebd52e9e60393e36aee1be5ec10c26ec6bce2cf7a811477fcb67baf99815ef755521b25d24678bf24a42d569fac31daaa29bf6f85911a0 +EBUILD gitlabhq-7.11.0_rc2.ebuild 11381 SHA256 05b93ff7702c30f74a83abe534006b5d67ae4f5501a1e44fadded54a6e430b0c SHA512 c2c215913dc648ac62b9654cb806faff4f2e6db029b6d104cf8c9d33a85d395776f96ca87d269e1ed7e9007e7566bd680db31e20186773ff348fb2d99ce3d8f4 WHIRLPOOL 8851923bfeec5ff2c5c76b3883e557fa9a7a489c427db562446b553a7a5dd31d96f9c9ab7f6e204dc7bce3a53ff9180265260402d1547b65e2583c6761177d7c EBUILD gitlabhq-7.8.1.ebuild 10966 SHA256 b5d3b822a4ce401b50909f0663bef4dacf7c9673c51bbbe2f600533f3bf7c365 SHA512 630b0b2bcda6fb7c5b407b4c094e35ad9de74ea9e6fd959f914f9944cd543ced2c3f9b1e8d3f98c6d3f1e0a3f6873e4ca64817ae3fe2aed61c4e656995e8ef62 WHIRLPOOL 3cede9b536a86cce0cc024a957d7b29c472cf60223ba9321bbe9e4b885cb9a58c3438d07708280a76dafb811551c3576559c4e6ec71b2050c3e81e88f460bce4 EBUILD gitlabhq-7.8.4.ebuild 11421 SHA256 bb3de388ee40f9d63789c65da6d331f543870e88371c65a1f56ad019bf13d07f SHA512 600e93ceb3b4dbf018197e1462e14501bb6a36e1febead7078743034137e442d9104e505a4de622a6ca6108ef0f2427f4feb08bd2dddf95cae3830b2aa744984 WHIRLPOOL 2d30fe945665abe83ca138a49b18eb808d555b9a1f00e61c197cc3bfbc3167a1b46359e639893628f0dcb2bad871571ba416982685602c5a9195240986083906 EBUILD gitlabhq-7.9.3.ebuild 11316 SHA256 491ab8495fe600a625a03826d5f4f0a70cd54781c69b35de4eefaa7d4bbca5d0 SHA512 c80a1a04c3090603bd2f795624a97ed9e69451d4027321ffa7291b252a643a7cc14b50303b5fec0968b79101b3d3c304ff9d3731dd897cfb2e7a0d7fc4ed177f WHIRLPOOL 84dba3eb8abc110fb88b71db1cf4ed1f1085109c6af330094e50a7eedd18ce4721a5157745978a2705a93d1b21d53d57a80acf85a121926259d723235dcce416 diff --git a/www-apps/gitlabhq/gitlabhq-7.11.0_rc2.ebuild b/www-apps/gitlabhq/gitlabhq-7.11.0_rc2.ebuild new file mode 100644 index 0000000..13f353d --- /dev/null +++ b/www-apps/gitlabhq/gitlabhq-7.11.0_rc2.ebuild @@ -0,0 +1,375 @@ +# 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" +SRC_URI="https://github.com/gitlabhq/gitlabhq/archive/v7.11.0.rc2.tar.gz -> ${P}.tar.gz" +RUBY_S="${PN}-7.11.0" + +RESTRICT="mirror" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="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.6.3 + dev-vcs/git + !app-crypt/heimdal" +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=( + "${PN}-7.9.3-fix-gemfile.patch" + "${PN}-7.10.3-fix-project-name-regex.patch" + "${PN}-6.0.2-fix-sendmail-config.patch" +) + +MY_NAME="gitlab" +MY_USER="git" # should be same as in gitlab-shell + +DEST_DIR="/opt/${MY_NAME}" +CONF_DIR="/etc/${MY_NAME}" +LOGS_DIR="/var/log/${MY_NAME}" +TEMP_DIR="/var/tmp/${MY_NAME}" + +# When updating ebuild to newer version, check list of the queues in +# https://gitlab.com/gitlab-org/gitlab-ce/blob/v${PV}/bin/background_jobs +SIDEKIQ_QUEUES="post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default" + +all_ruby_prepare() { + ewarn "Please note: This version of the Gitlab ebuild is unslotted, unlike older" + ewarn "versions (<7.8.4). Therefore, some directories have changed. Please update" + ewarn "your configuration accordingly. The changed directories as as follows:" + ewarn "- /etc/gitlab-6 -> /etc/gitlab" + ewarn "- /opt/gitlab-6 -> /opt/gitlab" + ewarn "If you feel uncomfortable with this change, please abort the build now." + sleep 5 + + # fix paths + local satellites_path="${TEMP_DIR}/repo_satellites" + local repos_path=/var/lib/git/repositories + local shell_path=/usr/share/gitlab-shell + sed -i -E \ + -e "/satellites:$/,/\w:$/ s|(\s*path:\s).*|\1${satellites_path}/|" \ + -e "/gitlab_shell:$/,/\w:$/ s|(\s*path:\s).*|\1${shell_path}/|" \ + -e "/gitlab_shell:$/,/\w:$/ s|(\s*repos_path:\s).*|\1${repos_path}/|" \ + -e "/gitlab_shell:$/,/\w:$/ s|(\s*hooks_path:\s).*|\1${shell_path}/hooks/|" \ + config/gitlab.yml.example || die "failed to filter gitlab.yml.example" + + local run_path=/run/${MY_NAME} + sed -i -E \ + -e "s|/home/git/gitlab/tmp/(pids\|sockets)|${run_path}|" \ + -e "s|/home/git/gitlab/log|${LOGS_DIR}|" \ + -e "s|/home/git/gitlab|${DEST_DIR}|" \ + config/unicorn.rb.example || die "failed to filter unicorn.rb.example" + + sed -i \ + -e "s|/home/git/gitlab/tmp/sockets|${run_path}|" \ + lib/support/nginx/gitlab || die "failed to filter nginx/gitlab" + + # modify default database settings for PostgreSQL + sed -i -E \ + -e 's|(username:).*|\1 gitlab|' \ + -e 's|(password:).*|\1 gitlab|' \ + -e 's|(socket:).*|\1 /run/postgresql/.s.PGSQL.5432|' \ + config/database.yml.postgresql \ + || die "failed to filter database.yml.postgresql" + + # rename config files + mv config/gitlab.yml.example config/gitlab.yml + mv config/unicorn.rb.example config/unicorn.rb + + local dbconf=config/database.yml + if use postgres && ! use mysql; then + mv ${dbconf}.postgresql ${dbconf} + rm ${dbconf}.mysql + elif use mysql && ! use postgres; then + mv ${dbconf}.mysql ${dbconf} + rm ${dbconf}.postgresql + fi + + # remove useless files + rm -r lib/support/{deploy,init.d} + use unicorn || rm config/unicorn.rb +} + +all_ruby_install() { + local dest=${DEST_DIR} + local conf=${CONF_DIR} + local logs=${LOGS_DIR} + local temp=${TEMP_DIR} + + # prepare directories + diropts -m750 + dodir ${logs} ${temp} ${temp}/repo_satellites + + diropts -m755 + dodir ${conf} ${dest}/public/uploads + + dosym ${temp} ${dest}/tmp + dosym ${logs} ${dest}/log + + # install configs + insinto ${conf} + doins -r config/* + dosym ${conf} ${dest}/config + + echo 'export RAILS_ENV=production' > "${D}/${dest}/.profile" + + # remove needless dirs + rm -Rf config tmp log + + # install the rest files + # using cp 'cause doins is slow + cp -Rl * "${D}/${dest}"/ + + # install logrotate config + dodir /etc/logrotate.d + cat > "${D}/etc/logrotate.d/${MY_NAME}" <<-EOF + ${logs}/*.log { + missingok + delaycompress + compress + copytruncate + } + EOF + + ## Install gems via bundler ## + + cd "${D}/${dest}" + + local without="development test aws" + local flag; for flag in mysql postgres unicorn; 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_newunit "${FILESDIR}/gitlab-sidekiq-7.service" "gitlab-sidekiq.service" + systemd_dounit "${FILESDIR}/gitlab-unicorn.service" + systemd_dotmpfilesd "${FILESDIR}/gitlab.conf" + else + local rcscript=gitlab-sidekiq-noslot.init + use unicorn && rcscript=gitlab-unicorn.init + + cp "${FILESDIR}/${rcscript}" "${T}" || die + sed -i \ + -e "s|@USER@|${MY_USER}|" \ + -e "s|@GITLAB_BASE@|${dest}|" \ + -e "s|@LOGS_DIR@|${logs}|" \ + -e "s|@QUEUES@|${SIDEKIQ_QUEUES}|" \ + "${T}/${rcscript}" \ + || die "failed to filter ${rcscript}" + + newinitd "${T}/${rcscript}" "${MY_NAME}" + fi +} + +pkg_postinst() { + elog + elog "1. Configure your GitLab's settings in ${CONF_DIR}/gitlab.yml." + elog + elog "2. Configure your database settings in ${CONF_DIR}/database.yml" + elog " for \"production\" environment." + elog + elog "3. Then you should create a database for your GitLab instance, if you" + elog "haven't done so already." + elog + if use postgres; then + elog "If you have local PostgreSQL running, just copy&run:" + elog " su postgres" + elog " psql -c \"CREATE ROLE gitlab PASSWORD 'gitlab' \\" + elog " NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;\"" + elog " createdb -E UTF-8 -O gitlab gitlabhq_production" + elog " Note: You should change your password to something more random..." + elog + fi + elog "4. Finally execute the following command to initlize environment:" + elog " emerge --config \"=${CATEGORY}/${PF}\"" + elog " Note: Do not forget to start Redis server first!" + elog + elog "If this is an update from previous version, it's HIGHLY recommended" + elog "to backup your database before running the config phase!" + elog + elog "If you're running GitLab behind an SSL proxy such as nginx or Apache and" + elog "you can't login after the upgrade, be sure to read the section about the" + elog "verification of the CSRF token in GitLab's trouble-shooting guide at" + elog "http://goo.gl/5XGRGv." +} + +pkg_config() { + local shell_conf='/etc/gitlab-shell.yml' + + einfo "Checking configuration files" + + if [ ! -r "${CONF_DIR}/database.yml" ]; then + eerror "Copy ${CONF_DIR}/database.yml.* to" + eerror "${CONF_DIR}/database.yml and edit this file in order to configure your" + eerror "database settings for \"production\" environment."; die + fi + + # check gitlab-shell configuration + if [ -r ${shell_conf} ]; then + local shell_repos_path="$(ryaml ${shell_conf} repos_path)" + local gitlab_repos_path="$(ryaml ${CONF_DIR}/gitlab.yml \ + production gitlab_shell repos_path)" + + if [ ! "${shell_repos_path}" -ef "${gitlab_repos_path}" ]; then + eerror "repos_path in ${CONF_DIR}/gitlab.yml and ${shell_conf}" + eerror "must points to the same location! Fix the repos_path location and" + eerror "run this again."; die + fi + else + ewarn "GitLab Shell checks skipped, could not find config file at" + ewarn "${shell_conf}. Make sure that you have gitlab-shell properly" + ewarn "installed and that repos_path is the same as in GitLab." + fi + + local email_from="$(ryaml ${CONF_DIR}/gitlab.yml production gitlab email_from)" + local git_home="$(egethome ${MY_USER})" + + # configure Git global settings + if [ ! -e "${git_home}/.gitconfig" ]; then + einfo "Setting git user" + su -l ${MY_USER} -c " + git config --global user.email '${email_from}'; + git config --global user.name 'GitLab'" \ + || die "failed to setup git name and email" + fi + + if [ ! -d "${DEST_DIR}/.git" ]; then + # create dummy git repo as workaround for + # https://github.com/bundler/bundler/issues/2039 + einfo "Initializing dummy git repository to avoid false errors from bundler" + su -l ${MY_USER} -c " + cd ${DEST_DIR} + git init + git add README.md + git commit -m 'Dummy repository'" >/dev/null + fi + + ## Initialize app ## + + local RAILS_ENV="production" + local RUBY=${RUBY:-/usr/bin/ruby} + local BUNDLE="${RUBY} /usr/bin/bundle" + + local dbname="$(ryaml ${CONF_DIR}/database.yml production database)" + + if [ -f "${DEST_DIR}/.secret" ]; then + local update=true + + einfo "Migrating database ..." + exec_rake db:migrate + + # https://github.com/gitlabhq/gitlabhq/issues/5311#issuecomment-31656496 + einfo "Migrating iids ..." + exec_rake migrate_iids + + einfo "Cleaning old precompiled assets ..." + exec_rake assets:clean + + einfo "Cleaning cache ..." + exec_rake cache:clear + else + local update=false + + einfo "Initializing database ..." + exec_rake gitlab:setup + fi + + einfo "Precompiling assests ..." + exec_rake assets:precompile + + if [ "${update}" = 'true' ]; then + ewarn + ewarn "This configuration script runs only common migration tasks." + ewarn "Please read guides on" + ewarn " https://github.com/gitlabhq/gitlabhq/blob/master/doc/update/" + ewarn "for any additional migration tasks specific to your previous GitLab" + ewarn "version." + fi +} + +ryaml() { + ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@" +} + +exec_rake() { + local command="${BUNDLE} exec rake $@ RAILS_ENV=${RAILS_ENV}" + + echo " ${command}" + su -l ${MY_USER} -c " + export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8 + cd ${DEST_DIR} + ${command}" \ + || die "failed to run rake $@" +}