added initial ebuild for gitlab-ci-multi-runner. doesn't build yet

This commit is contained in:
Manuel Friedli 2015-06-29 17:40:09 +02:00
parent 5aac15ae99
commit bd387b0842
4 changed files with 194 additions and 0 deletions

View file

@ -0,0 +1,4 @@
AUX gitlab-ci-multi-runner.conf 78 SHA256 3b9e4f922ff53cc57c4c883dd19c1343b2a61ceba7bef303d623aedc5d2651cd SHA512 af0b725e3eea789776962a085f53d8787f91b1c8bdd7aad76aeedad2304885ac890c81d95126ad5de2590ef2b0c93045d4ba50f8bc2ba7e0caeec3b27fa4f6f7 WHIRLPOOL 10563abf39449389e9cf53076fd21a106f555e58b708b679c9cc91213ec0319a7b0dfa15977c187ceedb9a2f7c060424f66891472a2e8e8ca78262e628e05968
AUX gitlab-ci-multi-runner.init 1569 SHA256 8c5166b6919e42e7130b2e782adff2d53dbafafee29b444cd06e609e193b09f1 SHA512 84ca9fca9c28a7c62a416166f2ca85b57a97432b043ba50f74193ba93416567d99103b23f9e154b310a902449737198e504c2d2f0732504f2ab34dc6b7f28407 WHIRLPOOL f7dac1e2cc24b9637d860a0ab29081ea1cc2f63e4422e07b1294092885146ecb869c2d6ac8e057068b0a108a8fbe385b4d12314a2db50587fcb7b67fdb2e9d03
DIST gitlab-ci-multi-runner-0.4.2.tar.gz 404292 SHA256 ca3c5e98017d55c7fb7397708332c7e2843b6db614cd21b820b5713718026797 SHA512 6131b6f420acc57083d6659c5b825f9f655f719cb38664933746c896ef79520189f9b160121466eedd901b5197f1bc7f85b993920d3cd42696940b33a576af80 WHIRLPOOL e9e09481694980a8f3c33dc41dc20de4fbbfc4729350cc1f087679544048ae453714e8b3c87038b1071a2c2266560926bbbda74a97296368879bda57542c5272
EBUILD gitlab-ci-multi-runner-0.4.2.ebuild 3225 SHA256 44b6408c4a211d329bb6eeeb1ff0f50b2cda79334a9dc6c6697285b21b7d3264 SHA512 77280f574a972540899a149f52e07d8ec554163caf561c76e3026c6fb0673f2a8147d2cd7d564d9e8df3afb7462b5d910cb33da857584007da15492c6f5c8818 WHIRLPOOL a1cc329c74f9a4e976b719dadc5afc6744dbc60f752dae7ff766a9f1fc9a381fb3e06107cfc2a543e78e4cb73af9cbcfb2c3c85b953553226300694cbbdb4389

View file

@ -0,0 +1,2 @@
# specify the number of runners to spawn. Default: 1
# gitlab_ci_runner_num=1

View file

@ -0,0 +1,58 @@
#!/sbin/runscript
name="GitLab CI Multi Runner"
description="GitLab CI Multi Runner, starts runners in the background"
: ${gitlab_ci_runner_user:=@USER@}
: ${gitlab_ci_runner_base:="@GITLAB_CI_RUNNER_BASE@"}
: ${gitlab_ci_runner_pidfile_base:="@RUN_DIR@/gitlab-ci-runner.pid"}
: ${gitlab_ci_runner_logfile:="@LOGS_DIR@/gitlab-ci-runner.log"}
: ${gitlab_ci_runner_num:=1} # number of runners to spawn
bundle_command="/usr/bin/bundle"
bundle_command_args="exec ./bin/runner"
depend() {
provide gitlab-ci-multi-runner
}
start() {
ebegin "Starting ${name}"
for (( i=1; i<=${gitlab_ci_runner_num}; i++ )) ; do
einfo "Starting runner ${i} of ${gitlab_ci_runner_num} ..."
local pidfile="${gitlab_ci_runner_pidfile_base}${i}"
checkpath -d -o ${gitlab_ci_runner_user} -m755 "$(dirname "${pidfile}")"
start-stop-daemon --start \
--chdir "${gitlab_ci_runner_base}" \
--user=${gitlab_ci_runner_user} \
--make-pidfile \
--pidfile="${pidfile}" \
--background \
--exec /bin/bash -- -c "exec ${bundle_command} ${bundle_command_args} >> ${gitlab_ci_runner_logfile} 2>&1"
local success=$?
if [ ${success}!=0 ] ; then
eend ${success}
fi
done
eend 0
}
stop() {
ebegin "Stopping ${name}"
for (( i=1; i<=${gitlab_ci_runner_num}; i++ )) ; do
einfo "Stopping runner ${i} of ${gitlab_ci_runner_num} ..."
local pidfile="${gitlab_ci_runner_pidfile_base}${i}"
start-stop-daemon --stop \
--pidfile="${pidfile}"
# DO WE NEED --exec? or --startas???
local success=$?
if [ ${success}!=0 ] ; then
eend ${success}
fi
done
eend 0
}

View file

@ -0,0 +1,130 @@
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="5"
#USE_RUBY="ruby19 ruby20 ruby21"
#PYTHON_DEPEND="2:2.7"
#inherit eutils python ruby-ng user
inherit eutils user
DESCRIPTION="GitLab CI Multi Runner is the new build processor needed for GitLab CI >= 7.12"
HOMEPAGE="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner"
SRC_URI="https://gitlab.com/gitlab-org/${PN}/repository/archive.tar.gz?ref=${PV} -> ${P}.tar.gz"
#"x86? ( https://${PN}-downloads.s3.amazonaws.com/${PV}/binaries/${PN}-linux-386 -> ${PN}-x86 )
# amd64? ( https://${PN}-downloads.s3.amazonaws.com/${PV}/binaries/${PN}-linux-amd64 -> ${PN}-amd64 )
# arm? ( https://${PN}-downloads.s3.amazonaws.com/${PV}/binaries/${PN}-linux-arm -> ${PN}-arm )"
RESTRICT="mirror"
REQUIRED_USE="^^ ( x86 amd64 arm )"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="amd64 arm x86"
DEPEND="dev-vcs/git"
CDEPEND="dev-lang/go"
RDEPEND="${DEPEND}
virtual/mta"
MY_NAME="${PN}"
MY_USER="gitlab_ci_runner"
DEST_DIR="/opt/${MY_NAME}"
LOGS_DIR="/var/log/${MY_NAME}"
TEMP_DIR="/var/tmp/${MY_NAME}"
RUN_DIR="/run/${MY_NAME}"
S="${WORKDIR}/${PN}.git"
pkg_setup() {
enewgroup ${MY_USER}
enewuser ${MY_USER} -1 /bin/bash ${DEST_DIR} ${MY_USER}
export GOPATH="${WORKDIR}"
}
#src_unpack() {
# local a="$(usev amd64)$(usev arm)$(usev x86)"
# mkdir -p "${S}"
# cp "${DISTDIR}/${PN}-${a}" "${S}/${PN}"
#}
src_prepare() {
git init
}
src_compile() {
emake deps build || die "Failed to make deps build"
}
src_install() {
local dest=${DEST_DIR}
# local logs=${LOGS_DIR}
# local temp=${TEMP_DIR}
# local runs=${RUN_DIR}
# prepare directories
# diropts -m750
# dodir ${logs} ${temp}
diropts -m755
dodir ${dest}
# dosym ${temp} ${dest}/tmp
# dosym ${logs} ${dest}/log
# install the files using cp 'cause doins is slow
cp -Rl "${S}/"* "${D}/${dest}/"
# install logrotate config
# dodir /etc/logrotate.d
# cat > "${D}/etc/logrotate.d/${MY_NAME}" <<-EOF
# ${logs}/*.log {
# missingok
# delaycompress
# compress
# copytruncate
# }
# EOF
# fix permissions
fowners -R ${MY_USER}:${MY_USER} ${dest}
# fowners -R ${MY_USER}:${MY_USER} ${dest} ${temp} ${logs}
## RC script and conf.d file ##
local rcscript=gitlab-ci-multi-runner.init
local rcconf=gitlab-ci-multi-runner.conf
cp "${FILESDIR}/${rcscript}" "${T}" || die
sed -i \
-e "s|@USER@|${MY_USER}|" \
-e "s|@GITLAB_CI_MULTI_RUNNER_BASE@|${dest}|" \
-e "s|@LOGS_DIR@|${logs}|" \
-e "s|@RUN_DIR@|${runs}|" \
"${T}/${rcscript}" \
|| die "failed to filter ${rcscript}"
newinitd "${T}/${rcscript}" "${MY_NAME}"
newconfd "${FILESDIR}/${rcconf}" "${MY_NAME}"
}
pkg_postinst() {
elog
elog "If this is a fresh install of GitLab CI Multi Runner, please configure it"
elog "with the following command:"
elog " emerge --config \"=${CATEGORY}/${PF}\""
}
pkg_config() {
einfo "You need to register the runner with your GitLab CI instance. Please"
einfo "Follow the instructions on"
einfo
einfo "https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/linux-manually.md"
einfo
einfo "Perhaps I'll improve the ebuild later ... kthxbye."
}