You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jenkins-debian-glue/scripts/jdg-remove-reprepro-codename

72 lines
2.2 KiB

#!/bin/bash
if [ -z ${JENKINS_DEBIAN_GLUE_QUIET:-} ]; then
set -x
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="${DEFAULT_REPOSITORY}"
echo "*** Repository variable REPOSITORY is unset, using default [$REPOSITORY] ***"
fi
# support usage of a reprepro wrapper
REPREPRO_CMD="${REPREPRO_CMD:-reprepro}"
if [ -z "${REPREPRO_OPTS:-}" ] ; then
REPREPRO_OPTS='--waitforlock 1000 -v'
fi
if [ "$#" -lt 1 ] ; then
echo "Usage: $0 <codename>" >&2
exit 1
fi
codename="$1"
if ! [ -r "${REPOSITORY}/conf/distributions" ] ; then
echo "*** Error: could not read ${REPOSITORY}/conf/distributions" >&2
exit 1
fi
if ! grep -q "^\(Codename\|Suite\): ${codename}$" "${REPOSITORY}/conf/distributions" ; then
echo "*** Codename $codename does not exist in ${REPOSITORY}/conf/distributions - nothing to do."
exit 0
fi
echo "*** Removing codename $codename from reprepro configuration in $REPOSITORY ***"
perl -i -00 -pe "if (!\$done && m|$codename|) { \$_=q(); \$done++}" "${REPOSITORY}/conf/distributions"
echo "*** Removing vanished data from reprepro ***"
${REPREPRO_CMD} $REPREPRO_OPTS -b "$REPOSITORY" --delete clearvanished
echo "*** Removing package indices files (${REPOSITORY}/dists/${codename}) ***"
rm -rf "${REPOSITORY}/dists/${codename}"
# vim:foldmethod=marker ts=2 ft=sh ai expandtab sw=2