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