Adapt perestroika to build fuel packages from custom source path

In case if we are not using gerrit we need to re-define path
to source code. There are a number of variables that must be
defined explicitly, otherwise custom build will fail.
   Example:

   1) rpm
    REMOTE_REPO_HOST=perestroika-repo-tst.infra.mirantis.net \
    RPM_OS_REPO_PATH=mos-repos/centos/mos8.0-centos7-fuel/os/ \
    PROJECT_NAME=mos \
    PROJECT_VERSION=8.0 \
    PACKAGENAME=openstack/fuel-agent \
    SRC_PROJECT=openstack/fuel-agent \
    SOURCE_BRANCH=master \
    CUSTOM_SRC_PATH=~/fuel-main/build/repos/fuel-agent \
               ./build-fuel-rpm.sh

   2) deb
    REMOTE_REPO_HOST=perestroika-repo-tst.infra.mirantis.net \
    DEB_REPO_PATH=/mos-repos/ubuntu/8.0/ \
    DEB_DIST_NAME=mos8.0 \
    COMPONENTS='main restricted' \
    PROJECT_NAME=mos \
    PROJECT_VERSION=8.0 \
    PACKAGENAME=openstack/fuel-agent \
    SRC_PROJECT=openstack/fuel-agent \
    SOURCE_BRANCH=master \
    CUSTOM_SRC_PATH=~/fuel-main/build/repos/fuel-agent \
               ./build-fuel-deb.sh

Change-Id: I95a6fa4fe8f5d1a95b68d106bead732a8d43c85e
This commit is contained in:
Sergey Kulanov 2015-10-23 15:03:18 +03:00
parent 5a1efffd41
commit bfe7af26b7
2 changed files with 34 additions and 11 deletions

27
perestroika/build-fuel-deb.sh Normal file → Executable file
View File

@ -13,9 +13,19 @@ main () {
[ -n "$GERRIT_PROJECT" ] && SRC_PROJECT=$GERRIT_PROJECT
PACKAGENAME=${SRC_PROJECT##*/}
local DEBSPECFILES="${PACKAGENAME}-src/debian"
fetch_upstream
local _srcpath="${MYOUTDIR}/${PACKAGENAME}-src"
# If we are triggered from gerrit env, let's keep current workflow,
# and fetch code from upstream
# otherwise let's define custom path to already prepared source code
# using $CUSTOM_SRC_PATH variable
if [ -n "${GERRIT_BRANCH}" ]; then
# Get package tree from gerrit
fetch_upstream
local _srcpath="${MYOUTDIR}/${PACKAGENAME}-src"
else
local _srcpath="${CUSTOM_SRC_PATH}"
fi
local _specpath=$_srcpath
local _debianpath=$_specpath
@ -57,11 +67,14 @@ main () {
DEBFULLNAME=$author DEBEMAIL=$email dch -c ${_debianpath}/debian/changelog -a "$commitsha $message"
# Prepare source tarball
# Exclude debian dir
mv ${_srcpath}/debian ${_srcpath}/renameforexcludedebian
pushd ${_srcpath} &>/dev/null
tar -czf "${BUILDDIR}/${TAR_NAME}" $EXCLUDES --exclude=renameforexcludedebian *
pushd $_srcpath &>/dev/null
cat >.gitattributes<<-EOF
/debian export-ignore
/.gitignore export-ignore
/.gitreview export-ignore
EOF
git archive --prefix=./ --format=tar.gz --worktree-attributes HEAD --output="${BUILDDIR}/${TAR_NAME}"
popd &>/dev/null
mv ${_srcpath}/renameforexcludedebian ${_srcpath}/debian
mkdir -p ${BUILDDIR}/$srcpackagename
cp -R ${_debianpath}/debian ${BUILDDIR}/${srcpackagename}/
@ -89,7 +102,7 @@ main () {
rm -f buildresult/exitstatus.sbuild
[ -f "buildresult/buildlog.sbuild" ] && mv buildresult/buildlog.sbuild ${WRKDIR}/buildlog.txt
fill_buildresult $exitstatus 0 $PACKAGENAME DEB
if [ "$exitstatus" == "0" ] ; then
if [ "$exitstatus" == "0" ] && [ -n "${GERRIT_BRANCH}" ]; then
tmpdir=`mktemp -d ${PKG_DIR}/build-XXXXXXXX`
rm -f ${WRKDIR}/buildresult.params
cat >${WRKDIR}/buildresult.params<<-EOL

18
perestroika/build-fuel-rpm.sh Normal file → Executable file
View File

@ -12,9 +12,19 @@ main () {
[ -n "$GERRIT_BRANCH" ] && SOURCE_BRANCH=$GERRIT_BRANCH && SOURCE_REFSPEC=$GERRIT_REFSPEC
[ -n "$GERRIT_PROJECT" ] && SRC_PROJECT=$GERRIT_PROJECT
PACKAGENAME=${SRC_PROJECT##*/}
# Get package tree from gerrit
fetch_upstream
local _srcpath="${MYOUTDIR}/${PACKAGENAME}-src"
# If we are triggered from gerrit env, let's keep current workflow,
# and fetch code from upstream
# otherwise let's define custom path to already prepared source code
# using $CUSTOM_SRC_PATH variable
if [ -n "${GERRIT_BRANCH}" ]; then
# Get package tree from gerrit
fetch_upstream
local _srcpath="${MYOUTDIR}/${PACKAGENAME}-src"
else
local _srcpath="${CUSTOM_SRC_PATH}"
fi
local _specpath="${_srcpath}/specs"
# Get last commit info
@ -93,7 +103,7 @@ main () {
[ -f "build/build.log" ] && mv build/build.log ${WRKDIR}/buildlog.txt
[ -f "build/root.log" ] && mv build/root.log ${WRKDIR}/rootlog.txt
fill_buildresult $exitstatus 0 $PACKAGENAME RPM
if [ "$exitstatus" == "0" ] ; then
if [ "$exitstatus" == "0" ] && [ -n "${GERRIT_BRANCH}" ]; then
tmpdir=`mktemp -d ${PKG_DIR}/build-XXXXXXXX`
rm -f ${WRKDIR}/buildresult.params
cat >${WRKDIR}/buildresult.params<<-EOL