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] [-Tvn|--tag-version-nest]
-[-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
+[-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
[{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
[--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
-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>
- add cvs tag <cvstag> for files,
-Tvs, --tag-version-stable
- add cvs tags STABLE and NAME-VERSION-RELEASE for files,
--Tvn, --tag-version-nest
- - add cvs tags NEST and NAME-VERSION-RELEASE for files,
-Ts, --tag-stable
- add cvs tag STABLE for files,
--Tn, --tag-nest
- - add cvs tag NEST for files,
-Tv, --tag-version
- add cvs tag NAME-VERSION-RELEASE for files,
-Tp, --tag-prefix <prefix>
}
cache_rpm_dump () {
- if [ -n "$DEBUG" ]; then
- set -x;
- set -v;
- fi
+ if [ -n "$DEBUG" ]; then
+ set -x;
+ set -v;
+ fi
update_shell_title "cache_rpm_dump"
local rpm_dump
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()
set -v;
fi
- if [ $# -gt 0 ]; then
- echo "Version: $PACKAGE_VERSION"
- echo "Release: $PACKAGE_RELEASE"
-
- TAGVER=`make_tagver`
+ echo "Version: $PACKAGE_VERSION"
+ echo "Release: $PACKAGE_RELEASE"
- if [ "$TAG_VERSION" = "yes" ]; then
- echo "CVS tag: $TAGVER"
- fi
- if [ -n "$TAG" ]; then
- echo "CVS tag: $TAG"
- fi
+ TAGVER=`make_tagver`
- local OPTIONS="tag -F"
- if [ -n "$CVSROOT" ]; then
- OPTIONS="-d $CVSROOT $OPTIONS"
- fi
+ if [ "$TAG_VERSION" = "yes" ]; then
+ echo "CVS tag: $TAGVER"
+ fi
+ if [ -n "$TAG" ]; then
+ echo "CVS tag: $TAG"
+ fi
- cd "$SOURCE_DIR"
- local tag_files
- for i in $TAG_FILES; do
- # don't tag files stored on distfiles
- [ -n "`src_md5 $i`" ] && continue
- local fp=`nourl "$i"`
- if [ -f "$fp" ]; then
- tag_files="$tag_files $fp"
- else
- Exit_error err_no_source_in_repo $i
- fi
- done
+ local OPTIONS="tag $CVS_FORCE"
+ if [ -n "$CVSROOT" ]; then
+ OPTIONS="-d $CVSROOT $OPTIONS"
+ fi
- if [ "$tag_files" ]; then
- if [ "$TAG_VERSION" = "yes" ]; then
- update_shell_title "tag sources: $TAGVER"
- cvs $OPTIONS $TAGVER $tag_files
- fi
- if [ -n "$TAG" ]; then
- update_shell_title "tag sources: $TAG"
- cvs $OPTIONS $TAG $tag_files
- fi
+ cd "$SOURCE_DIR"
+ local tag_files
+ for i in $TAG_FILES; do
+ # don't tag files stored on distfiles
+ [ -n "`src_md5 $i`" ] && continue
+ local fp=`nourl "$i"`
+ if [ -f "$fp" ]; then
+ tag_files="$tag_files $fp"
+ else
+ Exit_error err_no_source_in_repo $i
fi
+ done
- cd "$SPECS_DIR"
+ if [ "$tag_files" ]; then
if [ "$TAG_VERSION" = "yes" ]; then
- update_shell_title "tag spec: $TAGVER"
- cvs $OPTIONS $TAGVER $SPECFILE
+ update_shell_title "tag sources: $TAGVER"
+ cvs $OPTIONS $TAGVER $tag_files
fi
if [ -n "$TAG" ]; then
- update_shell_title "tag spec: $TAG"
- cvs $OPTIONS $TAG $SPECFILE
+ update_shell_title "tag sources: $TAG"
+ cvs $OPTIONS $TAG $tag_files
fi
fi
+
+ cd "$SPECS_DIR"
+ if [ "$TAG_VERSION" = "yes" ]; then
+ update_shell_title "tag spec: $TAGVER"
+ cvs $OPTIONS $TAGVER $SPECFILE
+ fi
+ if [ -n "$TAG" ]; then
+ update_shell_title "tag spec: $TAG"
+ cvs $OPTIONS $TAG $SPECFILE
+ fi
}
branch_files()
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 )
TAG="STABLE"
TAG_VERSION="yes"
shift;;
- -Tvn | --tag-version-nest )
- COMMAND="tag";
- TAG="NEST"
- TAG_VERSION="yes"
- shift;;
-Ts | --tag-stable )
COMMAND="tag";
TAG="STABLE"
TAG_VERSION="no"
shift;;
- -Tn | --tag-nest )
- COMMAND="tag";
- TAG="NEST"
- TAG_VERSION="no"
- shift;;
-Tv | --tag-version )
COMMAND="tag";
TAG=""
--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
# don't fetch sources from remote locations
new_SOURCES=""
- for file in $SOURCES
- do
+ for file in $SOURCES; do
[ -n "`src_md5 $file`" ] && continue
new_SOURCES="$new_SOURCES $file"
done