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/gitlab-ci/Manifest b/www-apps/gitlab-ci/Manifest index 2b90459..543cf34 100644 --- a/www-apps/gitlab-ci/Manifest +++ b/www-apps/gitlab-ci/Manifest @@ -1,9 +1,11 @@ AUX gitlab-ci-unicorn.init 1700 SHA256 ad75c1774db69d2ceae61983ba7227bb840c761d69eb387eaba120553fcd038a SHA512 fc2005db1523777f96867a3983efcb256ee8a3f62146dfc58af5536c0c869d665870b2f6710fe1d2f014fcb921ec3c79066b67b0189a6b525a7aea7f1afff78a WHIRLPOOL c80e72eb0c8f14c56662f91f2f1b51d1bbc83d956dcd3915c354e95ca5c1231c575b1fec91398c345fa71af61efe654e78f85e9d75be3b5624e65021e7102c28 DIST gitlab-ci-5.4.2.tar.gz 636802 SHA256 475e9fbb88f5206ad350ab21b9c800a31e90bfd771f18068d21109202961a175 SHA512 cefdeb9f20fec691f935340d4aabb2f9b11720608ec1f1ef037865b64e861aeb3d90a8ae2af16ea57c343b0da0c78973874fcb284a4cdf767831dbc5744826ed WHIRLPOOL ac2e9704b284986b605815f799729f22041a9944cbe8712ef567cfaea19718e69974957fa940d836a054472a30fa037d5c298ef9943272ef316ac24c1e06b80b DIST gitlab-ci-7.10.3.tar.gz 936802 SHA256 07f0ad3806068189b6e2d7ee08538c57dc23002a4c9318d5cc80af591f9dfd06 SHA512 e2b0fdd407bffe8b9d8821ef03c8266d83f0365a3b7024bdb1bc35f1486f2932f21e7369ad9aa8195966b5bd7e550036ce391b61dcb5c4e46d742a4d48651aa6 WHIRLPOOL fa7f9d4acde2b80beb74ee5d846606caf612558bf45aeca7e84c4f530b489cd5a1bc1727bc87d10bea219d90748da1745b537a5c07634acb463125fa61e6ed53 +DIST gitlab-ci-7.11.1.tar.gz 949770 SHA256 ada13495dfd008dd78fb39eeab5fb5debb75aab0f4f6b07c3dc1509821ea3f93 SHA512 de469361da16d824e4674f262b1be76cbce98816991ca2b8c617a2ed00fb4e067df3f0c3483c8b7981e2945754284953163a4518fa7e7f85bc15acaacd5e21f1 WHIRLPOOL 4c2be0f543b029d4e22a3719aac73c5f4ca1869b21f1f189bd0144bffb46424510330131adb6d947bece7f43302545cf0164737788a4ffc8b8fa2c14b63a7e81 DIST gitlab-ci-7.8.1.tar.gz 655403 SHA256 b7685c5f906d0b40bdf88b376af72554ad20b48bab2437465df7539213d156d6 SHA512 71e7e1b5873c50de9b577acb611def2fe9b7f3decf4842e77b7c4ad275f810114beaf32874f35e92119db06ac8dc6ed70baa2dea4ecfc798652f2e475d238d7b WHIRLPOOL 95450996a8f9b7af43b04359fde79b5181195820e353179d6a6d493accf3e55778c2c57e4deed2eab7f58dde5163824aae1d6c24c8852cc25ec03f2dbd1406e8 DIST gitlab-ci-7.9.4.tar.gz 669304 SHA256 dd21094def835a6492f27bd5507ee03b954b8fd65d1666cc9a32e4198c217336 SHA512 8ebb849ebe79180da7cef7163e276434a8fd1a5304539ca648221fbf7ac4b8a92189b61d911c2a597bcad21b3ca3a45a8adf7e9eb7e26d183866413ee28132ec WHIRLPOOL 1c372a9496fa11be72e3c1553d6b1ddfd417193841eda0a9a997758e7751c757feb98e8390ea0a3ec805aae5230bb17f24fab8af25b77fdc72dd8cd704135b95 EBUILD gitlab-ci-5.4.2.ebuild 8568 SHA256 0f983ce12281aecfb784b9d97153ad71b27b77a1fc77867017ad299d81c90cd1 SHA512 a3db89945616666554f95c7c0121b46d23b53a7a6fde87802d937fa069162fd675ecaeffcd994ec9c7faa23185ea54808e42921d006b3f7ceb5fac3a9f7c28ff WHIRLPOOL c863e122b2c5d2efef75bc324ca39005b6093aec4cb6ca8e6eb0df6a0017e283afcfbb2e1f6edf006a801b403fcde9d07bbfc5fd21781432cfeda0addfc2e3a6 EBUILD gitlab-ci-7.10.3.ebuild 8562 SHA256 f0fc6135840cd45cbd6ba5857d9294e4b2f95c9a382e22845033ce295849f087 SHA512 b0068f74167831b05c2d2bd963d3c6c544cf602790c0525b7e04e03f2e1daea37e34bdc4394b8a20fd74601494a25ec197b2fcad514c72df58b2f52bbcc5e11b WHIRLPOOL ec0dbd54ece559cc919a8917d00d740af2caeb0b4b75cf77549fc62fd17e05e95d765cf78e9f08eaeeeff5b2f55935f67e167505effb6280d90fc8c4a97aa1db +EBUILD gitlab-ci-7.11.1.ebuild 8562 SHA256 f0fc6135840cd45cbd6ba5857d9294e4b2f95c9a382e22845033ce295849f087 SHA512 b0068f74167831b05c2d2bd963d3c6c544cf602790c0525b7e04e03f2e1daea37e34bdc4394b8a20fd74601494a25ec197b2fcad514c72df58b2f52bbcc5e11b WHIRLPOOL ec0dbd54ece559cc919a8917d00d740af2caeb0b4b75cf77549fc62fd17e05e95d765cf78e9f08eaeeeff5b2f55935f67e167505effb6280d90fc8c4a97aa1db EBUILD gitlab-ci-7.8.1.ebuild 8562 SHA256 f0fc6135840cd45cbd6ba5857d9294e4b2f95c9a382e22845033ce295849f087 SHA512 b0068f74167831b05c2d2bd963d3c6c544cf602790c0525b7e04e03f2e1daea37e34bdc4394b8a20fd74601494a25ec197b2fcad514c72df58b2f52bbcc5e11b WHIRLPOOL ec0dbd54ece559cc919a8917d00d740af2caeb0b4b75cf77549fc62fd17e05e95d765cf78e9f08eaeeeff5b2f55935f67e167505effb6280d90fc8c4a97aa1db EBUILD gitlab-ci-7.9.4.ebuild 8562 SHA256 f0fc6135840cd45cbd6ba5857d9294e4b2f95c9a382e22845033ce295849f087 SHA512 b0068f74167831b05c2d2bd963d3c6c544cf602790c0525b7e04e03f2e1daea37e34bdc4394b8a20fd74601494a25ec197b2fcad514c72df58b2f52bbcc5e11b WHIRLPOOL ec0dbd54ece559cc919a8917d00d740af2caeb0b4b75cf77549fc62fd17e05e95d765cf78e9f08eaeeeff5b2f55935f67e167505effb6280d90fc8c4a97aa1db diff --git a/www-apps/gitlab-ci/gitlab-ci-7.11.1.ebuild b/www-apps/gitlab-ci/gitlab-ci-7.11.1.ebuild new file mode 100644 index 0000000..9fa3419 --- /dev/null +++ b/www-apps/gitlab-ci/gitlab-ci-7.11.1.ebuild @@ -0,0 +1,309 @@ +# 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 + +DESCRIPTION="GitLab CI is a continuous integration server that is tightly integrated with GitLab" +HOMEPAGE="https://gitlab.com/gitlab-org/gitlab-ci" +SRC_URI="https://github.com/gitlabhq/gitlab-ci/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +RESTRICT="mirror" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="mysql +postgres" + +## Gems dependencies: +# charlock_holmes dev-libs/icu +# grape, capybara dev-libs/libxml2, dev-libs/libxslt +# pg dev-db/postgresql-base +# mysql virtual/mysql +# + +GEMS_DEPEND=" + dev-libs/icu + dev-libs/libxml2 + dev-libs/libxslt + postgres? ( dev-db/postgresql-base ) + mysql? ( virtual/mysql )" +DEPEND="${GEMS_DEPEND} + dev-vcs/git" +RDEPEND="${DEPEND} + dev-db/redis + virtual/mta" +ruby_add_bdepend " + virtual/rubygems + >=dev-ruby/bundler-1.0" + +# no patches needed so far ... +#RUBY_PATCHES=( +#) + +MY_NAME="gitlab-ci" +MY_USER="gitlab_ci" + +DEST_DIR="/opt/${MY_NAME}" +CONF_DIR="/etc/${MY_NAME}" +LOGS_DIR="/var/log/${MY_NAME}" +TEMP_DIR="/var/tmp/${MY_NAME}" +RUN_DIR="/run/${MY_NAME}" + +# When updating ebuild to newer version, check list of the queues in +# https://gitlab.com/gitlab-org/gitlab-ci/blob/v${PV}/script/background_jobs +SIDEKIQ_QUEUES="runner,common,default" + +pkg_setup() { + enewgroup gitlab_ci + enewuser gitlab_ci -1 /bin/bash ${DEST_DIR} "gitlab_ci,cron,redis" +} + +all_ruby_prepare() { + + # fix paths + sed -i -E \ + -e "s|redis://redis.example.com:6379|unix:/run/redis/redis.sock|" \ + config/resque.yml.example || die "failed to filter resque.yml.example" + sed -i -E \ + -e "s|/home/gitlab_ci/gitlab-ci/tmp/(pids\|sockets)|${RUN_DIR}|" \ + -e "s|/home/gitlab_ci/gitlab-ci/log|${LOGS_DIR}|" \ + -e "s|/home/gitlab_ci/gitlab-ci|${DEST_DIR}|" \ + config/unicorn.rb.example || die "failed to filter unicorn.rb.example" + + sed -i \ + -e "s|/home/gitlab_ci/gitlab-ci/tmp/sockets|${RUN_DIR}|" \ + -e "s|/home/gitlab_ci/gitlab-ci/public|${DEST_DIR}/public|" \ + lib/support/nginx/gitlab_ci || die "failed to filter nginx/gitlab_ci" + + # 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" + # modify default database settings for MySQL + sed -i -E \ + -e "s|/tmp/mysql.sock|/run/mysqld/mysqld.sock|" \ + config/database.yml.mysql || die "failed to filter database.yml.mysql" + + # rename config files + mv config/application.yml.example config/application.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/init.d +} + +all_ruby_install() { + local dest=${DEST_DIR} + local conf=${CONF_DIR} + local logs=${LOGS_DIR} + local temp=${TEMP_DIR} + local runs=${RUN_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; 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} + fowners ${MY_USER}:${MY_USER} ${conf}/database.yml + fperms 640 ${conf}/database.yml + + ## RC script ## + + local rcscript=gitlab-ci-unicorn.init + + cp "${FILESDIR}/${rcscript}" "${T}" || die + sed -i \ + -e "s|@USER@|${MY_USER}|" \ + -e "s|@GITLAB_CI_BASE@|${dest}|" \ + -e "s|@LOGS_DIR@|${logs}|" \ + -e "s|@RUN_DIR@|${runs}|" \ + -e "s|@QUEUES@|${SIDEKIQ_QUEUES}|" \ + "${T}/${rcscript}" \ + || die "failed to filter ${rcscript}" + + newinitd "${T}/${rcscript}" "${MY_NAME}" +} + +pkg_postinst() { + elog + elog "1. Configure your GitLab CI's settings in ${CONF_DIR}/application.yml." + elog + elog "2. Configure your database settings in ${CONF_DIR}/database.yml" + elog " for \"production\" environment." + elog + elog "3. Adjust the webserver settings in ${CONF_DIR}/unicorn.rb" + elog + elog "4. Then you should create a database for your GitLab CI 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_ci PASSWORD 'gitlab_ci' \\" + elog " NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;\"" + elog " createdb -E UTF-8 -O gitlab_ci gitlab_ci_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!" +} + +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}/application.yml production gitlab_ci email_from)" + local gitlab_ci_home="$(egethome ${MY_USER})" + + # configure Git global settings + if [ ! -e "${gitlab_ci_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 CI'" \ + || 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 + + else + local update=false + + einfo "Initializing database ..." + exec_rake setup + + einfo "Setting up cron schedules ..." + exec_rake whenever -w + fi + + if [ "${update}" = 'true' ]; then + ewarn + ewarn "This configuration script runs only common migration tasks." + ewarn "Please read guides on" + ewarn " https://gitlab.com/gitlab-org/gitlab-ci/tree/v${PV}/doc/update" + ewarn "for any additional migration tasks specific to your previous GitLab CI" + 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 $@" +} diff --git a/www-apps/gitlabhq/Manifest b/www-apps/gitlabhq/Manifest index 4f9187d..2e98e23 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.1.tar.gz 5731386 SHA256 a877a0948df3f68d476316b88b9a10ea95a916d4c50532efd91e768bd7c04752 SHA512 477f124d72be0a744146691936182c06ff9770eb86a481a8da997150453995ca255f5e190162bacf312ea3111c1aa6ab53ada3fa2774354f15716bcff579583e WHIRLPOOL 69667a927be41c00200287167cb08e2980824a38da4f958cd8e5ee51f20a5c7c3dc2fc931c45f497cf4155c53c43b63d871e19ac6e6c8b6fd088f9fbb8cd25c1 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.1.ebuild 11337 SHA256 c2fae88e4a2ffc3aa16e4feaa56ad5e3ed7aaf891707db49296f77585dde5c56 SHA512 2cd81ec23f75846cc984961edc707ffa4aa837e7e0ca0aafac48e24616f5661aebc0912c5c191485465cc6a5c92edde6eda1b0ff7d79eaaf3688df1a4150cdca WHIRLPOOL c0c95e58f21d5496bc37654a67626eeb1fc7c660f14431fbf948dd2bb71a5fab409c69688dd44456fdc78d0456b24be978f732809305631e10b253a544586561 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.1.ebuild b/www-apps/gitlabhq/gitlabhq-7.11.1.ebuild new file mode 100644 index 0000000..a71d843 --- /dev/null +++ b/www-apps/gitlabhq/gitlabhq-7.11.1.ebuild @@ -0,0 +1,374 @@ +# 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}-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 $@" +}