CVSTAG=""
RES_FILE=""
+CVS_FORCE=""
CVS_SERVER="cvs.pld-linux.org"
DISTFILES_SERVER="://distfiles.pld-linux.org"
# let get_files skip over files which are present to get those damn files fetched
SKIP_EXISTING_FILES="no"
+TRY_UPGRADE=""
+# should the specfile be restored if upgrade failed?
+REVERT_BROKEN_UPGRADE="yes"
+
if [ -x /usr/bin/rpm-getdeps ]; then
FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
else
if [ -n "$DEBUG" ]; then set -xv; fi
echo "\
Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
-
[-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
-[{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
-[-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
+[{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
+[-g|--get] [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
[-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
[-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
[{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
-B, --branch - add branch
-c, --clean - clean all temporarily created files (in BUILD, SOURCES,
SPECS and \$RPM_BUILD_ROOT),
+-cf, --cvs-force - use -F when tagging (useful when moving branches)
-d <cvsroot>, --cvsroot <cvsroot>
- setup \$CVSROOT,
--define <macro> <value>
rpm_dump () {
if [ -z "$rpm_dump_cache" ] ; then
- echo "internal error: cache_rpm_dump not called!" 1>&2
+ echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
fi
echo "$rpm_dump_cache"
}
return
fi
- rpm_dump_cache="kalasaba" NODIST="yes" UPDATE5= get_files $ICONS
+ rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
}
parse_spec()
echo "CVS tag: $TAG"
fi
- local OPTIONS="tag -F"
+ local OPTIONS="tag $CVS_FORCE"
if [ -n "$CVSROOT" ]; then
OPTIONS="-d $CVSROOT $OPTIONS"
fi
set -v;
fi
- if [ $# -gt 0 ]; then
-
- local OPTIONS="tag -b"
- if [ -n "$CVSROOT" ]; then
- OPTIONS="-d $CVSROOT $OPTIONS"
- fi
- cd "$SOURCE_DIR"
- local tag_files
- for i in $TAG_FILES; do
- local fp=`nourl "$i"`
- if [ -f "$fp" ]; then
- tag_files="$tag_files $fp"
- else
- Exit_error err_no_source_in_repo $i
- fi
- done
- if [ "$tag_files" ]; then
- cvs $OPTIONS $TAG $tag_files
+ local OPTIONS="tag $CVS_FORCE -b"
+ if [ -n "$CVSROOT" ]; then
+ OPTIONS="-d $CVSROOT $OPTIONS"
+ fi
+ cd "$SOURCE_DIR"
+ local tag_files
+ for i in $TAG_FILES; do
+ local fp=`nourl "$i"`
+ if [ -f "$fp" ]; then
+ tag_files="$tag_files $fp"
+ else
+ Exit_error err_no_source_in_repo $i
fi
-
- cd "$SPECS_DIR"
- cvs $OPTIONS $TAG $SPECFILE
+ done
+ if [ "$tag_files" ]; then
+ cvs $OPTIONS $TAG $tag_files
fi
+
+ cd "$SPECS_DIR"
+ cvs $OPTIONS $TAG $SPECFILE
}
if [ -n "$TNEWVER" ]; then
TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
echo "New version found, updating spec file to version " $TNEWVER
- cp -f $SPECFILE $SPECFILE.bak
+ if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
+ cp -f $SPECFILE $SPECFILE.bak
+ fi
chmod +w $SPECFILE
eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
parse_spec;
- NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
+ NODIST="yes" get_files $SOURCES $PATCHES;
+ UPDATE5="yes" update_md5 $SOURCES
+
unset TOLDVER TNEWVER TNOTIFY
fi
fi
if [ "$RETVAL" -ne "0" ]; then
if [ -n "$TRY_UPGRADE" ]; then
echo "\n!!! Package with new version cannot be built automagically\n"
- mv -f $SPECFILE.bak $SPECFILE
+ if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
+ mv -f $SPECFILE.bak $SPECFILE
+ fi
fi
Exit_error err_build_fail;
fi
# use only flags which are in this package.
if [[ $bcond_avail = *${opt}* ]]; then
if [[ $flag = -* ]]; then
- BCOND="$BCOND --without $opt"
+ if [[ $BCOND != *--with?${opt}* ]]; then
+ BCOND="$BCOND --without $opt"
+ fi
else
- BCOND="$BCOND --with $opt"
+ if [[ $BCOND != *--without?${opt}* ]]; then
+ BCOND="$BCOND --with $opt"
+ fi
fi
fi
done
COMMAND="branch"; shift; TAG="${1}"; shift;;
-c | --clean )
CLEAN="--clean --rmspec --rmsource"; shift ;;
+ -cf | --cvs-force )
+ CVS_FORCE="-F"; shift;;
-d | --cvsroot )
shift; CVSROOT="${1}"; shift ;;
-g | --get )
--define)
shift
MACRO="${1}"
- VALUE="${2}"
- shift 2
- RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
+ shift
+ if echo "${MACRO}" | grep -q '\W'; then
+ RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
+ else
+ VALUE="${1}"
+ shift
+ RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
+ fi
;;
--show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
SHOW_BCONDS="yes"
CVSTAG="${SPECFILE##*:}";
SPECFILE="${SPECFILE%%:*}";
fi
- shift ;;
+ shift
esac
done
+if [ -z "$CVSTAG" ]; then
+ CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
+ if [ "$CVSTAG" ]; then
+ echo "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
+ fi
+elif [ "$CVSTAG" = "HEAD" ]; then
+ # assume -r HEAD is same as -A
+ CVSTAG=""
+fi
+
if [ -n "$DEBUG" ]; then
set -x;
set -v;
if [ -n "$SPECFILE" ]; then
get_spec;
parse_spec;
+ # don't fetch sources from remote locations
+ new_SOURCES=""
+ for file in $SOURCES; do
+ [ -n "`src_md5 $file`" ] && continue
+ new_SOURCES="$new_SOURCES $file"
+ done
+ SOURCES="$new_SOURCES"
get_files $SOURCES $PATCHES
check_md5 $SOURCES
branch_files $TAG $SOURCES $PATCHES $ICONS