# 100 - Unknown error (should not happen)
# Notes (todo/bugs):
-# - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
# - when Icon: field is present, -5 and -a5 doesn't work
# - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
# - does not respect NoSource: X, and tries to cvs up such files [ example: VirtualBox-bin.spec and its Source0 ]
-u, --try-upgrade - check version, and try to upgrade package
-un, --try-upgrade-with-float-version
- as above, but allow float version
+ php-pear-Services_Digg/
+--upgrade-version - upgrade to specified version in try-upgrade
--use-greed-sources
- try download source from tag head if don't find it in
current tag
%requires_eq() %{nil}
%requires_eq_to() %{nil}
%requires_ge() %{nil}
+%requires_ge_to() %{nil}
+%requires_ge() %{nil}
%releq_kernel_up(n:) ERROR
%releq_kernel_smp(n:) ERROR
%releq_kernel(n:) ERROR
%lua_remove_etc_shells() %{nil}
%required_jdk %{nil}
%buildrequires_jdk %{nil}
+%pear_package_print_optionalpackages %{nil}
EOF
if [ "$NOINIT" = "yes" ] ; then
cat >> $BUILDER_MACROS <<'EOF'
# XXX: still needed?
SPECFILE=$(basename $SPECFILE)
fi
- if [ "$NOCVSSPEC" != "yes" ]; then
+ if [ "$NOCVSSPEC" != "yes" ]; then
if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
echo "Warning: No CVS access defined - using local .spec file"
NOCVSSPEC="yes"
fi
- if [ -d "$ASSUMED_NAME" ]; then
+ if [ -d "$ASSUMED_NAME" -a -s "$ASSUMED_NAME/CVS/Root" ]; then
cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
else
- cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
+ cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || {
+ # softfail if new package, i.e not yet added to cvs
+ [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
+ echo "Warning: package not in CVS - assuming new package"
+ NOCVSSPEC="yes"
+ NOCVS="yes"
+ }
# remove Entries.Static -- so 'cvs up' would update all files in a repo
- rm "$ASSUMED_NAME/CVS/Entries.Static"
+ rm -f "$ASSUMED_NAME/CVS/Entries.Static"
cvsignore_df .cvsignore
+ # add default log format to .cvsignore if it is relative to package dir
+ if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
+ # substitute known "macros" to glob
+ local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
+ if [ "$logfile" ]; then
+ cvsignore_df "$logfile"
+ fi
+ fi
+
# create symlinks for tools
if [ "$SYMLINK_TOOLS" != "no" ]; then
- for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh; do
+ for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
[ -f $a ] || continue
- ln -s ../$a $ASSUMED_NAME
+ ln -sf ../$a $ASSUMED_NAME
cvsignore_df $a
done
fi
set_version() {
local specfile="$1"
- local ver="$2"
- local newver="$3"
+ local ver="$2" subver=$ver
+ local newver="$3" newsubver=$newver
+
+ # try handling subver, everything that's not numeric-dotted in version
+ if grep -Eq '%define\s+subver' $specfile; then
+ subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
+ ver=${ver%$subver}
+ newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
+ newver=${newver%$newsubver}
+ fi
sed -i -e "
s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
+ s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
" $specfile
}
-build_package() {
- update_shell_title "build_package"
- if [ -n "$DEBUG" ]; then
- set -x
- set -v
- fi
-
- cd "$PACKAGE_DIR"
-
+try_upgrade() {
if [ -n "$TRY_UPGRADE" ]; then
local TNOTIFY TNEWVER TOLDVER
update_shell_title "build_package: try_upgrade"
- if [ -n "$FLOAT_VERSION" ]; then
- TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
+ cd "$PACKAGE_DIR"
+
+ if [ "$UPGRADE_VERSION" ]; then
+ TNEWVER=$UPGRADE_VERSION
else
- TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
- fi
+ if [ -n "$FLOAT_VERSION" ]; then
+ TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
+ else
+ TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
+ fi
- TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
+ # pldnotify.awk does not set exit codes, but it has match for ERROR
+ # in output which means so.
+ if [[ "$TNOTIFY" = *ERROR* ]]; then
+ echo >&2 "$TNOTIFY"
+ exit 1
+ fi
+
+ TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
+ fi
if [ -n "$TNEWVER" ]; then
TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
cp -f $SPECFILE $SPECFILE.bak
fi
chmod +w $SPECFILE
- set_release $SPECFILE $PACKAGE_RELEASE 0.1
+ set_release $SPECFILE $PACKAGE_RELEASE 1
set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
parse_spec
- NODIST="yes" get_files $SOURCES $PATCHES
- update_md5 $SOURCES
+ if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
+ echo >&2 "Upgrading version failed, you need to update spec yourself"
+ exit 1
+ fi
+ return 1
fi
fi
+ return 0
+}
+
+build_package() {
+ update_shell_title "build_package"
+ if [ -n "$DEBUG" ]; then
+ set -x
+ set -v
+ fi
+
cd "$PACKAGE_DIR"
case "$COMMAND" in
fi
if [ "$RETVAL" -ne "0" ]; then
if [ -n "$TRY_UPGRADE" ]; then
- echo "\n!!! Package with new version cannot be built automagically\n"
+ echo "\nUpgrade package to new version failed."
if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
+ echo "Restoring old spec file."
mv -f $SPECFILE.bak $SPECFILE
fi
+ echo ""
fi
Exit_error err_build_fail
fi
AVAIL_BCONDS_WITHOUT=""
AVAIL_BCONDS_WITH=""
- if egrep -q '^# *_with' ${SPECFILE}; then
+ if grep -Eq '^# *_with' ${SPECFILE}; then
echo >&2 "ERROR: This spec has old style bconds."
exit 1
fi
update_shell_title "spawn_sub_builder $package_name"
sub_builder_opts=''
- if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
+ if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
sub_builder_opts="${sub_builder_opts} -R"
fi
- if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
+ if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
sub_builder_opts="${sub_builder_opts} -RB"
- elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
+ elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
sub_builder_opts="${sub_builder_opts} -FRB"
fi
- if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
+ if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
sub_builder_opts="${sub_builder_opts} -Upi"
fi
}
init_rpm_dir() {
- TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
- CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
+ local CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
+ local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
+ local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
+ local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
+ local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
+ local tmp
echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
- mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
- cd $TOP_DIR
- $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
+ mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
+
+ # need to checkout to tmp dir or we can't name our topdir
+ tmp=$(TMPDIR= TEMPDIR= mktemp -p $TOP_DIR -d) || exit 1
+ cd $tmp
+ $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh,ci,civim}
+ cd -
+ mv $tmp/packages/* $TOP_DIR
+ rm -rf $tmp
init_builder
echo "- run cvs co SPECS"
echo "To checkout *all* packages:"
- echo "- run cvs up -dP in $TOP_DIR/packages dir"
+ echo "- run cvs up -dP in $TOP_DIR dir"
echo ""
echo "To commit with your developer account:"
- echo "- edit $TOP_DIR/packages/CVS/Root"
+ echo "- edit $TOP_DIR/CVS/Root"
}
get_greed_sources() {
shift;;
-u | --try-upgrade )
TRY_UPGRADE="1"; shift ;;
+ --upgrade-version )
+ shift; UPGRADE_VERSION="$1"; shift;;
-un | --try-upgrade-with-float-version )
TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
-v | --verbose )
Exit_error err_invalid_cmdline "$1"
;;
*)
- SPECFILE=$1; shift
+ SPECFILE=${1%/}; shift
# check if specname was passed as specname:cvstag
if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
CVSTAG="${SPECFILE##*:}"
if [ -n "$NOSOURCE0" ] ; then
SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
fi
- get_files $SOURCES $PATCHES
- check_md5 $SOURCES
+ try_upgrade
+ case $? in
+ 0)
+ get_files $SOURCES $PATCHES
+ check_md5 $SOURCES
+ ;;
+ *)
+ NODIST="yes" get_files $SOURCES $PATCHES
+ update_md5 $SOURCES
+ ;;
+ esac
build_package
if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz