]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- year 2004 in VERSION
[packages/rpm-build-tools.git] / builder.sh
index dfbb595b40bb5d26e53014d1237f547a554f773d..23a462b1ab2c3668ef69d481e4b81f7768fdd7e9 100644 (file)
@@ -23,7 +23,7 @@
 
 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"
@@ -91,23 +91,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
 # 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.
@@ -120,12 +120,12 @@ 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()
 {
@@ -210,6 +210,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,
@@ -291,9 +292,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`"
@@ -362,8 +363,14 @@ get_spec()
                set -v;
        fi
 
+       CWD="$(pwd)"
+       cd "$SPECS_DIR"
+       if [ \! -f "$SPECFILE" ]; then
+               SPECFILE="`basename $SPECFILE .spec`.spec";
+       fi
+       cd "$CWD"
        if [ "$NOCVSSPEC" != "yes" ]; then
-               cd $SPECS_DIR
+               cd "$SPECS_DIR"
 
                OPTIONS="up "
 
@@ -444,7 +451,7 @@ 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 ()
@@ -454,7 +461,7 @@ src_md5 ()
        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 | \
@@ -467,7 +474,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
 }
 
@@ -476,6 +483,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")
@@ -493,7 +505,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
@@ -537,10 +549,11 @@ get_files()
                                        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
@@ -548,11 +561,25 @@ 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
+                                               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
@@ -572,7 +599,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"`"
@@ -585,7 +612,6 @@ get_files()
                                        fi
                                fi
 
-
                        fi
                        srcno=$(src_no $i)
                        if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
@@ -617,6 +643,13 @@ 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
 
@@ -671,11 +704,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`
@@ -688,7 +721,7 @@ tag_files()
                        fi
                done
 
-               cd $SPECS_DIR
+               cd "$SPECS_DIR"
                if [ "$TAG_VERSION" = "yes" ]; then
                        cvs $OPTIONS $TAGVER $SPECFILE
                fi
@@ -719,7 +752,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
@@ -728,7 +761,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
@@ -744,7 +777,7 @@ build_package()
                set -v;
        fi
 
-       cd $SPECS_DIR
+       cd "$SPECS_DIR"
 
        if [ -n "$TRY_UPGRADE" ]; then
                if [ -n "$FLOAT_VERSION" ]; then
@@ -767,7 +800,7 @@ build_package()
                        unset TOLDVER TNEWVER TNOTIFY
                fi
        fi
-       cd $SPECS_DIR
+       cd "$SPECS_DIR"
 
        case "$COMMAND" in
                build )
@@ -781,6 +814,11 @@ 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
@@ -973,7 +1011,7 @@ display_bconds()
                if [ "$BCOND" != "" ]; then
                        echo -ne "$BCOND"
                else
-                       echo -ne "No --with || --without conditions passed to $0!"
+                       echo -ne "No --with || --without conditions passed to $0"
                fi
                echo -ne "\n\nfrom available:\n\n"
                echo -ne "--with   :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
@@ -1192,6 +1230,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 )
@@ -1286,7 +1332,7 @@ do
                        RPMOPTS="${RPMOPTS} --nodeps"
                        ;;
                * )
-                       SPECFILE="`basename ${1} .spec`.spec";
+                       SPECFILE="${1}"
                        export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
                        shift ;;
        esac
@@ -1368,6 +1414,8 @@ case "$COMMAND" in
                fi
                ;;
        "tag" )
+               NOURLS=1
+               NODIST=1
                init_builder;
                if [ -n "$SPECFILE" ]; then
                        get_spec;
@@ -1380,7 +1428,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.049448 seconds and 4 git commands to generate.