git-svn-id: svn+ssh://svnintern.kmrc.de/projects/gentoo/iwm-overlay@34766 cbe59ace-07ea-0310-918e-868702b5370dmaster
@ -0,0 +1,6 @@ | |||
AUX fix-Makefile-0.2.12.patch 386 SHA256 66a4b8e4f883d5147266a7db4f84ffdf7147946ae5222f43adaee04f11a40d6b SHA512 f47adb7ace8f903b8261b83cbc589ebda009e2d1f694ff6fe125cf3cbb80b55d06a61dff815d84d35aa6948976e17ebbe28cff9eb8a5bc4608ad05baa82b3f7c WHIRLPOOL 550e82c1c041fa0a899eda1a598c2d4ea6ffbaf1f8182e1ca66cf24b13a244590a2317a279b9548a47196dfb6e7f1e6ee829b6bab3178b60d183ac5c00156453 | |||
AUX gitlab-git-http-server.conf 254 SHA256 b0c0a9a0c6db8743f46e38124ad3591f5f4e3b7d0cf1e0ff6a426504d85a1006 SHA512 9a6948e6491727737fb4faf12238e459992f95a8011726badba7202a8e3a409a4fd34d7a78b933e473bf0b6516d54c08b5905e35e304e022b5d9d2a8f7e38e62 WHIRLPOOL 1d2b11f973f7a0249a75df929c1f71f36c59bc0b7537cb7aed598dc40cb0ca581b9443eb499f2894069f3857d89c058fa3fd01418bbdab40b16a9896e83a52d2 | |||
AUX gitlab-git-http-server.init 689 SHA256 7c3ca271bfaa696fde364ca5915abe0874dfed67601680f3ab91a9560cabb810 SHA512 9d724a4a5c83d12ad817f33ba6d8a68df195e6a91ff75755c24f04678bb8e91f3708900770d87c824418406b3eca5774117e8a5b9e28210f2d8c48726007912b WHIRLPOOL 3078871755f1d425690adb30b4d096f6ed71e5da6aca7f28383ef154d958748536efef6c53e1417c36259591d165a364e1fde64bb8b490287183e02ac1b42571 | |||
DIST gitlab-git-http-server-0.2.12.tar.bz2 7352 SHA256 0a50682ac246a0f7b27844959da829521df7f86ef7e88fd72d84fb500f09a6a5 SHA512 393ec8fe17310a79e4094eca464bec2f9e4e8508c8bbd911c9f4843b400f28617e35a06b6e41a9c84f8db904f4f20a3386e3473896ad27a1d278260dd4cd3b93 WHIRLPOOL df9fb21fd63db3aac811b1a62eb60225822a6fcc0b874f5b399d2d38f5f3e4c5dcb370c3a1773dd73a67f34cfc21fb6b56144b02987c29f50cef35b33b48f8bc | |||
EBUILD gitlab-git-http-server-0.2.12.ebuild 889 SHA256 e17a6fef2fcbb31d705d7f086a490a7af9465c380e8942c90d9b414ebc7b3d43 SHA512 2f34f1f09caa33b41e948ffdf1f8f561a20cf51b10d7333ba315876fdd869d2b57baf57d995cf5632f08d9aff50e499f791ad47ba4a00b68d24dece5597f6182 WHIRLPOOL 72691c344d68b657c9b06da4f9c31160b5f9afc99b5d10de8140774712afe509fef152779e1395a6d2ed68fbde0863226537ac733f3aeb107687dadb575d8f1d | |||
MISC metadata.xml 234 SHA256 f35b97f99a26d73cc441e1d93bfe25aaa4e9f7f6d90c8d05a74f7b7bc5b68472 SHA512 59d8156b3ca3e99c40d5a2a32de7edf2eb53279b2424998862589d6bad77617d23fc852afec0a92f8ac5bb54a88ebc504cc0641029c1936412e90ab03dfdd447 WHIRLPOOL 935a1401910a42f888c991e443a49275ea8b87976c5aa977f670053d97d18754231749749bc92d37d4b5f45ecf65914480942a11b5827b6c08fb24313a428431 |
@ -0,0 +1,12 @@ | |||
diff --git a/Makefile b/Makefile | |||
index f6456e1..c25e29e 100644 | |||
--- a/Makefile | |||
+++ b/Makefile | |||
@@ -1,5 +1,5 @@ | |||
-PREFIX=/usr/local | |||
-VERSION=$(shell git describe)-$(shell date -u +%Y%m%d.%H%M%S) | |||
+PREFIX=${DESTDIR}/usr | |||
+VERSION=0.2.12-$(shell date -u +%Y%m%d.%H%M%S) | |||
gitlab-git-http-server: main.go githandler.go | |||
go build -ldflags "-X main.Version ${VERSION}" -o gitlab-git-http-server |
@ -0,0 +1,11 @@ | |||
AUTH_BACKEND=http://localhost:8080 | |||
LISTEN_ADDR=localhost:8181 | |||
LISTEN_NETWORK=tcp | |||
LISTEN_UMASK=022 | |||
PPROF_LISTEN_ADDRESS= | |||
GIT_REPO_PATH=/var/lib/git/repositories | |||
RUNAS_USER=git | |||
RUNAS_GROUP=${RUNAS_USER} | |||
LOGFILE=/var/log/gitlab/gitlab-git-http-server.log |
@ -0,0 +1,16 @@ | |||
#!/sbin/runscript | |||
start() { | |||
ebegin "Starting gitlab-git-http-server" | |||
start-stop-daemon --start --exec /usr/bin/gitlab-git-http-server --pidfile /run/gitlab-git-http-server.pid \ | |||
--make-pidfile --background --user ${RUNAS_USER}:${RUNAS_GROUP} --stdout "${LOGFILE}" --stderr "${LOGFILE}" \ | |||
-- -authBackend=${AUTH_BACKEND} -listenAddr=${LISTEN_ADDR} -listenNetwork=${LISTEN_NETWORK} -listenUmask=${LISTEN_UMASK} \ | |||
-pprofListenAddr=${PPROF_LISTEN_ADDR} ${GIT_REPO_PATH} | |||
eend $? | |||
} | |||
stop() { | |||
ebegin "Stopping gitlab-git-http-server" | |||
start-stop-daemon --stop --exec /usr/bin/gitlab-git-http-server --pidfile /run/gitlab-git-http-server.pid --user ${RUNAS_USER}:${RUNAS_GROUP} | |||
eend $? | |||
} |
@ -0,0 +1,37 @@ | |||
# Copyright 1999-2015 Gentoo Foundation | |||
# Distributed under the terms of the GNU General Public License v2 | |||
# $Id$ | |||
EAPI="5" | |||
inherit eutils user | |||
DESCRIPTION="GitLab Git HTTP Server is the new backend for Git-over-HTTP communication needed for GitLab >= 8.0" | |||
HOMEPAGE="https://gitlab.com/gitlab-org/gitlab-git-http-server" | |||
SRC_URI="https://gitlab.com/gitlab-org/${PN}/repository/archive.tar.bz2?ref=${PV} -> ${P}.tar.bz2" | |||
S="${WORKDIR}/${P}-dda7c98adf850e032fa19c24173cbe567a416065" | |||
RESTRICT="mirror" | |||
LICENSE="MIT" | |||
SLOT="0" | |||
KEYWORDS="~amd64 ~x86" | |||
DEPEND=">=dev-lang/go-1.5" | |||
src_prepare() { | |||
epatch "${FILESDIR}/fix-Makefile-${PV}.patch" | |||
} | |||
src_install() { | |||
local dest=/usr/bin | |||
diropts -m755 | |||
dodir ${dest} | |||
exeinto ${dest} | |||
doexe "${S}/${PN}" | |||
## RC script ## | |||
newinitd "${FILESDIR}/gitlab-git-http-server.init" "${PN}" | |||
newconfd "${FILESDIR}/gitlab-git-http-server.conf" "${PN}" | |||
} |
@ -0,0 +1,8 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> | |||
<pkgmetadata> | |||
<maintainer> | |||
<email>manuel@fritteli.ch</email> | |||
<name>Manuel Friedli</name> | |||
</maintainer> | |||
</pkgmetadata> |
@ -0,0 +1,48 @@ | |||
diff --git a/config.yml.example b/config.yml.example | |||
index 94eb593..3d60f48 100644 | |||
--- a/config.yml.example | |||
+++ b/config.yml.example | |||
@@ -19,10 +19,10 @@ http_settings: | |||
# Give the canonicalized absolute pathname, | |||
# REPOS_PATH MUST NOT CONTAIN ANY SYMLINK!!! | |||
# Check twice that none of the components is a symlink, including "/home". | |||
-repos_path: "/home/git/repositories" | |||
+repos_path: "/var/lib/git/repositories" | |||
# File used as authorized_keys for gitlab user | |||
-auth_file: "/home/git/.ssh/authorized_keys" | |||
+auth_file: "/var/lib/git/.ssh/authorized_keys" | |||
# Redis settings used for pushing commit notices to gitlab | |||
redis: | |||
@@ -36,7 +36,7 @@ redis: | |||
# Log file. | |||
# Default is gitlab-shell.log in the root directory. | |||
-# log_file: "/home/git/gitlab-shell/gitlab-shell.log" | |||
+# log_file: "/var/log/gitlab/gitlab-shell.log" | |||
# Log level. INFO by default | |||
log_level: INFO | |||
diff --git a/lib/gitlab_config.rb b/lib/gitlab_config.rb | |||
index c97743b..97f4658 100644 | |||
--- a/lib/gitlab_config.rb | |||
+++ b/lib/gitlab_config.rb | |||
@@ -8,7 +8,7 @@ class GitlabConfig | |||
end | |||
def home | |||
- ENV['HOME'] | |||
+ "/var/lib/git" | |||
end | |||
def repos_path | |||
@@ -36,7 +36,7 @@ class GitlabConfig | |||
end | |||
def log_file | |||
- @config['log_file'] ||= File.join(ROOT_PATH, 'gitlab-shell.log') | |||
+ @config['log_file'] ||= "/var/log/gitlab/gitlab-shell.log" | |||
end | |||
def log_level |
@ -0,0 +1,126 @@ | |||
# Copyright 1999-2014 Gentoo Foundation | |||
# Distributed under the terms of the GNU General Public License v2 | |||
# $Id$ | |||
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}." | |||
} |
@ -0,0 +1,25 @@ | |||
##################################################### | |||
# | |||
# GitLab version : 8.x - 8.x | |||
# Contributors : davispuh, mtorromeo, axilleas, boeserwolf91, Stefan Tatschner (rumpelsepp) | |||
# Downloaded from : https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/init/systemd | |||
# | |||
#################################################### | |||
[Unit] | |||
Description=Gitlab Git HTTP Worker | |||
Requires=gitlab-unicorn.service | |||
Wants=gitlab-unicorn.service | |||
After=gitlab-unicorn.service | |||
[Service] | |||
Type=forking | |||
User=git | |||
WorkingDirectory=/opt/gitlab | |||
SyslogIdentifier=gitlab-git-http-server | |||
PIDFile=/run/gitlab/gitlab-git-http-server.pid | |||
ExecStart=/opt/gitlab/bin/daemon_with_pidfile /run/gitlab/gitlab-git-http-server.pid /usr/bin/gitlab-git-http-server -listenUmask 0 -listenNetwork unix -listenAddr /run/gitlab/gitlab-git-http-server.socket -authBackend http://127.0.0.1:8080 /var/lib/git/repositories/ >> /var/log/gitlab/gitlab-git-http-server.log 2>&1 | |||
[Install] | |||
WantedBy=multi-user.target |
@ -0,0 +1,43 @@ | |||
#!/sbin/runscript | |||
name="GitLab Sidekiq" | |||
description="Sidekiq for GitLab" | |||
: ${gitlab_user:=@USER@} | |||
: ${gitlab_base:="@GITLAB_BASE@"} | |||
: ${rails_env:=production} | |||
: ${sidekiq_pidfile:="/run/gitlab/sidekiq.pid"} | |||
: ${sidekiq_logfile:="@LOGS_DIR@/sidekiq.log"} | |||
: ${sidekiq_queues:="@QUEUES@"} | |||
sidekiq_command="/usr/bin/bundle" | |||
sidekiq_command_args="exec sidekiq -q ${sidekiq_queues} -P ${sidekiq_pidfile} -L ${sidekiq_logfile}" | |||
depend() { | |||
need redis | |||
use net gitlab-git-http-server | |||
} | |||
start() { | |||
checkpath -d -o ${gitlab_user} -m755 "$(dirname "${sidekiq_pidfile}")" | |||
ebegin "Starting ${name} - Sidekiq" | |||
start-stop-daemon --start \ | |||
--background --quiet \ | |||
--chdir "${gitlab_base}" \ | |||
--user=${gitlab_user} \ | |||
--pidfile="${sidekiq_pidfile}" \ | |||
--env RAILS_ENV=${rails_env} \ | |||
--exec ${sidekiq_command} -- ${sidekiq_command_args} | |||
eend $? | |||
} | |||
stop() { | |||
ebegin "Stopping ${name} - Sidekiq" | |||
start-stop-daemon --stop \ | |||
--pidfile=${sidekiq_pidfile} \ | |||
--exec ${sidekiq_command} | |||
eend $? | |||
} |
@ -0,0 +1,27 @@ | |||
##################################################### | |||
# | |||
# GitLab version : 5.x - 7.x | |||
# Contributors : davispuh, mtorromeo, axilleas, boeserwolf91, Stefan Tatschner (rumpelsepp) | |||
# Downloaded from : https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/init/systemd | |||
# | |||
#################################################### | |||
[Unit] | |||
Description=GitLab Sidekiq Worker | |||
Requires=redis.service | |||
Wants=mysqld.service postgresql.service | |||
After=redis.service mysqld.service postgresql.service | |||
[Service] | |||
Type=forking | |||
User=git | |||
WorkingDirectory=/opt/gitlab | |||
Environment=RAILS_ENV=production | |||
SyslogIdentifier=gitlab-sidekiq | |||
PIDFile=/run/gitlab/sidekiq.pid | |||
ExecStart=/usr/bin/bundle exec "sidekiq -d -q archive_repo -q post_receive -q mailer -q system_hook -q project_web_hook -q gitlab_shell -q common -q default -e production -P /run/gitlab/sidekiq.pid -d -L /var/log/gitlab/sidekiq.log >> /var/log/gitlab/sidekiq.log 2>&1" | |||
ExecStop=/usr/bin/bundle exec "sidekiqctl stop /run/gitlab/sidekiq.pid >> /var/log/gitlab/sidekiq.log 2>&1" | |||
[Install] | |||
WantedBy=multi-user.target |
@ -0,0 +1,67 @@ | |||
#!/sbin/runscript | |||
name="GitLab" | |||
description="GitLab on Unicorns" | |||
: ${gitlab_user:=@USER@} | |||
: ${gitlab_base:="@GITLAB_BASE@"} | |||
: ${rails_env:=production} | |||
: ${server_pidfile:="/run/gitlab/unicorn.pid"} | |||
: ${sidekiq_pidfile:="/run/gitlab/sidekiq.pid"} | |||
: ${sidekiq_logfile:="@LOGS_DIR@/sidekiq.log"} | |||
: ${sidekiq_queues:="@QUEUES@"} | |||
server_command="/usr/bin/bundle" | |||
server_command_args="exec unicorn_rails -c ${gitlab_base}/config/unicorn.rb -E ${rails_env} -D" | |||
sidekiq_command="/usr/bin/bundle" | |||
sidekiq_command_args="exec sidekiq -q ${sidekiq_queues//,/ -q } -P ${sidekiq_pidfile} -L ${sidekiq_logfile}" | |||
depend() { | |||
provide gitlab | |||
need redis | |||
use net gitlab-git-http-server | |||
} | |||
start() { | |||
ebegin "Starting ${name} - Unicorn servers" | |||
checkpath -d -o ${gitlab_user} -m755 "$(dirname "${server_pidfile}")" | |||
checkpath -d -o ${gitlab_user} -m755 "$(dirname "${sidekiq_pidfile}")" | |||
start-stop-daemon --start \ | |||
--chdir "${gitlab_base}" \ | |||
--user=${gitlab_user} \ | |||
--pidfile="${server_pidfile}" \ | |||
--env RAILS_ENV=${rails_env} \ | |||
--exec ${server_command} -- ${server_command_args} | |||
eend $? | |||
ebegin "Starting ${name} - Sidekiq" | |||
start-stop-daemon --start \ | |||
--background --quiet \ | |||
--chdir "${gitlab_base}" \ | |||
--user=${gitlab_user} \ | |||
--pidfile="${sidekiq_pidfile}" \ | |||
--env RAILS_ENV=${rails_env} \ | |||
--exec ${sidekiq_command} -- ${sidekiq_command_args} | |||
eend $? | |||
} | |||
stop() { | |||
ebegin "Stopping ${name} - Sidekiq" | |||
start-stop-daemon --stop \ | |||
--pidfile=${sidekiq_pidfile} \ | |||
--exec ${sidekiq_command} | |||
eend $? | |||
ebegin "Stopping ${name} - Unicorn servers" | |||
start-stop-daemon --stop \ | |||
--signal QUIT \ | |||
--pidfile=${server_pidfile} \ | |||
--exec ${server_command} | |||
eend $? | |||
} |
@ -0,0 +1,25 @@ | |||
##################################################### | |||
# | |||
# GitLab version : 5.x - 7.x | |||
# Contributors : davispuh, mtorromeo, axilleas, boeserwolf91, Stefan Tatschner (rumpelsepp) | |||
# Downloaded from : https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/init/systemd | |||
# | |||
#################################################### | |||
[Unit] | |||
Description=GitLab Unicorn Server | |||
Requires=redis.service | |||
Wants=mysqld.service postgresql.service | |||
After=redis.service mysqld.service postgresql.service | |||
[Service] | |||
User=git | |||
WorkingDirectory=/opt/gitlab | |||
Environment=RAILS_ENV=production | |||
SyslogIdentifier=gitlab-unicorn | |||
PIDFile=/run/gitlab/unicorn.pid | |||
ExecStart=/usr/bin/bundle exec "unicorn_rails -D -c /opt/gitlab/config/unicorn.rb -E production" | |||
[Install] | |||
WantedBy=multi-user.target |
@ -0,0 +1 @@ | |||
d /run/gitlab 0755 git git |
@ -0,0 +1,56 @@ | |||
diff --git a/Gemfile b/Gemfile | |||
index 5443374..31e1db6 100644 | |||
--- a/Gemfile | |||
+++ b/Gemfile | |||
@@ -181,6 +181,9 @@ 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", '~> 4.3.0' | |||
@@ -190,9 +193,6 @@ gem 'ace-rails-ap', '~> 2.0.1' | |||
# Keyboard shortcuts | |||
gem 'mousetrap-rails', '~> 1.4.6' | |||
-# Detect and convert string character encoding | |||
-gem 'charlock_holmes', '~> 0.6.9.4' | |||
- | |||
gem "sass-rails", '~> 4.0.5' | |||
gem "coffee-rails", '~> 4.1.0' | |||
gem "uglifier", '~> 2.3.2' | |||
diff --git a/Gemfile.lock b/Gemfile.lock | |||
index 3c16251..960effc 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: | |||
@@ -101,7 +108,6 @@ GEM | |||
json (>= 1.7) | |||
celluloid (0.16.0) | |||
timers (~> 4.0.0) | |||
- charlock_holmes (0.6.9.4) | |||
chronic (0.10.2) | |||
chunky_png (1.3.4) | |||
cliver (0.3.2) | |||
@@ -802,7 +808,7 @@ DEPENDENCIES | |||
capybara (~> 2.4.0) | |||
capybara-screenshot (~> 1.0.0) | |||
carrierwave (~> 0.9.0) | |||
- charlock_holmes (~> 0.6.9.4) | |||
+ charlock_holmes! | |||
coffee-rails (~> 4.1.0) | |||
colored (~> 1.2) | |||
colorize (~> 0.5.8) |
@ -0,0 +1,64 @@ | |||
#!/sbin/runscript | |||
name="GitLab" | |||
description="GitLab 8.0 on Unicorns" | |||
: ${gitlab_user:=git} | |||
: ${gitlab_group:=git} | |||
: ${gitlab_home:="/opt/gitlabhq-8.0"} | |||
: ${server_pidfile:="/opt/gitlabhq-8.0/tmp/pids/unicorn.pid"} | |||
: ${sidekiq_pidfile:="/opt/gitlabhq-8.0/tmp/pids/sidekiq.pid"} | |||
: ${sidekiq_log:="/var/log/gitlabhq-8.0/sidekiq.log"} | |||
: ${rails_env:=production} | |||
server_command="/usr/bin/bundle" | |||
server_command_args="exec unicorn_rails -c ${gitlab_home}/config/unicorn.rb -E ${rails_env} -D" | |||
sidekiq_command="/usr/bin/bundle" | |||
sidekiq_start_command_args="exec sidekiq -q post_receive -q mailer -q system_hook -q project_web_hook -q gitlab_shell -q common -q default -e ${rails_env} -P ${sidekiq_pidfile} -d -L ${sidekiq_log} >> ${sidekiq_log}" | |||
sidekiq_stop_command_args="exec sidekiqctl stop ${sidekiq_pidfile} >> ${sidekiq_log}" | |||
if [ ${rails_env} = development ]; then | |||
sidekiq_command_args+=" VVERBOSE=1" | |||
fi | |||
depend() { | |||
provide gitlab | |||
need redis | |||
use net mysql | |||
} | |||
start() { | |||
ebegin "Starting GitLab 8.0 Unicorn servers" | |||
checkpath -d -o "${gitlab_user}:${gitlab_group}" -m750 "$(dirname "${server_pidfile}")" | |||
checkpath -d -o "${gitlab_user}:${gitlab_group}" -m750 "$(dirname "${sidekiq_pidfile}")" | |||
start-stop-daemon --start \ | |||
--chdir "${gitlab_home}" \ | |||
--user="${gitlab_user}:${gitlab_group}" \ | |||
--pidfile="${server_pidfile}" \ | |||
--exec ${server_command} -- ${server_command_args} | |||
eend $? | |||
ebegin "Starting GitLab 8.0 Sidekiq" | |||
cd "${gitlab_home}" | |||
sudo -u git -H ${sidekiq_command} ${sidekiq_start_command_args} | |||
eend $? | |||
} | |||
stop() { | |||
ebegin "Stopping GitLab 8.0 Sidekiq" | |||
cd "${gitlab_home}" | |||
sudo -u git -H ${sidekiq_command} ${sidekiq_stop_command_args} | |||
eend $? | |||
ebegin "Stopping GitLab 8.0 Unicorn servers" | |||
start-stop-daemon --stop \ | |||
--chdir "${gitlab_home}" \ | |||
--user="${gitlab_user}:${gitlab_group}" \ | |||
--pidfile="${server_pidfile}" | |||
eend $? | |||
} |
@ -0,0 +1,20 @@ | |||
diff --git a/config/environments/production.rb b/gitlab-6/environments/production.rb | |||
index 82eb250..10e25e5 100644 | |||
--- a/config/environments/production.rb | |||
+++ b/config/environments/production.rb | |||
@@ -73,11 +73,10 @@ Gitlab::Application.configure do | |||
# config.active_record.auto_explain_threshold_in_seconds = 0.5 | |||
config.action_mailer.delivery_method = :sendmail | |||
- # Defaults to: | |||
- # # config.action_mailer.sendmail_settings = { | |||
- # # location: '/usr/sbin/sendmail', | |||
- # # arguments: '-i -t' | |||
- # # } | |||
+ config.action_mailer.sendmail_settings = { | |||
+ location: '/usr/sbin/sendmail', | |||
+ arguments: '-i' | |||
+ } | |||
config.action_mailer.perform_deliveries = true | |||
config.action_mailer.raise_delivery_errors = true | |||
end |
@ -0,0 +1,371 @@ | |||
# Copyright 1999-2015 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="ruby21" | |||
PYTHON_COMPAT=( python2_7 ) | |||
inherit eutils python-r1 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/v8.0.0.rc1.tar.gz -> ${P}.tar.gz" | |||
#RUBY_S="${PN}-8.0.0" | |||
RESTRICT="mirror" | |||
LICENSE="MIT" | |||
SLOT="0" | |||
KEYWORDS="~amd64 ~x86" | |||
IUSE="kerberos mysql +postgres +unicorn systemd 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 | |||
postgres? ( >=dev-db/postgresql-9.1:* ) | |||
mysql? ( virtual/mysql ) | |||
kerberos? ( virtual/krb5 )" | |||
CDEPEND=" | |||
dev-util/cmake | |||
virtual/pkgconfig" | |||
DEPEND="${GEMS_DEPEND} | |||
>=dev-vcs/gitlab-shell-2.6.5 | |||
dev-vcs/git | |||
>=dev-vcs/gitlab-git-http-server-0.2.10 | |||
kerberos? ( !app-crypt/heimdal ) | |||
rugged_use_system_libraries? ( net-libs/http-parser =dev-libs/libgit2-0.22* )" | |||
RDEPEND="${DEPEND} | |||
dev-db/redis | |||
virtual/mta | |||
systemd? ( sys-apps/systemd:0= )" | |||
ruby_add_bdepend " | |||
virtual/rubygems | |||
dev-ruby/http_parser_rb | |||
>=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-sendmail-config: | |||
# Fix default settings to work with ssmtp that doesn't know '-t' argument. | |||
# | |||
RUBY_PATCHES=( | |||
"${PN}-8.0.2-fix-gemfile.patch" | |||
"${PN}-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,archive_repo,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:).*|\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 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" | |||
# clean gems cache | |||
rm -Rf vendor/bundle/ruby/*/cache | |||
rm -Rf vendor/bundle/ruby/*/bundler/gems/charlock_holmes-dde194609b35/.git | |||
# 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_dounit "${FILESDIR}/gitlab-git-http.service" | |||
systemd_dotmpfilesd "${FILESDIR}/gitlab.conf" | |||
else | |||
local rcscript=gitlab-sidekiq-8.init | |||
use unicorn && rcscript=gitlab-unicorn-8.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 $@" | |||
} |
@ -0,0 +1,441 @@ | |||
# Copyright 1999-2013 Gentoo Foundation | |||
# Distributed under the terms of the GNU General Public License v2 | |||
# $Header: $ | |||
EAPI="5" | |||
# Mainteiner 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 flags analytics and public-projects applies our custom patches, see | |||
# https://github.com/cvut/gitlabhq for more information. | |||
# | |||
USE_RUBY="ruby20" | |||
PYTHON_DEPEND="2:2.7" | |||
EGIT_REPO_URI="https://github.com/gitlabhq/gitlabhq.git" | |||
EGIT_COMMIT="v${PV}" | |||
inherit eutils git-2 python ruby-ng versionator user | |||
DESCRIPTION="GitLab is a free project and repository management application" | |||
HOMEPAGE="https://github.com/gitlabhq/gitlabhq" | |||
LICENSE="MIT" | |||
SLOT=$(get_version_component_range 1-2) | |||
KEYWORDS="~amd64 ~x86 ~arm" | |||
IUSE="memcached mysql +postgres +unicorn" | |||
## Gems dependencies: | |||
# charlock_holmes dev-libs/icu | |||
# grape, capybara dev-libs/libxml2, dev-libs/libxslt | |||
# json dev-util/ragel | |||
# yajl-ruby dev-libs/yajl | |||
# pygments.rb python 2.5+ | |||
# execjs net-libs/nodejs, or any other JS runtime | |||
# pg dev-db/postgresql-base | |||
# mysql virtual/mysql | |||
# rugged net-libs/http-parser dev-libs/libgit2 | |||
# | |||
GEMS_DEPEND=" | |||
dev-libs/icu | |||
dev-libs/libxml2 | |||
dev-libs/libxslt | |||
dev-ruby/rb-inotify | |||
dev-util/ragel | |||
dev-libs/yajl | |||
net-libs/nodejs | |||
postgres? ( dev-db/postgresql ) | |||
mysql? ( virtual/mysql ) | |||
memcached? ( net-misc/memcached ) | |||
net-libs/http-parser | |||
>=dev-libs/libgit2-0.22.0 | |||
<dev-libs/libgit2-0.23.0" | |||
DEPEND="${GEMS_DEPEND} | |||
$(ruby_implementation_depend ruby20)[readline,ssl] | |||
>=dev-vcs/git-1.8.1.5 | |||
>=dev-vcs/gitlab-shell-2.6.5 | |||
net-misc/curl | |||
virtual/ssh" | |||
RDEPEND="${DEPEND} | |||
dev-db/redis | |||
virtual/mta | |||
virtual/krb5" | |||
ruby_add_bdepend " | |||
virtual/rubygems | |||
>=dev-ruby/bundler-1.0" | |||
#RUBY_PATCHES=( | |||
# "${P}-fix-checks-gentoo.patch" | |||
#) | |||
GIT_USER="git" | |||
GIT_GROUP="git" | |||
GIT_HOME=$(getent passwd $GIT_USER | cut -d: -f6) | |||
DEST_DIR="/opt/${PN}-${SLOT}" | |||
CONF_DIR="/etc/${PN}-${SLOT}" | |||
GIT_REPOS="${GIT_HOME}/repositories" | |||
GIT_SATELLITES="${GIT_HOME}/gitlab-satellites" | |||
GITLAB_SHELL="/var/lib/gitlab-shell" | |||
GITLAB_SHELL_HOOKS="${GITLAB_SHELL}/hooks" | |||
RAILS_ENV=${RAILS_ENV:-production} | |||
RUBY=${RUBY:-ruby20} | |||
BUNDLE="${RUBY} /usr/bin/bundle" | |||
pkg_setup() { | |||
enewgroup ${GIT_GROUP} | |||
enewuser ${GIT_USER} -1 -1 ${DEST_DIR} "$GIT_GROUP}" | |||
} | |||
all_ruby_unpack() { | |||
git-2_src_unpack | |||
} | |||
each_ruby_prepare() { | |||
# fix path to repo and gitlab-shell hooks | |||
test -d "${GITLAB_SHELL_HOOKS}" || die "Gitlab Shell hooks directory not found: \"${GITLAB_SHELL_HOOKS}. Have you properly installed dev-vcs/gitlab-shell"? | |||
sed -i \ | |||
-e "s|\(\s*path:\s\)/.*/gitlab-shell/|\1 ${GITLAB_SHELL}/|" \ | |||
-e "s|\(\s*repos_path:\s\)/.*|\1 ${GIT_REPOS}/|" \ | |||
-e "s|\(\s*hooks_path:\s\)/.*|\1 ${GITLAB_SHELL_HOOKS}/|" \ | |||
-e "s|\(\s*path:\s\)/.*/gitlab-satellites/|\1 ${GIT_SATELLITES}/|" \ | |||
-e "s|\(\s*GITLAB_SHELL:\s*\)|\1\n\tpath: \"${GITLAB_SHELL}\"|" \ | |||
config/gitlab.yml.example || die "failed to filter gitlab.yml.example" | |||
# modify database settings | |||
sed -i \ | |||
-e 's|\(username:\) postgres.*|\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" | |||
# replace "secret" token with random one | |||
local randpw=$(echo ${RANDOM}|sha512sum|cut -c 1-128) | |||
sed -i -e "/secret_token =/ s/=.*/= '${randpw}'/" \ | |||
config/initializers/secret_token.rb \ | |||
|| die "failed to filter secret_token.rb" | |||
# remove needless files | |||
#rm -r .git Satisfy gitlab::check. | |||
rm .foreman .gitignore Procfile | |||
use unicorn || rm config/unicorn.rb.example | |||
use postgres || rm config/database.yml.postgresql | |||
use mysql || rm config/database.yml.mysql | |||
# remove dependency on therubyracer and libv8 (we're using nodejs instead) | |||
local tfile; for tfile in Gemfile{,.lock}; do | |||
sed -i \ | |||
-e '/therubyracer/d' \ | |||
-e '/libv8/d' \ | |||
"${tfile}" || die "failed to filter ${tfile}" | |||
done | |||
# change thin and unicorn dependencies to be optional | |||
sed -i \ | |||
-e '/^gem "thin"/ s/$/, group: :thin/' \ | |||
-e '/^gem "unicorn"/ s/$/, group: :unicorn/' \ | |||
Gemfile || die "failed to modify Gemfile" | |||
# change cache_store | |||
if use memcached; then | |||
sed -i \ | |||
-e "/\w*config.cache_store / s/=.*/= :dalli_store, { namespace: 'gitlab' }/" \ | |||
config/environments/production.rb \ | |||
|| die "failed to modify production.rb" | |||
fi | |||
# Update pathes for unicorn | |||
if use unicorn; then | |||
sed -i \ | |||
-e "s#/home/git/gitlab#${DEST_DIR}#" \ | |||
config/unicorn.rb.example \ | |||
|| die "failed to modify unicorn.rb.example" | |||
fi | |||
# Use >timfle-krb5-auth-0.8, see https://github.com/timfel/krb5-auth/pull/7 | |||
sed -i \ | |||
-e "s#timfel\-krb5\-auth (0.8)#timfel\-krb5\-auth (0.8.3)#g" \ | |||
Gemfile.lock \ | |||
|| die "failed to update Gemfile.lock" | |||
} | |||
each_ruby_install() { | |||
local dest="${DEST_DIR}" | |||
local conf="/etc/${PN}-${SLOT}" | |||
local temp="/var/tmp/${PN}-${SLOT}" | |||
local logs="/var/log/${PN}-${SLOT}" | |||
local uploads="${DEST_DIR}/public/uploads" | |||
## Prepare directories ## | |||
diropts -m750 | |||
keepdir "${logs}" | |||
dodir "${temp}" | |||
diropts -m755 | |||
keepdir "${conf}" | |||
dodir "${dest}" | |||
dodir "${uploads}" | |||
dosym "${temp}" "${dest}/tmp" | |||
dosym "${logs}" "${dest}/log" | |||
## Link gitlab-shell into git home | |||
dosym "${GITLAB_SHELL}" "${GIT_HOME}/gitlab-shell" | |||
## Install configs ## | |||
insinto "${conf}" | |||
doins -r config/* | |||
dosym "${conf}" "${dest}/config" | |||
insinto "${dest}/.ssh" | |||
newins "${FILESDIR}/config.ssh" config | |||
echo "export RAILS_ENV=production" > "${D}/${dest}/.profile" | |||
## Install all others ## | |||
# remove needless dirs | |||
rm -Rf config tmp log | |||
insinto "${dest}" | |||
doins -r ./ | |||
## Install logrotate config ## | |||
dodir /etc/logrotate.d | |||
sed -e "s|@LOG_DIR@|${logs}|" \ | |||
"${FILESDIR}"/gitlab.logrotate > "${D}"/etc/logrotate.d/${PN}-${SLOT} \ | |||
|| die "failed to filter gitlab.logrotate" | |||
## Install gems via bundler ## | |||
cd "${D}/${dest}" | |||
local without="development test thin" | |||
local flag; for flag in memcached mysql postgres unicorn; do | |||
without+="$(use $flag || echo ' '$flag)" | |||
done | |||
local bundle_args="--deployment ${without:+--without ${without}}" | |||
# Use systemlibs for rugged | |||
${BUNDLE} config build.rugged --use-system-libraries | |||
# Use systemlibs for nokogiri as suggested | |||
${BUNDLE} config build.nokogiri --use-system-libraries | |||
# Fix invalid ldflags for charlock_holmes, | |||
# see https://github.com/brianmario/charlock_holmes/issues/32 | |||
${BUNDLE} config build.charlock_holmes --with-ldflags='-L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,--no-undefined -lz -licuuc' | |||
einfo "Running bundle install ${bundle_args} ..." | |||
${BUNDLE} install ${bundle_args} || die "bundler failed" | |||
## Clean ## | |||
local gemsdir=vendor/bundle/ruby/$(ruby_rbconfig_value 'ruby_version') | |||
# remove gems cache | |||
rm -Rf ${gemsdir}/cache | |||
# fix permissions | |||
fowners -R ${GIT_USER}:${GIT_GROUP} "${dest}" "${conf}" "${temp}" "${logs}" | |||
fperms o+Xr "${temp}" # Let nginx access the unicorn socket | |||
## RC scripts ## | |||
local rcscript=${P}.init | |||
cp "${FILESDIR}/${rcscript}" "${T}" || die | |||
sed -i \ | |||
-e "s|@GIT_USER@|${GIT_USER}|" \ | |||
-e "s|@GIT_GROUP@|${GIT_USER}|" \ | |||
-e "s|@SLOT@|${SLOT}|" \ | |||
-e "s|@DEST_DIR@|${dest}|" \ | |||
-e "s|@LOG_DIR@|${logs}|" \ | |||
-e "s|@RESQUE_QUEUE@|${resque_queue}|" \ | |||
"${T}/${rcscript}" \ | |||
|| die "failed to filter ${rcscript}" | |||
if use memcached; then | |||
sed -i -e '/^depend/,// {/need / s/$/ memcached/}' \ | |||
"${T}/${rcscript}" || die "failed to filter ${rcscript}" | |||
fi | |||
newinitd "${T}/${rcscript}" "${PN}-${SLOT}" | |||
} | |||
pkg_postinst() { | |||
if [ ! -e "${GIT_HOME}/.ssh/id_rsa" ]; then | |||
einfo "Generating SSH key for git user" | |||
su -l ${GIT_USER} -s /bin/sh -c " | |||
ssh-keygen -q -N '' -t rsa -f ${GIT_HOME}/.ssh/id_rsa" \ | |||
|| die "failed to generate SSH key" | |||
fi | |||
if [ ! -e "${GIT_HOME}/.gitconfig" ]; then | |||
einfo "Setting git user in ${GIT_HOME}/.gitconfig, feel free to " | |||
einfo "modify this file according to your needs!" | |||
su -l ${GIT_USER} -s /bin/sh -c " | |||
git config --global user.email 'gitlab@localhost'; | |||
git config --global user.name 'GitLab'" \ | |||
|| die "failed to setup git name and email" | |||
fi | |||
elog "If this is a new installation, proceed with the following steps:" | |||
elog | |||
elog " 1. Copy ${CONF_DIR}/gitlab.yml.example to ${CONF_DIR}/gitlab.yml" | |||
elog " and edit this file in order to configure your GitLab settings." | |||
elog | |||
elog " 2. Copy ${CONF_DIR}/database.yml.* to ${CONF_DIR}/database.yml" | |||
elog " and edit this file in order to configure your database settings" | |||
elog " for \"production\" environment." | |||
elog | |||
elog " 3. If this is a new installation, create a database for your GitLab instance." | |||
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 gitlab_production" | |||
elog " Note: You should change your password to something more random..." | |||
elog | |||
elog " GitLab uses polymorphic associations which are not SQL-standard friendly." | |||
elog " To get it work you must use this ugly workaround:" | |||
elog " psql -U postgres -d gitlab" | |||
elog " CREATE CAST (integer AS text) WITH INOUT AS IMPLICIT;" | |||
elog | |||
fi | |||
elog " 4. Execute the following command to finalize your setup:" | |||
elog " emerge --config \"=${CATEGORY}/${PF}\"" | |||
elog " Note: Do not forget to start Redis server." | |||
elog | |||
elog "To update an existing instance, run the following command and choose upgrading when prompted:" | |||
elog " emerge --config \"=${CATEGORY}/${PF}\"" | |||
elog | |||
} | |||
pkg_config() { | |||
## Check config files existence ## | |||
einfo "Checking configuration files ..." | |||
if [ ! -r "${CONF_DIR}/database.yml" ] ; then | |||
eerror "Copy \"${CONF_DIR}/database.yml.*\" to \"${CONF_DIR}/database.yml\"" | |||
eerror "and edit this file in order to configure your database settings for" | |||
eerror "\"production\" environment." | |||
die | |||
fi | |||
if [ ! -r "${CONF_DIR}/gitlab.yml" ]; then | |||
eerror "Copy \"${CONF_DIR}/gitlab.yml.example\" to \"${CONF_DIR}/gitlab.yml\"" | |||
eerror "and edit this file in order to configure your GitLab settings" | |||
eerror "for \"production\" environment." | |||
die | |||
fi | |||
# Ask user whether this is the first installation | |||
einfo "Do you want to upgrade an existing installation? [Y|n] " | |||
do_upgrade="" | |||
while true | |||
do | |||
read -r do_upgrade | |||
if [[ $do_upgrade == "n" || $do_upgrade == "N" ]] ; then do_upgrade="" && break | |||
elif [[ $do_upgrade == "y" || $do_upgrade == "Y" || $do_upgrade == "" ]] ; then do_upgrade=1 && break | |||
else eerrorn "Please type either \"Y\" or \"N\" ... " ; fi | |||
done | |||
if [[ $do_upgrade ]] ; then | |||
LATEST_DEST=$(test -n "${LATEST_DEST}" && echo ${LATEST_DEST} || \ | |||
find /opt -maxdepth 1 -iname 'gitlabhq-*' -and -type d -and -not -iname "gitlabhq-${SLOT}" | \ | |||
sort -r | head -n1) | |||
if [[ -z "${LATEST_DEST}" || ! -d "${LATEST_DEST}" ]] ; then | |||
einfo "Please enter the path to your latest Gitlab instance:" | |||
while true | |||
do | |||
read -r LATEST_DEST | |||
test -d ${LATEST_DEST} && break ||\ | |||
eerror "Please specify a valid path to your Gitlab instance!" | |||
done | |||
else | |||
einfo "Found your latest Gitlab instance at \"${LATEST_DEST}\"." | |||
fi | |||
einfo "Please make sure that you've stopped your running Gitlab instance and that you've created a backup: " | |||
elog "\$ cd \"${LATEST_DEST}\" && sudo -u ${GIT_USER} ${BUNDLE} exec rake gitlab:backup:create RAILS_ENV=production" | |||
elog "" | |||
einfo "Press ENTER to continue, STRG-C to cancel" | |||
read | |||
einfo "Migrating uploads ..." | |||
einfo "This will move your uploads from \"$LATEST_DEST\" to \"${DEST_DIR}\", continue? [Y|n] " | |||
migrate_uploads="" | |||
while true | |||
do | |||
read -r migrate_uploads | |||
if [[ $migrate_uploads == "n" || $migrate_uploads == "N" ]] ; then migrate_uploads="" && break | |||
elif [[ $migrate_uploads == "y" || $migrate_uploads == "Y" || $migrate_uploads == "" ]] ; then migrate_uploads=1 && break | |||
else eerror "Please type either \"Y\" or \"N\" ... " ; fi | |||
done | |||
if [[ $migrate_uploads ]] ; then | |||
su -l ${GIT_USER} -s /bin/sh -c " | |||
mv ${LATEST_DEST}/public/uploads/* ${DEST_DIR}/public/uploads/" \ | |||
|| die "failed to migrate uplaods." | |||
fi | |||
einfo "Migrating config ..." | |||
for conf in database.yml gitlab.yml resque.yml unicorn.rb ; do | |||
cp "${LATEST_DEST}/config/${conf}" "${DEST_DIR}/config/" | |||
example="${DEST_DIR}/config/${conf}.example" | |||
test -d "${example}" && mv "${example}" "${DEST_DIR}/config/.cfg0000_${conf}" | |||
done | |||
CONFIG_PROTECT="${DEST_DIR}" dispatch-conf || die "failed to migrate config." | |||
einfo "Migrating database ..." | |||
su -l ${GIT_USER} -s /bin/sh -c " | |||
export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8 | |||
cd ${DEST_DIR} | |||
${BUNDLE} exec rake db:migrate RAILS_ENV=production | |||
${BUNDLE} exec rake gitlab:satellites:create RAILS_ENV=production" \ | |||
|| die "failed to migrate database." | |||
einfo "Clear redis cache ..." | |||
su -l ${GIT_USER} -s /bin/sh -c " | |||
export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8 | |||
cd ${DEST_DIR} | |||
${BUNDLE} exec rake cache:clear RAILS_ENV=production" \ | |||
|| die "failed to run cache:clear" | |||
einfo "Clear and precompile assets ..." | |||
su -l ${GIT_USER} -s /bin/sh -c " | |||
export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8 | |||
cd ${DEST_DIR} | |||
${BUNDLE} exec rake assets:clean RAILS_ENV=production | |||
${BUNDLE} exec rake assets:precompile RAILS_ENV=production" \ | |||
|| die "failed to run assets:precompile" | |||
else | |||
einfo "Initializing database ..." | |||
su -l ${GIT_USER} -s /bin/sh -c " | |||
export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8 | |||
cd ${DEST_DIR} | |||
${BUNDLE} exec rake gitlab:setup RAILS_ENV=${RAILS_ENV}" \ | |||
|| die "failed to run rake gitlab:setup" | |||
fi | |||
einfo "You might want to run the following in order to check your application status:" | |||
einfo "# cd ${DEST_DIR} && sudo -u ${GIT_USER} ${BUNDLE} exec rake gitlab:check RAILS_ENV=production" | |||
einfo "" | |||
einfo "GitLab is prepared, now you should configure your web server." | |||
} |