]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- implement --short-circuit,-bc,-bi and -bl
[packages/rpm-build-tools.git] / builder.sh
index 8b7902539733a5248781453a346bd519380da9b1..1041d4a4f14a4498420313b33d59ec40b0a740b5 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/ksh
 # -----------
 # $Id$
 # Exit codes:
@@ -22,7 +22,7 @@
 
 VERSION="\
 Build package utility from PLD Linux CVS repository
-v0.16 (C) 1999-2006 Free Penguins".
+v0.17 (C) 1999-2006 Free Penguins".
 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
 
 COMMAND="build"
@@ -193,14 +193,15 @@ 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] [-u|--try-upgrade]
-[{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] 
-[-g|--get] [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
-[-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
+[-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
+[{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
+[-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
+[-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
-[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
-[--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
+[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
+[--show-bconds] [--with/--without <feature>] [--define <macro> <value>] 
+<package>[.spec][:cvstag]
 
 -5, --update-md5    - update md5 comments in spec, implies -nd -ncs
 -a5, --add-md5      - add md5 comments to URL sources, implies -nc -nd -ncs
@@ -214,11 +215,12 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
                       only package from <package>.spec,
 -bp, --build-prep   - execute the %prep phase of <package>.spec,
--bc                 - reserved (not implemented)
--bi                   reserved (not implemented)
+-bc                 - execute the %build phase of <package>.spec,
+-bi                 - execute the %install phase of <package>.spec
+-bl                                    - execute the %files phase of <package>.spec
 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
                       them into src.rpm,
---short-circuit     - reserved (not implemented)
+--short-circuit     - short-circuit build
 -B, --branch        - add branch
 -c, --clean         - clean all temporarily created files (in BUILD, SOURCES,
                       SPECS and \$RPM_BUILD_ROOT),
@@ -302,6 +304,9 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
                     - don't apply <patchnumber>
 --show-bconds       - show available conditional builds, which can be used
                     - with --with and/or --without switches.
+--show-bcond-args   - show active bconds, from ~/.bcondrc. this is used by
+                      ./repackage.sh script. in other words, the output is
+                      parseable by scripts.
 --with/--without <feature>
                     - conditional build package depending on %_with_<feature>/
                       %_without_<feature> macro switch.  You may now use
@@ -398,6 +403,19 @@ cache_rpm_dump () {
 %py_ver ERROR
 %perl_vendorarch ERROR
 %perl_vendorlib ERROR
+# damn. need it here! - copied from /usr/lib/rpm/macros.build
+%tmpdir                %(echo "${TMPDIR:-/tmp}")
+%patchset_source(f:b:) %(
+       base=%{-b*}%{!-b*:10000};
+       start=$(expr $base + %1);
+       end=$(expr $base + %{?2}%{!?2:%{1}});
+       # we need to call seq twice as it doesn't allow two formats
+       seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
+       seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
+       paste %{tmpdir}/__ps{1,2};
+       rm -f %{tmpdir}/__ps{1,2};
+) \
+%{nil}
 EOF
        case "$RPMBUILD" in
        rpm)
@@ -819,7 +837,7 @@ update_md5()
                                tag="NoSource$srcno-md5"
                        fi
                        md5=$(md5sum "$fp" | cut -f1 -d' ')
-                       echo "Updating $tag ($md5)."
+                       echo "Updating $tag ($md5: $fp)."
                        perl -i -ne '
                                print unless /^\s*#\s*(No)?Source'$srcno'-md5\s*:/i;
                                print "# '$tag':\t'$md5'\n" if /^Source'$srcno'\s*:\s+/;
@@ -892,7 +910,15 @@ get_files()
                                                continue
                                        fi
                                        target="$fp"
-                                       url=$(distfiles_url "$i")
+
+                                       # prefer mirror over distfiles if there's mirror
+                                       # TODO: build url list and then try each url from the list
+                                       if [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
+                                               url="$im"
+                                       else
+                                               url=$(distfiles_url "$i")
+                                       fi
+
                                        url_attic=$(distfiles_attic_url "$i")
                                        FROM_DISTFILES=1
                                        # is $url local file?
@@ -1175,6 +1201,13 @@ build_package()
                        BUILD_SWITCH="-bs --nodeps" ;;
                build-prep )
                        BUILD_SWITCH="-bp --nodeps" ;;
+               build-build )
+                       BUILD_SWITCH="-bc" ;;
+               build-install )
+                       BUILD_SWITCH="-bi" ;;
+               build-list )
+                       BUILD_SWITCH="-bl" ;;
+
        esac
 
        update_shell_title "build_package: $COMMAND"
@@ -1717,7 +1750,7 @@ init_rpm_dir() {
 
        mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
        cd $TOP_DIR
-       cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
+       cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,{relup,repackage}.sh}
 
        init_builder
 
@@ -1734,15 +1767,14 @@ init_rpm_dir() {
 #---------------------------------------------
 # main()
 
-if [ "$#" = 0 ]; then
+if [ $# = 0 ]; then
        usage
        exit 1
 fi
 
-while test $# -gt 0
-do
+while [ $# -gt 0 ]; do
        case "${1}" in
-               -5 | --update-md5 )
+               -5 | --update-md5)
                        COMMAND="update_md5"
                        NODIST="yes"
                        NOCVSSPEC="yes"
@@ -1767,10 +1799,16 @@ do
                        COMMAND="build"; shift ;;
                -bb | --build-binary )
                        COMMAND="build-binary"; shift ;;
-               -bs | --build-source )
-                       COMMAND="build-source"; shift ;;
+               -bc )
+                       COMMAND="build-build"; shift ;;
+               -bi )
+                       COMMAND="build-install"; shift ;;
+               -bl )
+                       COMMAND="build-list"; shift ;;
                -bp | --build-prep )
                        COMMAND="build-prep"; shift ;;
+               -bs | --build-source )
+                       COMMAND="build-source"; shift ;;
                -B | --branch )
                        COMMAND="branch"; shift; TAG="${1}"; shift;;
                -c | --clean )
@@ -1941,10 +1979,18 @@ do
                                RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
                        fi
                        ;;
+               --short-circuit)
+                       RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
+                       shift
+                       ;;
                --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
                        COMMAND="show_bconds"
                        shift
                        ;;
+               --show-bcond-args)
+                       COMMAND="show_bcond_args"
+                       shift
+                       ;;
                --nodeps)
                        shift
                        RPMOPTS="${RPMOPTS} --nodeps"
@@ -1965,7 +2011,7 @@ done
 if [ -z "$CVSTAG" ]; then
        CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
        if [ "$CVSTAG" ]; then
-               echo "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
+               echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
        fi
 elif [ "$CVSTAG" = "HEAD" ]; then
        # assume -r HEAD is same as -A
@@ -1995,6 +2041,15 @@ fi
 update_shell_title "$COMMAND"
 case "$COMMAND" in
        "show_bconds")
+               init_builder
+               if [ -n "$SPECFILE" ]; then
+                       get_spec > /dev/null
+                       parse_spec
+                       set_bconds_values
+                       display_bconds
+               fi
+               ;;
+       "show_bcond_args")
                init_builder
                if [ -n "$SPECFILE" ]; then
                        get_spec > /dev/null
@@ -2003,7 +2058,7 @@ case "$COMMAND" in
                        echo "$BCOND"
                fi
                ;;
-       "build" | "build-binary" | "build-source" | "build-prep" )
+       "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
                init_builder
                if [ -n "$SPECFILE" ]; then
                        get_spec
This page took 0.042633 seconds and 4 git commands to generate.