]> 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 18db94e593b8e00ba726191b28609112cd215082..de77571b54844ca262791a95489b5b5fa1739bed 100644 (file)
@@ -27,6 +27,7 @@ V 0.11 (C) 1999-2004 Free Penguins".
 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
 
 COMMAND="build"
+TARGET=""
 
 SPECFILE=""
 BE_VERBOSE=""
@@ -63,6 +64,7 @@ CHMOD_MODE="0444"
 RPMOPTS=""
 BCOND=""
 GROUP_BCONDS="no"
+CVSIGNORE_DF="no"
 
 PATCHES=""
 SOURCES=""
@@ -80,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"
 
@@ -254,6 +256,8 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
                       %_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>.
 "
 }
 
@@ -496,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="$@"
@@ -544,7 +565,7 @@ 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
@@ -577,7 +598,9 @@ get_files()
                                                        fi
                                                fi
                                        fi
-                                       if ! test -s "$target"; then
+                                       if test -s "$target"; then
+                                               cvsignore_df $target
+                                       else
                                                rm -f "$target"
                                                FROM_DISTFILES=0
                                        fi
@@ -632,7 +655,7 @@ get_files()
                                $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
@@ -654,10 +677,10 @@ get_files()
                                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
@@ -809,7 +832,11 @@ build_package()
                fi
        fi
        cd "$SPECS_DIR"
-
+       
+       if [ -n "$TARGET" ]; then 
+               TARGET_SWITCH="--target $TARGET"
+       fi
+       
        case "$COMMAND" in
                build )
                        BUILD_SWITCH="-ba" ;;
@@ -831,7 +858,7 @@ build_package()
                        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
@@ -842,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
@@ -853,6 +880,7 @@ build_package()
                Exit_error err_build_fail;
        fi
        unset BUILD_SWITCH
+       unset TARGET_SWITCH
 }
 
 nourl()
@@ -873,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"
@@ -1282,6 +1310,8 @@ do
                                        BCOND="$BCOND $1 $2" ; shift 2 ;;
                        esac
                        ;;
+               --target )
+                       shift; TARGET="${1}"; shift ;;
                -q | --quiet )
                        QUIET="--quiet"; shift ;;
                --date )
This page took 0.258272 seconds and 4 git commands to generate.