blob: 1de585ba9afff75be371df4246b8cd4e14b16a63 [file] [log] [blame]
Sergey Otpuschennikovfc3a3832020-09-04 16:07:37 +04001#!/bin/bash -ex
2: ${JEEPYB_WORKSPACE:=$(pwd)/.workspace}
3
4PROJECTS_INI=${JEEPYB_WORKSPACE}/projects.ini
5PROJECTS_YAML=$(pwd)/projects.yaml
6
7export PROJECTS_INI PROJECTS_YAML
8
9mkdir -p "${JEEPYB_WORKSPACE}"
10
11cp "$(pwd)/conf/projects.ini.template" "${PROJECTS_INI}"
12
13[ -n "${JEEPYB_GERRIT_HOST}" ] \
14 && sed -i "s|^gerrit-host.*|gerrit-host=${JEEPYB_GERRIT_HOST}|" "${PROJECTS_INI}"
15[ -n "${JEEPYB_USER}" ] \
16 && sed -i "s|^gerrit-user.*|gerrit-user=${JEEPYB_USER}|" "${PROJECTS_INI}"
17[ -n "${JEEPYB_COMMITTER}" ] \
18 && sed -i "s|^gerrit-committer.*|gerrit-committer=${JEEPYB_COMMITTER}|" "${PROJECTS_INI}"
19[ -n "${JEEPYB_SSH_KEY}" ] \
20 && echo "gerrit-key=${JEEPYB_SSH_KEY}" >> "${PROJECTS_INI}"
21
22COMMITTER=$(git config --file "${PROJECTS_INI}" projects.gerrit-committer)
23GIT_COMMITTER_NAME=$(echo "${COMMITTER}" | awk -F '[<>]' '{print $1}')
24GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME% *}
25GIT_COMMITTER_EMAIL=$(echo "${COMMITTER}" | awk -F '[<>]' '{print $2}')
26export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
27
28sed -i "s|^gerrit-system-user.*|gerrit-system-user=$(id -u)|" "${PROJECTS_INI}"
29sed -i "s|^gerrit-system-group.*|gerrit-system-group=$(id -u)|" "${PROJECTS_INI}"
30sed -i "s|^acl-dir.*|acl-dir=$(pwd)/acls|" "${PROJECTS_INI}"
31sed -i "s|^local-git-dir.*|local-git-dir=${JEEPYB_WORKSPACE}/git|" "${PROJECTS_INI}"
32sed -i "s|^jeepyb-cache-dir.*|jeepyb-cache-dir=${JEEPYB_WORKSPACE}/cache|" "${PROJECTS_INI}"
33
34# Backward compatibility with legacy format:
35# remove acls/ path prefix from `acl-config` params
36sed -i 's|acl-config: acls/|acl-config: |g' "${PROJECTS_YAML}"
37
38manage-projects -v -d $@