]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - builder.sh
- Look into $SOURCE_DIR first to avoid some useless transmisions
[packages/rpm-build-tools.git] / builder.sh
1 #!/bin/sh
2 # -----------
3 # $Id$
4 # Exit codes:
5 #       0 - succesful
6 #       1 - help dispayed
7 #       2 - no spec file name in cmdl parameters
8 #       3 - spec file not stored in repo
9 #       4 - some source, patch or icon files not stored in repo
10 #       5 - package build failed
11
12 VERSION="\
13 Build package utility from PLD CVS repository
14 V 0.11 (C) 1999-2001 Free Penguins".
15 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
16
17 COMMAND="build"
18
19 SPECFILE=""
20 BE_VERBOSE=""
21 QUIET=""
22 CLEAN=""
23 DEBUG=""
24 NOURLS=""
25 NOCVS=""
26 NOCVSSPEC=""
27 NODIST=""
28 ALLWAYS_CVSUP=${ALLWAYS_CVSUP:-"yes"}
29 if [ -s CVS/Root ]; then
30     CVSROOT=$(cat CVS/Root)
31 else
32     CVSROOT=${CVSROOT:-""}
33 fi
34 # Example: LOGFILE='../log.$PACKAGE_NAME'
35 # Yes, you can use variable name! Note _single_ quotes!
36 LOGFILE=''
37
38 LOGDIR=""
39 LOGDIROK=""
40 LOGDIRFAIL=""
41 LASTLOG_FILE=""
42 LTAG=""
43 CHMOD="yes"
44 CHMOD_MODE="0444"
45 RPMOPTS=""
46 BCOND=""
47
48 PATCHES=""
49 SOURCES=""
50 ICONS=""
51 PACKAGE_RELEASE=""
52 PACKAGE_VERSION=""
53 PACKAGE_NAME=""
54 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
55 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
56
57 CVSTAG=""
58 RES_FILE=""
59
60 CVS_SERVER="cvs.pld-linux.org"
61 DISTFILES_SERVER="ftp://distfiles.pld-ppc.org"
62
63 DEF_NICE_LEVEL=0
64
65 FAIL_IF_NO_SOURCES="yes"
66
67 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES --inet"
68 GETURI2="wget -c -nd -t$WGET_RETRIES --inet"
69
70 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
71     RPM="rpm"
72     RPMBUILD="rpm"
73 else
74     RPM="rpm"
75     RPMBUILD="rpmbuild"
76 fi
77
78 if [ -f ~/etc/builderrc ]; then
79     . ~/etc/builderrc
80 elif [ -f ~/.builderrc ]; then
81     . ~/.builderrc
82 fi
83
84 #---------------------------------------------
85 # functions
86
87 usage()
88 {
89     if [ -n "$DEBUG" ]; then set -xv; fi
90     echo "\
91 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
92
93         [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
94         [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
95         [-h|--help] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
96         [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
97         [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
98         [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
99         [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
100         [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
101
102         -D, --debug     - enable script debugging mode,
103         -V, --version   - output builder version
104         -a, --as_anon   - get files via pserver as cvs@$CVS_SERVER,
105         -b, -ba,
106         --build         - get all files from CVS repo or HTTP/FTP and build
107                           package from <package>.spec,
108         -bb, --build-binary
109                         - get all files from CVS repo or HTTP/FTP and build
110                           binary only package from <package>.spec,
111         -bs,
112         --build-source  - get all files from CVS repo or HTTP/FTP and only
113                           pack them into src.rpm,
114         -B, --branch    - add branch
115         -c, --clean     - clean all temporarily created files (in BUILD,
116                           SOURCES, SPECS and \$RPM_BUILD_ROOT),
117         -d <cvsroot>, --cvsroot <cvsroot>
118                         - setup \$CVSROOT,
119         --define <macro> <value>
120                         - define a macro <macro> with value <value>,
121         -g, --get       - get <package>.spec and all related files from
122                           CVS repo or HTTP/FTP,
123         -h, --help      - this message,
124         -l <logfile>, --logtofile <logfile>
125                         - log all to file,
126         -m, --mr-proper - only remove all files related to spec file and
127                           all work resources,
128         -nc, --no-cvs   - don't download sources from CVS, if source URL is
129                           given,
130         -ncs, --no-cvs-specs
131                         - don't check specs in CVS
132         -nd, --no-distfiles
133                         - don't download from distfiles
134         -nm, --no-mirrors - don't download from mirror, if source URL is given,
135         -nu, --no-urls  - don't try to download from FTP/HTTP location,
136         -ns, --no-srcs  - don't download Sources
137         -ns0, --no-source0
138                         - don't download Source0
139         --opts <rpm opts>
140                         - additional options for rpm
141         -q, --quiet     - be quiet,
142         --date yyyy-mm-dd
143                         - build package using resources from specified CVS
144                           date,
145         -r <cvstag>, --cvstag <cvstag>
146                         - build package using resources from specified CVS
147                           tag,
148         -T <cvstag> , --tag <cvstag>
149                         - add cvs tag <cvstag> for files,
150         -Tvs, --tag-version-stable
151                         - add cvs tags STABLE and NAME-VERSION-RELESE for files,
152         -Tvn, --tag-version-nest
153                         - add cvs tags NEST and NAME-VERSION-RELESE for files,
154         -Ts, --tag-stable
155                         - add cvs tag STABLE for files,
156         -Tn, --tag-nest
157                         - add cvs tag NEST for files,
158         -Tv, --tag-version
159                         - add cvs tag NAME-VERSION-RELESE for files,
160         -v, --verbose   - be verbose,
161         -u, --try-upgrade
162                         - check version, and try to upgrade package
163         --with/--without <feature>
164                         - conditional build package depending on
165                           %_with_<feature>/%_without_<feature> macro
166                           switch
167 "
168 }
169
170 parse_spec()
171 {
172     if [ -n "$DEBUG" ]; then
173         set -x;
174         set -v;
175     fi
176
177     cd $SPECS_DIR
178     if [ "$NOSRCS" != "yes" ]; then
179         SOURCES="`$RPMBUILD -bp  $BCOND --define 'prep %dump' $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
180     fi
181     if ($RPMBUILD -bp  $BCOND --define 'prep %dump' $SPECFILE 2>&1 | grep -qEi ":.*nosource.*1"); then
182         FAIL_IF_NO_SOURCES="no"
183     fi
184
185     PATCHES="`$RPMBUILD -bp  $BCOND --define 'prep %dump' $SPECFILE 2>&1 | awk '/PATCHURL[0-9]+/ {print $3}'`"
186     ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
187     PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
188     PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
189     PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
190
191     if [ -n "$BE_VERBOSE" ]; then
192         echo "- Sources :  `nourl $SOURCES`"
193         if [ -n "$PATCHES" ]; then
194             echo "- Patches :  `nourl $PATCHES`"
195         else
196             echo "- Patches :  *no patches needed*"
197         fi
198         if [ -n "$ICONS" ]; then
199             echo "- Icon    :  `nourl $ICONS`"
200         else
201             echo "- Icon    :  *no package icon*"
202         fi
203         echo "- Name    : $PACKAGE_NAME"
204         echo "- Version : $PACKAGE_VERSION"
205         echo "- Release : $PACKAGE_RELEASE"
206     fi
207 }
208
209 Exit_error()
210 {
211     if [ -n "$DEBUG" ]; then
212         set -x;
213         set -v;
214     fi
215
216     cd $__PWD
217
218     case "$1" in
219     "err_no_spec_in_cmdl" )
220         echo "ERROR: spec file name not specified.";
221         exit 2 ;;
222     "err_no_spec_in_repo" )
223         echo "Error: spec file not stored in CVS repo.";
224         exit 3 ;;
225     "err_no_source_in_repo" )
226         echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
227         exit 4 ;;
228     "err_build_fail" )
229         echo "Error: package build failed. (${2:-no more info})";
230         exit 5 ;;
231     esac
232 }
233
234 init_builder()
235 {
236     if [ -n "$DEBUG" ]; then
237         set -x;
238         set -v;
239     fi
240
241     SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
242     SPECS_DIR="`$RPM --eval '%{_specdir}'`"
243
244     __PWD=`pwd`
245 }
246
247 get_spec()
248 {
249     if [ -n "$DEBUG" ]; then
250         set -x;
251         set -v;
252     fi
253
254     if [ "$NOCVSSPEC" != "yes" ]; then
255         cd $SPECS_DIR
256
257         OPTIONS="up "
258
259         if [ -n "$CVSROOT" ]; then
260             OPTIONS="-d $CVSROOT $OPTIONS"
261         else
262             if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
263                 echo "warning: No cvs access defined - using local .spec file"
264                 NOCVSSPEC="yes"
265             fi
266         fi
267
268         if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
269             OPTIONS="$OPTIONS -A"
270         else
271             if [ -n "$CVSDATE" ]; then
272                 OPTIONS="$OPTIONS -D $CVSDATE"
273             fi
274             if [ -n "$CVSTAG" ]; then
275                 OPTIONS="$OPTIONS -r $CVSTAG"
276             fi
277         fi
278
279         result=1
280         retries_counter=0
281         while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
282             retries_counter=$(( $retries_counter + 1 ))
283             output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
284             result=$?
285             [ -n "$output" ] && echo "$output"
286             if [ "$result" -ne "0" ]; then
287                 if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out)") && [ "$retries_counter" -le "$CVS_RETRIES" ]; then
288                     echo "Trying again [$SPECFILE]... ($retries_counter)"
289                     sleep 2
290                     continue
291                  fi
292                 Exit_error err_no_spec_in_repo;
293             fi
294         done
295     fi
296     if [ ! -f "$SPECFILE" ]; then
297         Exit_error err_no_spec_in_repo;
298     fi
299
300     if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
301         chmod $CHMOD_MODE $SPECFILE
302     fi
303     unset OPTIONS
304     grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
305 }
306
307 find_mirror(){
308
309     cd "$SPECS_DIR"
310     url="$1"
311     if [ ! -f "mirrors" ] ; then
312         cvs update mirrors >&2
313     fi
314
315     IFS="|"
316     while read origin mirror name rest; do
317         ol=`echo -n "$origin"|wc -c`
318         prefix="`echo -n "$url" | head -c $ol`"
319         if [ "$prefix" = "$origin" ] ; then
320             suffix="`echo "$url"|cut -b $ol-`"
321             echo -n "$mirror$suffix"
322             return 0
323         fi
324     done < mirrors
325     echo "$url"
326 }
327
328 src_no ()
329 {
330     cd $SPECS_DIR
331     $RPMBUILD -bp  $BCOND --define 'prep %dump' $SPECFILE 2>&1 | \
332        grep "SOURCEURL[0-9]*[   ]*$1""[         ]*$" | \
333        sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
334        xargs
335 }
336
337 src_md5 ()
338 {
339     no=$(src_no "$1")
340     [ -z "$no" ] && return
341     cd $SPECS_DIR
342     grep -i "#[        ]*Source$no-md5[        ]*:" $SPECFILE | sed -e 's/.*://' | xargs
343 }
344
345 distfiles_url ()
346 {
347     echo "$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')"
348 }
349
350 get_files()
351 {
352     GET_FILES="$@"
353
354     if [ -n "$DEBUG" ]; then
355         set -x;
356         set -v;
357     fi
358
359     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
360         cd $SOURCE_DIR
361
362         OPTIONS="up "
363         if [ -n "$CVSROOT" ]; then
364             OPTIONS="-d $CVSROOT $OPTIONS"
365         else
366             if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
367                 echo "warning: No cvs access defined for SOURCES"
368                 NOCVS="yes"
369             fi
370         fi
371        if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
372             OPTIONS="$OPTIONS -A"
373         else
374             if [ -n "$CVSDATE" ]; then
375                 OPTIONS="$OPTIONS -D $CVSDATE"
376             fi
377             if [ -n "$CVSTAG" ]; then
378                 OPTIONS="$OPTIONS -r $CVSTAG"
379             fi
380         fi
381         for i in $GET_FILES; do
382             if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]; then
383                 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
384                     echo "Warning: no URL given for $i"
385                 fi
386
387                 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
388                     if [ "$(src_md5 "$i")" = "$(md5sum $(nourl "$i")|sed -e 's/ [^$]\+//')" ]; then
389                         echo "$(nourl "$i") having proper md5sum already exists"
390                         continue
391                     fi
392                     target=$(nourl "$i")
393                     url=$(distfiles_url "$i")
394                     if [ -z "$NOMIRRORS" ] ; then
395                         url="`find_mirror "$url"`"
396                     fi
397                     ${GETURI} -O "$target" "$url" || \
398                         if [ `echo $url | grep -E 'ftp://'` ]; then
399                             ${GETURI2} -O "$target" "$url"
400                         fi
401                 elif [ -z "$NOCVS" ]|| [ `echo $i | grep -vE '(ftp|http|https)://'` ]; then
402                     result=1
403                     retries_counter=0
404                     while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
405                         retries_counter=$(( $retries_counter + 1 ))
406                         output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
407                         result=$?
408                         [ -n "$output" ] && echo "$output"
409                         if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out)") && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then
410                                 echo "Trying again [`nourl $i`]... ($retries_counter)"
411                                 sleep 2
412                                 continue
413                         else
414                                 break
415                         fi
416                     done
417                 fi
418
419                 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
420                     if [ -z "$NOMIRRORS" ] ; then
421                         i="`find_mirror "$i"`"
422                     fi
423                     ${GETURI} "$i" || \
424                         if [ `echo $i | grep -E 'ftp://'` ]; then ${GETURI2} "$i" ; fi
425 #                   echo -n "#Source$(src_no $i)-md5:   " >> $SPECS_DIR/$SPECFILE.md5
426 #                   md5sum `echo $i | perl -ne '/.*\/(.*)/; print "$1\n"'` | cut -f1 -d' ' >> $SPECS_DIR/$SPECFILE.md5
427                 fi
428
429                 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
430                     Exit_error err_no_source_in_repo $i;
431                 fi
432             fi
433         done
434
435         if [ "$CHMOD" = "yes" ]; then
436             CHMOD_FILES="`nourl $GET_FILES`"
437             if [ -n "$CHMOD_FILES" ]; then
438                 chmod $CHMOD_MODE $CHMOD_FILES
439             fi
440         fi
441         unset OPTIONS
442     fi
443 }
444
445 tag_files()
446 {
447     TAG_FILES="$@"
448
449     if [ -n "$DEBUG" ]; then
450         set -x;
451         set -v;
452     fi
453
454     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
455         echo $PACKAGE_VERSION
456         echo $PACKAGE_RELEASE
457         TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
458         if [ "$TAG_VERSION" = "yes" ]; then
459             echo "CVS tag: $TAGVER"
460         fi
461         if [ -n "$TAG" ]; then
462             echo "CVS tag: $TAG"
463         fi
464
465         OPTIONS="tag -F"
466         if [ -n "$CVSROOT" ]; then
467             OPTIONS="-d $CVSROOT $OPTIONS"
468         fi
469
470         cd $SOURCE_DIR
471         for i in $TAG_FILES; do
472             if [ -f `nourl $i` ]; then
473                 if [ "$TAG_VERSION" = "yes" ]; then
474                     cvs $OPTIONS $TAGVER `nourl $i`
475                 fi
476                 if [ -n "$TAG" ]; then
477                     cvs $OPTIONS $TAG `nourl $i`
478                 fi
479             else
480                 Exit_error err_no_source_in_repo $i
481             fi
482         done
483
484         cd $SPECS_DIR
485         if [ "$TAG_VERSION" = "yes" ]; then
486             cvs $OPTIONS $TAGVER $SPECFILE
487         fi
488         if [ -n "$TAG" ]; then
489             cvs $OPTIONS $TAG $SPECFILE
490         fi
491
492         unset OPTIONS
493     fi
494 }
495
496 branch_files()
497 {
498     TAG=$1
499     echo "CVS branch tag: $TAG"
500     shift;
501
502     TAG_FILES="$@"
503
504     if [ -n "$DEBUG" ]; then
505         set -x;
506         set -v;
507     fi
508
509     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
510
511         OPTIONS="tag -b"
512         if [ -n "$CVSROOT" ]; then
513             OPTIONS="-d $CVSROOT $OPTIONS"
514         fi
515         cd $SOURCE_DIR
516         for i in $TAG_FILES; do
517             if [ -f `nourl $i` ]; then
518                 cvs $OPTIONS $TAG `nourl $i`
519             else
520                 Exit_error err_no_source_in_repo $i
521             fi
522         done
523         cd $SPECS_DIR
524         cvs $OPTIONS $TAG $SPECFILE
525
526         unset OPTIONS
527     fi
528 }
529
530
531
532 build_package()
533 {
534     if [ -n "$DEBUG" ]; then
535         set -x;
536         set -v;
537     fi
538
539     cd $SPECS_DIR
540
541     if [ -n "$TRY_UPGRADE" ]; then
542
543         if [ -n "FLOAT_VERSION" ]; then
544             TNOTIFY=`./pldnotify.awk $SPECFILE -n`
545         else
546             TNOTIFY=`./pldnotify.awk $SPECFILE`
547         fi
548
549         TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
550
551         if [ -n "$TNEWVER" ]; then
552
553             TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
554
555             echo "New version found, updating spec file to version " $TNEWVER
556
557             cp -f $SPECFILE $SPECFILE.bak
558
559             chmod +w $SPECFILE
560
561             eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
562             eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
563
564             parse_spec;
565
566             get_files "$SOURCES $PATCHES";
567
568             unset TOLDVER TNEWVER TNOTIFY
569         fi
570
571     fi
572
573
574     cd $SPECS_DIR
575
576     case "$COMMAND" in
577         build )
578             BUILD_SWITCH="-ba" ;;
579         build-binary )
580             BUILD_SWITCH="-bb" ;;
581         build-source )
582             BUILD_SWITCH="-bs --nodeps" ;;
583     esac
584     if [ -n "$LOGFILE" ]; then
585         if [ -n "$CVSTAG" ]; then
586             LTAG="r_`echo $CVSTAG|sed -e 's/\./_/g'`_"
587         else
588             LTAG=""
589         fi
590         LOG=`eval echo $LOGFILE`
591         if [ -n "$LASTLOG_FILE" ]; then
592             echo "LASTLOG=$LOG" > $LASTLOG_FILE
593         fi
594         RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
595         (nice -n ${DEF_NICE_LEVEL} time $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
596         RETVAL=`cat $RES_FILE`
597         rm $RES_FILE
598         if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
599             if [ "$RETVAL" -eq "0" ]; then
600                 mv $LOG $LOGDIROK
601             else
602                 mv $LOG $LOGDIRFAIL
603             fi
604         fi
605     else
606         eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
607         RETVAL=$?
608     fi
609
610     if [ "$RETVAL" -ne "0" ]; then
611
612         if [ -n "$TRY_UPGRADE" ]; then
613             echo "\n!!! Package with new version cannot be build automagically\n"
614             mv -f $SPECFILE.bak $SPECFILE
615         fi
616
617         Exit_error err_build_fail;
618     fi
619
620     unset BUILD_SWITCH
621 }
622
623 nourl()
624 {
625     echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
626 }
627 #---------------------------------------------
628 # main()
629
630 if [ "$#" = 0 ]; then
631     usage;
632     exit 1
633 fi
634
635 while test $# -gt 0 ; do
636     case "${1}" in
637         -D | --debug )
638             DEBUG="yes"; shift ;;
639         -V | --version )
640             COMMAND="version"; shift ;;
641         -a | --as_anon )
642             CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
643         -b | -ba | --build )
644             COMMAND="build"; shift ;;
645         -bb | --build-binary )
646             COMMAND="build-binary"; shift ;;
647         -bs | --build-source )
648             COMMAND="build-source"; shift ;;
649         -B | --branch )
650             COMMAND="branch"; shift; TAG="${1}"; shift;;
651         -c | --clean )
652             CLEAN="--clean --rmspec --rmsource"; shift ;;
653         -d | --cvsroot )
654             shift; CVSROOT="${1}"; shift ;;
655         -g | --get )
656             COMMAND="get"; shift ;;
657         -h | --help )
658             COMMAND="usage"; shift ;;
659         -l | --logtofile )
660             shift; LOGFILE="${1}"; shift ;;
661         -ni| --nice )
662             shift; DEF_NICE_LEVEL=${1}; shift ;;
663         -m | --mr-proper )
664             COMMAND="mr-proper"; shift ;;
665         -nc | --no-cvs )
666             NOCVS="yes"; shift ;;
667         -ncs | --no-cvs-specs )
668             NOCVSSPEC="yes"; shift ;;
669         -nd | --no-distfiles )
670             NODIST="yes"; shift ;;
671         -nm | --no-mirrors )
672             NOMIRRORS="yes"; shift ;;
673         -nu | --no-urls )
674             NOURLS="yes"; shift ;;
675         -ns | --no-srcs )
676             NOSRCS="yes"; shift ;;
677         -ns0 | --no-source0 )
678             NOSOURCE0="yes"; shift ;;
679         --opts )
680             shift; RPMOPTS="${1}"; shift ;;
681         --with | --without )
682             BCOND="$BCOND $1 $2" ; shift 2 ;;
683         -q | --quiet )
684             QUIET="--quiet"; shift ;;
685         --date )
686             CVSDATE="${2}"; shift 2 ;;
687         -r | --cvstag )
688             shift; CVSTAG="${1}"; shift ;;
689         -Tvs | --tag-version-stable )
690             COMMAND="tag";
691             TAG="STABLE"
692             TAG_VERSION="yes"
693             shift;;
694         -Tvn | --tag-version-nest )
695             COMMAND="tag";
696             TAG="NEST"
697             TAG_VERSION="yes"
698             shift;;
699         -Ts | --tag-stable )
700             COMMAND="tag";
701             TAG="STABLE"
702             TAG_VERSION="no"
703             shift;;
704         -Tn | --tag-nest )
705             COMMAND="tag";
706             TAG="NEST"
707             TAG_VERSION="no"
708             shift;;
709         -Tv | --tag-version )
710             COMMAND="tag";
711             TAG=""
712             TAG_VERSION="yes"
713             shift;;
714         -T | --tag )
715             COMMAND="tag";
716             shift
717             TAG="$1"
718             TAG_VERSION="no"
719             shift;;
720         -v | --verbose )
721             BE_VERBOSE="1"; shift ;;
722         -u | --try-upgrade )
723             TRY_UPGRADE="1"; shift ;;
724         -un | --try-upgrade-with-float-version )
725             TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
726         --define)
727             shift
728             MACRO="${1}"
729             VALUE="${2}"
730             shift 2
731             RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
732             ;;
733         * )
734             SPECFILE="`basename ${1} .spec`.spec"; shift ;;
735     esac
736 done
737
738 if [ -n "$DEBUG" ]; then
739     set -x;
740     set -v;
741 fi
742
743 case "$COMMAND" in
744     "build" | "build-binary" | "build-source" )
745         init_builder;
746         if [ -n "$SPECFILE" ]; then
747             get_spec;
748             parse_spec;
749
750             if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
751                 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
752                 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
753                 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
754
755                 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
756                     Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
757                 fi
758             fi
759
760             if [ -n "$ICONS" ]; then
761                 get_files $ICONS;
762                 parse_spec;
763             fi
764             if [ -n "$NOSOURCE0" ] ; then
765                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
766             fi
767             get_files "$SOURCES $PATCHES";
768             build_package;
769         else
770             Exit_error err_no_spec_in_cmdl;
771         fi
772         ;;
773     "branch" )
774         init_builder;
775         if [ -n "$SPECFILE" ]; then
776                 get_spec;
777                 parse_spec;
778                 if [ -n "$ICONS" ]; then
779                         get_files $ICONS
780                         parse_spec;
781                 fi
782                 get_files $SOURCES $PATCHES;
783                 branch_files $TAG "$SOURCES $PATCHES $ICONS";
784         else
785                 Exit_error err_no_spec_in_cmdl;
786         fi
787         ;;
788     "get" )
789         init_builder;
790         if [ -n "$SPECFILE" ]; then
791             get_spec;
792             parse_spec;
793             if [ -n "$ICONS" ]; then
794                 get_files $ICONS
795                 parse_spec;
796             fi
797             if [ -n "$NOSOURCE0" ] ; then
798                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
799             fi
800             get_files $SOURCES $PATCHES
801         else
802             Exit_error err_no_spec_in_cmdl;
803         fi
804         ;;
805     "tag" )
806         init_builder;
807         if [ -n "$SPECFILE" ]; then
808             get_spec;
809             parse_spec;
810             if [ -n "$ICONS" ]; then
811                 get_files $ICONS
812                 parse_spec;
813             fi
814             get_files $SOURCES $PATCHES;
815             tag_files "$SOURCES $PATCHES $ICONS";
816         else
817             Exit_error err_no_spec_in_cmdl;
818         fi
819         ;;
820     "mr-proper" )
821         $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
822         ;;
823     "usage" )
824         usage;;
825     "version" )
826         echo "$VERSION";;
827 esac
828
829 cd $__PWD
This page took 0.146133 seconds and 4 git commands to generate.