| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
if [ -z ${JENKINS_DEBIAN_GLUE_QUIET:-} ]; then |
| 4 |
set -x |
| 5 |
fi |
| 6 |
set -e |
| 7 |
|
| 8 |
# backwards compatibility, see PR#94 |
| 9 |
if [ -z "${REPOSITORY:-}" ] ; then |
| 10 |
repository_is_missing_in_env=true |
| 11 |
else |
| 12 |
repository_is_missing_in_env=false |
| 13 |
fi |
| 14 |
|
| 15 |
if [ -r /etc/jenkins/debian_glue ] ; then |
| 16 |
. /etc/jenkins/debian_glue |
| 17 |
fi |
| 18 |
|
| 19 |
# backwards compatibility, see PR#94 |
| 20 |
if [ -n "${REPOSITORY:-}" ] && $repository_is_missing_in_env ; then |
| 21 |
echo "*** WARNING: 'REPOSITORY' set in /etc/jenkins/debian_glue but should be DEFAULT_REPOSITORY ***" |
| 22 |
echo "*** WARNING: Setting DEFAULT_REPOSITORY to $REPOSITORY for backwards compatibility ***" |
| 23 |
echo "*** WARNING: Please replace REPOSITORY=... in /etc/jenkins/debian_glue with DEFAULT_REPOSITORY=... ***" |
| 24 |
DEFAULT_REPOSITORY="${REPOSITORY}" |
| 25 |
fi |
| 26 |
|
| 27 |
if [ -z "${DEFAULT_REPOSITORY:-}" ] ; then |
| 28 |
echo "*** Repository variable DEFAULT_REPOSITORY is unset, using default [$DEFAULT_REPOSITORY] ***" |
| 29 |
DEFAULT_REPOSITORY='/srv/repository' |
| 30 |
fi |
| 31 |
|
| 32 |
# REPOSITORY can overwrite DEFAULT_REPOSITORY, so define only if unset |
| 33 |
if [ -z "${REPOSITORY:-}" ] ; then |
| 34 |
REPOSITORY="${DEFAULT_REPOSITORY}" |
| 35 |
echo "*** Repository variable REPOSITORY is unset, using default [$REPOSITORY] ***" |
| 36 |
fi |
| 37 |
|
| 38 |
# support usage of a reprepro wrapper |
| 39 |
REPREPRO_CMD="${REPREPRO_CMD:-reprepro}" |
| 40 |
|
| 41 |
if [ -z "${REPREPRO_OPTS:-}" ] ; then |
| 42 |
REPREPRO_OPTS='--waitforlock 1000 -v' |
| 43 |
fi |
| 44 |
|
| 45 |
if [ "$#" -lt 1 ] ; then |
| 46 |
echo "Usage: $0 <codename>" >&2 |
| 47 |
exit 1 |
| 48 |
fi |
| 49 |
|
| 50 |
codename="$1" |
| 51 |
|
| 52 |
if ! [ -r "${REPOSITORY}/conf/distributions" ] ; then |
| 53 |
echo "*** Error: could not read ${REPOSITORY}/conf/distributions" >&2 |
| 54 |
exit 1 |
| 55 |
fi |
| 56 |
|
| 57 |
if ! grep -q "^\(Codename\|Suite\): ${codename}$" "${REPOSITORY}/conf/distributions" ; then |
| 58 |
echo "*** Codename $codename does not exist in ${REPOSITORY}/conf/distributions - nothing to do." |
| 59 |
exit 0 |
| 60 |
fi |
| 61 |
|
| 62 |
echo "*** Removing codename $codename from reprepro configuration in $REPOSITORY ***" |
| 63 |
perl -i -00 -pe "if (!\$done && m|$codename|) { \$_=q(); \$done++}" "${REPOSITORY}/conf/distributions" |
| 64 |
|
| 65 |
echo "*** Removing vanished data from reprepro ***" |
| 66 |
${REPREPRO_CMD} $REPREPRO_OPTS -b "$REPOSITORY" --delete clearvanished |
| 67 |
|
| 68 |
echo "*** Removing package indices files (${REPOSITORY}/dists/${codename}) ***" |
| 69 |
rm -rf "${REPOSITORY}/dists/${codename}" |
| 70 |
|
| 71 |
# vim:foldmethod=marker ts=2 ft=sh ai expandtab sw=2 |