# Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="5" USE_RUBY="ruby19 ruby20" 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 virtual/ssh" ruby_add_bdepend " virtual/ruby-ssl" MERGE_TYPE="binary" RUBY_PATCHES=( "${P}-paths-from-config.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}" } 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}) # 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=$(getent passwd ${GIT_USER} | cut -d: -f6) 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 authorized_keys location in ${CONF_FILE}," ewarn "or change home directory of ${GIT_USER} user to ${DATA_DIR}." 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}." }