]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - builder.sh
- HOME_ETC support
[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 if [ -s CVS/Root ]; then
44     CVSROOT=$(cat CVS/Root)
45 else
46     CVSROOT=${CVSROOT:-""}
47 fi
48 # Example: LOGFILE='../log.$PACKAGE_NAME'
49 # Yes, you can use variable name! Note _single_ quotes!
50 LOGFILE=''
51
52 LOGDIR=""
53 LOGDIROK=""
54 LOGDIRFAIL=""
55 LASTLOG_FILE=""
56 CHMOD="no"
57 CHMOD_MODE="0444"
58 RPMOPTS=""
59 BCOND=""
60 GROUP_BCONDS="no"
61
62 PATCHES=""
63 SOURCES=""
64 ICONS=""
65 PACKAGE_RELEASE=""
66 PACKAGE_VERSION=""
67 PACKAGE_NAME=""
68 PROTOCOL="ftp"
69 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
70 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
71
72 CVSTAG=""
73 RES_FILE=""
74
75 CVS_SERVER="cvs.pld-linux.org"
76 DISTFILES_SERVER="://distfiles.pld-linux.org"
77
78 DEF_NICE_LEVEL=0
79
80 FAIL_IF_NO_SOURCES="yes"
81
82 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
83 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
84
85 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
86 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
87 GETLOCAL="cp -a"
88
89 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
90     RPM="rpm"
91     RPMBUILD="rpm"
92 else
93     RPM="rpm"
94     RPMBUILD="rpmbuild"
95 fi
96
97 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
98 POLDEK_SOURCE="cvs"
99
100 # Example grep cvs /etc/poldek.conf:
101 # source = cvs /home/users/yoshi/rpm/RPMS/
102 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
103         POLDEK_SOURCE_VALIDITY="`grep ${POLDEK_SOURCE} /etc/poldek.conf|grep -v ^#`"
104         if [ "${POLDEK_SOURCE_VALIDITY}" = "" ]; then 
105                 echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf"
106                 echo "Fix it and try to contiune"
107                 exit 7
108         fi
109 fi
110
111 if [ -f ~/etc/builderrc ]; then
112     . ~/etc/builderrc
113 fi
114
115 if [ -n "$HOME_ETC" ]; then
116     USER_CFG=$HOME_ETC/.builderrc
117 else
118     USER_CFG=~/.builderrc
119 fi
120
121 [ -f $USER_CFG ] && . $USER_CFG        
122
123 #---------------------------------------------
124 # functions
125
126 usage()
127 {
128     if [ -n "$DEBUG" ]; then set -xv; fi
129     echo "\
130 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
131
132         [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
133         [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
134         [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
135         [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
136         [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
137         [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version] 
138         [{-Tp|--tag-prefix} <prefix>]
139         [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
140         [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
141
142         -5, --update-md5
143                         - update md5 comments in spec, implies -nd -ncs
144         -a5, --add-md5  - add md5 comments to URL sources, implies -nc -nd -ncs
145         -D, --debug     - enable script debugging mode,
146         -V, --version   - output builder version
147         -a, --as_anon   - get files via pserver as cvs@$CVS_SERVER,
148         -b, -ba,
149         --build         - get all files from CVS repo or HTTP/FTP and build
150                           package from <package>.spec,
151         -bb, --build-binary
152                         - get all files from CVS repo or HTTP/FTP and build
153                           binary only package from <package>.spec,
154         -bs,
155         --build-source  - get all files from CVS repo or HTTP/FTP and only
156                           pack them into src.rpm,
157         -B, --branch    - add branch
158         -c, --clean     - clean all temporarily created files (in BUILD,
159                           SOURCES, SPECS and \$RPM_BUILD_ROOT),
160         -d <cvsroot>, --cvsroot <cvsroot>
161                         - setup \$CVSROOT,
162         --define <macro> <value>
163                         - define a macro <macro> with value <value>,
164         --nodeps        - rpm won't check any dependences
165         -g, --get       - get <package>.spec and all related files from
166                           CVS repo or HTTP/FTP,
167         -h, --help      - this message,
168         --http          - use http instead of ftp,
169         -l <logfile>, --logtofile <logfile>
170                         - log all to file,
171         -m, --mr-proper - only remove all files related to spec file and
172                           all work resources,
173         -nc, --no-cvs   - don't download sources from CVS, if source URL is
174                           given,
175         -ncs, --no-cvs-specs
176                         - don't check specs in CVS
177         -nd, --no-distfiles
178                         - don't download from distfiles
179         -nm, --no-mirrors - don't download from mirror, if source URL is given,
180         -nu, --no-urls  - don't try to download from FTP/HTTP location,
181         -ns, --no-srcs  - don't download Sources
182         -ns0, --no-source0
183                         - don't download Source0
184         --opts <rpm opts>
185                         - additional options for rpm
186         -q, --quiet     - be quiet,
187         --date yyyy-mm-dd
188                         - build package using resources from specified CVS
189                           date,
190         -r <cvstag>, --cvstag <cvstag>
191                         - build package using resources from specified CVS
192                           tag,
193         -R, --fetch-build-requires
194                         - fetch what is BuildRequired,
195         -RB, --remove-build-requires
196                         - remove all you fetched with -R or --fetch-build-requires
197                           remember, this option requires confirmation,
198         -FRB, --force-remove-build-requires
199                         - remove all you fetched with -R or --fetch-build-requires
200                           remember, this option works without confirmation,
201         -T <cvstag> , --tag <cvstag>
202                         - add cvs tag <cvstag> for files,
203         -Tvs, --tag-version-stable
204                         - add cvs tags STABLE and NAME-VERSION-RELESE for files,
205         -Tvn, --tag-version-nest
206                         - add cvs tags NEST and NAME-VERSION-RELESE for files,
207         -Ts, --tag-stable
208                         - add cvs tag STABLE for files,
209         -Tn, --tag-nest
210                         - add cvs tag NEST for files,
211         -Tv, --tag-version
212                         - add cvs tag NAME-VERSION-RELESE for files,
213         -Tp, --tag-prefix <prefix>
214                         - add <prefix> to NAME-VERSION-RELEASE tags,
215         -v, --verbose   - be verbose,
216         -u, --try-upgrade
217                         - check version, and try to upgrade package
218         -un, --try-upgrade-with-float-version
219                         - as above, but allow float version
220         -U, --update
221                         - refetch sources, don't use distfiles, and update md5 
222                           comments
223         -Upi, --update-poldek-indexes 
224                         - refresh or make poldek package index files.
225         --with/--without <feature>
226                         - conditional build package depending on
227                           %_with_<feature>/%_without_<feature> macro
228                           switch. 
229                           You may now use --with feat1 feat2 feat3 --without feat4
230                           feat5 --with feat6 constructions.
231 "
232 }
233
234 cache_rpm_dump () {
235    rpm_dump_cache=`
236         case "$RPMBUILD" in
237         rpm )
238                 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1 
239                 ;;
240         rpmbuild )
241                 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1 
242                 ;;
243         esac`
244 }
245
246 rpm_dump () {
247     if [ -z "$rpm_dump_cache" ] ; then
248         echo "internal error: cache_rpm_dump not called!" 1>&2
249     fi
250     echo "$rpm_dump_cache"
251 }
252
253 parse_spec()
254 {
255     if [ -n "$DEBUG" ]; then
256         set -x;
257         set -v;
258     fi
259
260     cd $SPECS_DIR
261
262     cache_rpm_dump
263
264     if [ "$NOSRCS" != "yes" ]; then
265         SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
266     fi
267     if (rpm_dump | grep -qEi ":.*nosource.*1"); then
268         FAIL_IF_NO_SOURCES="no"
269     fi
270
271     PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
272     ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
273     PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
274     PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
275     PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
276
277     if [ -n "$BE_VERBOSE" ]; then
278         echo "- Sources :  `nourl $SOURCES`"
279         if [ -n "$PATCHES" ]; then
280             echo "- Patches :  `nourl $PATCHES`"
281         else
282             echo "- Patches :  *no patches needed*"
283         fi
284         if [ -n "$ICONS" ]; then
285             echo "- Icon    :  `nourl $ICONS`"
286         else
287             echo "- Icon    :  *no package icon*"
288         fi
289         echo "- Name    : $PACKAGE_NAME"
290         echo "- Version : $PACKAGE_VERSION"
291         echo "- Release : $PACKAGE_RELEASE"
292     fi
293 }
294
295 Exit_error()
296 {
297     if [ -n "$DEBUG" ]; then
298         set -x;
299         set -v;
300     fi
301
302     cd $__PWD
303
304     case "$1" in
305     "err_no_spec_in_cmdl" )
306         remove_build_requires
307         echo "ERROR: spec file name not specified.";
308         exit 2 ;;
309     "err_no_spec_in_repo" )
310         remove_build_requires
311         echo "Error: spec file not stored in CVS repo.";
312         exit 3 ;;
313     "err_no_source_in_repo" )
314         remove_build_requires
315         echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
316         exit 4 ;;
317     "err_build_fail" )
318         remove_build_requires
319         echo "Error: package build failed. (${2:-no more info})";
320         exit 5 ;;
321     esac
322 }
323
324 init_builder()
325 {
326     if [ -n "$DEBUG" ]; then
327         set -x;
328         set -v;
329     fi
330
331     SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
332     SPECS_DIR="`$RPM --eval '%{_specdir}'`"
333
334     __PWD=`pwd`
335 }
336
337 get_spec()
338 {
339     if [ -n "$DEBUG" ]; then
340         set -x;
341         set -v;
342     fi
343
344     if [ "$NOCVSSPEC" != "yes" ]; then
345         cd $SPECS_DIR
346
347         OPTIONS="up "
348
349         if [ -n "$CVSROOT" ]; then
350             OPTIONS="-d $CVSROOT $OPTIONS"
351         else
352             if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
353                 echo "warning: No cvs access defined - using local .spec file"
354                 NOCVSSPEC="yes"
355             fi
356         fi
357
358         if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
359             OPTIONS="$OPTIONS -A"
360         else
361             if [ -n "$CVSDATE" ]; then
362                 OPTIONS="$OPTIONS -D $CVSDATE"
363             fi
364             if [ -n "$CVSTAG" ]; then
365                 OPTIONS="$OPTIONS -r $CVSTAG"
366             fi
367         fi
368
369         result=1
370         retries_counter=0
371         while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
372             retries_counter=$(( $retries_counter + 1 ))
373             output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
374             result=$?
375             [ -n "$output" ] && echo "$output"
376             if [ "$result" -ne "0" ]; then
377                 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
378                     echo "Trying again [$SPECFILE]... ($retries_counter)"
379                     sleep 2
380                     continue
381                 fi
382                 Exit_error err_no_spec_in_repo;
383             fi
384         done
385     fi
386     if [ ! -f "$SPECFILE" ]; then
387         Exit_error err_no_spec_in_repo;
388     fi
389
390     if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
391         chmod $CHMOD_MODE $SPECFILE
392     fi
393     unset OPTIONS
394     grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
395 }
396
397 find_mirror(){
398
399     cd "$SPECS_DIR"
400     url="$1"
401     if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
402         cvs update mirrors >&2
403     fi
404
405     IFS="|"
406     while read origin mirror name rest; do
407         ol=`echo -n "$origin"|wc -c`
408         prefix="`echo -n "$url" | head -c $ol`"
409         if [ "$prefix" = "$origin" ] ; then
410             suffix="`echo "$url"|cut -b $ol-`"
411             echo -n "$mirror$suffix"
412             return 0
413         fi
414     done < mirrors
415     echo "$url"
416 }
417
418 src_no ()
419 {
420     cd $SPECS_DIR
421     rpm_dump | \
422         grep "SOURCEURL[0-9]*[  ]*$1""[         ]*$" | \
423         sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
424         head -1 | xargs
425 }
426
427 src_md5 ()
428 {
429     no=$(src_no "$1")
430     [ -z "$no" ] && return
431     cd $SPECS_DIR
432     spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
433     if [ -z "$spec_rev" ]; then
434         spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
435     fi
436     spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
437     md5=$(grep -s -v '^#' additional-md5sums | \
438         grep -E "[      ]$(basename "$1")[      ]+${spec}([     ,]|\$)" | \
439         sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
440         grep -E '^[0-9a-f]{32}$')
441     if [ X"$md5" = X"" ] ; then
442         grep -i "#[     ]*Source$no-md5[        ]*:" $SPECFILE | sed -e 's/.*://' | xargs
443     else
444         if [ $(echo "$md5" | wc -l) != 1 ] ; then
445             echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
446         fi
447         echo "$md5" | tail -1
448     fi
449 }
450
451 distfiles_url ()
452 {
453     echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
454 }
455
456 good_md5 ()
457 {
458     md5=$(src_md5 "$1")
459     [ "$md5" = "" ] || \
460     [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
461 }
462
463 get_files()
464 {
465     GET_FILES="$@"
466
467     if [ -n "$DEBUG" ]; then
468         set -x;
469         set -v;
470     fi
471
472     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
473         cd $SOURCE_DIR
474
475         OPTIONS="up "
476         if [ -n "$CVSROOT" ]; then
477             OPTIONS="-d $CVSROOT $OPTIONS"
478         else
479             if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
480                 echo "warning: No cvs access defined for SOURCES"
481                 NOCVS="yes"
482             fi
483         fi
484         if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
485             OPTIONS="$OPTIONS -A"
486         else
487             if [ -n "$CVSDATE" ]; then
488                 OPTIONS="$OPTIONS -D $CVSDATE"
489             fi
490             if [ -n "$CVSTAG" ]; then
491                 OPTIONS="$OPTIONS -r $CVSTAG"
492             fi
493         fi
494         for i in $GET_FILES; do
495             if [ -n "$UPDATE5" ]; then
496                 if [ -n "$ADD5" ]; then
497                     [ `nourl $i` = "$i" ] && continue
498                     grep -qiE '^#[      ]*Source'$(src_no $i)'-md5[     ]*:' $SPECS_DIR/$SPECFILE && continue
499                 else
500                     grep -qiE '^#[      ]*Source'$(src_no $i)'-md5[     ]*:' $SPECS_DIR/$SPECFILE || continue
501                 fi
502             fi
503             FROM_DISTFILES=0
504             if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
505                 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
506                     echo "Warning: no URL given for $i"
507                 fi
508
509                 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
510                     if good_md5 "$i"; then
511                         echo "$(nourl "$i") having proper md5sum already exists"
512                         continue
513                     fi
514                     target=$(nourl "$i")
515                     url=$(distfiles_url "$i")
516                     if [ `echo $url | grep -E '^(\.|/)'` ]; then
517                         ${GETLOCAL} $url $target
518                     else
519                         FROM_DISTFILES=1
520                         if [ -z "$NOMIRRORS" ]; then
521                             url="`find_mirror "$url"`"
522                         fi
523                         ${GETURI} -O "$target" "$url" || \
524                             if [ `echo $url | grep -E 'ftp://'` ]; then
525                                 ${GETURI2} -O "$target" "$url"
526                             fi
527                         if ! test -s "$target"; then
528                             rm -f "$target"
529                             FROM_DISTFILES=0
530                         fi
531                     fi
532                 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
533                     # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
534                     result=1
535                     retries_counter=0
536                     while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
537                         retries_counter=$(( $retries_counter + 1 ))
538                         output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
539                         result=$?
540                         [ -n "$output" ] && echo "$output"
541                         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
542                                 echo "Trying again [`nourl $i`]... ($retries_counter)"
543                                 sleep 2
544                                 continue
545                         else
546                                 break
547                         fi
548                     done
549                 fi
550
551                 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
552                     if [ -z "$NOMIRRORS" ]; then
553                         im="`find_mirror "$i"`"
554                     else
555                         im="$i"
556                     fi
557                     ${GETURI} "$im" || \
558                         if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi
559                 fi
560
561
562             fi
563             srcno=$(src_no $i)
564             if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
565                 Exit_error err_no_source_in_repo $i;
566             elif [ -n "$UPDATE5" ] && \
567                 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
568                     [ -z "$(grep -E -i '^NoSource[      ]*:[    ]*'$i'([        ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
569                 grep -q -i -E '^#[      ]*source'$(src_no $i)'-md5[     ]*:' $SPECS_DIR/$SPECFILE )
570             then
571                 echo "Updating source-$srcno md5."
572                 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
573                 perl -i -ne '
574                                 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
575                                 print "# Source'$srcno'-md5:\t'$md5'\n" 
576                                         if /^Source'$srcno'\s*:\s+/;
577                                 ' \
578                                 $SPECS_DIR/$SPECFILE
579             fi
580
581             if good_md5 "$i"; then
582                 :
583             elif [ "$FROM_DISTFILES" = 1 ]; then
584                 # wrong md5 from distfiles: remove the file and try again
585                 # but only once ...
586                 echo "MD5 sum mismatch. Trying full fetch."
587                 FROM_DISTFILES=2
588                 rm -f $target
589                 ${GETURI} -O "$target" "$url" || \
590                     if [ `echo $url | grep -E 'ftp://'` ]; then
591                         ${GETURI2} -O "$target" "$url"
592                     fi
593                 test -s "$target" || rm -f "$target"
594             fi
595
596             if good_md5 "$i"; then
597                 :
598             else
599                 echo "MD5 sum mismatch.  Use -U to refetch sources,"
600                 echo "or -5 to update md5 sums, if you're sure files are correct."
601                 Exit_error err_no_source_in_repo $i
602             fi
603         done
604
605         if [ "$CHMOD" = "yes" ]; then
606             CHMOD_FILES="`nourl $GET_FILES`"
607             if [ -n "$CHMOD_FILES" ]; then
608                 chmod $CHMOD_MODE $CHMOD_FILES
609             fi
610         fi
611         unset OPTIONS
612     fi
613 }
614
615 tag_files()
616 {
617     TAG_FILES="$@"
618
619     if [ -n "$DEBUG" ]; then
620         set -x;
621         set -v;
622     fi
623
624     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
625         echo "Version: $PACKAGE_VERSION"
626         echo "Release: $PACKAGE_RELEASE"
627         # Check whether first character of PACKAGE_NAME is legal for tag name
628         if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
629             TAG_PREFIX=tag_
630         fi
631         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"`
632         # Remove #kernel.version_release from TAGVER because tagging sources
633         # could occur with different kernel-headers than kernel-headers used at build time.
634         TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
635         if [ "$TAG_VERSION" = "yes" ]; then
636             echo "CVS tag: $TAGVER"
637         fi
638         if [ -n "$TAG" ]; then
639             echo "CVS tag: $TAG"
640         fi
641
642         OPTIONS="tag -F"
643         if [ -n "$CVSROOT" ]; then
644             OPTIONS="-d $CVSROOT $OPTIONS"
645         fi
646
647         cd $SOURCE_DIR
648         for i in $TAG_FILES; do
649             # don't tag non cvs files (ie. stored on distfiles)
650             [ "`nourl $i`" != "$i" ] && continue
651             if [ -f "`nourl $i`" ]; then
652                 if [ "$TAG_VERSION" = "yes" ]; then
653                     cvs $OPTIONS $TAGVER `nourl $i`
654                 fi
655                 if [ -n "$TAG" ]; then
656                     cvs $OPTIONS $TAG `nourl $i`
657                 fi
658             else
659                 Exit_error err_no_source_in_repo $i
660             fi
661         done
662
663         cd $SPECS_DIR
664         if [ "$TAG_VERSION" = "yes" ]; then
665             cvs $OPTIONS $TAGVER $SPECFILE
666         fi
667         if [ -n "$TAG" ]; then
668             cvs $OPTIONS $TAG $SPECFILE
669         fi
670
671         unset OPTIONS
672     fi
673 }
674
675 branch_files()
676 {
677     TAG=$1
678     echo "CVS branch tag: $TAG"
679     shift;
680
681     TAG_FILES="$@"
682
683     if [ -n "$DEBUG" ]; then
684         set -x;
685         set -v;
686     fi
687
688     if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
689
690         OPTIONS="tag -b"
691         if [ -n "$CVSROOT" ]; then
692             OPTIONS="-d $CVSROOT $OPTIONS"
693         fi
694         cd $SOURCE_DIR
695         for i in $TAG_FILES; do
696             if [ -f `nourl $i` ]; then
697                 cvs $OPTIONS $TAG `nourl $i`
698             else
699                 Exit_error err_no_source_in_repo $i
700             fi
701         done
702         cd $SPECS_DIR
703         cvs $OPTIONS $TAG $SPECFILE
704
705         unset OPTIONS
706     fi
707 }
708
709
710
711 build_package()
712 {
713     if [ -n "$DEBUG" ]; then
714         set -x;
715         set -v;
716     fi
717
718     cd $SPECS_DIR
719
720     if [ -n "$TRY_UPGRADE" ]; then
721
722         if [ -n "$FLOAT_VERSION" ]; then
723             TNOTIFY=`./pldnotify.awk $SPECFILE -n`
724         else
725             TNOTIFY=`./pldnotify.awk $SPECFILE`
726         fi
727
728         TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
729
730         if [ -n "$TNEWVER" ]; then
731
732             TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
733
734             echo "New version found, updating spec file to version " $TNEWVER
735
736             cp -f $SPECFILE $SPECFILE.bak
737
738             chmod +w $SPECFILE
739
740             eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
741             eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
742
743             parse_spec;
744
745             get_files "$SOURCES $PATCHES";
746
747             unset TOLDVER TNEWVER TNOTIFY
748         fi
749
750     fi
751
752
753     cd $SPECS_DIR
754
755     case "$COMMAND" in
756         build )
757             BUILD_SWITCH="-ba" ;;
758         build-binary )
759             BUILD_SWITCH="-bb" ;;
760         build-source )
761             BUILD_SWITCH="-bs --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         -B | --branch )
1010             COMMAND="branch"; shift; TAG="${1}"; shift;;
1011         -c | --clean )
1012             CLEAN="--clean --rmspec --rmsource"; shift ;;
1013         -d | --cvsroot )
1014             shift; CVSROOT="${1}"; shift ;;
1015         -g | --get )
1016             COMMAND="get"; shift ;;
1017         -h | --help )
1018             COMMAND="usage"; shift ;;
1019         --http )
1020             PROTOCOL="http"; shift ;;
1021         -l | --logtofile )
1022             shift; LOGFILE="${1}"; shift ;;
1023         -ni| --nice )
1024             shift; DEF_NICE_LEVEL=${1}; shift ;;
1025         -m | --mr-proper )
1026             COMMAND="mr-proper"; shift ;;
1027         -nc | --no-cvs )
1028             NOCVS="yes"; shift ;;
1029         -ncs | --no-cvs-specs )
1030             NOCVSSPEC="yes"; shift ;;
1031         -nd | --no-distfiles )
1032             NODIST="yes"; shift ;;
1033         -nm | --no-mirrors )
1034             NOMIRRORS="yes"; shift ;;
1035         -nu | --no-urls )
1036             NOURLS="yes"; shift ;;
1037         -ns | --no-srcs )
1038             NOSRCS="yes"; shift ;;
1039         -ns0 | --no-source0 )
1040             NOSOURCE0="yes"; shift ;;
1041         --opts )
1042             shift; RPMOPTS="${1}"; shift ;;
1043         --with | --without )
1044             case $GROUP_BCONDS in
1045                 "yes")
1046                         COND=${1}
1047                         shift
1048                         while [ "`echo ${1}|grep ^-`" = "" ] && [ "`echo ${1}|grep spec`" = "" ]
1049                         do
1050                                 BCOND="$BCOND $COND $1"
1051                                 shift
1052                         done;;
1053                 "no")
1054                         BCOND="$BCOND $1 $2" ; shift 2 ;;
1055             esac
1056             ;;
1057         -q | --quiet )
1058             QUIET="--quiet"; shift ;;
1059         --date )
1060             CVSDATE="${2}"; shift 2 ;;
1061         -r | --cvstag )
1062             shift; CVSTAG="${1}"; shift ;;
1063         -R | --fetch-build-requires)
1064             FETCH_BUILD_REQUIRES="yes"
1065             #UPDATE_POLDEK_INDEXES="yes"
1066             NOT_INSTALLED_PACKAGES=
1067             shift ;;
1068         -RB | --remove-build-requires)
1069             REMOVE_BUILD_REQUIRES="nice"
1070             shift ;;
1071         -FRB | --force-remove-build-requires)
1072             REMOVE_BUILD_REQUIRES="force"
1073             shift ;;
1074         -Tvs | --tag-version-stable )
1075             COMMAND="tag";
1076             TAG="STABLE"
1077             TAG_VERSION="yes"
1078             shift;;
1079         -Tvn | --tag-version-nest )
1080             COMMAND="tag";
1081             TAG="NEST"
1082             TAG_VERSION="yes"
1083             shift;;
1084         -Ts | --tag-stable )
1085             COMMAND="tag";
1086             TAG="STABLE"
1087             TAG_VERSION="no"
1088             shift;;
1089         -Tn | --tag-nest )
1090             COMMAND="tag";
1091             TAG="NEST"
1092             TAG_VERSION="no"
1093             shift;;
1094         -Tv | --tag-version )
1095             COMMAND="tag";
1096             TAG=""
1097             TAG_VERSION="yes"
1098             shift;;
1099         -Tp | --tag-prefix )
1100             TAG_PREFIX="$2"
1101             shift 2;;
1102         -T | --tag )
1103             COMMAND="tag";
1104             shift
1105             TAG="$1"
1106             TAG_VERSION="no"
1107             shift;;
1108         -U | --update )
1109             COMMAND="get"
1110             UPDATE="yes"
1111             NOCVSSPEC="yes"
1112             NODIST="yes"
1113             UPDATE5="yes"
1114             shift ;;
1115         -Upi | --update-poldek-indexes )
1116             UPDATE_POLDEK_INDEXES="yes"
1117             shift ;;
1118         -u | --try-upgrade )
1119             TRY_UPGRADE="1"; shift ;;
1120         -un | --try-upgrade-with-float-version )
1121             TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1122         -v | --verbose )
1123             BE_VERBOSE="1"; shift ;;
1124         --define)
1125             shift
1126             MACRO="${1}"
1127             VALUE="${2}"
1128             shift 2
1129             RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1130             ;;
1131         --nodeps)
1132             shift
1133             RPMOPTS="${RPMOPTS} --nodeps"
1134             ;;
1135         * )
1136             SPECFILE="`basename ${1} .spec`.spec"; shift ;;
1137     esac
1138 done
1139
1140 if [ -n "$DEBUG" ]; then
1141     set -x;
1142     set -v;
1143 fi
1144
1145 case "$COMMAND" in
1146     "build" | "build-binary" | "build-source" )
1147         init_builder;
1148         if [ -n "$SPECFILE" ]; then
1149             get_spec;
1150             set_bconds_values;
1151             display_bconds;
1152             fetch_build_requires;
1153             parse_spec;
1154
1155             if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
1156                 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
1157                 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
1158                 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1159
1160                 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
1161                     Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
1162                 fi
1163             fi
1164
1165             if [ -n "$ICONS" ]; then
1166                 get_files $ICONS;
1167                 parse_spec;
1168             fi
1169             if [ -n "$NOSOURCE0" ] ; then
1170                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1171             fi
1172             get_files "$SOURCES $PATCHES";
1173             build_package;
1174             if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
1175                     poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1176                     poldek --sn ${POLDEK_SOURCE} --up
1177             fi
1178             remove_build_requires;
1179         else
1180             Exit_error err_no_spec_in_cmdl;
1181         fi
1182         ;;
1183     "branch" )
1184         init_builder;
1185         if [ -n "$SPECFILE" ]; then
1186                 get_spec;
1187                 parse_spec;
1188                 if [ -n "$ICONS" ]; then
1189                         get_files $ICONS
1190                         parse_spec;
1191                 fi
1192                 get_files $SOURCES $PATCHES;
1193                 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1194         else
1195                 Exit_error err_no_spec_in_cmdl;
1196         fi
1197         ;;
1198     "get" )
1199         init_builder;
1200         if [ -n "$SPECFILE" ]; then
1201             get_spec;
1202             parse_spec;
1203             if [ -n "$ICONS" ]; then
1204                 get_files $ICONS
1205                 parse_spec;
1206             fi
1207             if [ -n "$NOSOURCE0" ] ; then
1208                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1209             fi
1210             get_files $SOURCES $PATCHES
1211         else
1212             Exit_error err_no_spec_in_cmdl;
1213         fi
1214         ;;
1215     "tag" )
1216         init_builder;
1217         if [ -n "$SPECFILE" ]; then
1218             get_spec;
1219             parse_spec;
1220             if [ -n "$ICONS" ]; then
1221                 get_files $ICONS
1222                 parse_spec;
1223             fi
1224             # don't fetch sources from remote locations
1225             new_SOURCES=""
1226             for file in $SOURCES; do
1227                 [ "`nourl $file`" != "$file" ] && continue
1228                 new_SOURCES="$new_SOURCES $file"
1229             done
1230             SOURCES="$new_SOURCES"
1231             get_files $SOURCES $PATCHES;
1232             tag_files "$SOURCES $PATCHES $ICONS";
1233         else
1234             Exit_error err_no_spec_in_cmdl;
1235         fi
1236         ;;
1237     "mr-proper" )
1238         $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1239         ;;
1240     "usage" )
1241         usage;;
1242     "version" )
1243         echo "$VERSION";;
1244 esac
1245 cd $__PWD
This page took 0.13478 seconds and 4 git commands to generate.