ci-image-git-buildpackage/gitlab-ci-git-buildpackage

70 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
if [ "$CI_COMMIT_REF_NAME" == "upstream" ] || [ "$CI_COMMIT_REF_NAME" == "pristine-tar" ]; then
echo No builds run on the $CI_COMMIT_REF_NAME branch, exiting
exit 0
fi
# https://gitlab.com/gitlab-org/gitlab-runner/issues/1380#note_48552305
lockfile=/.lock
if [[ ! -f $lockfile ]] ; then
set -e
set -x
gitlab-ci-enable-sid
gitlab-ci-enable-experimental
apt_get="apt-get -qy"
if [ ! -z "$APT_GET_OPTIONS" ]; then
apt_get="$apt_get $APT_GET_OPTIONS"
fi
if [ ! -z "$EXTRA_APT_SOURCE" ]; then
printf "\n$EXTRA_APT_SOURCE\n" >> /etc/apt/sources.list
fi
if [ ! -z "$DEBIAN_RELEASE" ]; then
sed -i "s, testing , $DEBIAN_RELEASE ," /etc/apt/sources.list
fi
$apt_get update
$apt_get dist-upgrade
cd $CI_PROJECT_DIR
if dpkg --compare-versions `dpkg -s apt |sed -n 's,^Version: \(.*\),\1,p'` ge 1.1; then
$apt_get build-dep $CI_PROJECT_DIR
else
# this is running on an older version, like jessie-backports
export BUILD_DEPENDS=`sed 's/\s*|[^,]*,/,/g' debian/control | perl -ne 'next if /^#/; $p=(s/^Build-Depends:\s*/ / or (/^ / and $p)); s/,|\n|\([^)]+\)//mg; print if $p'`
$apt_get install --no-install-recommends \
build-essential fakeroot git-buildpackage pristine-tar $BUILD_DEPENDS
fi
$apt_get autoremove --purge
dpkg-checkbuilddeps
echo "ensure pristine-tar branch exists and is current"
git clean -fdx
git reset --hard
git fetch --all
git checkout -B pristine-tar origin/pristine-tar
echo "make $CI_COMMIT_REF_NAME branch current for gbp"
git checkout -B "$CI_COMMIT_REF_NAME" "$CI_COMMIT_SHA"
if [ -z "$CI_COMMIT_TAG" ]; then
gbp buildpackage -uc -us --git-debian-branch="$CI_COMMIT_REF_NAME"
else
gbp buildpackage -uc -us
fi
echo "performing general and experimental lintian checks"
su --shell /bin/sh nobody --command "lintian --color always -EviIL +pedantic ../*.changes" || true
echo "performing ftp-master-rejects lintian checks"
su --shell /bin/sh nobody --command "lintian --color always -viF ../*.changes"
if [ -e debian/tests/control ]; then
autopkgtest ../*.changes -- null
fi
fi
[[ $CI ]] && touch $lockfile
exec "$@"