]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - builder.sh
- don't use CVSROOT from the current environment, get it from builderrc
[packages/rpm-build-tools.git] / builder.sh
1 #!/bin/sh
2 # -----------
3 # $Id$
4 # Exit codes:
5 #       0 - succesful
6 #       1 - help displayed
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 #       6 - spec file with errors
12 #       7 - wrong source in /etc/poldek.conf
13
14 # Notes (todo):
15 #       - builder -u fetches current version first
16 #       - tries to get new version from distfiles without new md5
17 #       - after fetching new version doesn't update md5
18 #       - doesn't get sources for specs with %include /usr/lib/rpm/macros.python
19 #         when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway)
20 #       - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov
21 #       - when Icon: field is present, -5 and -a5 doesn't work
22
23 VERSION="\
24 Build package utility from PLD CVS repository
25 V 0.11 (C) 1999-2003 Free Penguins".
26 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
27
28 COMMAND="build"
29
30 SPECFILE=""
31 BE_VERBOSE=""
32 QUIET=""
33 CLEAN=""
34 DEBUG=""
35 NOURLS=""
36 NOCVS=""
37 NOCVSSPEC=""
38 NODIST=""
39 UPDATE=""
40 UPDATE5=""
41 ADD5=""
42 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
43 CVSROOT=""
44 # Example: LOGFILE='../log.$PACKAGE_NAME'
45 # Yes, you can use variable name! Note _single_ quotes!
46 LOGFILE=''
47
48 LOGDIR=""
49 LOGDIROK=""
50 LOGDIRFAIL=""
51 LASTLOG_FILE=""
52 CHMOD="no"
53 CHMOD_MODE="0444"
54 RPMOPTS=""
55 BCOND=""
56 GROUP_BCONDS="no"
57
58 PATCHES=""
59 SOURCES=""
60 ICONS=""
61 PACKAGE_RELEASE=""
62 PACKAGE_VERSION=""
63 PACKAGE_NAME=""
64 PROTOCOL="ftp"
65 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
66 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
67
68 CVSTAG=""
69 RES_FILE=""
70
71 CVS_SERVER="cvs.pld-linux.org"
72 DISTFILES_SERVER="://distfiles.pld-linux.org"
73
74 DEF_NICE_LEVEL=0
75
76 FAIL_IF_NO_SOURCES="yes"
77
78 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
79 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
80
81 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
82 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
83 GETLOCAL="cp -a"
84
85 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
86     RPM="rpm"
87     RPMBUILD="rpm"
88 else
89     RPM="rpm"
90     RPMBUILD="rpmbuild"
91 fi
92
93 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
94 POLDEK_SOURCE="cvs"
95
96 # Example grep cvs /etc/poldek.conf:
97 # source = cvs /home/users/yoshi/rpm/RPMS/
98 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
99         POLDEK_SOURCE_VALIDITY="`grep ${POLDEK_SOURCE} /etc/poldek.conf|grep -v ^#`"
100         if [ "${POLDEK_SOURCE_VALIDITY}" = "" ]; then 
101                 echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf"
102                 echo "Fix it and try to contiune"
103                 exit 7
104         fi
105 fi
106
107 if [ -f ~/etc/builderrc ]; then
108     . ~/etc/builderrc
109 fi
110
111 if [ -n "$HOME_ETC" ]; then
112     USER_CFG=$HOME_ETC/.builderrc
113 else
114     USER_CFG=~/.builderrc
115 fi
116
117 [ -f $USER_CFG ] && . $USER_CFG        
118
119 #---------------------------------------------
120 # functions
121
122 usage()
123 {
124     if [ -n "$DEBUG" ]; then set -xv; fi
125     echo "\
126 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
127
128         [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
129         [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
130         [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
131         [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
132         [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
133         [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version] 
134         [{-Tp|--tag-prefix} <prefix>]
135         [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
136         [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
137
138         -5, --update-md5
139                         - update md5 comments in spec, implies -nd -ncs
140         -a5, --add-md5  - add md5 comments to URL sources, implies -nc -nd -ncs
141         -D, --debug     - enable script debugging mode,
142         -V, --version   - output builder version
143         -a, --as_anon   - get files via pserver as cvs@$CVS_SERVER,
144         -b, -ba,
145         --build         - get all files from CVS repo or HTTP/FTP and build
146                           package from <package>.spec,
147         -bb, --build-binary
148                         - get all files from CVS repo or HTTP/FTP and build
149                           binary only package from <package>.spec,
150         -bs,
151         --build-source  - get all files from CVS repo or HTTP/FTP and only
152                           pack them into src.rpm,
153         -bp, --build-prep
154                         - execute the %prep phase of <package>.spec,
155         -B, --branch    - add branch
156         -c, --clean     - clean all temporarily created files (in BUILD,
157                           SOURCES, SPECS and \$RPM_BUILD_ROOT),
158         -d <cvsroot>, --cvsroot <cvsroot>
159                         - setup \$CVSROOT,
160         --define <macro> <value>
161                         - define a macro <macro> with value <value>,
162         --nodeps        - rpm won't check any dependences
163         -g, --get       - get <package>.spec and all related files from
164                           CVS repo or HTTP/FTP,
165         -h, --help      - this message,
166         --http          - use http instead of ftp,
167         -l <logfile>, --logtofile <logfile>
168                         - log all to file,
169         -m, --mr-proper - only remove all files related to spec file and
170                           all work resources,
171         -nc, --no-cvs   - don't download sources from CVS, if source URL is
172                           given,
173         -ncs, --no-cvs-specs
174                         - don't check specs in CVS
175         -nd, --no-distfiles
176                         - don't download from distfiles
177         -nm, --no-mirrors - don't download from mirror, if source URL is given,
178         -nu, --no-urls  - don't try to download from FTP/HTTP location,
179         -ns, --no-srcs  - don't download Sources
180         -ns0, --no-source0
181                         - don't download Source0
182         --opts <rpm opts>
183                         - additional options for rpm
184         -q, --quiet     - be quiet,
185         --date yyyy-mm-dd
186                         - build package using resources from specified CVS
187                           date,
188         -r <cvstag>, --cvstag <cvstag>
189                         - build package using resources from specified CVS
190                           tag,
191         -R, --fetch-build-requires
192                         - fetch what is BuildRequired,
193         -RB, --remove-build-requires
194                         - remove all you fetched with -R or --fetch-build-requires
195                           remember, this option requires confirmation,
196         -FRB, --force-remove-build-requires
197                         - remove all you fetched with -R or --fetch-build-requires
198                           remember, this option works without confirmation,
199         -T <cvstag> , --tag <cvstag>
200                         - add cvs tag <cvstag> for files,
201         -Tvs, --tag-version-stable
202                         - add cvs tags STABLE and NAME-VERSION-RELESE for files,
203         -Tvn, --tag-version-nest
204                         - add cvs tags NEST and NAME-VERSION-RELESE for files,
205         -Ts, --tag-stable
206                         - add cvs tag STABLE for files,
207         -Tn, --tag-nest
208                         - add cvs tag NEST for files,
209         -Tv, --tag-version
210                         - add cvs tag NAME-VERSION-RELESE for files,
211         -Tp, --tag-prefix <prefix>
212                         - add <prefix> to NAME-VERSION-RELEASE tags,
213         -v, --verbose   - be verbose,
214         -u, --try-upgrade
215                         - check version, and try to upgrade package
216         -un, --try-upgrade-with-float-version
217                         - as above, but allow float version
218         -U, --update
219                         - refetch sources, don't use distfiles, and update md5 
220                           comments
221         -Upi, --update-poldek-indexes 
222                         - refresh or make poldek package index files.
223         --with/--without <feature>
224                         - conditional build package depending on
225                           %_with_<feature>/%_without_<feature> macro
226                           switch. 
227                           You may now use --with feat1 feat2 feat3 --without feat4
228                           feat5 --with feat6 constructions.
229 "
230 }
231
232 cache_rpm_dump () {
233    rpm_dump_cache=`
234         case "$RPMBUILD" in
235         rpm )
236                 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1 
237                 ;;
238         rpmbuild )
239                 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1 
240                 ;;
241         esac`
242 }
243
244 rpm_dump () {
245     if [ -z "$rpm_dump_cache" ] ; then
246         echo "internal error: cache_rpm_dump not called!" 1>&2
247     fi
248     echo "$rpm_dump_cache"
249 }
250
251 parse_spec()
252 {
253     if [ -n "$DEBUG" ]; then
254         set -x;
255         set -v;
256     fi
257
258     cd $SPECS_DIR
259
260     cache_rpm_dump
261
262     if [ "$NOSRCS" != "yes" ]; then
263         SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
264     fi
265     if (rpm_dump | grep -qEi ":.*nosource.*1"); then
266         FAIL_IF_NO_SOURCES="no"
267     fi
268
269     PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
270     ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
271     PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
272     PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
273     PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
274
275     if [ -n "$BE_VERBOSE" ]; then
276         echo "- Sources :  `nourl $SOURCES`"
277         if [ -n "$PATCHES" ]; then
278             echo "- Patches :  `nourl $PATCHES`"
279         else
280             echo "- Patches :  *no patches needed*"
281         fi
282         if [ -n "$ICONS" ]; then
283             echo "- Icon    :  `nourl $ICONS`"
284         else
285             echo "- Icon    :  *no package icon*"
286         fi
287         echo "- Name    : $PACKAGE_NAME"
288         echo "- Version : $PACKAGE_VERSION"
289         echo "- Release : $PACKAGE_RELEASE"
290     fi
291 }
292
293 Exit_error()
294 {
295     if [ -n "$DEBUG" ]; then
296         set -x;
297         set -v;
298     fi
299
300     cd $__PWD
301
302     case "$1" in
303     "err_no_spec_in_cmdl" )
304         remove_build_requires
305         echo "ERROR: spec file name not specified.";
306         exit 2 ;;
307     "err_no_spec_in_repo" )
308         remove_build_requires
309         echo "Error: spec file not stored in CVS repo.";
310         exit 3 ;;
311     "err_no_source_in_repo" )
312         remove_build_requires
313         echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
314         exit 4 ;;
315     "err_build_fail" )
316         remove_build_requires
317         echo "Error: package build failed. (${2:-no more info})";
318         exit 5 ;;
319     esac
320 }
321
322 init_builder()
323 {
324     if [ -n "$DEBUG" ]; then
325         set -x;
326         set -v;
327     fi
328
329     SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
330     SPECS_DIR="`$RPM --eval '%{_specdir}'`"
331
332     __PWD=`pwd`
333 }
334
335 get_spec()
336 {
337     if [ -n "$DEBUG" ]; then
338         set -x;
339         set -v;
340     fi
341
342     if [ "$NOCVSSPEC" != "yes" ]; then
343         cd $SPECS_DIR
344
345         OPTIONS="up "
346
347         if [ -n "$CVSROOT" ]; then
348             OPTIONS="-d $CVSROOT $OPTIONS"
349         else
350             if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
351                 echo "warning: No cvs access defined - using local .spec file"
352                 NOCVSSPEC="yes"
353             fi
354         fi
355
356         if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
357             OPTIONS="$OPTIONS -A"
358         else
359             if [ -n "$CVSDATE" ]; then
360                 OPTIONS="$OPTIONS -D $CVSDATE"
361             fi
362             if [ -n "$CVSTAG" ]; then
363                 OPTIONS="$OPTIONS -r $CVSTAG"
364             fi
365         fi
366
367         result=1
368         retries_counter=0
369         while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
370             retries_counter=$(( $retries_counter + 1 ))
371             output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
372             result=$?
373             [ -n "$output" ] && echo "$output"
374             if [ "$result" -ne "0" ]; then
375                 if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$retries_counter" -le "$CVS_RETRIES" ]; then
376                     echo "Trying again [$SPECFILE]... ($retries_counter)"
377                     sleep 2
378                     continue
379                 fi
380                 Exit_error err_no_spec_in_repo;
381             fi
382         done
383     fi
384     if [ ! -f "$SPECFILE" ]; then
385         Exit_error err_no_spec_in_repo;
386     fi
387
388     if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
389         chmod $CHMOD_MODE $SPECFILE
390     fi
391     unset OPTIONS
392     grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
393 }
394
395 find_mirror(){
396
397     cd "$SPECS_DIR"
398     url="$1"
399     if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
400         cvs update mirrors >&2
401     fi
402
403     IFS="|"
404     while read origin mirror name rest; do
405         ol=`echo -n "$origin"|wc -c`
406         prefix="`echo -n "$url" | head -c $ol`"
407         if [ "$prefix" = "$origin" ] ; then
408             suffix="`echo "$url"|cut -b $ol-`"
409             echo -n "$mirror$suffix"
410             return 0
411         fi
412     done < mirrors
413     echo "$url"
414 }
415
416 src_no ()
417 {
418     cd $SPECS_DIR
419     rpm_dump | \
420         grep "SOURCEURL[0-9]*[  ]*$1""[         ]*$" | \
421         sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
422         head -1 | xargs
423 }
424
425 src_md5 ()
426 {
427     no=$(src_no "$1")
428     [ -z "$no" ] && return
429     cd $SPECS_DIR
430     spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
431     if [ -z "$spec_rev" ]; then
432         spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
433     fi
434     spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
435     md5=$(grep -s -v '^#' additional-md5sums | \
436         grep -E "[      ]$(basename "$1")[      ]+${spec}([     ,]|\$)" | \
437         sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
438         grep -E '^[0-9a-f]{32}$')
439     if [ X"$md5" = X"" ] ; then
440         grep -i "#[     ]*Source$no-md5[        ]*:" $SPECFILE | sed -e 's/.*://' | xargs
441     else
442         if [ $(echo "$md5" | wc -l) != 1 ] ; then
443             echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
444         fi
445         echo "$md5" | tail -1
446     fi
447 }
448
449 distfiles_url ()
450 {
451     echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
452 }
453
454 good_md5 ()
455 {
456     md5=$(src_md5 "$1")
457     [ "$md5" = "" ] || \
458     [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
459 }
460
461 get_files()
462 {
463     GET_FILES="$@"
464
465     if [ -n "$DEBUG" ]; then
466         set -x;
467         set -v;
468     fi
469
470     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
471         cd $SOURCE_DIR
472
473         OPTIONS="up "
474         if [ -n "$CVSROOT" ]; then
475             OPTIONS="-d $CVSROOT $OPTIONS"
476         else
477             if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
478                 echo "warning: No cvs access defined for SOURCES"
479                 NOCVS="yes"
480             fi
481         fi
482         if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
483             OPTIONS="$OPTIONS -A"
484         else
485             if [ -n "$CVSDATE" ]; then
486                 OPTIONS="$OPTIONS -D $CVSDATE"
487             fi
488             if [ -n "$CVSTAG" ]; then
489                 OPTIONS="$OPTIONS -r $CVSTAG"
490             fi
491         fi
492         for i in $GET_FILES; do
493             if [ -n "$UPDATE5" ]; then
494                 if [ -n "$ADD5" ]; then
495                     [ `nourl $i` = "$i" ] && continue
496                     grep -qiE '^#[      ]*Source'$(src_no $i)'-md5[     ]*:' $SPECS_DIR/$SPECFILE && continue
497                 else
498                     grep -qiE '^#[      ]*Source'$(src_no $i)'-md5[     ]*:' $SPECS_DIR/$SPECFILE || continue
499                 fi
500             fi
501             FROM_DISTFILES=0
502             if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
503                 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
504                     echo "Warning: no URL given for $i"
505                 fi
506
507                 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
508                     if good_md5 "$i"; then
509                         echo "$(nourl "$i") having proper md5sum already exists"
510                         continue
511                     fi
512                     target=$(nourl "$i")
513                     url=$(distfiles_url "$i")
514                     if [ `echo $url | grep -E '^(\.|/)'` ]; then
515                         ${GETLOCAL} $url $target
516                     else
517                         FROM_DISTFILES=1
518                         if [ -z "$NOMIRRORS" ]; then
519                             url="`find_mirror "$url"`"
520                         fi
521                         ${GETURI} -O "$target" "$url" || \
522                             if [ `echo $url | grep -E 'ftp://'` ]; then
523                                 ${GETURI2} -O "$target" "$url"
524                             fi
525                         if ! test -s "$target"; then
526                             rm -f "$target"
527                             FROM_DISTFILES=0
528                         fi
529                     fi
530                 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
531                     # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
532                     result=1
533                     retries_counter=0
534                     while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
535                         retries_counter=$(( $retries_counter + 1 ))
536                         output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
537                         result=$?
538                         [ -n "$output" ] && echo "$output"
539                         if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then
540                                 echo "Trying again [`nourl $i`]... ($retries_counter)"
541                                 sleep 2
542                                 continue
543                         else
544                                 break
545                         fi
546                     done
547                 fi
548
549                 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
550                     if [ -z "$NOMIRRORS" ]; then
551                         im="`find_mirror "$i"`"
552                     else
553                         im="$i"
554                     fi
555                     ${GETURI} "$im" || \
556                         if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi
557                 fi
558
559
560             fi
561             srcno=$(src_no $i)
562             if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
563                 Exit_error err_no_source_in_repo $i;
564             elif [ -n "$UPDATE5" ] && \
565                 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
566                     [ -z "$(grep -E -i '^NoSource[      ]*:[    ]*'$i'([        ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
567                 grep -q -i -E '^#[      ]*source'$(src_no $i)'-md5[     ]*:' $SPECS_DIR/$SPECFILE )
568             then
569                 echo "Updating source-$srcno md5."
570                 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
571                 perl -i -ne '
572                                 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
573                                 print "# Source'$srcno'-md5:\t'$md5'\n" 
574                                         if /^Source'$srcno'\s*:\s+/;
575                                 ' \
576                                 $SPECS_DIR/$SPECFILE
577             fi
578
579             if good_md5 "$i"; then
580                 :
581             elif [ "$FROM_DISTFILES" = 1 ]; then
582                 # wrong md5 from distfiles: remove the file and try again
583                 # but only once ...
584                 echo "MD5 sum mismatch. Trying full fetch."
585                 FROM_DISTFILES=2
586                 rm -f $target
587                 ${GETURI} -O "$target" "$url" || \
588                     if [ `echo $url | grep -E 'ftp://'` ]; then
589                         ${GETURI2} -O "$target" "$url"
590                     fi
591                 test -s "$target" || rm -f "$target"
592             fi
593
594             if good_md5 "$i"; then
595                 :
596             else
597                 echo "MD5 sum mismatch.  Use -U to refetch sources,"
598                 echo "or -5 to update md5 sums, if you're sure files are correct."
599                 Exit_error err_no_source_in_repo $i
600             fi
601         done
602
603         if [ "$CHMOD" = "yes" ]; then
604             CHMOD_FILES="`nourl $GET_FILES`"
605             if [ -n "$CHMOD_FILES" ]; then
606                 chmod $CHMOD_MODE $CHMOD_FILES
607             fi
608         fi
609         unset OPTIONS
610     fi
611 }
612
613 tag_files()
614 {
615     TAG_FILES="$@"
616
617     if [ -n "$DEBUG" ]; then
618         set -x;
619         set -v;
620     fi
621
622     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
623         echo "Version: $PACKAGE_VERSION"
624         echo "Release: $PACKAGE_RELEASE"
625         # Check whether first character of PACKAGE_NAME is legal for tag name
626         if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
627             TAG_PREFIX=tag_
628         fi
629         TAGVER=$TAG_PREFIX$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
630         # Remove #kernel.version_release from TAGVER because tagging sources
631         # could occur with different kernel-headers than kernel-headers used at build time.
632         TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
633         if [ "$TAG_VERSION" = "yes" ]; then
634             echo "CVS tag: $TAGVER"
635         fi
636         if [ -n "$TAG" ]; then
637             echo "CVS tag: $TAG"
638         fi
639
640         OPTIONS="tag -F"
641         if [ -n "$CVSROOT" ]; then
642             OPTIONS="-d $CVSROOT $OPTIONS"
643         fi
644
645         cd $SOURCE_DIR
646         for i in $TAG_FILES; do
647             # don't tag non cvs files (ie. stored on distfiles)
648             [ "`nourl $i`" != "$i" ] && continue
649             if [ -f "`nourl $i`" ]; then
650                 if [ "$TAG_VERSION" = "yes" ]; then
651                     cvs $OPTIONS $TAGVER `nourl $i`
652                 fi
653                 if [ -n "$TAG" ]; then
654                     cvs $OPTIONS $TAG `nourl $i`
655                 fi
656             else
657                 Exit_error err_no_source_in_repo $i
658             fi
659         done
660
661         cd $SPECS_DIR
662         if [ "$TAG_VERSION" = "yes" ]; then
663             cvs $OPTIONS $TAGVER $SPECFILE
664         fi
665         if [ -n "$TAG" ]; then
666             cvs $OPTIONS $TAG $SPECFILE
667         fi
668
669         unset OPTIONS
670     fi
671 }
672
673 branch_files()
674 {
675     TAG=$1
676     echo "CVS branch tag: $TAG"
677     shift;
678
679     TAG_FILES="$@"
680
681     if [ -n "$DEBUG" ]; then
682         set -x;
683         set -v;
684     fi
685
686     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
687
688         OPTIONS="tag -b"
689         if [ -n "$CVSROOT" ]; then
690             OPTIONS="-d $CVSROOT $OPTIONS"
691         fi
692         cd $SOURCE_DIR
693         for i in $TAG_FILES; do
694             if [ -f `nourl $i` ]; then
695                 cvs $OPTIONS $TAG `nourl $i`
696             else
697                 Exit_error err_no_source_in_repo $i
698             fi
699         done
700         cd $SPECS_DIR
701         cvs $OPTIONS $TAG $SPECFILE
702
703         unset OPTIONS
704     fi
705 }
706
707
708
709 build_package()
710 {
711     if [ -n "$DEBUG" ]; then
712         set -x;
713         set -v;
714     fi
715
716     cd $SPECS_DIR
717
718     if [ -n "$TRY_UPGRADE" ]; then
719
720         if [ -n "$FLOAT_VERSION" ]; then
721             TNOTIFY=`./pldnotify.awk $SPECFILE -n`
722         else
723             TNOTIFY=`./pldnotify.awk $SPECFILE`
724         fi
725
726         TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
727
728         if [ -n "$TNEWVER" ]; then
729
730             TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
731
732             echo "New version found, updating spec file to version " $TNEWVER
733
734             cp -f $SPECFILE $SPECFILE.bak
735
736             chmod +w $SPECFILE
737
738             eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
739             eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
740
741             parse_spec;
742
743             get_files "$SOURCES $PATCHES";
744
745             unset TOLDVER TNEWVER TNOTIFY
746         fi
747
748     fi
749
750
751     cd $SPECS_DIR
752
753     case "$COMMAND" in
754         build )
755             BUILD_SWITCH="-ba" ;;
756         build-binary )
757             BUILD_SWITCH="-bb" ;;
758         build-source )
759             BUILD_SWITCH="-bs --nodeps" ;;
760         build-prep )
761             BUILD_SWITCH="-bp --nodeps" ;;
762     esac
763     if [ -n "$LOGFILE" ]; then
764         LOG=`eval echo $LOGFILE`
765         if [ -n "$LASTLOG_FILE" ]; then
766             echo "LASTLOG=$LOG" > $LASTLOG_FILE
767         fi
768         RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
769         (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
770         RETVAL=`cat $RES_FILE`
771         rm $RES_FILE
772         if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
773             if [ "$RETVAL" -eq "0" ]; then
774                 mv $LOG $LOGDIROK
775             else
776                 mv $LOG $LOGDIRFAIL
777             fi
778         fi
779     else
780         eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
781         RETVAL=$?
782     fi
783
784     if [ "$RETVAL" -ne "0" ]; then
785
786         if [ -n "$TRY_UPGRADE" ]; then
787             echo "\n!!! Package with new version cannot be build automagically\n"
788             mv -f $SPECFILE.bak $SPECFILE
789         fi
790
791         Exit_error err_build_fail;
792     fi
793
794     unset BUILD_SWITCH
795 }
796
797 nourl()
798 {
799     echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
800 }
801
802 set_bconds_values()
803 {
804 AVAIL_BCONDS_WITHOUT=""
805 AVAIL_BCONDS_WITH=""
806 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
807 do
808         AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
809         if [ "`echo $BCOND|grep -- "--without $AVAIL_BCOND_WITHOUT"`" != "" ];then
810                 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
811         else
812                 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
813         fi
814 done
815
816 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
817 do
818         AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
819         if [ "`echo $BCOND|grep -- "--with $AVAIL_BCOND_WITH"`" != "" ];then
820                 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
821         else
822                 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
823         fi
824 done
825 }
826
827 remove_build_requires()
828 {
829     if [ "$INSTALLED_PACKAGES" != "" ]; then
830             case "$REMOVE_BUILD_REQUIRES" in
831                     "force")
832                         poldek --noask -e $INSTALLED_PACKAGES
833                     ;;
834                     "nice")
835                         poldek --ask -e $INSTALLED_PACKAGES
836                     ;;
837                     *)
838                             echo You may want to manually remove following BuildRequires fetched:
839                             echo $INSTALLED_PACKAGES
840                             echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
841                     ;;
842             esac
843     fi
844 }
845
846 display_bconds()
847 {
848 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
849         echo -ne "We are going to build $SPECFILE with the following conditional flags:\n"
850         if [ "$BCOND" != "" ]; then
851                 echo -ne "$BCOND"
852         else
853                 echo -ne "No --with || --without conditions passed to $0!"
854         fi
855         echo -ne "\n\nfrom available:\n\n"
856         echo -ne "--with   :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
857 fi
858 }
859
860 fetch_build_requires()
861 {
862 if [ "$FETCH_BUILD_REQUIRES" = "yes" ]; then
863             echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
864             echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
865             echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
866             echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
867             echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
868             for package_item in `cat $SPECFILE|grep -B100000 ^%changelog|grep -v ^#|grep BuildRequires|grep -v ^-|sed -e "s/^.*BuildRequires://g"|awk '{print $1}'|sed -e s,\(.*\),,g -e s,%{,,g`
869             do
870                 package_item=`echo $package_item|sed -e s,rpmbuild,rpm-build,g`
871                 GO="yes"
872                 package=`basename "$package_item"|sed -e "s/}$//g"`
873                 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
874                 mach=`uname -m`
875                 
876                 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
877                 if [ "`echo $COND_TST|grep '^BuildRequires:'`" != "" ]; then
878                         if [ "$COND_ARCH_TST" != "" ] && [ "`echo $COND_ARCH_TST|sed -e "s/i.86/ix86/g"`" != "`echo $mach|sed -e "s/i.86/ix86/g"`" ]; then
879                                 GO="yes"
880                         fi
881                 # bcond:
882                 else
883                         COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
884                         GO=""
885                         # %{without}
886                         if [ "`echo $COND_TST|grep 'without_'`" != "" ]; then
887                                 COND_NAME=`echo $COND_NAME|sed -e s,^.*_without_,,g`
888                                 if [ "`echo $COND_TST|grep !`" != "" ]; then
889                                         COND_STATE="with"
890                                 else
891                                         COND_STATE="wout"
892                                 fi
893                                 if [ "`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`" != "" ]; then
894                                         COND_ARGV="wout"
895                                 else
896                                         COND_ARGV="with"
897                                 fi
898                         # %{with}
899                         elif [ "`echo $COND_TST|grep 'with_'`" != "" ]; then
900                                 COND_NAME=`echo $COND_NAME|sed -e s,^.*_with_,,g`
901                                 if [ "`echo $COND_TST|grep !`" != "" ]; then
902                                         COND_STATE="wout"
903                                 else
904                                         COND_STATE="with"
905                                 fi                                      
906                                 if [ "`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`" != "" ]; then
907                                         COND_ARGV="with"
908                                 else
909                                         COND_ARGV="wout"
910                                 fi      
911                         fi
912                         RESULT="${COND_STATE}-${COND_ARGV}"
913                         case "$RESULT" in 
914                                 "with-wout" | "wout-with" )
915                                         GO=""
916                                         ;;
917                                 "wout-wout" | "with-with" )
918                                         GO="yes"
919                                         ;;
920                                 * )
921                                         echo "Action '$RESULT' was not defined for package '$package_item'"
922                                         ;;
923                         esac
924
925                 fi
926                
927                 if [ "$GO" = "yes" ]; then
928                         if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
929                                 echo "Testing if $package has subrequirements..."
930                                 poldek -t -i $package --dumpn=".$package-req.txt"
931                                 for package_name in `cat ".$package-req.txt"|grep -v ^#`
932                                 do 
933                                         if [ "$package_name" = "$package" ]; then
934                                                 echo -ne "Installing BuildRequired package:\t$package_name\n"
935                                                 poldek -i $package_name
936                                         else
937                                                 echo -ne "Installing (sub)Required package:\t$package_name\n"
938                                                 poldek -i $package_name
939                                         fi
940                                         case $? in
941                                         1)
942                                                 echo -ne "Package installation failed:\t$package_name\n"
943                                                 #
944                                                 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
945                                                 # pakieta zbudowaæ. 
946                                                 #
947                                                 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
948                                                 ;;
949                                         0)
950                                                 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
951                                                 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
952                                                 ;;
953                                         esac
954                                 done
955                                 rm ".$package-req.txt"
956                         else
957                                 echo "Package $package is already installed. BuildRequirement satisfied."
958                         fi
959                 fi
960             done
961             if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
962                     echo "Nie uda³o siê zainstalowaæ nastêpuj±cych pakietów i ich zale¿no¶ci:"
963                     for pkg in "$NOT_INSTALLED_PACKAGES"
964                     do
965                             echo $pkg
966                     done
967                     remove_build_requires
968                     exit 1
969             fi
970 fi
971 }
972
973 #---------------------------------------------
974 # main()
975
976 if [ "$#" = 0 ]; then
977     usage;
978     exit 1
979 fi
980
981 while test $# -gt 0 ; do
982     case "${1}" in
983         -5 | --update-md5 )
984             COMMAND="get";
985             NODIST="yes"
986             NOCVSSPEC="yes"
987             UPDATE5="yes"
988             shift ;;
989         -a5 | --add-md5 )
990             COMMAND="get";
991             NODIST="yes"
992             NOCVS="yes"
993             NOCVSSPEC="yes"
994             UPDATE5="yes"
995             ADD5="yes"
996             shift ;;
997         -D | --debug )
998             DEBUG="yes"; shift ;;
999         -V | --version )
1000             COMMAND="version"; shift ;;
1001         -a | --as_anon )
1002             CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1003         -b | -ba | --build )
1004             COMMAND="build"; shift ;;
1005         -bb | --build-binary )
1006             COMMAND="build-binary"; shift ;;
1007         -bs | --build-source )
1008             COMMAND="build-source"; shift ;;
1009         -bp | --build-prep )
1010             COMMAND="build-prep"; shift ;;
1011         -B | --branch )
1012             COMMAND="branch"; shift; TAG="${1}"; shift;;
1013         -c | --clean )
1014             CLEAN="--clean --rmspec --rmsource"; shift ;;
1015         -d | --cvsroot )
1016             shift; CVSROOT="${1}"; shift ;;
1017         -g | --get )
1018             COMMAND="get"; shift ;;
1019         -h | --help )
1020             COMMAND="usage"; shift ;;
1021         --http )
1022             PROTOCOL="http"; shift ;;
1023         -l | --logtofile )
1024             shift; LOGFILE="${1}"; shift ;;
1025         -ni| --nice )
1026             shift; DEF_NICE_LEVEL=${1}; shift ;;
1027         -m | --mr-proper )
1028             COMMAND="mr-proper"; shift ;;
1029         -nc | --no-cvs )
1030             NOCVS="yes"; shift ;;
1031         -ncs | --no-cvs-specs )
1032             NOCVSSPEC="yes"; shift ;;
1033         -nd | --no-distfiles )
1034             NODIST="yes"; shift ;;
1035         -nm | --no-mirrors )
1036             NOMIRRORS="yes"; shift ;;
1037         -nu | --no-urls )
1038             NOURLS="yes"; shift ;;
1039         -ns | --no-srcs )
1040             NOSRCS="yes"; shift ;;
1041         -ns0 | --no-source0 )
1042             NOSOURCE0="yes"; shift ;;
1043         --opts )
1044             shift; RPMOPTS="${1}"; shift ;;
1045         --with | --without )
1046             case $GROUP_BCONDS in
1047                 "yes")
1048                         COND=${1}
1049                         shift
1050                         while [ "`echo ${1}|grep ^-`" = "" ] && [ "`echo ${1}|grep spec`" = "" ]
1051                         do
1052                                 BCOND="$BCOND $COND $1"
1053                                 shift
1054                         done;;
1055                 "no")
1056                         BCOND="$BCOND $1 $2" ; shift 2 ;;
1057             esac
1058             ;;
1059         -q | --quiet )
1060             QUIET="--quiet"; shift ;;
1061         --date )
1062             CVSDATE="${2}"; shift 2 ;;
1063         -r | --cvstag )
1064             shift; CVSTAG="${1}"; shift ;;
1065         -R | --fetch-build-requires)
1066             FETCH_BUILD_REQUIRES="yes"
1067             #UPDATE_POLDEK_INDEXES="yes"
1068             NOT_INSTALLED_PACKAGES=
1069             shift ;;
1070         -RB | --remove-build-requires)
1071             REMOVE_BUILD_REQUIRES="nice"
1072             shift ;;
1073         -FRB | --force-remove-build-requires)
1074             REMOVE_BUILD_REQUIRES="force"
1075             shift ;;
1076         -Tvs | --tag-version-stable )
1077             COMMAND="tag";
1078             TAG="STABLE"
1079             TAG_VERSION="yes"
1080             shift;;
1081         -Tvn | --tag-version-nest )
1082             COMMAND="tag";
1083             TAG="NEST"
1084             TAG_VERSION="yes"
1085             shift;;
1086         -Ts | --tag-stable )
1087             COMMAND="tag";
1088             TAG="STABLE"
1089             TAG_VERSION="no"
1090             shift;;
1091         -Tn | --tag-nest )
1092             COMMAND="tag";
1093             TAG="NEST"
1094             TAG_VERSION="no"
1095             shift;;
1096         -Tv | --tag-version )
1097             COMMAND="tag";
1098             TAG=""
1099             TAG_VERSION="yes"
1100             shift;;
1101         -Tp | --tag-prefix )
1102             TAG_PREFIX="$2"
1103             shift 2;;
1104         -T | --tag )
1105             COMMAND="tag";
1106             shift
1107             TAG="$1"
1108             TAG_VERSION="no"
1109             shift;;
1110         -U | --update )
1111             COMMAND="get"
1112             UPDATE="yes"
1113             NOCVSSPEC="yes"
1114             NODIST="yes"
1115             UPDATE5="yes"
1116             shift ;;
1117         -Upi | --update-poldek-indexes )
1118             UPDATE_POLDEK_INDEXES="yes"
1119             shift ;;
1120         -u | --try-upgrade )
1121             TRY_UPGRADE="1"; shift ;;
1122         -un | --try-upgrade-with-float-version )
1123             TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1124         -v | --verbose )
1125             BE_VERBOSE="1"; shift ;;
1126         --define)
1127             shift
1128             MACRO="${1}"
1129             VALUE="${2}"
1130             shift 2
1131             RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1132             ;;
1133         --nodeps)
1134             shift
1135             RPMOPTS="${RPMOPTS} --nodeps"
1136             ;;
1137         * )
1138             SPECFILE="`basename ${1} .spec`.spec"; shift ;;
1139     esac
1140 done
1141
1142 if [ -n "$DEBUG" ]; then
1143     set -x;
1144     set -v;
1145 fi
1146
1147 case "$COMMAND" in
1148     "build" | "build-binary" | "build-source" | "build-prep" )
1149         init_builder;
1150         if [ -n "$SPECFILE" ]; then
1151             get_spec;
1152             set_bconds_values;
1153             display_bconds;
1154             fetch_build_requires;
1155             parse_spec;
1156
1157             if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
1158                 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
1159                 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
1160                 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1161
1162                 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
1163                     Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
1164                 fi
1165             fi
1166
1167             if [ -n "$ICONS" ]; then
1168                 get_files $ICONS;
1169                 parse_spec;
1170             fi
1171             if [ -n "$NOSOURCE0" ] ; then
1172                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1173             fi
1174             get_files "$SOURCES $PATCHES";
1175             build_package;
1176             if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
1177                     poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1178                     poldek --sn ${POLDEK_SOURCE} --up
1179             fi
1180             remove_build_requires;
1181         else
1182             Exit_error err_no_spec_in_cmdl;
1183         fi
1184         ;;
1185     "branch" )
1186         init_builder;
1187         if [ -n "$SPECFILE" ]; then
1188                 get_spec;
1189                 parse_spec;
1190                 if [ -n "$ICONS" ]; then
1191                         get_files $ICONS
1192                         parse_spec;
1193                 fi
1194                 get_files $SOURCES $PATCHES;
1195                 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1196         else
1197                 Exit_error err_no_spec_in_cmdl;
1198         fi
1199         ;;
1200     "get" )
1201         init_builder;
1202         if [ -n "$SPECFILE" ]; then
1203             get_spec;
1204             parse_spec;
1205             if [ -n "$ICONS" ]; then
1206                 get_files $ICONS
1207                 parse_spec;
1208             fi
1209             if [ -n "$NOSOURCE0" ] ; then
1210                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1211             fi
1212             get_files $SOURCES $PATCHES
1213         else
1214             Exit_error err_no_spec_in_cmdl;
1215         fi
1216         ;;
1217     "tag" )
1218         init_builder;
1219         if [ -n "$SPECFILE" ]; then
1220             get_spec;
1221             parse_spec;
1222             if [ -n "$ICONS" ]; then
1223                 get_files $ICONS
1224                 parse_spec;
1225             fi
1226             # don't fetch sources from remote locations
1227             new_SOURCES=""
1228             for file in $SOURCES; do
1229                 [ "`nourl $file`" != "$file" ] && continue
1230                 new_SOURCES="$new_SOURCES $file"
1231             done
1232             SOURCES="$new_SOURCES"
1233             get_files $SOURCES $PATCHES;
1234             tag_files "$SOURCES $PATCHES $ICONS";
1235         else
1236             Exit_error err_no_spec_in_cmdl;
1237         fi
1238         ;;
1239     "mr-proper" )
1240         $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1241         ;;
1242     "usage" )
1243         usage;;
1244     "version" )
1245         echo "$VERSION";;
1246 esac
1247 cd $__PWD
This page took 0.135102 seconds and 3 git commands to generate.