#!/bin/bash set -x set -e if [ -r /etc/jenkins/debian_glue ] ; then . /etc/jenkins/debian_glue fi if [ "${BUILD_ONLY:-}" = "true" ] ; then echo "BUILD_ONLY is set to true, ignoring request to generate local repository." exit 0 fi if [ "$#" -lt 1 ] ; then echo "Usage: $0 " >&2 exit 1 fi # repository/codename that should be added REPOS="$1" JENKINS_DEBIAN_GLUE_VERSION=$(dpkg --list jenkins-debian-glue 2>/dev/null | awk '/^ii/ {print $3}') if [ -n "${JENKINS_DEBIAN_GLUE_VERSION:-}" ] ; then echo "*** Running jenkins-debian-glue version $JENKINS_DEBIAN_GLUE_VERSION ***" fi if [ -z "${REPOSITORY:-}" ] ; then REPOSITORY='/srv/repository' echo "*** Repository variable REPOSITORY is unset, using default [$REPOSITORY] ***" fi if ! ${SUDO_CMD:-} mkdir -p "${REPOSITORY}"/conf ; then echo "Error creating ${REPOSITORY}/conf (forgot to create /srv/repository and chown jenkins?)" >&2 exit 1 fi ${SUDO_CMD:-} chown $(id -un) "${REPOSITORY}"/conf touch "${REPOSITORY}"/conf/distributions if [ -r /etc/jenkins/debian_glue ] ; then echo "*** Sourcing /etc/jenkins/debian_glue ***" . /etc/jenkins/debian_glue fi # support setting key id if [ -z "${KEY_ID:-}" ] ; then echo "*** WARNING: No KEY_ID found, can not sign repository. ***" echo "*** Generate a key executing 'gpg --gen-key' as user root" echo "*** and then set up /etc/jenkins/debian_glue, see" echo "*** /usr/share/jenkins-debian-glue/examples/debian_glue" fi if grep -q "^Codename: ${REPOS}$" "${REPOSITORY}"/conf/distributions ; then echo "Codename/repository $REPOS exists already, ignoring request to add again." exit 0 fi cat >> "${REPOSITORY}"/conf/distributions << EOF Codename: ${REPOS} AlsoAcceptFor: unstable Architectures: amd64 i386 source Components: main DebIndices: Packages Release . .gz DscIndices: Sources Release .gz Tracking: minimal EOF if [ -n "${KEY_ID:-}" ] ; then echo "*** Signing repository with Key ID $KEY_ID ***" printf "SignWith: ${KEY_ID}\n\n" >> "${REPOSITORY}"/conf/distributions fi echo "Added $REPOS as new codename/repos to the reprepro configuration." # vim:foldmethod=marker ts=2 ft=sh ai expandtab sw=2