/usr/bin/generate-reprepro-codename is in jenkins-debian-glue 0.18.4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | #!/bin/bash
if [ -z ${JENKINS_DEBIAN_GLUE_QUIET:-} ]; then
set -x
fi
set -e
bailout() {
[ -n "${1:-}" ] && EXIT="${1}" || EXIT=0
[ -n "${2:-}" ] && echo "$2" >&2
rm -f /var/lock/jdg-generate-reprepro-codename."$(id -un)"
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
fi
ARCHITECTURES="${ARCHITECTURES:-amd64 i386 source}"
COMPONENTS="${COMPONENTS:-main}"
UDEB_COMPONENTS="${UDEB_COMPONENTS:-main}"
usage() {
echo "Usage: $0" \
"[ --architectures <architectures> ]" \
"[ --components <components> ]" \
"[ --udeb-components <udeb components> ]" \
"[ --origin <origin> ]" \
"[ --suite <suite> ]" \
"<codename>"
}
while [ "$#" -gt 1 ]; do
case "$1" in
--architectures)
ARCHITECTURES="$2"
shift 2
;;
--components)
COMPONENTS="$2"
shift 2
;;
--udeb-components)
UDEB_COMPONENTS="$2"
shift 2
;;
--origin)
ORIGIN="$2"
shift 2
;;
--suite)
SUITE="$2"
shift 2
;;
--)
shift; break
;;
*)
echo "Usage error." >&2
usage >&2
exit 1
;;
esac
done
if [ "$#" -lt 1 ] ; then
usage >&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 "${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
if ! ${SUDO_CMD:-} mkdir -p "${REPOSITORY}"/conf ; then
echo "Error creating ${REPOSITORY}/conf (forgot to create ${REPOSITORY} and chown jenkins?)" >&2
exit 1
fi
if ! ${SUDO_CMD:-} chown $(id -un) "${REPOSITORY}"/conf ; then
echo "*** Warning: failed to adjust permissions of ${REPOSITORY}/conf ***"
echo "*** This might be caused by a remote FS like sshfs, so not failing the build. ***"
echo "*** Please fix the underlying problem if you depend on according permissions. ***"
fi
touch "${REPOSITORY}"/conf/distributions
# 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 adjust /etc/jenkins/debian_glue."
fi
# lock access to file to avoid duplicate entries when two generate-reprepro-codename
# runs happen at the very same time
(
flock --timeout 5 9 || bailout 1 "Error: could not lock file ${REPOSITORY}/conf/distributions, giving up."
if grep -q "^\(Codename\|Suite\): ${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}
Architectures: ${ARCHITECTURES}
Components: ${COMPONENTS}
EOF
if [ -n "${SUITE:-}" ]; then
printf "Suite: ${SUITE}\n" >> "${REPOSITORY}"/conf/distributions
fi
if [ -n "${ORIGIN:-}" ]; then
printf "Origin: ${ORIGIN}\n" >> "${REPOSITORY}"/conf/distributions
fi
if [ -n "${UDEB_COMPONENTS:-}" ]; then
printf "UDebComponents: ${UDEB_COMPONENTS}\n" >> "${REPOSITORY}"/conf/distributions
fi
printf "Tracking: minimal\n" >> "${REPOSITORY}"/conf/distributions
if [ -n "${KEY_ID:-}" ] ; then
echo "*** Signing repository with Key ID $KEY_ID ***"
printf "SignWith: ${KEY_ID}\n" >> "${REPOSITORY}"/conf/distributions
fi
echo "Added $REPOS as new codename/repos to the reprepro configuration."
) 9>/var/lock/jdg-generate-reprepro-codename."$(id -un)" || bailout 1 "Error while generating reprepro codename/repos."
rm -f /var/lock/jdg-generate-reprepro-codename."$(id -un)"
# vim:foldmethod=marker ts=2 ft=sh ai expandtab sw=2
|