Browse Source

Rename global REPOSITORY to DEFAULT_REPOSITORY to support overwriting it on demand (Closes #94)

The REPOSITORY variable is used to set the main/base path for the
(reprepro) repositories (defaulting to /srv/repository).  This
REPOSITORY setting could be defined via /etc/jenkins/debian_glue.
Since we are sourcing /etc/jenkins/debian_glue in our scripts
this overwrites a possibly existing environment variables named
REPOSITORY, preventing us to overwrite the REPOSITORY setting on
demand as needed as soon as REPOSITORY is configured in
/etc/jenkins/debian_glue.

To fix that behaviour we hereby rename the REPOSITORY variable to
DEFAULT_REPOSITORY while being backwards compatible. If you have
configured REPOSITORY via /etc/jenkins/debian_glue please rename
it to DEFAULT_REPOSITORY instead. In an upcoming release we might
drop backwards compatibility.

Thanks: Jean Baptiste Favre for the bug report
keep-around/8fe677820fae2a195e2dccace10b19edde8dc200
Michael Prokop 7 years ago
parent
commit
a1cba38ff7
  1. 5
      examples/debian_glue
  2. 22
      scripts/build-and-provide-package
  3. 25
      scripts/generate-reprepro-codename
  4. 24
      scripts/remove-reprepro-codename
  5. 24
      scripts/repository_checker

5
examples/debian_glue

@ -30,9 +30,10 @@
# By default no user specific pbuilder configuration file is used.
# PBUILDER_CONFIG=/etc/jenkins/pbuilderrc
# Base directory for reprepro repositories
# Base directory for reprepro repositories, can be overwritten
# via REPOSITORY on demand
# Default:
# REPOSITORY='/srv/repository'
# DEFAULT_REPOSITORY='/srv/repository'
# In order to keep the build versions unique and to ensure that there
# are no duplicates, the version number from the changelog is padded

22
scripts/build-and-provide-package

@ -59,10 +59,25 @@ set_debootstrap() {
}
checks_and_defaults() {
# backwards compatibility, see PR#94
if [ -z "${REPOSITORY:-}" ] ; then
local repository_is_missing_in_env=true
else
local repository_is_missing_in_env=false
fi
if [ -r /etc/jenkins/debian_glue ] ; then
. /etc/jenkins/debian_glue
fi
# backwards compatibility, see PR#94
if [ -n "${REPOSITORY:-}" ] && $repository_is_missing_in_env ; then
echo "*** WARNING: 'REPOSITORY' set in /etc/jenkins/debian_glue but should be DEFAULT_REPOSITORY ***"
echo "*** WARNING: Setting DEFAULT_REPOSITORY to $REPOSITORY for backwards compatibility ***"
echo "*** WARNING: Please replace REPOSITORY=... in /etc/jenkins/debian_glue with DEFAULT_REPOSITORY=... ***"
DEFAULT_REPOSITORY="${REPOSITORY}"
fi
# make sure cowbuilder/pbuilder has access to the variable
if [ -n "${DEB_KEEP_BUILD_ENV:-}" ] ; then
export DEB_KEEP_BUILD_ENV
@ -86,8 +101,13 @@ checks_and_defaults() {
echo "*** REPREPRO_OPTS is unset, using default: $REPREPRO_OPTS ***"
fi
if [ -z "${DEFAULT_REPOSITORY:-}" ] ; then
DEFAULT_REPOSITORY='/srv/repository'
fi
# REPOSITORY can overwrite DEFAULT_REPOSITORY, so define only if unset
if [ -z "${REPOSITORY:-}" ] ; then
REPOSITORY='/srv/repository'
REPOSITORY="${DEFAULT_REPOSITORY}"
fi
if [ -z "${PBUILDER_HOOKDIR:-}" ] ; then

25
scripts/generate-reprepro-codename

@ -12,11 +12,26 @@ bailout() {
exit $EXIT
}
# backwards compatibility, see PR#94
if [ -z "${REPOSITORY:-}" ] ; then
repository_is_missing_in_env=true
else
repository_is_missing_in_env=false
fi
if [ -r /etc/jenkins/debian_glue ] ; then
echo "*** Sourcing /etc/jenkins/debian_glue ***"
. /etc/jenkins/debian_glue
fi
# backwards compatibility, see PR#94
if [ -n "${REPOSITORY:-}" ] && $repository_is_missing_in_env ; then
echo "*** WARNING: 'REPOSITORY' set in /etc/jenkins/debian_glue but should be DEFAULT_REPOSITORY ***"
echo "*** WARNING: Setting DEFAULT_REPOSITORY to $REPOSITORY for backwards compatibility ***"
echo "*** WARNING: Please replace REPOSITORY=... in /etc/jenkins/debian_glue with DEFAULT_REPOSITORY=... ***"
DEFAULT_REPOSITORY="${REPOSITORY}"
fi
if [ "${BUILD_ONLY:-}" = "true" ] ; then
echo "BUILD_ONLY is set to true, ignoring request to generate local repository."
exit 0
@ -83,13 +98,19 @@ if [ -n "${JENKINS_DEBIAN_GLUE_VERSION:-}" ] ; then
echo "*** Running jenkins-debian-glue version $JENKINS_DEBIAN_GLUE_VERSION ***"
fi
if [ -z "${DEFAULT_REPOSITORY:-}" ] ; then
echo "*** Repository variable DEFAULT_REPOSITORY is unset, using default [$DEFAULT_REPOSITORY] ***"
DEFAULT_REPOSITORY='/srv/repository'
fi
# REPOSITORY can overwrite DEFAULT_REPOSITORY, so define only if unset
if [ -z "${REPOSITORY:-}" ] ; then
REPOSITORY='/srv/repository'
REPOSITORY="${DEFAULT_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
echo "Error creating ${REPOSITORY}/conf (forgot to create ${REPOSITORY} and chown jenkins?)" >&2
exit 1
fi

24
scripts/remove-reprepro-codename

@ -5,12 +5,34 @@ if [ -z ${JENKINS_DEBIAN_GLUE_QUIET:-} ]; then
fi
set -e
# backwards compatibility, see PR#94
if [ -z "${REPOSITORY:-}" ] ; then
repository_is_missing_in_env=true
else
repository_is_missing_in_env=false
fi
if [ -r /etc/jenkins/debian_glue ] ; then
. /etc/jenkins/debian_glue
fi
# backwards compatibility, see PR#94
if [ -n "${REPOSITORY:-}" ] && $repository_is_missing_in_env ; then
echo "*** WARNING: 'REPOSITORY' set in /etc/jenkins/debian_glue but should be DEFAULT_REPOSITORY ***"
echo "*** WARNING: Setting DEFAULT_REPOSITORY to $REPOSITORY for backwards compatibility ***"
echo "*** WARNING: Please replace REPOSITORY=... in /etc/jenkins/debian_glue with DEFAULT_REPOSITORY=... ***"
DEFAULT_REPOSITORY="${REPOSITORY}"
fi
if [ -z "${DEFAULT_REPOSITORY:-}" ] ; then
echo "*** Repository variable DEFAULT_REPOSITORY is unset, using default [$DEFAULT_REPOSITORY] ***"
DEFAULT_REPOSITORY='/srv/repository'
fi
# REPOSITORY can overwrite DEFAULT_REPOSITORY, so define only if unset
if [ -z "${REPOSITORY:-}" ] ; then
REPOSITORY='/srv/repository'
REPOSITORY="${DEFAULT_REPOSITORY}"
echo "*** Repository variable REPOSITORY is unset, using default [$REPOSITORY] ***"
fi
if [ -z "${REPREPRO_OPTS:-}" ] ; then

24
scripts/repository_checker

@ -3,12 +3,34 @@
JENKINS_DEBIAN_GLUE_VERSION=$(dpkg --list jenkins-debian-glue 2>/dev/null | awk '/^ii/ {print $3}')
JENKINS_DEBIAN_GLUE_VERSION=${JENKINS_DEBIAN_GLUE_VERSION:-unidentified}
# backwards compatibility, see PR#94
if [ -z "${REPOSITORY:-}" ] ; then
repository_is_missing_in_env=true
else
repository_is_missing_in_env=false
fi
if [ -r /etc/jenkins/debian_glue ] ; then
. /etc/jenkins/debian_glue
fi
# backwards compatibility, see PR#94
if [ -n "${REPOSITORY:-}" ] && $repository_is_missing_in_env ; then
echo "*** WARNING: 'REPOSITORY' set in /etc/jenkins/debian_glue but should be DEFAULT_REPOSITORY ***"
echo "*** WARNING: Setting DEFAULT_REPOSITORY to $REPOSITORY for backwards compatibility ***"
echo "*** WARNING: Please replace REPOSITORY=... in /etc/jenkins/debian_glue with DEFAULT_REPOSITORY=... ***"
DEFAULT_REPOSITORY="${REPOSITORY}"
fi
if [ -z "${DEFAULT_REPOSITORY:-}" ] ; then
echo "*** Repository variable DEFAULT_REPOSITORY is unset, using default [$DEFAULT_REPOSITORY] ***"
DEFAULT_REPOSITORY='/srv/repository'
fi
# REPOSITORY can overwrite DEFAULT_REPOSITORY, so define only if unset
if [ -z "${REPOSITORY:-}" ] ; then
REPOSITORY='/srv/repository'
REPOSITORY="${DEFAULT_REPOSITORY}"
echo "*** Repository variable REPOSITORY is unset, using default [$REPOSITORY] ***"
fi
if [ -z "${REPREPRO_OPTS:-}" ] ; then

Loading…
Cancel
Save