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.
159 lines
4.3 KiB
159 lines
4.3 KiB
#!/bin/bash
|
|
# Purpose: generate Debian source package based on project's git repository
|
|
# schema:
|
|
# $debian_dir: and one directory for every distribution
|
|
# $debian_auto_version: how the automatic version is created
|
|
# $tagbase: tag to use for git describe
|
|
cd source || {
|
|
echo "cannot change to source/ directory" >&2
|
|
exit 1
|
|
}
|
|
|
|
# debug info
|
|
env
|
|
|
|
kamailio_nightly() {
|
|
case "${DISTRIBUTION}" in
|
|
UNRELEASED) echo "*** UNRELEASED detected, use ${VERSION}" ;;
|
|
*)
|
|
if [ "${GIT_BRANCH}" != "origin/master" ]; then
|
|
# use next point version instead, this is a nightly build
|
|
# if we have A.B.C as ORIG_VERSION we should use A.B.C+1 instead
|
|
if [[ ${VERSION} =~ ([0-9]+)\.([0-9]+)\.([0-9]+)$ ]] ; then
|
|
NEXT=${BASH_REMATCH[3]}
|
|
(( NEXT++ ))
|
|
VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${NEXT}"
|
|
echo "*** branch build detected, next version is ${VERSION}"
|
|
fi
|
|
fi
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# defaults
|
|
build_tag=false
|
|
TAG=unknown
|
|
BASE_DIR=${debian_dir:-pkg/kamailio/deb}
|
|
JOB_NAME=${JOB_NAME:-kamailio-source}
|
|
distribution=${distribution:-unknown}
|
|
BUILD_NUMBER=${BUILD_NUMBER:-0}
|
|
|
|
if [ -n "$GIT_BRANCH" ] ; then
|
|
# support both
|
|
case "$GIT_BRANCH" in
|
|
origin/tags/*)
|
|
build_tag=true
|
|
TAG=${GIT_BRANCH#origin/tags/}
|
|
;;
|
|
refs/tags/*)
|
|
build_tag=true
|
|
TAG=${GIT_BRANCH#refs/tags/}
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
if [ ! -d "$BASE_DIR" ]; then
|
|
# shellcheck disable=SC2016
|
|
echo "No \$BASE_DIR [${BASE_DIR}] found on source" >&2
|
|
exit 1
|
|
fi
|
|
|
|
git clean -fxd
|
|
|
|
if [ -x "${BASE_DIR}/generator.sh" ]; then
|
|
echo "generate base debian directory"
|
|
(
|
|
cd "${BASE_DIR}" || exit 1
|
|
./generator.sh
|
|
)
|
|
fi
|
|
|
|
if [ -x "${BASE_DIR}/debian/backports/${distribution}" ]; then
|
|
echo "build debian directory for ${distribution}"
|
|
(
|
|
cd "${BASE_DIR}" || exit 1
|
|
./debian/backports/"${distribution}"
|
|
)
|
|
fi
|
|
|
|
if [ ! -d "${BASE_DIR}/${distribution}" ]; then
|
|
echo "${distribution} not supported" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! [ -f "${BASE_DIR}/${distribution}/changelog" ] ; then
|
|
case "${JOB_NAME}" in
|
|
rtpengine*)
|
|
echo "update changelog from ngcp-rtpengine to rtpengine source"
|
|
sed -i 's/ngcp-rtpengine/rtpengine/g' debian/changelog
|
|
echo "source format native"
|
|
sed -i 's/quilt/native/g' debian/source/format
|
|
cp debian/source/format "${BASE_DIR}/${distribution}/"source/
|
|
;;
|
|
esac
|
|
echo "copying changelog from debian dir"
|
|
cp debian/changelog "${BASE_DIR}/${distribution}/"
|
|
fi
|
|
|
|
rm -rf debian
|
|
cp -a "${BASE_DIR}/${distribution}" debian
|
|
|
|
export DEBEMAIL="Jenkins Sipwise <jenkins@sipwise.com>"
|
|
|
|
case "${distribution}" in
|
|
precise) BPO=ubuntu12.04 ;;
|
|
trusty) BPO=ubuntu14.04 ;;
|
|
xenial) BPO=ubuntu16.04 ;;
|
|
bionic) BPO=ubuntu18.04 ;;
|
|
focal) BPO=ubuntu20.04 ;;
|
|
jammy) BPO=ubuntu22.04 ;;
|
|
noble) BPO=ubuntu24.04 ;;
|
|
bullseye) BPO=bpo11 ;;
|
|
bookworm) BPO=bpo12 ;;
|
|
trixie) BPO=bpo13 ;;
|
|
*)
|
|
echo "${distribution} not supported" >&2
|
|
exit 2 ;;
|
|
esac
|
|
|
|
# not yet released, in order to avoid bad-distribution-in-changes-file error
|
|
case "${distribution}" in
|
|
sid)
|
|
echo "*** switch ${distribution} to unstable ***"
|
|
distribution_control=unstable
|
|
;;
|
|
*) distribution_control=${distribution} ;;
|
|
esac
|
|
|
|
if "$build_tag" ; then
|
|
case "${JOB_NAME}" in
|
|
rtpengine*) TAG=${TAG#mr} ;;
|
|
*) TAG=${TAG#v} ;;
|
|
esac
|
|
echo "*** Building a tagged version (${TAG}+${BPO}).***"
|
|
dch -b --distribution="${distribution_control}" \
|
|
--newversion="${TAG}+${BPO}" \
|
|
-- "Automated package build for tag $TAG and distribution $distribution."
|
|
else
|
|
VERSION=$(dpkg-parsechangelog --count 1 | awk '/^Version/ {print $2}')
|
|
DISTRIBUTION=$(dpkg-parsechangelog --count 1 | awk '/^Distribution/ {print $2}')
|
|
case "${JOB_NAME}" in
|
|
kamailio*|kamcli*) kamailio_nightly ;;
|
|
rtpengine*) echo ;;
|
|
*) echo "unknown JOB_NAME:${JOB_NAME}" >&2; exit 3 ;;
|
|
esac
|
|
TIMESTAMP="$(date -u +%Y%m%d%H%M%S)"
|
|
if [[ "${VERSION}" =~ ~(dev|rc|pre)[0-9]+ ]] ; then
|
|
echo "*** ${BASH_REMATCH[1]} version detected ***"
|
|
AUTO_VERSION="${VERSION}+${BPO}.${TIMESTAMP}.${BUILD_NUMBER}"
|
|
else
|
|
AUTO_VERSION="${VERSION}~${BPO}.${TIMESTAMP}.${BUILD_NUMBER}"
|
|
fi
|
|
echo "*** Building version ${AUTO_VERSION} for ${distribution}.***"
|
|
dch -b --distribution="${distribution_control}" \
|
|
--newversion="${AUTO_VERSION}" \
|
|
-- "Automated package build."
|
|
fi
|
|
|
|
dpkg-buildpackage -uc -us -nc -d -S -i -I --source-option=--unapply-patches
|