]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - builder.sh
- set user agent for wget
[packages/rpm-build-tools.git] / builder.sh
1 #!/bin/ksh
2 # -----------
3 # Exit codes:
4 #         0 - succesful
5 #         1 - help displayed
6 #         2 - no spec file name in cmdl parameters
7 #         3 - spec file not stored in repo
8 #         4 - some source, patch or icon files not stored in repo
9 #         5 - package build failed
10 #         6 - spec file with errors
11 #         7 - wrong source in /etc/poldek.conf
12 #         8 - Failed installing buildrequirements and subrequirements
13 #         9 - Requested tag already exist
14 #        10 - Refused to build fractional release
15 #       100 - Unknown error (should not happen)
16
17 # Notes (todo):
18 #       - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
19 #       - when Icon: field is present, -5 and -a5 doesn't work
20 #       - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
21
22 RCSID='$Id$'
23 r=${RCSID#* * }
24 rev=${r%% *}
25 VERSION="v0.18/$rev"
26 VERSIONSTRING="\
27 Build package utility from PLD Linux CVS repository
28 $VERSION (C) 1999-2007 Free Penguins".
29
30 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
31
32 COMMAND="build"
33 TARGET=""
34
35 SPECFILE=""
36 BE_VERBOSE=""
37 QUIET=""
38 CLEAN=""
39 DEBUG=""
40 NOURLS=""
41 NOCVS=""
42 NOCVSSPEC=""
43 NODIST=""
44 NOINIT=""
45 UPDATE=""
46 ADD5=""
47 NO5=""
48 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
49 CVSROOT=""
50
51 # user agent when fetching files
52 USER_AGENT="PLD/Builder($VERSION)"
53
54 # It can be used i.e. in log file naming.
55 # See LOGFILE example.
56 DATE=`date +%Y-%m-%d_%H-%M-%S`
57
58 # Example: LOGFILE='../log.$PACKAGE_NAME'
59 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
60 # Yes, you can use variable name! Note _single_ quotes!
61 LOGFILE=''
62
63 LOGDIR=""
64 LOGDIROK=""
65 LOGDIRFAIL=""
66 LASTLOG_FILE=""
67
68 CHMOD="no"
69 CHMOD_MODE="0444"
70 RPMOPTS=""
71 RPMBUILDOPTS=""
72 BCOND=""
73 GROUP_BCONDS="no"
74 CVSIGNORE_DF="no"
75
76 PATCHES=""
77 SOURCES=""
78 ICONS=""
79 PACKAGE_RELEASE=""
80 PACKAGE_VERSION=""
81 PACKAGE_NAME=""
82 PROTOCOL="ftp"
83 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
84 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
85
86 CVSTAG=""
87 RES_FILE=""
88 CVS_FORCE=""
89
90 CVS_SERVER="cvs.pld-linux.org"
91 DISTFILES_SERVER="://distfiles.pld-linux.org"
92 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
93
94 DEF_NICE_LEVEL=19
95 SCHEDTOOL="auto"
96
97 FAIL_IF_NO_SOURCES="yes"
98
99 # let get_files skip over files which are present to get those damn files fetched
100 SKIP_EXISTING_FILES="no"
101
102 TRY_UPGRADE=""
103 # should the specfile be restored if upgrade failed?
104 REVERT_BROKEN_UPGRADE="yes"
105
106 if [ -x /usr/bin/rpm-getdeps ]; then
107         FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
108 else
109         FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
110 fi
111
112 # Here we load saved user environment used to
113 # predefine options set above, or passed to builder
114 # in command line.
115 # This one reads global system environment settings:
116 if [ -f ~/etc/builderrc ]; then
117         . ~/etc/builderrc
118 fi
119 # And this one cascades settings using user personal
120 # builder settings.
121 # Example of ~/.builderrc:
122 #
123 #UPDATE_POLDEK_INDEXES="yes"
124 #FETCH_BUILD_REQUIRES="yes"
125 #REMOVE_BUILD_REQUIRES="force"
126 #GROUP_BCONDS="yes"
127 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
128 #TITLECHANGE=no
129 #
130 SU_SUDO=""
131 if [ -n "$HOME_ETC" ]; then
132         USER_CFG="$HOME_ETC/.builderrc"
133 else
134         USER_CFG=~/.builderrc
135 fi
136
137 [ -f "$USER_CFG" ] && . "$USER_CFG"
138
139 if [ "$SCHEDTOOL" = "auto" ]; then
140         if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
141                 SCHEDTOOL="schedtool -B -e"
142         else
143                 SCHEDTOOL="no"
144         fi
145 fi
146
147 if [ -n "$USE_PROZILLA" ]; then
148         GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
149         GETURI2="$GETURI"
150         OUTFILEOPT="-O"
151 elif [ -n "$USE_AXEL" ]; then
152         GETURI="axel -a $AXEL_OPTS"
153         GETURI2="$GETURI"
154         OUTFILEOPT="-o"
155 else
156         wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
157         wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
158         wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
159         WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
160
161         GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
162         GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
163         OUTFILEOPT="-O"
164 fi
165
166 GETLOCAL="cp -a"
167
168 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
169         RPM="rpm"
170         RPMBUILD="rpm"
171 else
172         RPM="rpm"
173         RPMBUILD="rpmbuild"
174 fi
175
176 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
177 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
178
179 run_poldek()
180 {
181         RES_FILE=~/tmp/poldek-exit-status.$RANDOM
182         if [ -n "$LOGFILE" ]; then
183                 LOG=`eval echo $LOGFILE`
184                 if [ -n "$LASTLOG_FILE" ]; then
185                         echo "LASTLOG=$LOG" > $LASTLOG_FILE
186                 fi
187                 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
188                 return $exit_pldk
189         else
190                 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
191                 return `cat ${RES_FILE}`
192                 rm -rf ${RES_FILE}
193         fi
194 }
195
196 #---------------------------------------------
197 # functions
198
199 usage()
200 {
201         if [ -n "$DEBUG" ]; then set -xv; fi
202         echo "\
203 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
204 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
205 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
206 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
207 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
208 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
209 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
210 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
211 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
212 <package>[.spec][:cvstag]
213
214 -5, --update-md5    - update md5 comments in spec, implies -nd -ncs
215 -a5, --add-md5      - add md5 comments to URL sources, implies -nc -nd -ncs
216 -n5, --no-md5       - ignore md5 comments in spec
217 -D, --debug         - enable builder script debugging mode,
218 -debug              - produce rpm debug package (same as --opts -debug)
219 -V, --version       - output builder version string
220 --short-version     - output builder short version
221 -a, --as_anon       - get files via pserver as cvs@$CVS_SERVER,
222 -b, -ba, --build    - get all files from CVS repo or HTTP/FTP and build package
223                       from <package>.spec,
224 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
225                       only package from <package>.spec,
226 -bp, --build-prep   - execute the %prep phase of <package>.spec,
227 -bc                 - execute the %build phase of <package>.spec,
228 -bi                 - execute the %install phase of <package>.spec
229 -bl                                     - execute the %files phase of <package>.spec
230 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
231                       them into src.rpm,
232 --short-circuit     - short-circuit build
233 -B, --branch        - add branch
234 -c, --clean         - clean all temporarily created files (in BUILD, SOURCES,
235                       SPECS and \$RPM_BUILD_ROOT),
236 -cf, --cvs-force        - use -F when tagging (useful when moving branches)
237 -d <cvsroot>, --cvsroot <cvsroot>
238                     - setup \$CVSROOT,
239 --define <macro> <value>
240                     - define a macro <macro> with value <value>,
241 --nodeps            - rpm won't check any dependences
242 -g, --get           - get <package>.spec and all related files from CVS repo
243                       or HTTP/FTP,
244 -h, --help          - this message,
245 --http              - use http instead of ftp,
246 -l <logfile>, --logtofile <logfile>
247                     - log all to file,
248 -m, --mr-proper     - only remove all files related to spec file and all work
249                       resources,
250 -nc, --no-cvs       - don't download sources from CVS, if source URL is given,
251 -ncs, --no-cvs-specs
252                     - don't check specs in CVS
253 -nd, --no-distfiles - don't download from distfiles
254 -nm, --no-mirrors   - don't download from mirror, if source URL is given,
255 -nu, --no-urls      - don't try to download from FTP/HTTP location,
256 -ns, --no-srcs      - don't download Sources
257 -ns0, --no-source0  - don't download Source0
258 -nn, --no-net       - don't download anything from the net
259 --no-init           - don't initialize builder paths (SPECS and SOURCES)
260 -ske,
261 --skip-existing-files - skip existing files in get_files
262 --opts <rpm opts>   - additional options for rpm
263 -q, --quiet         - be quiet,
264 --date yyyy-mm-dd   - build package using resources from specified CVS date,
265 -r <cvstag>, --cvstag <cvstag>
266                     - build package using resources from specified CVS tag,
267 -A                  - build package using CVS resources as any sticky tags/date/kopts being reset.
268 -R, --fetch-build-requires
269                     - fetch what is BuildRequired,
270 -RB, --remove-build-requires
271                     - remove all you fetched with -R or --fetch-build-requires
272                       remember, this option requires confirmation,
273 -FRB, --force-remove-build-requires
274                     - remove all you fetched with -R or --fetch-build-requires
275                       remember, this option works without confirmation,
276 -sd, --source-distfiles - list sources available from distfiles (intended for offline
277                       operations; does not work when Icon field is present
278                       but icon file is absent),
279 -sdp, --source-distfiles-paths - list sources available from distfiles -
280                       paths relative to distfiles directory (intended for offline
281                       operations; does not work when Icon field is present
282                       but icon file is absent),
283 -sf, --source-files - list sources - bare filenames (intended for offline
284                       operations; does not work when Icon field is present
285                       but icon file is absent),
286 -sp, --source-paths - list sources - filenames with full local paths (intended for
287                       offline operations; does not work when Icon field is present
288                       but icon file is absent),
289 -su, --source-urls  - list urls - urls to sources and patches
290                       intended for copying urls with spec with lots of macros in urls
291 -T <cvstag> , --tag <cvstag>
292                     - add cvs tag <cvstag> for files,
293 -Tvs, --tag-version-stable
294                     - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
295 -Ts, --tag-stable
296                     - add cvs tag STABLE for files,
297 -Tv, --tag-version
298                     - add cvs tag NAME-VERSION-RELEASE for files,
299 -Tp, --tag-prefix <prefix>
300                     - add <prefix> to NAME-VERSION-RELEASE tags,
301 -tt, --test-tag <prefix>
302                     - fail if tag is already present,
303 -ir, --integer-release-only
304                     - allow only integer and snapshot releases
305 -v, --verbose       - be verbose,
306 -u, --try-upgrade   - check version, and try to upgrade package
307 -un, --try-upgrade-with-float-version
308                     - as above, but allow float version
309 -U, --update        - refetch sources, don't use distfiles, and update md5 comments
310 -Upi, --update-poldek-indexes
311                     - refresh or make poldek package index files.
312 -np, --nopatch <patchnumber>
313                     - don't apply <patchnumber>
314 --show-bconds       - show available conditional builds, which can be used
315                     - with --with and/or --without switches.
316 --show-bcond-args   - show active bconds, from ~/.bcondrc. this is used by
317                       ./repackage.sh script. in other words, the output is
318                       parseable by scripts.
319 --with/--without <feature>
320                     - conditional build package depending on %_with_<feature>/
321                       %_without_<feature> macro switch.  You may now use
322                       --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
323                       constructions. Set GROUP_BCONDS to yes to make use of it.
324 --target <platform>, --target=<platform>
325                      - build for platform <platform>.
326 --init-rpm-dir       - initialize ~/rpm directory structure
327 "
328 }
329
330 update_shell_title() {
331         [ -t 1 ] || return
332         local len=${COLUMNS:-80}
333         local msg=$(echo "$*" | cut -c-$len)
334
335         if [ -n "$BE_VERBOSE" ]; then
336                 echo >&2 "$(date +%s.%N) $*"
337         fi
338
339         if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
340                 local pkg
341                 if [ -n "$PACKAGE_NAME" ]; then
342                         pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
343                 else
344                         pkg=${SPECFILE}
345                 fi
346
347                 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
348                 msg="$(echo $msg | tr -d '\n\r')"
349                 case "$TERM" in
350                         cygwin|xterm*)
351                         echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
352                 ;;
353                         screen*)
354                         echo >&2 -ne "\033]0;$msg\007"
355                 ;;
356                 esac
357         fi
358 }
359
360 # set TARGET from BuildArch: from SPECFILE
361 set_spec_target() {
362         if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
363                 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
364                 if [ "$tmp" ]; then
365                                 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
366                                 TARGET="$tmp"
367                                 case "$RPMBUILD" in
368                                 "rpmbuild")
369                                         TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
370                                 "rpm")
371                                         TARGET_SWITCH="--target=$TARGET" ;;
372                                 esac
373                 fi
374         fi
375 }
376
377 # runs rpm with minimal macroset
378 minirpm() {
379         # we reset macros not to contain macros.build as all the %() macros are
380         # executed here, while none of them are actually needed.
381         # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
382         safe_macrofiles=$(rpm --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
383
384         # TODO: move these to /usr/lib/rpm/macros
385         cat > .builder-rpmmacros <<'EOF'
386 %x8664 x86_64 amd64 ia32e
387 %alt_kernel %{nil}
388 %_alt_kernel %{nil}
389 %requires_releq_kernel_up %{nil}
390 %requires_releq_kernel_smp %{nil}
391 %requires_releq_kernel %{nil}
392 %requires_releq() %{nil}
393 %pyrequires_eq() %{nil}
394 %requires_eq() %{nil}
395 %requires_eq_to() %{nil}
396 %releq_kernel_up ERROR
397 %releq_kernel_smp ERROR
398 %releq_kernel ERROR
399 %kgcc_package ERROR
400 %_fontsdir ERROR
401 %ruby_version ERROR
402 %ruby_ver_requires_eq() %{nil}
403 %ruby_mod_ver_requires_eq() %{nil}
404 %__php_api_requires() %{nil}
405 %php_major_version ERROR
406 %php_api_version ERROR
407 %py_ver ERROR
408 %perl_vendorarch ERROR
409 %perl_vendorlib ERROR
410 # damn. need it here! - copied from /usr/lib/rpm/macros.build
411 %tmpdir         %(echo "${TMPDIR:-/tmp}")
412 %patchset_source(f:b:) %(
413         base=%{-b*}%{!-b*:10000};
414         start=$(expr $base + %1);
415         end=$(expr $base + %{?2}%{!?2:%{1}});
416         # we need to call seq twice as it doesn't allow two formats
417         seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
418         seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
419         paste %{tmpdir}/__ps{1,2};
420         rm -f %{tmpdir}/__ps{1,2};
421 ) \
422 %{nil}
423 EOF
424         if [ "$NOINIT" = "yes" ] ; then
425                 cat >> .builder-rpmmacros <<'EOF'
426 %_specdir ./
427 %_sourcedir ./
428 EOF
429         fi
430         eval $RPMBUILD --macros "$safe_macrofiles:.builder-rpmmacros" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
431 }
432
433 cache_rpm_dump() {
434         if [ -n "$DEBUG" ]; then
435                 set -x
436                 set -v
437         fi
438
439         update_shell_title "cache_rpm_dump"
440         local rpm_dump
441         rpm_dump=`
442                 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
443                 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
444                 case "$RPMBUILD" in
445                 rpm)
446                         ARGS='-bp'
447                         ;;
448                 rpmbuild)
449                         ARGS='--nodigest --nosignature --nobuild'
450                         ;;
451                 esac
452                 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
453         `
454         if [ $? -gt 0 ]; then
455                 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
456                 echo "$error" >&2
457                 Exit_error err_build_fail
458         fi
459
460         # make small dump cache
461         rpm_dump_cache=`echo "$rpm_dump" | awk '
462                 $2 ~ /^SOURCEURL/ {print}
463                 $2 ~ /^PATCHURL/  {print}
464                 $2 ~ /^nosource/ {print}
465                 $2 ~ /^PACKAGE_/ {print}
466         '`
467
468         update_shell_title "cache_rpm_dump: OK!"
469 }
470
471 rpm_dump() {
472         if [ -z "$rpm_dump_cache" ] ; then
473                 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
474         fi
475         echo "$rpm_dump_cache"
476 }
477
478 get_icons()
479 {
480         update_shell_title "get icons"
481         ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
482         if [ -z "$ICONS" ]; then
483                 return
484         fi
485
486         rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
487 }
488
489 parse_spec()
490 {
491         update_shell_title "parsing specfile"
492         if [ -n "$DEBUG" ]; then
493                 set -x
494                 set -v
495         fi
496
497         # icons are needed for successful spec parse
498         get_icons
499
500         cd $SPECS_DIR
501         cache_rpm_dump
502
503         if [ "$NOSRCS" != "yes" ]; then
504                 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
505         fi
506
507         if (rpm_dump | grep -qEi ":.*nosource.*1"); then
508                 FAIL_IF_NO_SOURCES="no"
509         fi
510
511         PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
512         ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
513         PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
514         PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
515         PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
516
517         if [ -n "$BE_VERBOSE" ]; then
518                 echo "- Sources :  `nourl $SOURCES`"
519                 if [ -n "$PATCHES" ]; then
520                         echo "- Patches :  `nourl $PATCHES`"
521                 else
522                         echo "- Patches :  *no patches needed*"
523                 fi
524                 if [ -n "$ICONS" ]; then
525                         echo "- Icon    :  `nourl $ICONS`"
526                 else
527                         echo "- Icon    :  *no package icon*"
528                 fi
529                 echo "- Name    : $PACKAGE_NAME"
530                 echo "- Version : $PACKAGE_VERSION"
531                 echo "- Release : $PACKAGE_RELEASE"
532         fi
533
534         update_shell_title "parse_spec: OK!"
535 }
536
537 Exit_error()
538 {
539         if [ -n "$DEBUG" ]; then
540                 set -x
541                 set -v
542         fi
543
544         cd "$__PWD"
545
546         case "$1" in
547                 "err_no_spec_in_cmdl" )
548                         remove_build_requires
549                         echo "ERROR: spec file name not specified."
550                         exit 2 ;;
551                 "err_invalid_cmdline" )
552                         echo "ERROR: invalid command line arg ($2)."
553                         exit 2 ;;
554                 "err_no_spec_in_repo" )
555                         remove_build_requires
556                         echo "Error: spec file not stored in CVS repo."
557                         exit 3 ;;
558                 "err_no_source_in_repo" )
559                         remove_build_requires
560                         echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"
561                         exit 4 ;;
562                 "err_build_fail" )
563                         remove_build_requires
564                         echo "Error: package build failed. (${2:-no more info})"
565                         exit 5 ;;
566                 "err_no_package_data" )
567                         remove_build_requires
568                         echo "Error: couldn't get out package name/version/release from spec file."
569                         exit 6 ;;
570                 "err_tag_exists" )
571                         remove_build_requires
572                         echo "Tag ${2} already exists (spec release: ${3})."
573                         exit 9 ;;
574                 "err_fract_rel" )
575                         remove_build_requires
576                         echo "Release ${2} not integer and not a snapshot."
577                         exit 10 ;;
578                 "err_branch_exists" )
579                         remove_build_requires
580                         echo "Tree branch already exists (${2})."
581                         exit 11 ;;
582                 "err_acl_deny" )
583                         remove_build_requires
584                         echo "Error: conditions reject building this spec (${2})."
585                         exit 12 ;;
586         esac
587         echo "Unknown error."
588         exit 100
589 }
590
591 init_builder()
592 {
593         if [ -n "$DEBUG" ]; then
594                 set -x
595                 set -v
596         fi
597
598         if [ "$NOINIT" != "yes" ] ; then
599                 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
600                 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
601         else
602                 SOURCE_DIR="."
603                 SPECS_DIR="."
604         fi
605
606         __PWD="`pwd`"
607 }
608
609 get_spec()
610 {
611
612         update_shell_title "get_spec"
613
614         if [ -n "$DEBUG" ]; then
615                 set -x
616                 set -v
617         fi
618
619         cd "$SPECS_DIR"
620         if [ ! -f "$SPECFILE" ]; then
621                 SPECFILE="`basename $SPECFILE .spec`.spec"
622         fi
623         if [ "$NOCVSSPEC" != "yes" ]; then
624
625                 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
626                         echo "Warning: No CVS access defined - using local .spec file"
627                         NOCVSSPEC="yes"
628                 fi
629
630                 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
631         fi
632
633         if [ ! -f "$SPECFILE" ]; then
634                 Exit_error err_no_spec_in_repo
635         fi
636
637         if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
638                 chmod $CHMOD_MODE $SPECFILE
639         fi
640         unset OPTIONS
641         [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
642
643         set_spec_target
644 }
645
646 find_mirror()
647 {
648         cd "$SPECS_DIR"
649         local url="$1"
650         if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
651                 cvs update mirrors >&2
652         fi
653
654         IFS="|"
655         local origin mirror name rest ol prefix
656         while read origin mirror name rest; do
657                 # skip comments and empty lines
658                 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
659                         continue
660                 fi
661                 ol=`echo -n "$origin"|wc -c`
662                 prefix="`echo -n "$url" | head -c $ol`"
663                 if [ "$prefix" = "$origin" ] ; then
664                         suffix="`echo "$url"|cut -b $((ol+1))-`"
665                         echo -n "$mirror$suffix"
666                         return 0
667                 fi
668         done < mirrors
669         echo "$url"
670 }
671
672 # Warning: unpredictable results if same URL used twice
673 src_no ()
674 {
675         cd $SPECS_DIR
676         rpm_dump | \
677         grep "SOURCEURL[0-9]*[  ]*$1""[         ]*$" | \
678         sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
679         head -n 1 | xargs
680 }
681
682 src_md5()
683 {
684         [ "$NO5" = "yes" ] && return
685         no=$(src_no "$1")
686         [ -z "$no" ] && return
687         cd $SPECS_DIR
688         local md5
689
690         if [ -f additional-md5sums ]; then
691                 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
692                 if [ -z "$spec_rev" ]; then
693                         spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
694                 fi
695                 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
696                 md5=$(grep -s -v '^#' additional-md5sums | \
697                 grep -E "[      ]$(basename "$1")[      ]+${spec}([     ,]|\$)" | \
698                 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
699                 grep -E '^[0-9a-f]{32}$')
700
701                 if [ "$md5" ]; then
702                         if [ $(echo "$md5" | wc -l) != 1 ] ; then
703                                 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
704                         fi
705                         echo "$md5" | tail -n 1
706                         return
707                 fi
708         fi
709
710         source_md5=`grep -i "#[         ]*Source$no-md5[        ]*:" $SPECFILE | sed -e 's/.*://'`
711         if [ -n "$source_md5" ]; then
712                 echo $source_md5
713         else
714                 # we have empty SourceX-md5, but it is still possible
715                 # that we have NoSourceX-md5 AND NoSource: X
716                 nosource_md5=`grep -i "#[        ]*NoSource$no-md5[      ]*:" $SPECFILE | sed -e 's/.*://'`
717                 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[     ]*$no$" $SPECFILE`" ] ; then
718                         echo $nosource_md5
719                 fi
720         fi
721 }
722
723 distfiles_path ()
724 {
725         echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
726 }
727
728 distfiles_url ()
729 {
730         echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
731 }
732
733 distfiles_attic_url ()
734 {
735         echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
736 }
737
738 good_md5 ()
739 {
740         md5=$(src_md5 "$1")
741         [ "$md5" = "" ] || \
742         [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
743 }
744
745 good_size ()
746 {
747         size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
748         [ -n "$size" -a "$size" -gt 0 ]
749 }
750
751 cvsignore_df ()
752 {
753         if [ "$CVSIGNORE_DF" != "yes" ]; then
754                 return
755         fi
756         cvsignore=${SOURCE_DIR}/.cvsignore
757         if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
758                 echo "$1" >> $cvsignore
759         fi
760 }
761
762 cvsup()
763 {
764         update_shell_title "cvsup"
765         local OPTIONS="up "
766         if [ -n "$CVSROOT" ]; then
767                 OPTIONS="-d $CVSROOT $OPTIONS"
768         fi
769
770         if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
771                 OPTIONS="$OPTIONS -A"
772         else
773                 if [ -n "$CVSDATE" ]; then
774                         OPTIONS="$OPTIONS -D $CVSDATE"
775                 fi
776                 if [ -n "$CVSTAG" ]; then
777                         OPTIONS="$OPTIONS -r $CVSTAG"
778                 fi
779         fi
780
781         local result=1
782         local retries_counter=0
783         if [ $# = 1 ]; then
784                 update_shell_title "cvsup: $*"
785         else
786                 update_shell_title "cvsup: $# files"
787         fi
788         while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
789                 retries_counter=$(( $retries_counter + 1 ))
790                 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
791                 result=$?
792                 [ -n "$output" ] && echo "$output"
793                 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
794                         echo "Trying again [$*]... ($retries_counter)"
795                         update_shell_title "cvsup: retry #$retries_counter"
796                         sleep 2
797                         continue
798                 else
799                         break
800                 fi
801         done
802         update_shell_title "cvsup: done!"
803         return $result
804 }
805
806 # returns true if "$1" is ftp, http or https protocol url
807 is_url()
808 {
809         case "$1" in
810         ftp://*|http://*|https://*)
811                 return 0
812         ;;
813         esac
814         return 1
815 }
816
817 update_md5()
818 {
819         if [ $# -eq 0 ]; then
820                 return
821         fi
822
823         update_shell_title "update md5"
824         if [ -n "$DEBUG" ]; then
825                 set -x
826                 set -v
827         fi
828
829         cd "$SOURCE_DIR"
830
831         # pass 1: check files to be fetched
832         local todo
833         local need_files
834         for i in "$@"; do
835                 local fp=$(nourl "$i")
836                 local srcno=$(src_no "$i")
837                 if [ -n "$ADD5" ]; then
838                         [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
839                         grep -qiE '^#[  ]*Source'$srcno'-md5[   ]*:' $SPECS_DIR/$SPECFILE && continue
840                 else
841                         grep -qiE '^#[  ]*Source'$srcno'-md5[   ]*:' $SPECS_DIR/$SPECFILE || continue
842                 fi
843                 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
844                         need_files="$need_files $i"
845                 fi
846         done
847
848         # pass 1a: get needed files
849         if [ "$need_files" ]; then
850                 get_files $need_files
851         fi
852
853         # pass 2: proceed with md5 adding or updating
854         for i in "$@"; do
855                 local fp=$(nourl "$i")
856                 local srcno=$(src_no "$i")
857                 local md5=$(grep -iE '^#[       ]*(No)?Source'$srcno'-md5[      ]*:' $SPECS_DIR/$SPECFILE )
858                 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
859                         local tag="Source$srcno-md5"
860                         if [[ "$md5" == *NoSource* ]]; then
861                                 tag="NoSource$srcno-md5"
862                         fi
863                         md5=$(md5sum "$fp" | cut -f1 -d' ')
864                         echo "Updating $tag ($md5: $fp)."
865                         perl -i -ne '
866                                 print unless /^\s*#\s*(No)?Source'$srcno'-md5\s*:/i;
867                                 print "# '$tag':\t'$md5'\n" if /^Source'$srcno'\s*:\s+/;
868                         ' \
869                         $SPECS_DIR/$SPECFILE
870                 fi
871         done
872 }
873
874 check_md5()
875 {
876         update_shell_title "check md5"
877
878         for i in "$@"; do
879                 if good_md5 "$i" && good_size "$i"; then
880                         continue
881                 fi
882
883                 echo "MD5 sum mismatch or 0 size.  Use -U to refetch sources,"
884                 echo "or -5 to update md5 sums, if you're sure files are correct."
885                 Exit_error err_no_source_in_repo $i
886         done
887 }
888
889 get_files()
890 {
891         update_shell_title "get_files"
892
893         if [ -n "$DEBUG" ]; then
894                 set -x
895                 set -v
896         fi
897
898         if [ $# -gt 0 ]; then
899                 cd "$SOURCE_DIR"
900
901                 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
902                         echo "Warning: No CVS access defined for SOURCES"
903                         NOCVS="yes"
904                 fi
905
906                 local nc=0
907                 local get_files_cvs=""
908                 for i in "$@"; do
909                         nc=$((nc + 1))
910                         local cvsup=0
911                         SHELL_TITLE_PREFIX="get_files[$nc/$#]"
912                         update_shell_title "$i"
913                         local fp=`nourl "$i"`
914                         if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
915                                 continue
916                         fi
917
918                         FROM_DISTFILES=0
919                         local srcmd5=$(src_md5 "$i")
920
921                         # we know if source/patch is present in cvs/distfiles
922                         # - has md5 (in distfiles)
923                         # - in cvs... ideas?
924
925                         # CHECK: local file didn't exist or always cvs up (first) requested.
926                         if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
927                                 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
928                                         echo "Warning: no URL given for $i"
929                                 fi
930
931                                 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
932                                         if good_md5 "$i" && good_size "$i"; then
933                                                 echo "$fp having proper md5sum already exists"
934                                                 continue
935                                         fi
936                                         target="$fp"
937
938                                         # prefer mirror over distfiles if there's mirror
939                                         # TODO: build url list and then try each url from the list
940                                         if [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
941                                                 url="$im"
942                                         else
943                                                 url=$(distfiles_url "$i")
944                                         fi
945
946                                         url_attic=$(distfiles_attic_url "$i")
947                                         FROM_DISTFILES=1
948                                         # is $url local file?
949                                         if [[ "$url" = [./]* ]]; then
950                                                 update_shell_title "${GETLOCAL%% *}: $url"
951                                                 ${GETLOCAL} $url $target
952                                         else
953                                                 if [ -z "$NOMIRRORS" ]; then
954                                                         url=$(find_mirror "$url")
955                                                 fi
956
957                                                 local uri=${url}
958                                                 # make shorter message for distfiles urls
959                                                 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
960                                                         uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
961                                                         uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
962                                                         uri="df: $uri"
963                                                 fi
964                                                 update_shell_title "${GETURI%% *}: $uri"
965                                                 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
966                                                 if [ "`echo $url | grep -E 'ftp://'`" ]; then
967                                                         update_shell_title "${GETURI2%% *}: $url"
968                                                         ${GETURI2} ${OUTFILEOPT} "$target" "$url"
969                                                 fi
970                                         fi
971
972                                         # is it empty file?
973                                         if [ ! -s "$target" ]; then
974                                                 rm -f "$target"
975                                                 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
976                                                         update_shell_title "${GETLOCAL%% *}: $url_attic"
977                                                         ${GETLOCAL} $url_attic $target
978                                                 else
979                                                         if [ -z "$NOMIRRORS" ]; then
980                                                                 url_attic="`find_mirror "$url_attic"`"
981                                                         fi
982                                                         update_shell_title "${GETURI%% *}: $url_attic"
983                                                         ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
984                                                         if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
985                                                                 update_shell_title "${GETURI2%% *}: $url_attic"
986                                                                 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
987                                                         fi
988                                                 fi
989                                         fi
990
991                                         if [ -s "$target" ]; then
992                                                 cvsignore_df $target
993                                         else
994                                                 rm -f "$target"
995                                                 FROM_DISTFILES=0
996                                         fi
997                                 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
998                                         if [ $# -gt 1 ]; then
999                                                 get_files_cvs="$get_files_cvs $fp"
1000                                                 update_shell_title "$fp (will cvs up later)"
1001                                                 cvsup=1
1002                                         else
1003                                                 cvsup $fp
1004                                         fi
1005                                 fi
1006
1007                                 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1008                                         if [ -z "$NOMIRRORS" ]; then
1009                                                 im="`find_mirror "$i"`"
1010                                         else
1011                                                 im="$i"
1012                                         fi
1013                                         update_shell_title "${GETURI%% *}: $im"
1014                                         ${GETURI} "$im" || \
1015                                         if [ "`echo $im | grep -E 'ftp://'`" ]; then
1016                                                 update_shell_title "${GETURI2%% *}: $im"
1017                                                 ${GETURI2} "$im"
1018                                         fi
1019                                 fi
1020
1021                                 if [ "$cvsup" = 1 ]; then
1022                                         continue
1023                                 fi
1024
1025                         fi
1026
1027                         # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1028                         if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1029                                 Exit_error err_no_source_in_repo $i
1030                         fi
1031
1032                         # we check md5 here just only to refetch immediately
1033                         if good_md5 "$i" && good_size "$i"; then
1034                                 :
1035                         elif [ "$FROM_DISTFILES" = 1 ]; then
1036                                 # wrong md5 from distfiles: remove the file and try again
1037                                 # but only once ...
1038                                 echo "MD5 sum mismatch. Trying full fetch."
1039                                 FROM_DISTFILES=2
1040                                 rm -f $target
1041                                 update_shell_title "${GETURI%% *}: $url"
1042                                 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1043                                 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1044                                         update_shell_title "${GETURI2%% *}: $url"
1045                                         ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1046                                 fi
1047                                 if [ ! -s "$target" ]; then
1048                                         rm -f "$target"
1049                                         update_shell_title "${GETURI%% *}: $url_attic"
1050                                         ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1051                                         if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1052                                                 update_shell_title "${GETURI2%% *}: $url_attic"
1053                                                 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1054                                         fi
1055                                 fi
1056                                 test -s "$target" || rm -f "$target"
1057                         fi
1058                 done
1059                 SHELL_TITLE_PREFIX=""
1060
1061                 if [ "$get_files_cvs" ]; then
1062                         cvsup $get_files_cvs
1063                 fi
1064
1065                 if [ "$CHMOD" = "yes" ]; then
1066                         CHMOD_FILES="`nourl "$@"`"
1067                         if [ -n "$CHMOD_FILES" ]; then
1068                                 chmod $CHMOD_MODE $CHMOD_FILES
1069                         fi
1070                 fi
1071         fi
1072 }
1073
1074 make_tagver() {
1075         if [ -n "$DEBUG" ]; then
1076                 set -x
1077                 set -v
1078         fi
1079
1080         # Check whether first character of PACKAGE_NAME is legal for tag name
1081         if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1082                 TAG_PREFIX=tag_
1083         fi
1084
1085         # NOTE: CVS tags may must not contain the characters `$,.:;@'
1086         TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1087
1088         # Remove #kernel.version_release from TAGVER because tagging sources
1089         # could occur with different kernel-headers than kernel-headers used at build time.
1090         # besides, %{_kernel_ver_str} is not expanded.
1091
1092         # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1093         # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1094
1095         TAGVER=${TAGVER%#*}
1096         echo -n "$TAGVER"
1097 }
1098
1099 tag_files()
1100 {
1101         TAG_FILES="$@"
1102
1103         if [ -n "$DEBUG" ]; then
1104                 set -x
1105                 set -v
1106         fi
1107
1108         echo "Version: $PACKAGE_VERSION"
1109         echo "Release: $PACKAGE_RELEASE"
1110
1111         local TAGVER
1112         if [ "$TAG_VERSION" = "yes" ]; then
1113                 TAGVER=`make_tagver`
1114                 echo "CVS tag: $TAGVER"
1115         fi
1116         if [ -n "$TAG" ]; then
1117                 echo "CVS tag: $TAG"
1118         fi
1119
1120         local OPTIONS="tag $CVS_FORCE"
1121         if [ -n "$CVSROOT" ]; then
1122                 OPTIONS="-d $CVSROOT $OPTIONS"
1123         fi
1124
1125         cd "$SOURCE_DIR"
1126         local tag_files
1127         for i in $TAG_FILES; do
1128                 # don't tag files stored on distfiles
1129                 [ -n "`src_md5 $i`" ] && continue
1130                 local fp=`nourl "$i"`
1131                 if [ -f "$fp" ]; then
1132                         tag_files="$tag_files $fp"
1133                 else
1134                         Exit_error err_no_source_in_repo $i
1135                 fi
1136         done
1137
1138         if [ "$tag_files" ]; then
1139                 if [ "$TAG_VERSION" = "yes" ]; then
1140                         update_shell_title "tag sources: $TAGVER"
1141                         cvs $OPTIONS $TAGVER $tag_files || exit
1142                 fi
1143                 if [ -n "$TAG" ]; then
1144                         update_shell_title "tag sources: $TAG"
1145                         cvs $OPTIONS $TAG $tag_files || exit
1146                 fi
1147         fi
1148
1149         cd "$SPECS_DIR"
1150         if [ "$TAG_VERSION" = "yes" ]; then
1151                 update_shell_title "tag spec: $TAGVER"
1152                 cvs $OPTIONS $TAGVER $SPECFILE || exit
1153         fi
1154         if [ -n "$TAG" ]; then
1155                 update_shell_title "tag spec: $TAG"
1156                 cvs $OPTIONS $TAG $SPECFILE || exit
1157         fi
1158 }
1159
1160 branch_files()
1161 {
1162         TAG=$1
1163         echo "CVS branch tag: $TAG"
1164         shift
1165
1166         TAG_FILES="$@"
1167
1168         if [ -n "$DEBUG" ]; then
1169                 set -x
1170                 set -v
1171         fi
1172
1173         local OPTIONS="tag $CVS_FORCE -b"
1174         if [ -n "$CVSROOT" ]; then
1175                 OPTIONS="-d $CVSROOT $OPTIONS"
1176         fi
1177         cd "$SOURCE_DIR"
1178         local tag_files
1179         for i in $TAG_FILES; do
1180                 local fp=`nourl "$i"`
1181                 if [ -f "$fp" ]; then
1182                         tag_files="$tag_files $fp"
1183                 else
1184                         Exit_error err_no_source_in_repo $i
1185                 fi
1186         done
1187         if [ "$tag_files" ]; then
1188                 cvs $OPTIONS $TAG $tag_files || exit
1189         fi
1190
1191         cd "$SPECS_DIR"
1192         cvs $OPTIONS $TAG $SPECFILE || exit
1193 }
1194
1195
1196 # this function should exit early if package can't be built for this arch
1197 # this avoids unneccessary BR filling.
1198 check_buildarch() {
1199         local out ret
1200         out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1201         ret=$?
1202         if [ $ret -ne 0 ]; then
1203                 echo >&2 "$out"
1204                 exit $ret
1205         fi
1206 }
1207
1208
1209 build_package()
1210 {
1211         update_shell_title "build_package"
1212         if [ -n "$DEBUG" ]; then
1213                 set -x
1214                 set -v
1215         fi
1216
1217         cd "$SPECS_DIR"
1218
1219         if [ -n "$TRY_UPGRADE" ]; then
1220                 update_shell_title "build_package: try_upgrade"
1221                 if [ -n "$FLOAT_VERSION" ]; then
1222                         TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1223                 else
1224                         TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1225                 fi
1226
1227                 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1228
1229                 if [ -n "$TNEWVER" ]; then
1230                         TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1231                         echo "New version found, updating spec file to version " $TNEWVER
1232                         if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1233                                 cp -f $SPECFILE $SPECFILE.bak
1234                         fi
1235                         chmod +w $SPECFILE
1236                         eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1237                         eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1238                         parse_spec
1239                         NODIST="yes" get_files $SOURCES $PATCHES
1240                         update_md5 $SOURCES
1241
1242                         unset TOLDVER TNEWVER TNOTIFY
1243                 fi
1244         fi
1245         cd "$SPECS_DIR"
1246
1247         case "$COMMAND" in
1248                 build )
1249                         BUILD_SWITCH="-ba" ;;
1250                 build-binary )
1251                         BUILD_SWITCH="-bb" ;;
1252                 build-source )
1253                         BUILD_SWITCH="-bs --nodeps" ;;
1254                 build-prep )
1255                         BUILD_SWITCH="-bp --nodeps" ;;
1256                 build-build )
1257                         BUILD_SWITCH="-bc" ;;
1258                 build-install )
1259                         BUILD_SWITCH="-bi" ;;
1260                 build-list )
1261                         BUILD_SWITCH="-bl" ;;
1262
1263         esac
1264
1265         update_shell_title "build_package: $COMMAND"
1266         if [ -n "$LOGFILE" ]; then
1267                 LOG=`eval echo $LOGFILE`
1268                 if [ -d "$LOG" ]; then
1269                         echo "Log file $LOG is a directory."
1270                         echo "Parse error in the spec?"
1271                         Exit_error err_build_fail
1272                 fi
1273                 if [ -n "$LASTLOG_FILE" ]; then
1274                         echo "LASTLOG=$LOG" > $LASTLOG_FILE
1275                 fi
1276                 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1277                 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1278                 RETVAL=`cat $RES_FILE`
1279                 rm $RES_FILE
1280                 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1281                         if [ "$RETVAL" -eq "0" ]; then
1282                                 mv $LOG $LOGDIROK
1283                         else
1284                                 mv $LOG $LOGDIRFAIL
1285                         fi
1286                 fi
1287         else
1288                 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1289                 RETVAL=$?
1290         fi
1291         if [ "$RETVAL" -ne "0" ]; then
1292                 if [ -n "$TRY_UPGRADE" ]; then
1293                         echo "\n!!! Package with new version cannot be built automagically\n"
1294                         if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1295                                 mv -f $SPECFILE.bak $SPECFILE
1296                         fi
1297                 fi
1298                 Exit_error err_build_fail
1299         fi
1300         unset BUILD_SWITCH
1301 }
1302
1303 nourl()
1304 {
1305         echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1306 }
1307
1308 install_required_packages()
1309 {
1310         run_poldek -vi $1
1311         return $?
1312 }
1313
1314 find_spec_bcond() {
1315         # taken from find-spec-bcond, but with just getting the list
1316         local SPEC="$1"
1317         # quick revert hint: '$RPMBUILD --bcond $SPEC'
1318         awk -F"\n" '
1319         /^%changelog/ { exit }
1320         /_with(out)?_[_a-zA-Z0-9]+/{
1321                 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1322                 print substr($0, RSTART, RLENGTH);
1323         }
1324         /^%bcond_with/{
1325                 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1326                 bcond = substr($0, RSTART +5 , RLENGTH -5);
1327                 gsub(/[ \t]+/,"_",bcond);
1328                 print bcond
1329         }' $SPEC | LC_ALL=C sort -u
1330 }
1331
1332 process_bcondrc() {
1333         # expand bconds from ~/.bcondrc
1334         # The file structure is like gentoo's package.use:
1335         # ---
1336         # * -selinux
1337         # samba -mysql -pgsql
1338         # w32codec-installer license_agreement
1339         # php +mysqli
1340         # ---
1341         if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1342                 :
1343         else
1344                 return
1345         fi
1346
1347         SN=${SPECFILE%%\.spec}
1348
1349         local bcondrc=$HOME/.bcondrc
1350         [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1351
1352         local bcond_avail=$(find_spec_bcond $SPECFILE)
1353
1354         while read pkg flags; do
1355                 # ignore comments
1356                 [[ "$pkg" == \#* ]] && continue
1357
1358                 # any package or current package?
1359                 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1360                         for flag in $flags; do
1361                                 local opt=${flag#[+-]}
1362
1363                                 # use only flags which are in this package.
1364                                 if [[ $bcond_avail = *${opt}* ]]; then
1365                                         if [[ $flag = -* ]]; then
1366                                                 if [[ $BCOND != *--with?${opt}* ]]; then
1367                                                         BCOND="$BCOND --without $opt"
1368                                                 fi
1369                                         else
1370                                                 if [[ $BCOND != *--without?${opt}* ]]; then
1371                                                         BCOND="$BCOND --with $opt"
1372                                                 fi
1373                                         fi
1374                                 fi
1375                         done
1376                 fi
1377         done < $bcondrc
1378         update_shell_title "parse ~/.bcondrc: DONE!"
1379 }
1380
1381 set_bconds_values()
1382 {
1383         update_shell_title "set bcond values"
1384
1385         AVAIL_BCONDS_WITHOUT=""
1386         AVAIL_BCONDS_WITH=""
1387         if `grep -q ^%bcond ${SPECFILE}`; then
1388                 BCOND_VERSION="NEW"
1389         elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1390                 BCOND_VERSION="OLD"
1391         else
1392                 return
1393         fi
1394
1395         local bcond_avail=$(find_spec_bcond $SPECFILE)
1396         process_bcondrc "$SPECFILE"
1397
1398         update_shell_title "parse bconds"
1399         case "${BCOND_VERSION}" in
1400                 NONE)
1401                         :
1402                         ;;
1403                 OLD)
1404                         echo "Warning: This spec has old style bconds. Fix it || die."
1405                         for opt in `echo "$bcond_avail" | grep ^_without_`
1406                         do
1407                                 AVAIL_BCOND_WITHOUT=${opt#_without_}
1408                                 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1409                                         AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1410                                 else
1411                                         AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1412                                 fi
1413                         done
1414
1415                         for opt in `echo "$bcond_avail" | grep ^_with_`
1416                         do
1417                                 AVAIL_BCOND_WITH=${opt#_with_}
1418                                 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1419                                         AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1420                                 else
1421                                         AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1422                                 fi
1423                         done
1424                         ;;
1425                 NEW)
1426                         local cond_type="" # with || without
1427                         for opt in $bcond_avail; do
1428                                 case "$opt" in
1429                                         _without)
1430                                                 cond_type="without"
1431                                                 ;;
1432                                         _with)
1433                                                 cond_type="with"
1434                                                 ;;
1435                                         _without_*)
1436                                                 AVAIL_BCOND_WITHOUT=${opt#_without_}
1437                                                 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1438                                                         AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1439                                                 else
1440                                                         AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1441                                                 fi
1442                                                 ;;
1443                                         _with_*)
1444                                                 AVAIL_BCOND_WITH=${opt#_with_}
1445                                                 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1446                                                         AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1447                                                 else
1448                                                         AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1449                                                 fi
1450                                                 ;;
1451                                         *)
1452                                                 case "$cond_type" in
1453                                                         with)
1454                                                                 cond_type=''
1455                                                                 AVAIL_BCOND_WITH="$opt"
1456                                                                 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1457                                                                         AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1458                                                                 else
1459                                                                         AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1460                                                                 fi
1461                                                                 ;;
1462                                                         without)
1463                                                                 cond_type=''
1464                                                                 AVAIL_BCOND_WITHOUT="$opt"
1465                                                                 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1466                                                                         AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1467                                                                 else
1468                                                                         AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1469                                                                 fi
1470                                                                 ;;
1471                                                 esac
1472                                                 ;;
1473                                 esac
1474                         done
1475                         ;;
1476         esac
1477 }
1478
1479 run_sub_builder()
1480 {
1481         package_name="${1}"
1482         update_shell_title "run_sub_builder $package_name"
1483         #
1484         # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1485         # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1486         # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1487         # jakby nie bylo tego kawalka kodu.
1488         #
1489         # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1490         #         Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1491         #
1492         #
1493         # y0shi.
1494
1495         parent_spec_name=''
1496
1497         # Istnieje taki spec? ${package}.spec
1498         if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1499                 parent_spec_name=${package}.spec
1500         elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1501                 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1502         else
1503                 for provides_line in `grep ^Provides:.*$package  ${SPECS_DIR} -R`
1504                 do
1505                         echo $provides_line
1506                 done
1507         fi
1508
1509         if [ "${parent_spec_name}" != "" ]; then
1510                 spawn_sub_builder $parent_spec_name
1511         fi
1512         NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1513 }
1514
1515 spawn_sub_builder()
1516 {
1517         package_name="${1}"
1518         update_shell_title "spawn_sub_builder $package_name"
1519
1520         sub_builder_opts=''
1521         if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1522                 sub_builder_opts="${sub_builder_opts} -R"
1523         fi
1524         if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1525                 sub_builder_opts="${sub_builder_opts} -RB"
1526         elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1527                 sub_builder_opts="${sub_builder_opts} -FRB"
1528         fi
1529         if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1530                 sub_builder_opts="${sub_builder_opts} -Upi"
1531         fi
1532
1533         cd "${SPECS_DIR}"
1534         ./builder ${sub_builder_opts} "$@"
1535 }
1536
1537 remove_build_requires()
1538 {
1539         if [ "$INSTALLED_PACKAGES" != "" ]; then
1540                 case "$REMOVE_BUILD_REQUIRES" in
1541                         "force")
1542                                 run_poldek --noask -ve $INSTALLED_PACKAGES
1543                                 ;;
1544                         "nice")
1545                                 run_poldek --ask -ve $INSTALLED_PACKAGES
1546                                 ;;
1547                         *)
1548                                 echo You may want to manually remove following BuildRequires fetched:
1549                                 echo $INSTALLED_PACKAGES
1550                                 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1551                                 ;;
1552                 esac
1553         fi
1554 }
1555
1556 display_bconds()
1557 {
1558         if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1559                 if [ "$BCOND" != "" ]; then
1560                         echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1561                         echo -ne "$BCOND"
1562                 else
1563                         echo -ne "\nNo conditional flags passed"
1564                 fi
1565                 echo -ne "\n\nfrom available:\n"
1566                 echo -ne "--with   :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1567         fi
1568 }
1569
1570 display_branches()
1571 {
1572         if [ "$NOCVSSPEC" != "yes" ]; then
1573                 echo -ne "Available branches: "
1574                 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1575         fi
1576 }
1577
1578 # checks a given list of packages/files/provides agains current rpmdb.
1579 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1580 # input can be either STDIN or parameters
1581 _rpm_prov_check()
1582 {
1583         local DEPS
1584
1585         if [ "$#" -gt 0 ]; then
1586                 DEPS="$@"
1587         else
1588                 DEPS=$(cat)
1589         fi
1590
1591         DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1592
1593         # packages
1594         echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1595
1596         # other deps (files)
1597         echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1598 }
1599
1600 # checks if given package/files/provides exists in rpmdb.
1601 # inout can be either stdin or parameters
1602 # returns packages wchi hare present in the rpmdb
1603 _rpm_cnfl_check()
1604 {
1605         local DEPS
1606
1607         if [ "$#" -gt 0 ]; then
1608                 DEPS="$@"
1609         else
1610                 DEPS=$(cat)
1611         fi
1612
1613         rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1614 }
1615
1616 fetch_build_requires()
1617 {
1618         if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1619                 update_shell_title "fetch build requires"
1620                 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1621                         # TODO: Conflicts list doesn't check versions
1622                         local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1623                         local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1624
1625                         if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1626                                 echo "fetch builderequires: install $DEPS; remove $CNFL"
1627                                 update_shell_title "poldek: install $DEPS; remove $CNFL"
1628                                 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1629                         fi
1630                         if [ -n "$CNFL" ]; then
1631                                 update_shell_title "uninstall conflicting packages: $CNFL"
1632                                 echo "Trying to uninstall conflicting packages ($CNFL):"
1633                                 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1634                         fi
1635
1636                         while [ "$DEPS" ]; do
1637                                         update_shell_title "install deps: $DEPS"
1638                                         echo "Trying to install dependencies ($DEPS):"
1639                                         local log=.${SPECFILE}_poldek.log
1640                                         $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1641                                         failed=$(awk -F: '/^error:/{print $2}' $log)
1642                                         rm -f $log
1643                                         local ok
1644                                         if [ -n "$failed" ]; then
1645                                                 for package in $failed; do
1646                                                         # FIXME: sanitise, deps could be not .spec files
1647                                                         spawn_sub_builder -bb $package && ok="$ok $package"
1648                                                 done
1649                                                 DEPS="$ok"
1650                                         else
1651                                                 DEPS=""
1652                                         fi
1653                         done
1654                         return
1655                 fi
1656
1657                 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1658                 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1659                 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1660                 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1661                 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1662                 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,perl\(,perl-,g -e s,::,-,g -e s,\(.*\),,g -e s,%{,,g -e s,},,g|grep -v OpenGL-devel|sed -e s,sh-utils,coreutils,g -e s,fileutils,coreutils,g -e s,textutils,coreutils,g -e s,kgcc_package,gcc,g -e s,\),,g`
1663                 do
1664                         package_item="`echo $package_item|sed -e s,rpmbuild,rpm-build,g |sed -e s,__perl,perl,g |sed -e s,gasp,binutils-gasp,g -e s,binutils-binutils,binutils,g -e s,apxs,apache,g|sed -e s,apache\(EAPI\)-devel,apache-devel,g -e s,kernel-headers\(netfilter\),kernel-headers,g -e s,awk,mawk,g -e s,mmawk,mawk,g -e s,motif,openmotif,g -e s,openopenmotif,openmotif,g`"
1665                         GO="yes"
1666                         package=`basename "$package_item"|sed -e "s/}$//g"`
1667                         COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1668                         mach=`uname -m`
1669
1670                         COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1671                         if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1672                                 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
1673                                         GO="yes"
1674                                 fi
1675                         # bcond:
1676                         else
1677                                 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1678                                 GO=""
1679                                 # %{without}
1680                                 if `echo $COND_TST|grep -q 'without_'`; then
1681                                         COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1682                                         if `echo $COND_TST|grep -q !`; then
1683                                                 COND_STATE="with"
1684                                         else
1685                                                 COND_STATE="wout"
1686                                         fi
1687                                         COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1688                                         COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1689                                         if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1690                                                 COND_ARGV="wout"
1691                                         else
1692                                                 COND_ARGV="with"
1693                                         fi
1694                                 # %{with}
1695                                 elif `echo $COND_TST|grep -q 'with_'`; then
1696                                         COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1697                                         if `echo $COND_TST|grep -q !`; then
1698                                                 COND_STATE="wout"
1699                                         else
1700                                                 COND_STATE="with"
1701                                         fi
1702                                         COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1703                                         COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1704                                         if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1705                                                 COND_ARGV="with"
1706                                         else
1707                                                 COND_ARGV="wout"
1708                                         fi
1709                                 fi
1710                                 RESULT="${COND_STATE}-${COND_ARGV}"
1711                                 case "$RESULT" in
1712                                         "with-wout" | "wout-with" )
1713                                                 GO=""
1714                                                 ;;
1715                                         "wout-wout" | "with-with" )
1716                                                 GO="yes"
1717                                                 ;;
1718                                         * )
1719                                                 echo "Action '$RESULT' was not defined for package '$package_item'"
1720                                                 GO="yes"
1721                                                 ;;
1722                                 esac
1723                         fi
1724
1725                         if [ "$GO" = "yes" ]; then
1726                                 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1727                                         echo "Testing if $package has subrequirements..."
1728                                         run_poldek -t -i $package --dumpn=".$package-req.txt"
1729                                         if [ -f ".$package-req.txt" ]; then
1730                                                 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1731                                                 do
1732                                                         if [ "$package_name" = "$package" ]; then
1733                                                                 echo -ne "Installing BuildRequired package:\t$package_name\n"
1734                                                                 update_shell_title "Installing BuildRequired package: ${package_name}"
1735                                                                 install_required_packages $package
1736                                                         else
1737                                                                 echo -ne "Installing (sub)Required package:\t$package_name\n"
1738                                                                 update_shell_title "Installing (sub)Required package: ${package_name}"
1739                                                                 install_required_packages $package_name
1740                                                         fi
1741                                                         case $? in
1742                                                                 0)
1743                                                                         INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1744                                                                         echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1745                                                                         ;;
1746                                                                 *)
1747                                                                         echo "Attempting to run spawn sub - builder..."
1748                                                                         echo -ne "Package installation failed:\t$package_name\n"
1749                                                                         run_sub_builder $package_name
1750                                                                         if [ $? -eq 0 ]; then
1751                                                                                 install_required_packages $package_name
1752                                                                                 case $? in
1753                                                                                         0)
1754                                                                                                 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1755                                                                                                 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1756                                                                                                 ;;
1757                                                                                         *)
1758                                                                                                 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1759                                                                                                 ;;
1760                                                                                 esac
1761                                                                         fi
1762                                                                         ;;
1763                                                         esac
1764                                                 done
1765                                                 rm -f ".$package-req.txt"
1766                                         else
1767                                                 echo "Attempting to run spawn sub - builder..."
1768                                                 echo -ne "Package installation failed:\t$package\n"
1769                                                 run_sub_builder $package
1770                                                 if [ $? -eq 0 ]; then
1771                                                         install_required_packages $package
1772                                                         case $? in
1773                                                                 0)
1774                                                                         INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1775                                                                         echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1776                                                                         ;;
1777                                                                 *)
1778                                                                         NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1779                                                                         ;;
1780                                                         esac
1781                                                 fi
1782                                         fi
1783                                 else
1784                                         echo "Package $package is already installed. BuildRequirement satisfied."
1785                                 fi
1786                         fi
1787                 done
1788                 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1789                         echo "Unable to install following packages and their dependencies:"
1790                         for pkg in "$NOT_INSTALLED_PACKAGES"
1791                         do
1792                                 echo $pkg
1793                         done
1794                         remove_build_requires
1795                         exit 8
1796                 fi
1797         fi
1798 }
1799
1800 init_rpm_dir() {
1801
1802         TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1803         CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1804
1805         mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1806         cd $TOP_DIR
1807         cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1808
1809         init_builder
1810
1811         echo "To checkout *all* .spec files:"
1812         echo "- remove $SPECS_DIR/CVS/Entries.Static"
1813         echo "- run cvs up in $SPECS_DIR dir"
1814
1815         echo ""
1816         echo "To commit with your developer account:"
1817         echo "- edit $SPECS_DIR/CVS/Root"
1818         echo "- edit $SOURCE_DIR/CVS/Root"
1819 }
1820
1821 #---------------------------------------------
1822 # main()
1823
1824 if [ $# = 0 ]; then
1825         usage
1826         exit 1
1827 fi
1828
1829 while [ $# -gt 0 ]; do
1830         case "${1}" in
1831                 -5 | --update-md5)
1832                         COMMAND="update_md5"
1833                         NODIST="yes"
1834                         NOCVSSPEC="yes"
1835                         shift ;;
1836                 -a5 | --add-md5 )
1837                         COMMAND="update_md5"
1838                         NODIST="yes"
1839                         NOCVS="yes"
1840                         NOCVSSPEC="yes"
1841                         ADD5="yes"
1842                         shift ;;
1843                 -n5 | --no-md5 )
1844                         NO5="yes"
1845                         shift ;;
1846                 -D | --debug )
1847                         DEBUG="yes"; shift ;;
1848                 -V | --version )
1849                         COMMAND="version"; shift ;;
1850                 --short-version )
1851                         COMMAND="short-version"; shift ;;
1852                 -a | --as_anon )
1853                         CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1854                 -b | -ba | --build )
1855                         COMMAND="build"; shift ;;
1856                 -bb | --build-binary )
1857                         COMMAND="build-binary"; shift ;;
1858                 -bc )
1859                         COMMAND="build-build"; shift ;;
1860                 -bi )
1861                         COMMAND="build-install"; shift ;;
1862                 -bl )
1863                         COMMAND="build-list"; shift ;;
1864                 -bp | --build-prep )
1865                         COMMAND="build-prep"; shift ;;
1866                 -bs | --build-source )
1867                         COMMAND="build-source"; shift ;;
1868                 -B | --branch )
1869                         COMMAND="branch"; shift; TAG="${1}"; shift;;
1870                 -c | --clean )
1871                         CLEAN="--clean --rmspec --rmsource"; shift ;;
1872                 -cf | --cvs-force )
1873                         CVS_FORCE="-F"; shift;;
1874                 -d | --cvsroot )
1875                         shift; CVSROOT="${1}"; shift ;;
1876                 -g | --get )
1877                         COMMAND="get"; shift ;;
1878                 -h | --help )
1879                         COMMAND="usage"; shift ;;
1880                 --http )
1881                         PROTOCOL="http"; shift ;;
1882                 -l | --logtofile )
1883                         shift; LOGFILE="${1}"; shift ;;
1884                 -ni| --nice )
1885                         shift; DEF_NICE_LEVEL=${1}; shift ;;
1886                 -ske | --skip-existing-files)
1887                         SKIP_EXISTING_FILES="yes"; shift ;;
1888                 -m | --mr-proper )
1889                         COMMAND="mr-proper"; shift ;;
1890                 -nc | --no-cvs )
1891                         NOCVS="yes"; shift ;;
1892                 -ncs | --no-cvs-specs )
1893                         NOCVSSPEC="yes"; shift ;;
1894                 -nd | --no-distfiles )
1895                         NODIST="yes"; shift ;;
1896                 -nm | --no-mirrors )
1897                         NOMIRRORS="yes"; shift ;;
1898                 -nu | --no-urls )
1899                         NOURLS="yes"; shift ;;
1900                 -ns | --no-srcs )
1901                         NOSRCS="yes"; shift ;;
1902                 -ns0 | --no-source0 )
1903                         NOSOURCE0="yes"; shift ;;
1904                 -nn | --no-net )
1905                         NOCVS="yes"
1906                         NOCVSSPEC="yes"
1907                         NODIST="yes"
1908                         NOMIRRORS="yes"
1909                         NOURLS="yes"
1910                         NOSRCS="yes"
1911                         ALWAYS_CVSUP="no"
1912                         shift;;
1913                 --no-init )
1914                         NOINIT="yes"
1915                         shift;;
1916                 --opts )
1917                         shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
1918                 --nopatch | -np )
1919                         shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1920                 --with | --without )
1921                         case $GROUP_BCONDS in
1922                                 "yes")
1923                                         COND=${1}
1924                                         shift
1925                                         while ! `echo ${1}|grep -qE '(^-|spec)'`
1926                                         do
1927                                                 BCOND="$BCOND $COND $1"
1928                                                 shift
1929                                         done;;
1930                                 "no")
1931                                         if [[ "$2" = *,* ]]; then
1932                                                 for a in $(echo "$2" | tr , ' '); do
1933                                                         BCOND="$BCOND $1 $a"
1934                                                 done
1935                                         else
1936                                                 BCOND="$BCOND $1 $2"
1937                                         fi
1938                                         shift 2 ;;
1939                         esac
1940                         ;;
1941                 --target )
1942                         shift; TARGET="${1}"; shift ;;
1943                 --target=* )
1944                         TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1945                 -q | --quiet )
1946                         QUIET="--quiet"; shift ;;
1947                 --date )
1948                         CVSDATE="${2}"; shift 2 ;;
1949                 -r | --cvstag )
1950                         shift; CVSTAG="${1}"; shift ;;
1951                 -A)
1952                         shift; CVSTAG="HEAD"; ;;
1953                 -R | --fetch-build-requires)
1954                         FETCH_BUILD_REQUIRES="yes"
1955                         NOT_INSTALLED_PACKAGES=
1956                         shift ;;
1957                 -RB | --remove-build-requires)
1958                         REMOVE_BUILD_REQUIRES="nice"
1959                         shift ;;
1960                 -FRB | --force-remove-build-requires)
1961                         REMOVE_BUILD_REQUIRES="force"
1962                         shift ;;
1963                 -sd | --sources-distfiles)
1964                         COMMAND="list-sources-distfiles"
1965                         shift ;;
1966                 -sdp | --sources-distfiles-paths)
1967                         COMMAND="list-sources-distfiles-paths"
1968                         shift ;;
1969                 -sf | --sources-files)
1970                         COMMAND="list-sources-files"
1971                         shift ;;
1972                 -sp | --sources-paths)
1973                         COMMAND="list-sources-local-paths"
1974                         shift ;;
1975                 -su | --sources-urls)
1976                         COMMAND="list-sources-urls"
1977                         shift ;;
1978                 -Tvs | --tag-version-stable )
1979                         COMMAND="tag"
1980                         TAG="STABLE"
1981                         TAG_VERSION="yes"
1982                         shift;;
1983                 -Ts | --tag-stable )
1984                         COMMAND="tag"
1985                         TAG="STABLE"
1986                         TAG_VERSION="no"
1987                         shift;;
1988                 -Tv | --tag-version )
1989                         COMMAND="tag"
1990                         TAG=""
1991                         TAG_VERSION="yes"
1992                         shift;;
1993                 -Tp | --tag-prefix )
1994                         TAG_PREFIX="$2"
1995                         shift 2;;
1996                 -tt | --test-tag )
1997                         TEST_TAG="yes"
1998                         shift;;
1999                 -T | --tag )
2000                         COMMAND="tag"
2001                         shift
2002                         TAG="$1"
2003                         TAG_VERSION="no"
2004                         shift;;
2005                 -ir | --integer-release-only )
2006                         INTEGER_RELEASE="yes"
2007                         shift;;
2008                 -U | --update )
2009                         COMMAND="update_md5"
2010                         UPDATE="yes"
2011                         NOCVSSPEC="yes"
2012                         NODIST="yes"
2013                         shift ;;
2014                 -Upi | --update-poldek-indexes )
2015                         UPDATE_POLDEK_INDEXES="yes"
2016                         shift ;;
2017                 --init-rpm-dir)
2018                         COMMAND="init_rpm_dir"
2019                         shift ;;
2020                 -u | --try-upgrade )
2021                         TRY_UPGRADE="1"; shift ;;
2022                 -un | --try-upgrade-with-float-version )
2023                         TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2024                 -v | --verbose )
2025                         BE_VERBOSE="1"; shift ;;
2026                 --define)
2027                         shift
2028                         MACRO="${1}"
2029                         shift
2030                         if echo "${MACRO}" | grep -q '\W'; then
2031                                 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2032                         else
2033                                 VALUE="${1}"
2034                                 shift
2035                                 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2036                         fi
2037                         ;;
2038                 --short-circuit)
2039                         RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2040                         shift
2041                         ;;
2042                 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2043                         COMMAND="show_bconds"
2044                         shift
2045                         ;;
2046                 --show-bcond-args)
2047                         COMMAND="show_bcond_args"
2048                         shift
2049                         ;;
2050                 --nodeps)
2051                         shift
2052                         RPMOPTS="${RPMOPTS} --nodeps"
2053                         ;;
2054                 -debug)
2055                         RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2056                         ;;
2057                 -* )
2058                         Exit_error err_invalid_cmdline "$1"
2059                         ;;
2060                 * )
2061                         SPECFILE="${1}"
2062                         # check if specname was passed as specname:cvstag
2063                         if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2064                                 CVSTAG="${SPECFILE##*:}"
2065                                 SPECFILE="${SPECFILE%%:*}"
2066                         fi
2067                         shift
2068         esac
2069 done
2070
2071 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2072         CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2073         if [ "$CVSTAG" ]; then
2074                 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2075         fi
2076 elif [ "$CVSTAG" = "HEAD" ]; then
2077         # assume -r HEAD is same as -A
2078         CVSTAG=""
2079 fi
2080
2081 if [ -n "$DEBUG" ]; then
2082         set -x
2083         set -v
2084 fi
2085
2086 if [ -n "$TARGET" ]; then
2087         case "$RPMBUILD" in
2088                 "rpmbuild")
2089                         TARGET_SWITCH="--target $TARGET" ;;
2090                 "rpm")
2091                         TARGET_SWITCH="--target=$TARGET" ;;
2092         esac
2093 fi
2094
2095 if [ "$SCHEDTOOL" != "no" ]; then
2096         NICE_COMMAND="$SCHEDTOOL"
2097 else
2098         NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2099 fi
2100
2101 update_shell_title "$COMMAND"
2102 case "$COMMAND" in
2103         "show_bconds")
2104                 init_builder
2105                 if [ -n "$SPECFILE" ]; then
2106                         get_spec > /dev/null
2107                         parse_spec
2108                         set_bconds_values
2109                         display_bconds
2110                 fi
2111                 ;;
2112         "show_bcond_args")
2113                 init_builder
2114                 if [ -n "$SPECFILE" ]; then
2115                         get_spec > /dev/null
2116                         parse_spec
2117                         set_bconds_values
2118                         echo "$BCOND"
2119                 fi
2120                 ;;
2121         "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2122                 init_builder
2123                 if [ -n "$SPECFILE" ]; then
2124                         get_spec
2125                         parse_spec
2126                         set_bconds_values
2127                         display_bconds
2128                         display_branches
2129                         if [ "$COMMAND" != "build-source" ]; then
2130                                 check_buildarch
2131                         fi
2132                         fetch_build_requires
2133                         if [ "$INTEGER_RELEASE" = "yes" ]; then
2134                                 echo "Checking release $PACKAGE_RELEASE..."
2135                                 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2136                                         Exit_error err_fract_rel "$PACKAGE_RELEASE"
2137                                 fi
2138                         fi
2139
2140                         # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2141                         if [ -n "$TEST_TAG" ]; then
2142                                 # - do not allow utf8 encoded specs on AC-branch
2143                                 if [ "$CVSTAG" = "AC-branch" ]; then
2144                                         local t
2145                                         t=$(grep '^Summary(.*\.UTF-8):' $SPECFILE)
2146                                         if [ "$t" ]; then
2147                                                 Exit_error err_acl_deny "UTF-8 .specs not allowed on $CVSTAG"
2148                                         fi
2149                                 fi
2150
2151                                 local TAGVER=`make_tagver`
2152                                 echo "Searching for tag $TAGVER..."
2153                                 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2154                                 if [ -n "$TAGREL" ]; then
2155                                         Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2156                                 fi
2157
2158                                 # - do not allow to build from HEAD when XX-branch exists
2159                                 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2160                                 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2161                                         TAG_BRANCH="${TREE_PREFIX}-branch"
2162                                         TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2163                                         if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2164                                                 Exit_error err_branch_exists "$TAG_STATUS"
2165                                         fi
2166                                 fi
2167
2168                         fi
2169
2170                         if [ -n "$NOSOURCE0" ] ; then
2171                                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2172                         fi
2173                         get_files $SOURCES $PATCHES
2174                         check_md5 $SOURCES
2175                         build_package
2176                         if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2177                                 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2178                         fi
2179                         remove_build_requires
2180                 else
2181                         Exit_error err_no_spec_in_cmdl
2182                 fi
2183                 ;;
2184         "branch" )
2185                 init_builder
2186                 if [ -n "$SPECFILE" ]; then
2187                         get_spec
2188                         parse_spec
2189                         # don't fetch sources from remote locations
2190                         new_SOURCES=""
2191                         for file in $SOURCES; do
2192                                 [ -n "`src_md5 $file`" ] && continue
2193                                 new_SOURCES="$new_SOURCES $file"
2194                         done
2195                         SOURCES="$new_SOURCES"
2196                         get_files $SOURCES $PATCHES
2197                         check_md5 $SOURCES
2198                         branch_files $TAG $SOURCES $PATCHES $ICONS
2199                 else
2200                         Exit_error err_no_spec_in_cmdl
2201                 fi
2202                 ;;
2203         "get" )
2204                 init_builder
2205                 if [ -n "$SPECFILE" ]; then
2206                         get_spec
2207                         parse_spec
2208
2209                         if [ -n "$NOSOURCE0" ] ; then
2210                                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2211                         fi
2212                         get_files $SOURCES $PATCHES
2213                         check_md5 $SOURCES
2214                 else
2215                         Exit_error err_no_spec_in_cmdl
2216                 fi
2217                 ;;
2218         "update_md5" )
2219                 init_builder
2220                 if [ -n "$SPECFILE" ]; then
2221                         get_spec
2222                         parse_spec
2223
2224                         if [ -n "$NOSOURCE0" ] ; then
2225                                 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2226                         fi
2227                         update_md5 $SOURCES
2228                 else
2229                         Exit_error err_no_spec_in_cmdl
2230                 fi
2231                 ;;
2232         "tag" )
2233                 NOURLS=1
2234                 NODIST="yes"
2235                 init_builder
2236                 if [ -n "$SPECFILE" ]; then
2237                         get_spec
2238                         parse_spec
2239
2240                         # don't fetch sources from remote locations
2241                         new_SOURCES=""
2242                         for file in $SOURCES; do
2243                                 [ -n "`src_md5 $file`" ] && continue
2244                                 new_SOURCES="$new_SOURCES $file"
2245                         done
2246                         SOURCES="$new_SOURCES"
2247                         get_files $SOURCES $PATCHES
2248                         check_md5 $SOURCES
2249                         tag_files $SOURCES $PATCHES $ICONS
2250                 else
2251                         Exit_error err_no_spec_in_cmdl
2252                 fi
2253                 ;;
2254         "mr-proper" )
2255                 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2256                 ;;
2257         "list-sources-files" )
2258                 init_builder
2259                 NOCVSSPEC="yes"
2260                 DONT_PRINT_REVISION="yes"
2261                 get_spec
2262                 parse_spec
2263                 for SAP in $SOURCES $PATCHES; do
2264                         echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2265                 done
2266                 ;;
2267         "list-sources-urls" )
2268                 init_builder
2269                 NOCVSSPEC="yes"
2270                 DONT_PRINT_REVISION="yes"
2271                 get_spec
2272                 parse_spec
2273                 SAPS="$SOURCES $PATCHES"
2274                 for SAP in $SAPS ; do
2275                         echo $SAP
2276                 done
2277                 ;;
2278         "list-sources-local-paths" )
2279                 init_builder
2280                 NOCVSSPEC="yes"
2281                 DONT_PRINT_REVISION="yes"
2282                 get_spec
2283                 parse_spec
2284                 for SAP in $SOURCES $PATCHES; do
2285                         echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2286                 done
2287                 ;;
2288         "list-sources-distfiles-paths" )
2289                 init_builder
2290                 NOCVSSPEC="yes"
2291                 DONT_PRINT_REVISION="yes"
2292                 get_spec
2293                 parse_spec
2294                 for SAP in $SOURCES $PATCHES; do
2295                         if [ -n "$(src_md5 "$SAP")" ]; then
2296                                 distfiles_path "$SAP"
2297                         fi
2298                 done
2299                 ;;
2300         "list-sources-distfiles" )
2301                 init_builder
2302                 NOCVSSPEC="yes"
2303                 DONT_PRINT_REVISION="yes"
2304                 get_spec
2305                 parse_spec
2306                 for SAP in $SOURCES $PATCHES; do
2307                         if [ -n "$(src_md5 "$SAP")" ]; then
2308                                 distfiles_url "$SAP"
2309                         fi
2310                 done
2311                 ;;
2312         "init_rpm_dir")
2313                 init_rpm_dir
2314                 ;;
2315         "usage" )
2316                 usage
2317                 ;;
2318         "short-version" )
2319                 echo "$VERSION"
2320                 ;;
2321         "version" )
2322                 echo "$VERSIONSTRING"
2323                 ;;
2324 esac
2325 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2326         rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2327 fi
2328 cd "$__PWD"
2329
2330 # vi:syntax=sh:ts=4:sw=4:noet
This page took 0.2773 seconds and 4 git commands to generate.