Commit baf2553c authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmbph: realize gear repo backporting (eterbug #4766)

parent 31f00ed0
#!/bin/bash
# 2003-2009 (c) Etersoft www.etersoft.ru
# 2003-2010 (c) Etersoft www.etersoft.ru
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
#
......@@ -16,7 +16,7 @@ load_mod repl rpm git
DISTRVERSION=`distr_vendor -v`
alt_tolocal()
altspec_to_local()
{
local TXTRELEASE
local SPECNAME
......@@ -26,17 +26,20 @@ BASERELEASE=$(get_numrelease $SPECNAME)
FIXPATCHFUZZ="%define _default_patch_fuzz 3"
echo "Converting spec $SPECNAME to $MDISTR..."
# Set buildreq
if [ "$VENDOR" = "alt" ] ; then
BUILDREQ="BuildRequires: rpm-build-compat >= 0.95"
[ -z "$BUILDCOMMAND" ] && BUILDCOMMAND="$ETERBUILDBIN/rpmbsh $GIRARHOST"
# Change release according to alt policy with extensions
# General rule: alwars alt(N-1).MM.(N)
set_release $SPECNAME $(get_txtrelease $SPECNAME)$(decrement_release $BASERELEASE).$MDISTR.$BASERELEASE
ADDDEF=""
CLEANTEXT=""
# due new libtool, affected on ALT Linux
if echo "$MDISTR" | egrep -q "M24|M30|M40|M41" ; then
RECONFT="%undefine __libtoolize"
fi
else
# Need our compat package and disable strong patch checking
BUILDREQ="BuildRequires: rpm-build-altlinux-compat >= 0.95 make gcc\n$FIXPATCHFUZZ"
......@@ -240,8 +243,6 @@ fi
test -n "$TOCHANGELOG" && ENTRY=`echo -e "$ENTRY\n- $TOCHANGELOG"`
add_changelog $SPECNAME -e "$ENTRY"
$BUILDCOMMAND $LISTRPMARGS $REMOTEBUILD $DISTRARG $SPECNAME || fatal "Can't build"
}
......@@ -262,16 +263,16 @@ phelp()
echog " -r - remote build"
# echog " -m - send result via e-mail"
echog " -u/-U - sign and upload after build"
echog " -n - do not build in hasher"
echog " -n - do not build in hasher (use first in the list)"
echog " -i - install built packages in test hasher"
echog " -v - more verbose"
}
while getopts :hniv opt; do
while getopts :hniuv opt; do
case $opt in
h) phelp; exit 0;;
n) BUILDCOMMAND="$ETERBUILDBIN/rpmbs --rmsource --rmspec";;
n) NOBUILD=1;;
v) VERBOSE=1;;
+?) echog "$name: options should not be preceded by a '+'." 1>&2; exit 2;;
# ?) echog "$name: $OPTARG: bad option. Use -h for help." 1>&2 ; exit 2;;
......@@ -310,7 +311,57 @@ fi
unset MENV MENVARG
# handle src.rpm too, LISTBUILT - result with full pathes to src.rpms
[ -n "$NOBUILD" ] && BUILDCOMMAND="$ETERBUILDBIN/rpmbs --rmsource --rmspec"
[ -z "$BUILDCOMMAND" ] && BUILDCOMMAND="$ETERBUILDBIN/rpmbsh $GIRARHOST"
if [ "$VENDOR" = "alt" ] ; then
# run inside gear repo, just create backported spec
# set SPECDIR from LISTNAMES if empty
[ -n "$SPECDIR" ] || set_specdir $LISTNAMES
if is_gear $SPECDIR ; then
[ -f "$LISTNAMES" ] || fatal "Run with one spec inside gear repo"
SPEC=$LISTNAMES
BPSPEC=$SPEC.$MDISTR
[ -f "$BPSPEC" ] && fatal "File $BPSPEC is already exists, check it"
CURBRANCH=$(get_current_branch)
if [ "$CURBRANCH" = "$MDISTR" ] ; then
fatal "Run rpmbph in sisyphus branch, not in backport branch $MDISTR"
fi
# Create branch M?? if not exist yet
if ! is_exist_branch $MDISTR ; then
git branch $MDISTR
fi
cp -f $LISTNAMES $BPSPEC
altspec_to_local $BPSPEC
git checkout $MDISTR || fatal "Can't checkout branch $MDISTR. Use $BPSPEC manually or remove it."
git merge $CURBRANCH
mv -f $BPSPEC $SPEC
# FIXME: Ctrl-\ and q will cancelled less with return error code
if ! git diff $MDISTR ; then
#git checkout $SPEC $MDISTR
#git checkout $CURBRANCH
fatal "User cancelled. You are still in $MDISTR branch with modified spec"
fi
git add $SPEC
if ! git commit -a -m "backported to $MDISTR by rpmbph script as $(get_version $SPEC)-$(get_release $SPEC)" ; then
#git checkout $CURBRANCH
#fatal "Commit error. You are still in $MDISTR branch with modified and uncommitted spec"
# FIXME: git commit returns error if no commit needed
echo
fi
[ -n "$NOBUILD" ] && BUILDCOMMAND="$ETERBUILDBIN/rpmbs"
$BUILDCOMMAND $LISTRPMARGS $REMOTEBUILD $DISTRARG $SPEC || { git checkout $CURBRANCH ; fatal "Can't build" ; }
git checkout $CURBRANCH
exit $?
fi
fi
# handle src.rpm and spec both, LISTBUILT - result with full pathes to src.rpms
pack_src_rpm $LISTNAMES
export RPMTOPDIR=$RPMDIR/BP
......@@ -325,6 +376,8 @@ for i in $LISTBUILT ; do
test -f "$SPECNAME" || fatal "Spec $SPECNAME is not found"
# FIXME: do not remove if not repacked
#rm -f $SPKG
alt_tolocal $SPECNAME
altspec_to_local $SPECNAME
$BUILDCOMMAND $LISTRPMARGS $REMOTEBUILD $DISTRARG $SPECNAME || fatal "Can't build"
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment