]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- message added
[packages/rpm-build-tools.git] / builder.sh
index 07a13713cb4c87d7ff306256415d0ec99608b48f..1f25e9bce6407fed02e4b94b2cbd30ae37588f46 100644 (file)
@@ -13,8 +13,9 @@
 #      - builder -u fetches current version first
 #      - tries to get new version from distfiles without new md5
 #      - after fetching new version doesn't update md5
-#      - doesn't get sources for specs with %include  /usr/lib/rpm/macros.python
+#      - doesn't get sources for specs with %include /usr/lib/rpm/macros.python
 #        when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway)
+#      - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov
 
 VERSION="\
 Build package utility from PLD CVS repository
@@ -61,6 +62,7 @@ ICONS=""
 PACKAGE_RELEASE=""
 PACKAGE_VERSION=""
 PACKAGE_NAME=""
+PROTOCOL="ftp"
 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
 
@@ -68,7 +70,7 @@ CVSTAG=""
 RES_FILE=""
 
 CVS_SERVER="cvs.pld-linux.org"
-DISTFILES_SERVER="ftp://distfiles.pld-linux.org"
+DISTFILES_SERVER="://distfiles.pld-linux.org"
 
 DEF_NICE_LEVEL=0
 
@@ -103,7 +105,7 @@ 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] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
+       [-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]
@@ -135,6 +137,7 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
        -g, --get       - get <package>.spec and all related files from
                          CVS repo or HTTP/FTP,
        -h, --help      - this message,
+       --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
@@ -390,7 +393,7 @@ src_md5 ()
 
 distfiles_url ()
 {
-    echo "$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
+    echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
 }
 
 good_md5 ()
@@ -432,6 +435,7 @@ get_files()
            fi
        fi
        for i in $GET_FILES; do
+           FROM_DISTFILES=0
            if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
                if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
                    echo "Warning: no URL given for $i"
@@ -444,10 +448,11 @@ get_files()
                    fi
                    target=$(nourl "$i")
                    url=$(distfiles_url "$i")
-                   if [ `echo $url | grep -E '^(\.|/)'` ] ; then
+                   if [ `echo $url | grep -E '^(\.|/)'` ]; then
                        ${GETLOCAL} $url $target
                    else
-                       if [ -z "$NOMIRRORS" ] ; then
+                       FROM_DISTFILES=1
+                       if [ -z "$NOMIRRORS" ]; then
                            url="`find_mirror "$url"`"
                        fi
                        ${GETURI} -O "$target" "$url" || \
@@ -476,7 +481,7 @@ get_files()
                fi
 
                if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
-                   if [ -z "$NOMIRRORS" ] ; then
+                   if [ -z "$NOMIRRORS" ]; then
                        im="`find_mirror "$i"`"
                    else
                        im="$i"
@@ -505,6 +510,21 @@ get_files()
                                $SPECS_DIR/$SPECFILE
            fi
 
+           if good_md5 "$i"; then
+               :
+           elif [ "$FROM_DISTFILES" = 1 ]; then
+               # wrong md5 from distfiles: remove the file and try again
+               # but only once ...
+               echo "MD5 sum mismatch. Trying full fetch."
+               FROM_DISTFILES=2
+               rm -f $target
+               ${GETURI} -O "$target" "$url" || \
+                   if [ `echo $url | grep -E 'ftp://'` ]; then
+                       ${GETURI2} -O "$target" "$url"
+                   fi
+               test -s "$target" || rm -f "$target"
+           fi
+
            if good_md5 "$i"; then
                :
            else
@@ -750,6 +770,8 @@ while test $# -gt 0 ; do
            COMMAND="get"; shift ;;
        -h | --help )
            COMMAND="usage"; shift ;;
+       --http )
+           PROTOCOL="http"; shift ;;
        -l | --logtofile )
            shift; LOGFILE="${1}"; shift ;;
        -ni| --nice )
This page took 0.031865 seconds and 4 git commands to generate.