X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=builder.sh;h=58e90656872e663fd5d82079db481a6693df20e9;hb=80222d62805027b5ce6b79151b9b6a03df846d9b;hp=6476d47cf2c56e8d941923965d6955c96610ebba;hpb=8076976a2d732584594446e63434e3131d9e5f93;p=packages%2Frpm-build-tools.git diff --git a/builder.sh b/builder.sh index 6476d47..58e9065 100644 --- a/builder.sh +++ b/builder.sh @@ -79,6 +79,7 @@ CVS_RETRIES=${MAX_CVS_RETRIES:-1000} CVSTAG="" RES_FILE="" +CVS_FORCE="" CVS_SERVER="cvs.pld-linux.org" DISTFILES_SERVER="://distfiles.pld-linux.org" @@ -92,6 +93,10 @@ FAIL_IF_NO_SOURCES="yes" # 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 @@ -189,13 +194,11 @@ usage() 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} ] [{-d|--cvsroot} ] [-g|--get] -[-h|--help] [--http] [{-l,--logtofile} ] [-m|--mr-proper] +[{-cf|--cvs-force}] [{-B|--branch} ] [{-d|--cvsroot} ] +[-g|--get] [-h|--help] [--http] [{-l,--logtofile} ] [-m|--mr-proper] [-q|--quiet] [--date [-r ] [{-T--tag ] -[-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} ] [{-tt|--test-tag}] [-nu|--no-urls] [-v|--verbose] [--opts ] [--show-bconds] [--with/--without ] [--define ] [.spec][:cvstag] @@ -220,6 +223,7 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] -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 - setup \$CVSROOT, --define @@ -277,12 +281,8 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] - add cvs tag 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 @@ -432,7 +432,7 @@ EOF 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" } @@ -445,7 +445,7 @@ get_icons() return fi - rpm_dump_cache="kalasaba" NODIST="yes" UPDATE5= get_files $ICONS + rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS } parse_spec() @@ -1040,7 +1040,7 @@ tag_files() echo "CVS tag: $TAG" fi - local OPTIONS="tag -F" + local OPTIONS="tag $CVS_FORCE" if [ -n "$CVSROOT" ]; then OPTIONS="-d $CVSROOT $OPTIONS" fi @@ -1093,29 +1093,26 @@ 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 } @@ -1143,12 +1140,16 @@ build_package() 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 @@ -1194,7 +1195,9 @@ build_package() 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 @@ -1272,9 +1275,13 @@ set_bconds_values() # 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 @@ -1750,6 +1757,8 @@ do 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 ) @@ -1857,21 +1866,11 @@ do 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="" @@ -1914,9 +1913,14 @@ do --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" @@ -1935,10 +1939,20 @@ do 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; @@ -2016,6 +2030,13 @@ case "$COMMAND" in 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