]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- drop SourceX-size, please fix DF bugs in DF itself instead of adding such workarounds
[packages/rpm-build-tools.git] / builder.sh
index b47f012d9d323d3012ee9ccaaa94545d4931c315..de77571b54844ca262791a95489b5b5fa1739bed 100644 (file)
@@ -10,6 +10,7 @@
 #      5 - package build failed
 #      6 - spec file with errors
 #      7 - wrong source in /etc/poldek.conf
+#  8 - Failed installing buildrequirements and subrequirements
 
 # Notes (todo):
 #      - builder -u fetches current version first
 
 VERSION="\
 Build package utility from PLD CVS repository
-V 0.11 (C) 1999-2003 Free Penguins".
+V 0.11 (C) 1999-2004 Free Penguins".
 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
 
 COMMAND="build"
+TARGET=""
 
 SPECFILE=""
 BE_VERBOSE=""
@@ -39,6 +41,7 @@ NODIST=""
 UPDATE=""
 UPDATE5=""
 ADD5=""
+NO5=""
 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
 CVSROOT=""
 
@@ -61,6 +64,7 @@ CHMOD_MODE="0444"
 RPMOPTS=""
 BCOND=""
 GROUP_BCONDS="no"
+CVSIGNORE_DF="no"
 
 PATCHES=""
 SOURCES=""
@@ -78,7 +82,7 @@ RES_FILE=""
 CVS_SERVER="cvs.pld-linux.org"
 DISTFILES_SERVER="://distfiles.pld-linux.org"
 
-DEF_NICE_LEVEL=0
+DEF_NICE_LEVEL=19
 
 FAIL_IF_NO_SOURCES="yes"
 
@@ -90,23 +94,23 @@ GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
 GETLOCAL="cp -a"
 
 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
-    RPM="rpm"
-    RPMBUILD="rpm"
+       RPM="rpm"
+       RPMBUILD="rpm"
 else
-    RPM="rpm"
-    RPMBUILD="rpmbuild"
+       RPM="rpm"
+       RPMBUILD="rpmbuild"
 fi
 
 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
 POLDEK_SOURCE="cvs"
-POLDEK_CMD="/usr/bin/poldek"
+POLDEK_CMD="/usr/bin/poldek --noask"
 
-# Here we load saved user environment used to 
+# Here we load saved user environment used to
 # predefine options set above, or passed to builder
 # in command line.
 # This one reads global system environment settings:
 if [ -f ~/etc/builderrc ]; then
-    . ~/etc/builderrc
+       . ~/etc/builderrc
 fi
 # And this one cascades settings using user personal
 # builder settings.
@@ -119,25 +123,27 @@ fi
 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
 #
 if [ -n "$HOME_ETC" ]; then
-       USER_CFG=$HOME_ETC/.builderrc
+       USER_CFG="$HOME_ETC/.builderrc"
 else
        USER_CFG=~/.builderrc
 fi
 
-[ -f $USER_CFG ] && . $USER_CFG        
+[ -f "$USER_CFG" ] && . "$USER_CFG"
 
 run_poldek()
 {
+       RES_FILE=~/tmp/poldek-exit-status.$RANDOM
        if [ -n "$LOGFILE" ]; then
-       LOG=`eval echo $LOGFILE`
-      if [ -n "$LASTLOG_FILE" ]; then
-       echo "LASTLOG=$LOG" > $LASTLOG_FILE
-      fi
-               (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; exit_pldk=$?)|tee $LOG
+               LOG=`eval echo $LOGFILE`
+               if [ -n "$LASTLOG_FILE" ]; then
+                       echo "LASTLOG=$LOG" > $LASTLOG_FILE
+               fi
+               (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee $LOG
                return $exit_pldk
        else
-               (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; exit_pldk=$?) 1>&2 >/dev/null
-               return $exit_pldk
+               (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
+               return `cat ${RES_FILE}`
+               rm -rf ${RES_FILE}
        fi
 }
 
@@ -145,7 +151,7 @@ run_poldek()
 # source = cvs /home/users/yoshi/rpm/RPMS/
 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
        run_poldek -l -n ${POLDEK_SOURCE} 1>&2 > /dev/null
-       if [ ! "$?" == "0" ]; then 
+       if [ ! "$?" == "0" ]; then
                echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf"
                echo "Fix it and try to continue"
                exit 7
@@ -166,25 +172,26 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
 [-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] 
-[{-Tp|--tag-prefix} <prefix>]
+[-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
+[{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
        
 -5, --update-md5    - update md5 comments in spec, implies -nd -ncs
 -a5, --add-md5      - add md5 comments to URL sources, implies -nc -nd -ncs
+-n5, --no-md5       - ignore md5 comments in spec
 -D, --debug         - enable script debugging mode,
 -V, --version       - output builder version
 -a, --as_anon       - get files via pserver as cvs@$CVS_SERVER,
 -b, -ba, --build    - get all files from CVS repo or HTTP/FTP and build package
                       from <package>.spec,
--bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary 
+-bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
                       only package from <package>.spec,
--bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack 
+-bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
                       them into src.rpm,
 -bp, --build-prep   - execute the %prep phase of <package>.spec,
 -B, --branch        - add branch
--c, --clean         - clean all temporarily created files (in BUILD, SOURCES, 
+-c, --clean         - clean all temporarily created files (in BUILD, SOURCES,
                       SPECS and \$RPM_BUILD_ROOT),
 -d <cvsroot>, --cvsroot <cvsroot>      
                     - setup \$CVSROOT,
@@ -197,7 +204,7 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
 --http              - use http instead of ftp,
 -l <logfile>, --logtofile <logfile>
                     - log all to file,
--m, --mr-proper     - only remove all files related to spec file and all work 
+-m, --mr-proper     - only remove all files related to spec file and all work
                       resources,
 -nc, --no-cvs       - don't download sources from CVS, if source URL is given,
 -ncs, --no-cvs-specs
@@ -207,6 +214,7 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
 -nu, --no-urls      - don't try to download from FTP/HTTP location,
 -ns, --no-srcs      - don't download Sources
 -ns0, --no-source0  - don't download Source0
+-nn, --no-net       - don't download anything from the net
 --opts <rpm opts>   - additional options for rpm
 -q, --quiet         - be quiet,
 --date yyyy-mm-dd   - build package using resources from specified CVS date,
@@ -234,18 +242,22 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
                     - add cvs tag NAME-VERSION-RELESE for files,
 -Tp, --tag-prefix <prefix>
                     - add <prefix> to NAME-VERSION-RELEASE tags,
+-tt, --test-tag <prefix>
+                    - fail if tag is already present,
 -v, --verbose       - be verbose,
 -u, --try-upgrade   - check version, and try to upgrade package
 -un, --try-upgrade-with-float-version
                     - as above, but allow float version
 -U, --update        - refetch sources, don't use distfiles, and update md5 comments
--Upi, --update-poldek-indexes 
+-Upi, --update-poldek-indexes
                     - refresh or make poldek package index files.
 --with/--without <feature>
                     - conditional build package depending on %_with_<feature>/
-                      %_without_<feature> macro switch.  You may now use 
-                      --with feat1 feat2 feat3 --without feat4 feat5 --with feat6 
+                      %_without_<feature> macro switch.  You may now use
+                      --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
                       constructions. Set GROUP_BCONDS to yes to make use of it.
+--target <platform>
+                   - build for platform <platform>.
 "
 }
 
@@ -253,10 +265,10 @@ cache_rpm_dump () {
 rpm_dump_cache=`
        case "$RPMBUILD" in
                rpm )
-                       rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1 
+                       rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1
                        ;;
                rpmbuild )
-                       rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1 
+                       rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
                        ;;
        esac`
 }
@@ -288,9 +300,9 @@ parse_spec()
 
        PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
        ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
-       PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
-       PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
-       PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
+       PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
+       PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
+       PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
 
        if [ -n "$BE_VERBOSE" ]; then
                echo "- Sources :  `nourl $SOURCES`"
@@ -359,9 +371,11 @@ get_spec()
                set -v;
        fi
 
+       cd "$SPECS_DIR"
+       if [ \! -f "$SPECFILE" ]; then
+               SPECFILE="`basename $SPECFILE .spec`.spec";
+       fi
        if [ "$NOCVSSPEC" != "yes" ]; then
-               cd $SPECS_DIR
-
                OPTIONS="up "
 
                if [ -n "$CVSROOT" ]; then
@@ -441,17 +455,18 @@ src_no ()
        rpm_dump | \
        grep "SOURCEURL[0-9]*[  ]*$1""[         ]*$" | \
        sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
-       head -1 | xargs
+       head -1 | xargs
 }
 
 src_md5 ()
 {
+       [ X"$NO5" = X"yes" ] && return
        no=$(src_no "$1")
        [ -z "$no" ] && return
        cd $SPECS_DIR
        spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
        if [ -z "$spec_rev" ]; then
-               spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
+               spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
        fi
        spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
        md5=$(grep -s -v '^#' additional-md5sums | \
@@ -464,7 +479,7 @@ src_md5 ()
                if [ $(echo "$md5" | wc -l) != 1 ] ; then
                        echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
                fi
-               echo "$md5" | tail -1
+               echo "$md5" | tail -1
        fi
 }
 
@@ -473,6 +488,11 @@ distfiles_url ()
        echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
 }
 
+distfiles_attic_url ()
+{
+       echo "$PROTOCOL$DISTFILES_SERVER/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
+}
+
 good_md5 ()
 {
        md5=$(src_md5 "$1")
@@ -480,6 +500,23 @@ good_md5 ()
        [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
 }
 
+good_size ()
+{
+        size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
+        [ -n "$size" -a "$size" -gt 0 ]
+}
+
+cvsignore_df ()
+{
+       if [ "$CVSIGNORE_DF" != "yes" ]; then
+               return
+       fi
+       cvsignore=${SOURCE_DIR}/.cvsignore
+       if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
+               echo "$1" >> $cvsignore
+       fi
+}
+
 get_files()
 {
        GET_FILES="$@"
@@ -490,7 +527,7 @@ get_files()
        fi
 
        if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
-               cd $SOURCE_DIR
+               cd "$SOURCE_DIR"
 
                OPTIONS="up "
                if [ -n "$CVSROOT" ]; then
@@ -528,16 +565,17 @@ get_files()
                                fi
 
                                if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
-                                       if good_md5 "$i"; then
+                                       if good_md5 "$i" && good_size "$i"; then
                                                echo "$(nourl "$i") having proper md5sum already exists"
                                                continue
                                        fi
                                        target=$(nourl "$i")
                                        url=$(distfiles_url "$i")
+                                       url_attic=$(distfiles_attic_url "$i")
+                                       FROM_DISTFILES=1
                                        if [ `echo $url | grep -E '^(\.|/)'` ]; then
                                                ${GETLOCAL} $url $target
                                        else
-                                               FROM_DISTFILES=1
                                                if [ -z "$NOMIRRORS" ]; then
                                                        url="`find_mirror "$url"`"
                                                fi
@@ -545,11 +583,27 @@ get_files()
                                                if [ `echo $url | grep -E 'ftp://'` ]; then
                                                        ${GETURI2} -O "$target" "$url"
                                                fi
-                                               if ! test -s "$target"; then
-                                                       rm -f "$target"
-                                                       FROM_DISTFILES=0
+                                       fi
+                                       if ! test -s "$target"; then
+                                               rm -f "$target"
+                                               if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
+                                                       ${GETLOCAL} $url_attic $target
+                                               else
+                                                       if [ -z "$NOMIRRORS" ]; then
+                                                               url_attic="`find_mirror "$url_attic"`"
+                                                       fi
+                                                       ${GETURI} -O "$target" "$url_attic" || \
+                                                       if [ `echo $url_attic | grep -E 'ftp://'` ]; then
+                                                               ${GETURI2} -O "$target" "$url_attic"
+                                                       fi
                                                fi
                                        fi
+                                       if test -s "$target"; then
+                                               cvsignore_df $target
+                                       else
+                                               rm -f "$target"
+                                               FROM_DISTFILES=0
+                                       fi
                                elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
                                        # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
                                        result=1
@@ -569,7 +623,7 @@ get_files()
                                                fi
                                        done
                                fi
-       
+
                                if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
                                        if [ -z "$NOMIRRORS" ]; then
                                                im="`find_mirror "$i"`"
@@ -577,12 +631,11 @@ get_files()
                                                im="$i"
                                        fi
                                        ${GETURI} "$im" || \
-                                       if [ `echo $im | grep -E 'ftp://'` ]; then 
+                                       if [ `echo $im | grep -E 'ftp://'` ]; then
                                                ${GETURI2} "$im"
                                        fi
                                fi
 
-
                        fi
                        srcno=$(src_no $i)
                        if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
@@ -596,13 +649,13 @@ get_files()
                                md5=$(md5sum `nourl $i` | cut -f1 -d' ')
                                perl -i -ne '
                                print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
-                               print "# Source'$srcno'-md5:\t'$md5'\n" 
+                               print "# Source'$srcno'-md5:\t'$md5'\n"
                                if /^Source'$srcno'\s*:\s+/;
                                ' \
                                $SPECS_DIR/$SPECFILE
                        fi
        
-                       if good_md5 "$i"; then
+                       if good_md5 "$i" && good_size "$i"; then
                                :
                        elif [ "$FROM_DISTFILES" = 1 ]; then
                                # wrong md5 from distfiles: remove the file and try again
@@ -614,13 +667,20 @@ get_files()
                                if [ `echo $url | grep -E 'ftp://'` ]; then
                                        ${GETURI2} -O "$target" "$url"
                                fi
+                               if ! test -s "$target"; then
+                                       rm -f "$target"
+                                       ${GETURI} -O "$target" "$url_attic" || \
+                                       if [ `echo $url_attic | grep -E 'ftp://'` ]; then
+                                               ${GETURI2} -O "$target" "$url_attic"
+                                       fi
+                               fi
                                test -s "$target" || rm -f "$target"
                        fi
 
-                       if good_md5 "$i"; then
+                       if good_md5 "$i" && good_size "$i" ; then
                                :
                        else
-                               echo "MD5 sum mismatch.  Use -U to refetch sources,"
+                               echo "MD5 sum mismatch or 0 size.  Use -U to refetch sources,"
                                echo "or -5 to update md5 sums, if you're sure files are correct."
                                Exit_error err_no_source_in_repo $i
                        fi
@@ -636,6 +696,18 @@ get_files()
        fi
 }
 
+make_tagver() {
+               # Check whether first character of PACKAGE_NAME is legal for tag name
+               if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
+                       TAG_PREFIX=tag_
+               fi
+               TAGVER=$TAG_PREFIX$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
+               # Remove #kernel.version_release from TAGVER because tagging sources
+               # could occur with different kernel-headers than kernel-headers used at build time.
+               TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
+               echo -n "$TAGVER"
+}
+
 tag_files()
 {
        TAG_FILES="$@"
@@ -648,14 +720,9 @@ tag_files()
        if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
                echo "Version: $PACKAGE_VERSION"
                echo "Release: $PACKAGE_RELEASE"
-               # Check whether first character of PACKAGE_NAME is legal for tag name
-               if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
-                       TAG_PREFIX=tag_
-               fi
-               TAGVER=$TAG_PREFIX$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
-               # Remove #kernel.version_release from TAGVER because tagging sources
-               # could occur with different kernel-headers than kernel-headers used at build time.
-               TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
+
+               TAGVER=`make_tagver`
+
                if [ "$TAG_VERSION" = "yes" ]; then
                        echo "CVS tag: $TAGVER"
                fi
@@ -668,11 +735,11 @@ tag_files()
                        OPTIONS="-d $CVSROOT $OPTIONS"
                fi
 
-               cd $SOURCE_DIR
+               cd "$SOURCE_DIR"
                for i in $TAG_FILES
                do
-                       # don't tag non cvs files (ie. stored on distfiles)
-                       [ "`nourl $i`" != "$i" ] && continue
+                       # don't tag files stored on distfiles
+                       [ -n "`src_md5 $i`" ] && continue
                        if [ -f "`nourl $i`" ]; then
                                if [ "$TAG_VERSION" = "yes" ]; then
                                        cvs $OPTIONS $TAGVER `nourl $i`
@@ -685,7 +752,7 @@ tag_files()
                        fi
                done
 
-               cd $SPECS_DIR
+               cd "$SPECS_DIR"
                if [ "$TAG_VERSION" = "yes" ]; then
                        cvs $OPTIONS $TAGVER $SPECFILE
                fi
@@ -716,7 +783,7 @@ branch_files()
                if [ -n "$CVSROOT" ]; then
                        OPTIONS="-d $CVSROOT $OPTIONS"
                fi
-               cd $SOURCE_DIR
+               cd "$SOURCE_DIR"
                for i in $TAG_FILES
                do
                        if [ -f `nourl $i` ]; then
@@ -725,7 +792,7 @@ branch_files()
                                Exit_error err_no_source_in_repo $i
                        fi
                done
-               cd $SPECS_DIR
+               cd "$SPECS_DIR"
                cvs $OPTIONS $TAG $SPECFILE
 
                unset OPTIONS
@@ -741,7 +808,7 @@ build_package()
                set -v;
        fi
 
-       cd $SPECS_DIR
+       cd "$SPECS_DIR"
 
        if [ -n "$TRY_UPGRADE" ]; then
                if [ -n "$FLOAT_VERSION" ]; then
@@ -764,8 +831,12 @@ build_package()
                        unset TOLDVER TNEWVER TNOTIFY
                fi
        fi
-       cd $SPECS_DIR
-
+       cd "$SPECS_DIR"
+       
+       if [ -n "$TARGET" ]; then 
+               TARGET_SWITCH="--target $TARGET"
+       fi
+       
        case "$COMMAND" in
                build )
                        BUILD_SWITCH="-ba" ;;
@@ -778,11 +849,16 @@ build_package()
        esac
        if [ -n "$LOGFILE" ]; then
                LOG=`eval echo $LOGFILE`
+               if [ -d "$LOG" ]; then
+                       echo "Log file $LOG is a directory."
+                       echo "Parse error in the spec?"
+                       Exit_error err_build_fail;
+               fi
                if [ -n "$LASTLOG_FILE" ]; then
                        echo "LASTLOG=$LOG" > $LASTLOG_FILE
                fi
                RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
-               (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
+               (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH $TARGET_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
                RETVAL=`cat $RES_FILE`
                rm $RES_FILE
                if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
@@ -793,7 +869,7 @@ build_package()
                        fi
                fi
        else
-               eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
+               eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH $TARGET_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
                RETVAL=$?
        fi
        if [ "$RETVAL" -ne "0" ]; then
@@ -804,6 +880,7 @@ build_package()
                Exit_error err_build_fail;
        fi
        unset BUILD_SWITCH
+       unset TARGET_SWITCH
 }
 
 nourl()
@@ -824,7 +901,7 @@ set_bconds_values()
        AVAIL_BCONDS_WITH=""
        if `grep -q ^%bcond ${SPECFILE}`; then
                BCOND_VERSION="NEW"
-       elif `grep -q bcond ${SPECFILE}`; then
+       elif `egrep -q ^#\ *_with ${SPECFILE}`; then
                BCOND_VERSION="OLD"
        else
                BCOND_VERSION="NONE"
@@ -865,7 +942,7 @@ set_bconds_values()
                                                ;;
                                        _with)
                                                cond_type="with"
-                                               ;;
+                                               ;;
                                        *)
                                                case "$cond_type" in
                                                        with)
@@ -906,7 +983,7 @@ run_sub_builder()
        #
        # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
        #         Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
-       #         
+       #
        #
        # y0shi.
 
@@ -966,20 +1043,37 @@ remove_build_requires()
 display_bconds()
 {
        if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
-               echo -ne "We are going to build $SPECFILE with the following conditional flags:\n"
                if [ "$BCOND" != "" ]; then
+                       echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
                        echo -ne "$BCOND"
                else
-                       echo -ne "No --with || --without conditions passed to $0!"
+                       echo -ne "\nNo conditional flags passed"
                fi
-               echo -ne "\n\nfrom available:\n\n"
+               echo -ne "\n\nfrom available:\n"
                echo -ne "--with   :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
        fi
 }
 
 fetch_build_requires()
 {
-       if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
+       if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
+               if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
+                        CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print "@" $3 } ' | xargs)
+                        DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print "@" $3 } ' | xargs)
+                        if [ -n "$CONF" -o -n "$DEPS" ]; then
+                                 /usr/bin/poldek --update; /usr/bin/poldek --upa
+                        fi
+                        if [ -n "$CONF" ]; then
+                                 echo "Trying to uninstall conflicting packages ($CONF):"
+                                 /usr/bin/poldek --noask --nofollow -ev $CONF
+                        fi
+                        if [ -n "$DEPS" ]; then
+                                 echo "Trying to install dependencies ($DEPS):"
+                                 /usr/bin/poldek --caplookup -uGv $DEPS
+                        fi
+                        return
+               fi
+                
                echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
                echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
                echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
@@ -1030,7 +1124,7 @@ fetch_build_requires()
                                        fi      
                                fi
                                RESULT="${COND_STATE}-${COND_ARGV}"
-                               case "$RESULT" in 
+                               case "$RESULT" in
                                        "with-wout" | "wout-with" )
                                                GO=""
                                                ;;
@@ -1050,7 +1144,7 @@ fetch_build_requires()
                                        run_poldek -t -i $package --dumpn=".$package-req.txt"
                                        if [ -f ".$package-req.txt" ]; then
                                                for package_name in `cat ".$package-req.txt"|grep -v ^#`
-                                               do 
+                                               do
                                                        if [ "$package_name" = "$package" ]; then
                                                                echo -ne "Installing BuildRequired package:\t$package_name\n"
                                                                export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
@@ -1067,7 +1161,7 @@ fetch_build_requires()
                                                                        ;;
                                                                *)
                                                                        echo "Attempting to run spawn sub - builder..."
-                                                                       run_sub_builder $package_name 
+                                                                       run_sub_builder $package_name
                                                                        if [ $? -eq 0 ]; then
                                                                                install_required_packages $package_name;
                                                                                case $? in
@@ -1097,8 +1191,8 @@ fetch_build_requires()
                                                                *)
                                                                        NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
                                                                        ;;
-                                                       esac    
-                                               fi      
+                                                       esac
+                                               fi
                                        fi
                                else
                                        echo "Package $package is already installed. BuildRequirement satisfied."
@@ -1107,13 +1201,13 @@ fetch_build_requires()
                done
                export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
                if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
-                       echo "Nie uda³o siê zainstalowaæ nastêpuj±cych pakietów i ich zale¿no¶ci:"
+                       echo "Unable to install following packages and their dependencies:"
                        for pkg in "$NOT_INSTALLED_PACKAGES"
                        do
                                echo $pkg
                        done
                        remove_build_requires
-                       exit 1
+                       exit 8
                fi
        fi
 }
@@ -1143,6 +1237,9 @@ do
                        UPDATE5="yes"
                        ADD5="yes"
                        shift ;;
+               -n5 | --no-md5 )
+                       NO5="yes"
+                       shift ;;
                -D | --debug )
                        DEBUG="yes"; shift ;;
                -V | --version )
@@ -1189,6 +1286,14 @@ do
                        NOSRCS="yes"; shift ;;
                -ns0 | --no-source0 )
                        NOSOURCE0="yes"; shift ;;
+               -nn | --no-net )
+                       NOCVS="yes"
+                       NOCVSSPEC="yes"
+                       NODIST="yes"
+                       NOMIRRORS="yes"
+                       NOURLS="yes"
+                       NOSRCS="yes"
+                       shift;;
                --opts )
                        shift; RPMOPTS="${1}"; shift ;;
                --with | --without )
@@ -1205,6 +1310,8 @@ do
                                        BCOND="$BCOND $1 $2" ; shift 2 ;;
                        esac
                        ;;
+               --target )
+                       shift; TARGET="${1}"; shift ;;
                -q | --quiet )
                        QUIET="--quiet"; shift ;;
                --date )
@@ -1249,6 +1356,9 @@ do
                -Tp | --tag-prefix )
                        TAG_PREFIX="$2"
                        shift 2;;
+               -tt | --test-tag )
+                       TEST_TAG="yes"
+                       shift;;
                -T | --tag )
                        COMMAND="tag";
                        shift
@@ -1283,7 +1393,7 @@ do
                        RPMOPTS="${RPMOPTS} --nodeps"
                        ;;
                * )
-                       SPECFILE="`basename ${1} .spec`.spec"; 
+                       SPECFILE="${1}"
                        export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
                        shift ;;
        esac
@@ -1304,13 +1414,13 @@ case "$COMMAND" in
                fetch_build_requires;
                parse_spec;
 
-               if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
-                       TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
-                       CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
+               if [ -n "$TEST_TAG" ]; then
+                       TAGVER=`make_tagver`
+                       echo "Searching for tag $TAGVER..."
                        TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
 
-                       if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
-                               Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
+                       if [ -n "$TAGREL" ]; then
+                               Exit_error err_build_fail "Tag $TAGVER already present (spec release: $TAGREL)"
                        fi
                fi
 
@@ -1365,6 +1475,8 @@ case "$COMMAND" in
                fi
                ;;
        "tag" )
+               NOURLS=1
+               NODIST=1
                init_builder;
                if [ -n "$SPECFILE" ]; then
                        get_spec;
@@ -1377,7 +1489,7 @@ case "$COMMAND" in
                        new_SOURCES=""
                        for file in $SOURCES
                        do
-                               [ "`nourl $file`" != "$file" ] && continue
+                               [ -n "`src_md5 $file`" ] && continue
                                new_SOURCES="$new_SOURCES $file"
                        done
                        SOURCES="$new_SOURCES"
This page took 0.616597 seconds and 4 git commands to generate.