]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- make builder's chmod configurable
[packages/rpm-build-tools.git] / builder.sh
index a8551c94dce4af494cd1cf6ab0dc7ce89e824e3e..108327ff54d58ee588b295e19cb59963f6ce3f90 100644 (file)
@@ -25,10 +25,16 @@ DEBUG=""
 NOURLS=""
 NOCVS=""
 ALLWAYS_CVSUP="yes"
-CVSROOT=${CVSROOT:-""}
+if [ -s CVS/Root ]; then
+    CVSROOT=$(cat CVS/Root)
+else
+    CVSROOT=${CVSROOT:-""}
+fi
 LOGFILE=""
-CHMOD="yes"
+CHMOD=${CHMOD:-"yes"}
+CHMOD_MODE=${CHMOD_MODE:-444}
 RPMOPTS=""
+BCOND=""
 
 PATCHES=""
 SOURCES=""
@@ -36,10 +42,13 @@ ICONS=""
 PACKAGE_RELEASE=""
 PACKAGE_VERSION=""
 PACKAGE_NAME=""
+WGET_RETRIES=${MAX_WGET_RETRIES:-0}
 
 DEF_NICE_LEVEL=0
 
-GETURI="wget -c -nd -t0"
+FAIL_IF_NO_SOURCES="yes"
+
+GETURI="wget -c -nd -t$WGET_RETRIES"
 
 if [ -f ~/etc/builderrc ]; then
   . ~/etc/builderrc
@@ -59,7 +68,7 @@ Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
        [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
        [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
        [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
-       [--opts <rpm opts>] <package>.spec
+       [--opts <rpm opts>] [--with/--without pkg] <package>.spec
 
        -D, --debug     - enable script debugging mode,
        -V, --version   - output builder version
@@ -106,10 +115,14 @@ parse_spec()
     cd $SPECS_DIR
 
     if [ "$NOSRCS" != "yes" ]; then
-        SOURCES="`rpm -bp --nobuild --define "prep %dump" $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
+        SOURCES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
+    fi
+    if (rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | grep -qEi ":.*nosource.*1"); then
+       FAIL_IF_NO_SOURCES="no"
     fi
 
-    PATCHES="`rpm -bp --nobuild --define "prep %dump" $SPECFILE 2>&1 | awk '/PATCHURL[0-9]+/ {print $3}'`"
+
+    PATCHES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | 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`"
@@ -142,7 +155,7 @@ Exit_error()
 
     cd $__PWD
 
-    case "$@" in
+    case "$1" in
     "err_no_spec_in_cmdl" )
        echo "ERROR: spec file name not specified.";
        exit 2 ;;
@@ -150,7 +163,7 @@ Exit_error()
        echo "Error: spec file not stored in CVS repo.";
        exit 3 ;;
     "err_no_source_in_repo" )
-       echo "Error: some source, patch or icon files not stored in CVS repo.";
+       echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
        exit 4 ;;
     "err_build_fail" )
        echo "Error: package build failed.";
@@ -165,8 +178,8 @@ init_builder()
        set -v; 
     fi
 
-    SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
-    SPECS_DIR="`rpm --eval "%{_specdir}"`"
+    SOURCE_DIR="`rpm --eval '%{_sourcedir}'`"
+    SPECS_DIR="`rpm --eval '%{_specdir}'`"
 
     __PWD=`pwd`
 }
@@ -200,7 +213,7 @@ get_spec()
        fi
     
     if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
-        chmod 444 $SPECFILE
+        chmod $CHMOD_MODE $SPECFILE
     fi
     unset OPTIONS
 }
@@ -248,8 +261,8 @@ get_files()
                        ${GETURI} "$i"
                fi
 
-               if [ ! -f "`nourl $i`" ]; then
-                       Exit_error err_no_source_in_repo;
+               if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
+                       Exit_error err_no_source_in_repo $i;
                fi
            fi
        done
@@ -257,7 +270,7 @@ get_files()
        if [ "$CHMOD" = "yes" ]; then
            CHMOD_FILES="`nourl $GET_FILES`"
            if [ -n "$CHMOD_FILES" ]; then
-                   chmod 444 $CHMOD_FILES
+                   chmod $CHMOD_MODE $CHMOD_FILES
            fi
        fi
        unset OPTIONS
@@ -290,7 +303,7 @@ tag_files()
                cvs $OPTIONS $TAG `nourl $i`
                cvs $OPTIONS STABLE `nourl $i`
            else
-               Exit_error err_no_source_in_repo
+               Exit_error err_no_source_in_repo $i
            fi
        done
 
@@ -318,7 +331,7 @@ build_package()
        build-source )
            BUILD_SWITCH="-bs --nodeps" ;;
     esac
-    nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE 
+    nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE 
 
     if [ "$?" -ne "0" ]; then
        Exit_error err_build_fail;
@@ -374,6 +387,8 @@ while test $# -gt 0 ; do
            NOSRCS="yes"; shift ;;
        --opts )
            shift; RPMOPTS="${1}"; shift ;;
+       --with | --without )
+           BCOND="$BCOND $1 $2" ; shift 2 ;;
        -q | --quiet )
            QUIET="--quiet"; shift ;;
        -r | --cvstag )
@@ -449,6 +464,32 @@ esac
 cd $__PWD
 
 # $Log$
+# Revision 1.83  2001/10/10 08:41:32  misiek
+# - allow more bconds than one
+#
+# Revision 1.82  2001/09/18 10:55:37  ankry
+# - added support for limitting number of wget retries when fetching a file
+#   from ftp/http server via environment variable MAX_WGET_RETRIES.
+#   Defaults to infinite (0).
+#
+# Revision 1.81  2001/07/06 16:52:30  misiek
+# - by default use CVSroot from CVS/Root and if it doesn't exist use from CVSROOT variable
+#
+# Revision 1.80  2001/06/22 18:52:39  misiek
+# - added support for --with/--without options
+#
+# Revision 1.79  2001/05/28 14:44:16  baggins
+# - if file is not in repo TELL which fucking file it is!
+#
+# Revision 1.78  2001/05/13 19:04:44  misiek
+# fixes for ksh93
+#
+# Revision 1.77  2001/05/13 10:51:30  misiek
+# don't fail if no sources found (hack to allow build nosrc packages)
+#
+# Revision 1.76  2001/04/19 23:24:06  misiek
+# fix chmod again
+#
 # Revision 1.75  2001/04/19 23:14:25  misiek
 # redirect errors from query to /dev/null
 #
This page took 0.036594 seconds and 4 git commands to generate.