| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
set -x |
| 5 |
|
| 6 |
. /etc/pkgos/pkgos.conf |
| 7 |
|
| 8 |
PKG_NAME=${1} |
| 9 |
SUBGROUP=${2} |
| 10 |
|
| 11 |
ARCH=i386 ; if [ `uname -m` = "x86_64" ] ; then ARCH=amd64 ; fi |
| 12 |
if ! [ `whoami` = "root" ] ; then SU=sudo ; fi |
| 13 |
|
| 14 |
################################# |
| 15 |
# Define some utility functions # |
| 16 |
################################# |
| 17 |
# Is the package from the pkgs-js group? |
| 18 |
is_pkg_js () { |
| 19 |
ISPKGJS="no" |
| 20 |
for i in $PKG_JS ; do |
| 21 |
if [ "${i}" = "${PKG_NAME}" ] ; then |
| 22 |
ISPKGJS="yes" |
| 23 |
fi |
| 24 |
done |
| 25 |
} |
| 26 |
|
| 27 |
# Is the package maintained on a debian/<openstack-release-name> branch? |
| 28 |
is_core () { |
| 29 |
ISCORE="no" |
| 30 |
for i in $OSTACK_PKGS ; do |
| 31 |
if [ "${i}" = "${PKG_NAME}" ] ; then |
| 32 |
ISCORE="yes" |
| 33 |
return |
| 34 |
fi |
| 35 |
done |
| 36 |
} |
| 37 |
|
| 38 |
# Is the package maintained on a debian/experimental branch? |
| 39 |
is_experi () { |
| 40 |
ISEXPERI="no" |
| 41 |
for i in ${EXPERIMENTAL_BRANCH} ; do |
| 42 |
if [ "${i}" = "${PKG_NAME}" ] ; then |
| 43 |
ISEXPERI="yes" |
| 44 |
return |
| 45 |
fi |
| 46 |
done |
| 47 |
} |
| 48 |
|
| 49 |
is_server () { |
| 50 |
ISSERVER="no" |
| 51 |
for i in ${SERVERS} ; do |
| 52 |
if [ "${i}" = "${PKG_NAME}" ] ; then |
| 53 |
ISSERVER="yes" |
| 54 |
return |
| 55 |
fi |
| 56 |
done |
| 57 |
} |
| 58 |
|
| 59 |
# Get some version information out of the debian/changelog last entry |
| 60 |
get_deb_version() { |
| 61 |
PKG_NAME=`dpkg-parsechangelog -SSource` |
| 62 |
DEB_VERS=`dpkg-parsechangelog -SVersion` |
| 63 |
NO_EPOC=`echo ${DEB_VERS} | cut -d":" -f2` |
| 64 |
if echo ${DEB_VERS} | grep -q ':' ; then |
| 65 |
EPOC=`echo ${DEB_VERS} | cut -d":" -f1` |
| 66 |
fi |
| 67 |
UPSTREAM_VERS=`echo ${NO_EPOC} | cut -d"-" -f1` |
| 68 |
if [ "${DEB_VERS}" = "${UPSTREAM_VERS}" ] ; then IS_NATIVE="yes" ; else IS_NATIVE="no" ; fi |
| 69 |
ORIG=${PKG_NAME}_${UPSTREAM_VERS}.orig.tar.xz |
| 70 |
CHANGE=${PKG_NAME}_${NO_EPOC}_${ARCH}.changes |
| 71 |
PKG_NAME_FIRST_CHAR=`echo ${PKG_NAME} | awk '{print substr($0,1,1)}'` |
| 72 |
} |
| 73 |
|
| 74 |
############################## |
| 75 |
# Start of the actual script # |
| 76 |
############################## |
| 77 |
MY_CWD=`pwd` |
| 78 |
|
| 79 |
# Go in the build dir and make sure it's cleaned |
| 80 |
BUILD_ROOT=/var/lib/jenkins/jobs/${PKG_NAME}/builds/${BUILD_NUMBER} |
| 81 |
rm -rf ${BUILD_ROOT}/$PKG_NAME |
| 82 |
mkdir -p ${BUILD_ROOT}/$PKG_NAME |
| 83 |
cd ${BUILD_ROOT}/$PKG_NAME |
| 84 |
|
| 85 |
# "git clone" the package from the correct repo (either pkg-javascript or openstack) |
| 86 |
is_pkg_js |
| 87 |
if [ "${ISPKGJS}" = "yes" ] ; then |
| 88 |
git clone ${CLONE_URL_PKGJS}/${PKG_NAME}.git |
| 89 |
else |
| 90 |
if [ -n "${SUBGROUP}" ] ; then |
| 91 |
git clone ${CLONE_URL_BASE}/${SUBGROUP}/${PKG_NAME}.git |
| 92 |
else |
| 93 |
git clone ${CLONE_URL_BASE}/${PKG_NAME}.git |
| 94 |
fi |
| 95 |
fi |
| 96 |
cd $PKG_NAME |
| 97 |
|
| 98 |
# Checkout the correct branch(es) before building |
| 99 |
PRIS=$(grep pristine-tar debian/gbp.conf | awk '{print $1}') |
| 100 |
if [ "${PRIS}" = "pristine-tar" ] ; then |
| 101 |
PRIS_VAL=$(grep pristine-tar debian/gbp.conf | cut -d'=' -f2 | awk '{print $1}') |
| 102 |
if [ "${PRIS_VAL}" = "False" ] ; then |
| 103 |
PRIS="none" |
| 104 |
fi |
| 105 |
fi |
| 106 |
if [ "${PRIS}" = "pristine-tar" ] ; then |
| 107 |
# Guess the upstream-branch and debian-branch reading gbp.conf |
| 108 |
PRIS_UPSTREAM_BRANCH=$(grep upstream-branch debian/gbp.conf | cut -d'=' -f2 | awk '{print $1}') |
| 109 |
PRIS_DEBIAN_BRANCH=$(grep debian-branch debian/gbp.conf | cut -d'=' -f2 | awk '{print $1}') |
| 110 |
|
| 111 |
if [ -z "${PRIS_DEBIAN_BRANCH}" ] ; then |
| 112 |
PRIS_DEBIAN_BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') |
| 113 |
fi |
| 114 |
|
| 115 |
# If it's a pristine-tar package, checkout the pristine-tar and upstream-unstable branches |
| 116 |
git checkout -b pristine-tar origin/pristine-tar |
| 117 |
git checkout -b ${PRIS_UPSTREAM_BRANCH} origin/${PRIS_UPSTREAM_BRANCH} |
| 118 |
is_experi |
| 119 |
if [ "${ISEXPERI}" = "yes" ] ; then |
| 120 |
git checkout -b debian-experimental origin/debian-experimental |
| 121 |
else |
| 122 |
git checkout ${PRIS_DEBIAN_BRANCH} |
| 123 |
fi |
| 124 |
get_deb_version |
| 125 |
else |
| 126 |
is_core |
| 127 |
if [ "${ISCORE}" = "yes" ] ; then |
| 128 |
# If it's a core package, listed in OSTACK_PKGS in /etc/pkgos/pkgos.conf |
| 129 |
# then we use debian/juno, debian/kilo, etc. as packaging branch. |
| 130 |
git checkout -b debian/${TARGET_OPENSTACK_REL} origin/debian/${TARGET_OPENSTACK_REL} || true |
| 131 |
|
| 132 |
if [ "${BUILD_FROM_TRUNK}" = "yes" ] ; then |
| 133 |
is_server |
| 134 |
if [ "${ISSERVER}" = "yes" ] ; then |
| 135 |
# Get the master branch |
| 136 |
./debian/rules get-master-branch |
| 137 |
git checkout master |
| 138 |
|
| 139 |
# Calculate a new tag |
| 140 |
GIT_SHA256_FULL=`git log | head -n1 | cut -d' ' -f2` |
| 141 |
GIT_SHA256=`echo ${GIT_SHA256_FULL} | awk '{print substr($0,0,10)}'` |
| 142 |
DATETIME=`date +%F | sed s/-/./g`.`date +%T | sed s/:/./g` |
| 143 |
UPSTREAM_NEW_TAG=`echo ${UPSTREAM_VERS} | sed s/~/_/`+git${DATETIME}.${GIT_SHA256} |
| 144 |
UPSTREAM_NEW_VERSION=${UPSTREAM_VERS}+git${DATETIME}.${GIT_SHA256} |
| 145 |
|
| 146 |
# Tag it |
| 147 |
git tag ${UPSTREAM_NEW_TAG} |
| 148 |
|
| 149 |
# Get back to our original Debian packaging branch, merge the tag |
| 150 |
git checkout -b debian/${TARGET_OPENSTACK_REL} |
| 151 |
git merge -X theirs ${UPSTREAM_NEW_TAG} |
| 152 |
|
| 153 |
# and fix the debian/changelog with a new entry |
| 154 |
if [ -n "${EPOC}" ] ; then |
| 155 |
NEW_DEBVERSION="${EPOC}:" |
| 156 |
fi |
| 157 |
NEW_DEBVERSION=${NEW_DEBVERSION}${UPSTREAM_NEW_VERSION}-1 |
| 158 |
dch --newversion ${NEW_DEBVERSION} -b --allow-lower-version --distribution unstable -m "New upstream release based on commit ${GIT_SHA256_FULL}." |
| 159 |
git commit debian/changelog -m "New upstream release based on commit ${GIT_SHA256_FULL}." |
| 160 |
fi |
| 161 |
fi |
| 162 |
else |
| 163 |
# If it's listed as EXPERIMENTAL_BRANCH in /etc/pkgos/pkgos.conf, then we |
| 164 |
# use debian/experimental branch. |
| 165 |
is_experi |
| 166 |
if [ "${ISEXPERI}" = "yes" ] ; then |
| 167 |
CURBRANCH=`git branch | grep '*' | cut -d' ' -f2` |
| 168 |
if [ "${CURBRANCH}" = "debian/experimental" ] ; then |
| 169 |
echo "Already on debian/experimental" |
| 170 |
else |
| 171 |
git checkout -b debian/experimental origin/debian/experimental |
| 172 |
fi |
| 173 |
else |
| 174 |
git checkout debian/${TARGET_OPENSTACK_REL} || true |
| 175 |
# git checkout -b ${DEBIAN_BRANCH} origin/${DEBIAN_BRANCH} || true |
| 176 |
fi |
| 177 |
fi |
| 178 |
get_deb_version |
| 179 |
# Generate the .orig.tar.xz using git archive... |
| 180 |
if [ "${IS_NATIVE}" = "no" ] ; then |
| 181 |
./debian/rules gen-orig-xz |
| 182 |
fi |
| 183 |
fi |
| 184 |
|
| 185 |
# Build the package using sbuild (see that script, which can be used |
| 186 |
# in your own laptop if you don't want to use jenkins...) |
| 187 |
echo "calling pkgos-bop from "`pwd` |
| 188 |
pkgos-bop |