]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- s/^Utilities/Applications
[packages/rpm-build-tools.git] / builder.sh
index 545e0aec71f125aa0aa27e1549894a96cf8a70ad..f2c514f31b47530376c8c030f5f06237714cca68 100644 (file)
 
 VERSION="\
 Build package utility from PLD CVS repository
-V 0.7 (C) 1999 Tomasz K³oczko".
+V 0.8 (C) 1999 Tomasz K³oczko".
 
 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
-
 COMMAND="build"
 
 SPECFILE=""
@@ -22,9 +22,12 @@ QUIET=""
 CLEAN=""
 DEBUG=""
 NOURLS=""
+NOCVS=""
+ALLWAYS_CVSUP="yes"
 CVSROOT=${CVSROOT:-""}
 LOGFILE=""
 CHMOD="yes"
+RPMOPTS=""
 
 PATCHES=""
 SOURCES=""
@@ -33,7 +36,11 @@ PACKAGE_RELEASE=""
 PACKAGE_VERSION=""
 PACKAGE_NAME=""
 
-if [ -f ~/.builderrc ]; then
+DEF_NICE_LEVEL=0
+
+if [ -f ~/etc/builderrc ]; then
+  . ~/etc/builderrc
+elif [ -f ~/.builderrc ]; then
   . ~/.builderrc
 fi
 
@@ -45,10 +52,11 @@ usage()
     if [ -n "$DEBUG" ]; then set -xv; fi
     echo "\
 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
-       [--build] [-bb] [--build-binary] [-bs] [--build-source] [-d <cvsroot>]
-       [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help] [-l <logfile>]
-       [--logtofile <logfile>] [-q] [--quiet] [-r <cvstag>]
-       [--cvstag <cvstag>] [-v] [--verbose] <package>.spec
+       [--build] [-bb] [--build-binary] [-bs] [--build-source]
+       [-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
 
        -D, --debug     - enable script debugging mode,
        -V, --version   - output builder version
@@ -70,10 +78,14 @@ Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
                          CVS repo or HTTP/FTP,
        -h, --help      - this message,
        -l, --logtofile - log all to file,
+       -m, --mr-proper - only remove all files related to spec file and
+                         all work resources,
+       -nc, --no-cvs   - don't download from CVS, if source URL is given,
+       -nu, --no-urls  - don't try to download from FTP/HTTP location,
+       --opts          - additional options for rpm
        -q, --quiet     - be quiet,
        -r, --cvstag    - build package using resources from specified CVS
                          tag,
-       -u, --no_urls   - try to get sources only from CVS repo,
        -v, --verbose   - be verbose,
 
 "
@@ -81,7 +93,10 @@ Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
 
 parse_spec()
 {
-    if [ -n "$DEBUG" ]; then set -xv; fi
+    if [ -n "$DEBUG" ]; then 
+       set -x;
+       set -v; 
+    fi
 
     sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
 
@@ -114,7 +129,10 @@ parse_spec()
 
 Exit_error()
 {
-    if [ -n "$DEBUG" ]; then set -xv; fi
+    if [ -n "$DEBUG" ]; then 
+       set -x;
+       set -v; 
+    fi
 
     cd $__PWD
 
@@ -136,7 +154,10 @@ Exit_error()
 
 init_builder()
 {
-    if [ -n "$DEBUG" ]; then set -xv; fi
+    if [ -n "$DEBUG" ]; then 
+       set -x;
+       set -v; 
+    fi
 
     SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
     SPECS_DIR="`rpm --eval "%{_specdir}"`"
@@ -146,7 +167,10 @@ init_builder()
 
 get_spec()
 {
-    if [ -n "$DEBUG" ]; then set -xv; fi
+    if [ -n "$DEBUG" ]; then 
+       set -x;
+       set -v; 
+    fi
 
     cd $SPECS_DIR
 
@@ -169,7 +193,7 @@ get_spec()
        Exit_error err_no_spec_in_repo;
        fi
     
-    if [ "$CHMODE" = "yes" ]; then
+    if [ "$CHMOD" = "yes" ]; then
         chmod 444 $SPECFILE
     fi
     unset OPTIONS
@@ -177,7 +201,10 @@ get_spec()
 
 get_all_files()
 {
-    if [ -n "$DEBUG" ]; then set -xv; fi
+    if [ -n "$DEBUG" ]; then 
+       set -x;
+       set -v; 
+    fi
 
     if [ -n "$SOURCES$PATCHES$ICONS" ]; then
        cd $SOURCE_DIR
@@ -191,24 +218,34 @@ get_all_files()
        else
            OPTIONS="$OPTIONS -A"
        fi
-
-       cvs $OPTIONS `nourl $SOURCES $PATCHES $ICONS`
-       
-       if [ -z "$NOURLS" ]; then
-               for i in $SOURCES $PATCHES $ICONS; do
-                       if [ ! -f "`nourl $i`" ]&&\
-                       [ `echo $i | grep 'ftp://\|http://'` ]; then
-                               wget -c -t0 "$i"
-                       fi
-               done
-       fi
-       
        for i in $SOURCES $PATCHES $ICONS; do
+           if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ] 
+             then
+               if 
+                       echo $i | grep -vE '(http|ftp|https|cvs)://' |\
+                       grep -qE '\.(gz|bz2)$'
+               then
+                       echo "Warning: no URL given for $i"
+               fi
+               
+               if      [ -z "$NOCVS" ]||\
+                       [ `echo $i | grep -vE '(ftp|http|https)://'` ]
+               then
+                       cvs $OPTIONS `nourl $i`
+               fi
+               
+               if      [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
+                       [ `echo $i | grep -E 'ftp://|http://|https://'` ]
+               then
+                       wget -c -nd -t0 "$i"
+               fi
+
                if [ ! -f "`nourl $i`" ]; then
                        Exit_error err_no_source_in_repo;
                fi
+           fi
        done
-
+       
        if [ "$CHMOD" = "yes" ]; then
            chmod 444 `nourl $SOURCES $PATCHES $ICONS`
        fi
@@ -218,7 +255,10 @@ get_all_files()
 
 build_package()
 {
-    if [ -n "$DEBUG" ]; then set -xv; fi
+    if [ -n "$DEBUG" ]; then 
+       set -x;
+       set -v; 
+    fi
 
     cd $SPECS_DIR
     case "$COMMAND" in
@@ -227,9 +267,9 @@ build_package()
        build-binary )
            BUILD_SWITCH="-bb" ;;
        build-source )
-           BUILD_SWITCH="-bs" ;;
+           BUILD_SWITCH="-bs --nodeps" ;;
     esac
-    rpm $BUILD_SWITCH -v $QUIET $CLEAN $SPECFILE
+    nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE 
 
     if [ "$?" -ne "0" ]; then
        Exit_error err_build_fail;
@@ -239,7 +279,7 @@ build_package()
 
 nourl()
 {
-       echo "$@" | sed 's#\<\(ftp\|http\)://.*/##g'
+       echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
 }
 #---------------------------------------------
 # main()
@@ -273,20 +313,31 @@ while test $# -gt 0 ; do
            COMMAND="usage"; shift ;;
        -l | --logtofile )
            shift; LOGFILE="${1}"; shift ;;
+       -ni| --nice )
+           shift; DEF_NICE_LEVEL=${1}; shift ;;
+       -m | --mr-proper )
+           COMMAND="mr-proper"; shift ;;
+       -nc | --no-cvs )
+           NOCVS="yes"; shift ;;
+       -nu | --no-urls )
+           NOURLS="yes"; shift ;;
+       --opts )
+           shift; RPMOPTS="${1}"; shift ;;
        -q | --quiet )
            QUIET="--quiet"; shift ;;
        -r | --cvstag )
            shift; CVSTAG="${1}"; shift ;;
        -v | --verbose )
            BE_VERBOSE="1"; shift ;;
-       -u | --no_urls )
-           NOURLS="yes"; shift ;;
        * )
            SPECFILE="${1}"; shift ;;
     esac
 done
 
-if [ -n "$DEBUG" ]; then set -xv; fi
+if [ -n "$DEBUG" ]; then 
+       set -x;
+       set -v; 
+fi
 
 case "$COMMAND" in
     "build" | "build-binary" | "build-source" )
@@ -310,6 +361,9 @@ case "$COMMAND" in
            Exit_error err_no_spec_in_cmdl;
        fi
        ;;
+    "mr-proper" )
+       rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE
+       ;;
     "usage" )
        usage;;
     "version" )
This page took 0.03434 seconds and 4 git commands to generate.