/usr/bin/pkgos-infra-build-pkg is in openstack-pkg-tools 75.
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 | #!/bin/sh
set -e
set -x
detect_distro () {
DISTRO_VENDOR=$(lsb_release --id -s | awk '{print tolower($0)}')
DISTRO_NAME=$(lsb_release -c -s)
}
# Get some version information out of the debian/changelog last entry
get_deb_version() {
PKG_NAME=$(dpkg-parsechangelog -SSource)
DEB_VERS=$(dpkg-parsechangelog -SVersion)
NO_EPOC=$(echo ${DEB_VERS} | cut -d":" -f2)
if echo ${DEB_VERS} | grep -q ':' ; then
EPOC=$(echo ${DEB_VERS} | cut -d":" -f1)
fi
UPSTREAM_VERS=$(echo ${NO_EPOC} | cut -d"-" -f1)
if [ "${DEB_VERS}" = "${UPSTREAM_VERS}" ] ; then IS_NATIVE="yes" ; else IS_NATIVE="no" ; fi
ORIG=${PKG_NAME}_${UPSTREAM_VERS}.orig.tar.xz
CHANGE=${PKG_NAME}_${NO_EPOC}_${ARCH}.changes
PKG_NAME_FIRST_CHAR=$(echo ${PKG_NAME} | awk '{print substr($0,1,1)}')
}
calc_bpo_version () {
case ${DISTRO_NAME} in
jessie)
BPO_DISTRO_NUM="~bpo8+1"
;;
stretch)
BPO_DISTRO_NUM="~bpo9+1"
;;
buster)
BPO_DISTRO_NUM="~bpo10+1"
;;
sid)
BPO_DISTRO_NUM=""
;;
trusty)
BPO_DISTRO_NUM="~bpo14.04+1"
;;
xenial)
BPO_DISTRO_NUM="~bpo16.04+1"
;;
*)
echo "Distribution not supported!"
echo "Falling back to no changelog bpo version tag"
BPO_DISTRO_NUM=""
;;
esac
}
create_orig_tarball () {
if grep pristine-tar debian/gbp.conf | grep -q -i true ; then
echo "Nothing special to do with Pristine tar: not generating orig file!"
else
if [ "${IS_NATIVE}" = "no" ] ; then
GENORIG_DEBRULES_TARGET=gen-orig-xz
if [ -r debian/gbp.conf ] ; then
COMPRESSION_IN_FILE=$(cat debian/gbp.conf | grep compression | cut -d'=' -f2 | awk '{print $1}')
if [ "${COMPRESSION_IN_FILE}" = "gz" ] ; then
GENORIG_DEBRULES_TARGET=gen-orig-gz
elif [ "${COMPRESSION_IN_FILE}" = "bzip2" ] ; then
GENORIG_DEBRULES_TARGET=gen-orig-bz2
fi
fi
./debian/rules ${GENORIG_DEBRULES_TARGET}
fi
fi
}
detect_branch_name () {
PACKAGING_BRANCH_NAME=$(grep debian-branch debian/gbp.conf | cut -d= -f2 | awk '{print $1}')
}
build_backport_package () {
echo "===> Building using git-buildpackage"
# Edit debian/changelog to show we're building a backport
LAST_GIT_COMMIT=$(git log | head -n 1 | awk '{print $2}')
NUM_COMMITS_FROM_LAST_TAG=$(git rev-list --no-merges $(git describe --no-abbrev --candidates=1)..HEAD | wc -l)
DEBFULLNAME="Jenkins" DEBEMAIL=jenkins@openstack.org dch --newversion ${DEB_VERS}+${NUM_COMMITS_FROM_LAST_TAG}${BPO_DISTRO_NUM} -b --allow-lower-version -m "Backport rebuilt by Jenkins in OpenStack infra."
git commit debian/changelog -m "Backport rebuilt by Jenkins in OpenStack infra."
git checkout -B ${PACKAGING_BRANCH_NAME}
#
echo "Checking /etc/passwd and /etc/group just to please clarkb"
cat /etc/group | grep sbuild
cat /etc/passwd | grep sbuild
echo "Now attempting to build with sbuild"
# Create ssh key
if ! [ -e ~/.ssh/id_rsa ] ; then
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
fi
# Copy it to authorized_keys
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys2
# Build the package with gbp buildpackage
echo "===> Building with gbp buildpackage from ${WORKSPACE}"
if [ "${IS_NATIVE}" = "no" ] ; then
SAFLAG=" --force-orig-source"
else
SAFLAG=""
fi
echo "===> Building with gbp buildpackage from ${WORKSPACE}"
if ! ssh -o "StrictHostKeyChecking no" localhost "cd ${WORKSPACE} ; gbp buildpackage${SAFLAG}" ; then
git reset --hard ${LAST_GIT_COMMIT}
echo "Error building the package with gbp buildpackage: exiting."
exit 1
else
git reset --hard ${LAST_GIT_COMMIT}
fi
}
lintian_test_the_package () {
echo "===> Starting Lintian check"
lintian -I -E --pedantic --suppress-tags bad-distribution-in-changes-file --suppress-tags privacy-breach-uses-embedded-file ../build-area/*.changes
}
prepare_for_upload () {
# When we switch to zuul v3, we can use this:
#UPDIR=../uploads
# Until then, we must stay in the WORKSPACE
UPDIR=uploads
mkdir -p ${UPDIR}/${LAST_GIT_COMMIT}
cp ../build-area/* ${UPDIR}/${LAST_GIT_COMMIT}
rm ${UPDIR}/${LAST_GIT_COMMIT}/*.build
cp -auxf ../build-area .
lintian -I -E --pedantic --suppress-tags bad-distribution-in-changes-file ../build-area/*.changes
}
prepare_for_upload () {
# When we switch to zuul v3, we can use this:
#UPDIR=../uploads
# Until then, we must stay in the WORKSPACE
UPDIR=uploads
mkdir -p ${UPDIR}/${LAST_GIT_COMMIT}
cp ../build-area/* ${UPDIR}/${LAST_GIT_COMMIT}
rm ${UPDIR}/${LAST_GIT_COMMIT}/*.build
cp -auxf ../build-area .
}
# We need this because we don't re-login, and
# sbuild has just been installed:
newgrp - sbuild
# Then we can start...
detect_distro
calc_bpo_version
get_deb_version
create_orig_tarball
detect_branch_name
build_backport_package
lintian_test_the_package
prepare_for_upload
|