Sergey Otpuschennikov | fc3a383 | 2020-09-04 16:07:37 +0400 | [diff] [blame^] | 1 | #!/bin/bash -ex |
| 2 | : ${JEEPYB_WORKSPACE:=$(pwd)/.workspace} |
| 3 | |
| 4 | PROJECTS_INI=${JEEPYB_WORKSPACE}/projects.ini |
| 5 | PROJECTS_YAML=$(pwd)/projects.yaml |
| 6 | |
| 7 | export PROJECTS_INI PROJECTS_YAML |
| 8 | |
| 9 | mkdir -p "${JEEPYB_WORKSPACE}" |
| 10 | |
| 11 | cp "$(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 | |
| 22 | COMMITTER=$(git config --file "${PROJECTS_INI}" projects.gerrit-committer) |
| 23 | GIT_COMMITTER_NAME=$(echo "${COMMITTER}" | awk -F '[<>]' '{print $1}') |
| 24 | GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME% *} |
| 25 | GIT_COMMITTER_EMAIL=$(echo "${COMMITTER}" | awk -F '[<>]' '{print $2}') |
| 26 | export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL |
| 27 | |
| 28 | sed -i "s|^gerrit-system-user.*|gerrit-system-user=$(id -u)|" "${PROJECTS_INI}" |
| 29 | sed -i "s|^gerrit-system-group.*|gerrit-system-group=$(id -u)|" "${PROJECTS_INI}" |
| 30 | sed -i "s|^acl-dir.*|acl-dir=$(pwd)/acls|" "${PROJECTS_INI}" |
| 31 | sed -i "s|^local-git-dir.*|local-git-dir=${JEEPYB_WORKSPACE}/git|" "${PROJECTS_INI}" |
| 32 | sed -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 |
| 36 | sed -i 's|acl-config: acls/|acl-config: |g' "${PROJECTS_YAML}" |
| 37 | |
| 38 | manage-projects -v -d $@ |