]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - builder.sh
- don't use -B when tagging if cvs-nserver is used
[packages/rpm-build-tools.git] / builder.sh
CommitLineData
1d7abbe3 1#!/bin/ksh
44058243 2#
dece74ed
AM
3# This program is free software, distributed under the terms of
4# the GNU General Public License Version 2.
5#
cd445739 6# -----------
cd445739 7# Exit codes:
2a5f078d 8# 0 - succesful
9# 1 - help displayed
10# 2 - no spec file name in cmdl parameters
11# 3 - spec file not stored in repo
12# 4 - some source, patch or icon files not stored in repo
13# 5 - package build failed
14# 6 - spec file with errors
15# 7 - wrong source in /etc/poldek.conf
16# 8 - Failed installing buildrequirements and subrequirements
17# 9 - Requested tag already exist
18# 10 - Refused to build fractional release
19# 100 - Unknown error (should not happen)
cd445739
AM
20
21# Notes (todo):
f7b91886 22# - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
cd445739 23# - when Icon: field is present, -5 and -a5 doesn't work
f3ada241 24# - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
931a4acf 25
d43959a2
ER
26RCSID='$Id$'
27r=${RCSID#* * }
28rev=${r%% *}
521e6179 29VERSION="v0.21/$rev"
d43959a2 30VERSIONSTRING="\
c9acaed9 31Build package utility from PLD Linux CVS repository
d43959a2
ER
32$VERSION (C) 1999-2007 Free Penguins".
33
d6a77ddb 34PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
b03f053b 35
cd445739 36COMMAND="build"
64ea5308 37TARGET=""
cd445739 38
bde1c404 39SPECFILE=""
d287305c 40BE_VERBOSE=""
4003ad8c 41QUIET=""
cd445739
AM
42CLEAN=""
43DEBUG=""
44NOURLS=""
45NOCVS=""
46NOCVSSPEC=""
47NODIST=""
47761337 48NOINIT=""
bc10f694 49PREFMIRRORS=""
cd445739 50UPDATE=""
cd445739
AM
51ADD5=""
52NO5=""
53ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
c8f50498 54CVSROOT=""
cdbd30e8 55GREEDSRC=""
cd445739 56
6c1b2e7d
PZ
57# use rpm 4.4.6+ digest format instead of comments if non-zero
58USEDIGEST=
59
e3aa6f5e
ER
60# user agent when fetching files
61USER_AGENT="PLD/Builder($VERSION)"
62
cd445739
AM
63# It can be used i.e. in log file naming.
64# See LOGFILE example.
65DATE=`date +%Y-%m-%d_%H-%M-%S`
66
67# Example: LOGFILE='../log.$PACKAGE_NAME'
68# Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
69# Yes, you can use variable name! Note _single_ quotes!
70LOGFILE=''
71
72LOGDIR=""
73LOGDIROK=""
74LOGDIRFAIL=""
75LASTLOG_FILE=""
76
77CHMOD="no"
78CHMOD_MODE="0444"
79RPMOPTS=""
d1c5a9a7 80RPMBUILDOPTS=""
cd445739
AM
81BCOND=""
82GROUP_BCONDS="no"
947025e5 83CVSIGNORE_DF="no"
d287305c 84
85PATCHES=""
86SOURCES=""
cd445739 87ICONS=""
d287305c 88PACKAGE_RELEASE=""
89PACKAGE_VERSION=""
90PACKAGE_NAME=""
14bead22 91ASSUMED_NAME=""
cd445739
AM
92PROTOCOL="ftp"
93WGET_RETRIES=${MAX_WGET_RETRIES:-0}
94CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
95
96CVSTAG=""
97RES_FILE=""
39dcc7de 98CVS_FORCE=""
cd445739
AM
99
100CVS_SERVER="cvs.pld-linux.org"
101DISTFILES_SERVER="://distfiles.pld-linux.org"
d4730dae 102ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
cd445739 103
36d03934 104DEF_NICE_LEVEL=19
86aafdbe 105SCHEDTOOL="auto"
cd445739
AM
106
107FAIL_IF_NO_SOURCES="yes"
108
18e5347d
ER
109# let get_files skip over files which are present to get those damn files fetched
110SKIP_EXISTING_FILES="no"
111
975d7b23 112TRY_UPGRADE=""
257af81b
ER
113# should the specfile be restored if upgrade failed?
114REVERT_BROKEN_UPGRADE="yes"
115
90baf90b
ER
116if rpm --specsrpm 2>/dev/null; then
117 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
ce40491a 118 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
90baf90b
ER
119else
120 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
121 if [ -x /usr/bin/rpm-getdeps ]; then
122 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
123 else
124 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
125 fi
ab4a2b6e
ER
126fi
127
90baf90b 128
cd445739
AM
129# Here we load saved user environment used to
130# predefine options set above, or passed to builder
131# in command line.
132# This one reads global system environment settings:
133if [ -f ~/etc/builderrc ]; then
134 . ~/etc/builderrc
135fi
136# And this one cascades settings using user personal
137# builder settings.
138# Example of ~/.builderrc:
139#
140#UPDATE_POLDEK_INDEXES="yes"
141#FETCH_BUILD_REQUIRES="yes"
142#REMOVE_BUILD_REQUIRES="force"
143#GROUP_BCONDS="yes"
144#LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
982e358c 145#TITLECHANGE=no
cd445739 146#
a83e5405 147SU_SUDO=""
cd445739
AM
148if [ -n "$HOME_ETC" ]; then
149 USER_CFG="$HOME_ETC/.builderrc"
20117088 150 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
cd445739
AM
151else
152 USER_CFG=~/.builderrc
20117088 153 BUILDER_MACROS=~/.builder-rpmmacros
cd445739
AM
154fi
155
156[ -f "$USER_CFG" ] && . "$USER_CFG"
157
86aafdbe
ER
158if [ "$SCHEDTOOL" = "auto" ]; then
159 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
160 SCHEDTOOL="schedtool -B -e"
161 else
162 SCHEDTOOL="no"
163 fi
164fi
165
ca2e6c31 166if [ -n "$USE_PROZILLA" ]; then
7e365483
KK
167 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
168 GETURI2="$GETURI"
169 OUTFILEOPT="-O"
ca2e6c31 170elif [ -n "$USE_AXEL" ]; then
cede92b3 171 GETURI="axel -a $AXEL_OPTS"
7e365483
KK
172 GETURI2="$GETURI"
173 OUTFILEOPT="-o"
ca2e6c31 174else
5700ee32
ER
175 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
176 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
177 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
e3aa6f5e 178 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
6f9a5d76 179
7e365483
KK
180 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
181 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
182 OUTFILEOPT="-O"
2bc5451f 183fi
11468b23 184
11468b23
AM
185GETLOCAL="cp -a"
186
187if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
188 RPM="rpm"
189 RPMBUILD="rpm"
190else
191 RPM="rpm"
192 RPMBUILD="rpmbuild"
193fi
194
28c23a72
AG
195#
196# are we using cvs-nserver ?
197#
198cvs --version 2>&1 | grep -qv 'CVS-nserver'
199CVS_NSERVER=$?
200
11468b23 201POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
a83e5405 202POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
11468b23 203
cd445739
AM
204run_poldek()
205{
206 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
207 if [ -n "$LOGFILE" ]; then
208 LOG=`eval echo $LOGFILE`
209 if [ -n "$LASTLOG_FILE" ]; then
210 echo "LASTLOG=$LOG" > $LASTLOG_FILE
211 fi
86aafdbe 212 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
cd445739
AM
213 return $exit_pldk
214 else
86aafdbe 215 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
cd445739
AM
216 return `cat ${RES_FILE}`
217 rm -rf ${RES_FILE}
218 fi
219}
220
cd445739
AM
221#---------------------------------------------
222# functions
da946cd6 223
5a491465 224usage()
225{
cd445739
AM
226 if [ -n "$DEBUG" ]; then set -xv; fi
227 echo "\
d43959a2 228Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
6594293d 229[-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
4efa0b98 230[{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
19dc5591 231[-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
232[-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
a7b2951c 233[-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
f8dba812 234[{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
6594293d 235[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
3009b80d 236[--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
6594293d 237<package>[.spec][:cvstag]
2a5f078d 238
cd445739
AM
239-5, --update-md5 - update md5 comments in spec, implies -nd -ncs
240-a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
241-n5, --no-md5 - ignore md5 comments in spec
9243e80b
ER
242-D, --debug - enable builder script debugging mode,
243-debug - produce rpm debug package (same as --opts -debug)
d43959a2
ER
244-V, --version - output builder version string
245--short-version - output builder short version
cd445739
AM
246-a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
247-b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
248 from <package>.spec,
249-bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
250 only package from <package>.spec,
c56807e0 251-bp, --build-prep - execute the %prep phase of <package>.spec,
6594293d
AG
252-bc - execute the %build phase of <package>.spec,
253-bi - execute the %install phase of <package>.spec
254-bl - execute the %files phase of <package>.spec
cd445739
AM
255-bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
256 them into src.rpm,
6594293d 257--short-circuit - short-circuit build
cd445739
AM
258-B, --branch - add branch
259-c, --clean - clean all temporarily created files (in BUILD, SOURCES,
6f10b394
ER
260 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
261-m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
262 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
263 any rpm building.
39dcc7de 264-cf, --cvs-force - use -F when tagging (useful when moving branches)
2a5f078d 265-d <cvsroot>, --cvsroot <cvsroot>
cd445739
AM
266 - setup \$CVSROOT,
267--define <macro> <value>
268 - define a macro <macro> with value <value>,
44058243
ER
269--alt_kernel <kernel>
270 - same as --define 'alt_kernel <kernel>'
cd445739
AM
271--nodeps - rpm won't check any dependences
272-g, --get - get <package>.spec and all related files from CVS repo
273 or HTTP/FTP,
274-h, --help - this message,
275--http - use http instead of ftp,
276-l <logfile>, --logtofile <logfile>
277 - log all to file,
cd445739
AM
278-nc, --no-cvs - don't download sources from CVS, if source URL is given,
279-ncs, --no-cvs-specs
280 - don't check specs in CVS
281-nd, --no-distfiles - don't download from distfiles
282-nm, --no-mirrors - don't download from mirror, if source URL is given,
283-nu, --no-urls - don't try to download from FTP/HTTP location,
284-ns, --no-srcs - don't download Sources
285-ns0, --no-source0 - don't download Source0
286-nn, --no-net - don't download anything from the net
a93e8cdf 287-pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
b572253e 288--no-init - don't initialize builder paths (SPECS and SOURCES)
18e5347d
ER
289-ske,
290--skip-existing-files - skip existing files in get_files
cd445739
AM
291--opts <rpm opts> - additional options for rpm
292-q, --quiet - be quiet,
293--date yyyy-mm-dd - build package using resources from specified CVS date,
294-r <cvstag>, --cvstag <cvstag>
295 - build package using resources from specified CVS tag,
5323fffd 296-A - build package using CVS resources as any sticky tags/date/kopts being reset.
cd445739
AM
297-R, --fetch-build-requires
298 - fetch what is BuildRequired,
299-RB, --remove-build-requires
300 - remove all you fetched with -R or --fetch-build-requires
301 remember, this option requires confirmation,
302-FRB, --force-remove-build-requires
303 - remove all you fetched with -R or --fetch-build-requires
304 remember, this option works without confirmation,
06541433
JR
305-sd, --source-distfiles - list sources available from distfiles (intended for offline
306 operations; does not work when Icon field is present
307 but icon file is absent),
e15852ab 308-sc, --source-cvs - list sources available from CVS
06541433
JR
309-sdp, --source-distfiles-paths - list sources available from distfiles -
310 paths relative to distfiles directory (intended for offline
311 operations; does not work when Icon field is present
312 but icon file is absent),
a7eefc54 313-sf, --source-files - list sources - bare filenames (intended for offline
314 operations; does not work when Icon field is present
3621e588 315 but icon file is absent),
a7eefc54 316-sp, --source-paths - list sources - filenames with full local paths (intended for
317 offline operations; does not work when Icon field is present
3621e588 318 but icon file is absent),
2dddf439
ER
319-su, --source-urls - list urls - urls to sources and patches
320 intended for copying urls with spec with lots of macros in urls
cd445739
AM
321-T <cvstag> , --tag <cvstag>
322 - add cvs tag <cvstag> for files,
323-Tvs, --tag-version-stable
094bd95b 324 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
cd445739
AM
325-Ts, --tag-stable
326 - add cvs tag STABLE for files,
cd445739 327-Tv, --tag-version
1691a37b 328 - add cvs tag NAME-VERSION-RELEASE for files,
cd445739
AM
329-Tp, --tag-prefix <prefix>
330 - add <prefix> to NAME-VERSION-RELEASE tags,
331-tt, --test-tag <prefix>
332 - fail if tag is already present,
50321881
JK
333-ir, --integer-release-only
334 - allow only integer and snapshot releases
cd445739
AM
335-v, --verbose - be verbose,
336-u, --try-upgrade - check version, and try to upgrade package
337-un, --try-upgrade-with-float-version
338 - as above, but allow float version
f8dba812 339--use-greed-sources
340 - try download source from tag head if don't find it in
341 current tag
deccc50e 342-U, --update - refetch sources, don't use distfiles, and update md5 comments
cd445739
AM
343-Upi, --update-poldek-indexes
344 - refresh or make poldek package index files.
c890b916 345-np, --nopatch <patchnumber>
bed98670 346 - don't apply <patchnumber>
dfe2cb9a
MK
347--show-bconds - show available conditional builds, which can be used
348 - with --with and/or --without switches.
9b78be50
ER
349--show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
350 ./repackage.sh script. in other words, the output is
351 parseable by scripts.
cd445739
AM
352--with/--without <feature>
353 - conditional build package depending on %_with_<feature>/
354 %_without_<feature> macro switch. You may now use
355 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
356 constructions. Set GROUP_BCONDS to yes to make use of it.
6dd19291 357--target <platform>, --target=<platform>
3621e588
ER
358 - build for platform <platform>.
359--init-rpm-dir - initialize ~/rpm directory structure
5a491465 360"
361}
362
31d2bd0b
ER
363# change dependency to specname
364# common changes:
365# - perl(Package::Name) -> perl-Package-Name
366depspecname() {
367 local package="$1"
368
369 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
370 echo "$package"
371}
372
c890b916 373update_shell_title() {
a0d6396b 374 [ -t 1 ] || return
0b65d15e
ER
375 local len=${COLUMNS:-80}
376 local msg=$(echo "$*" | cut -c-$len)
377
e225de91
ER
378 if [ -n "$BE_VERBOSE" ]; then
379 echo >&2 "$(date +%s.%N) $*"
380 fi
381
982e358c 382 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
138bbc98
ER
383 local pkg
384 if [ -n "$PACKAGE_NAME" ]; then
385 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
386 else
387 pkg=${SPECFILE}
388 fi
389
390 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
10c1e115 391 msg="$(echo $msg | tr -d '\n\r')"
982e358c
MP
392 case "$TERM" in
393 cygwin|xterm*)
394 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
395 ;;
396 screen*)
397 echo >&2 -ne "\033]0;$msg\007"
398 ;;
399 esac
400 fi
c890b916
ER
401}
402
7e40520f
ER
403# set TARGET from BuildArch: from SPECFILE
404set_spec_target() {
ce40491a
ER
405 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
406 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
407 if [ "$tmp" ]; then
f9109a96 408 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
7e40520f
ER
409 TARGET="$tmp"
410 case "$RPMBUILD" in
411 "rpmbuild")
f9109a96 412 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
7e40520f 413 "rpm")
ce40491a 414 TARGET_SWITCH="--target=$TARGET" ;;
7e40520f 415 esac
ce40491a
ER
416 fi
417 fi
7e40520f
ER
418}
419
ace3fd80
ER
420# runs rpm with minimal macroset
421minirpm() {
fa4bf1df 422 # we reset macros not to contain macros.build as all the %() macros are
559d511f 423 # executed here, while none of them are actually needed.
559d511f 424 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
13c3c336 425 safe_macrofiles=$(rpm --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
ace3fd80
ER
426
427 # TODO: move these to /usr/lib/rpm/macros
20117088 428 cat > $BUILDER_MACROS <<'EOF'
5b5e5f7f 429%x8664 x86_64 amd64 ia32e
f78a0bb7 430%alt_kernel %{nil}
431%_alt_kernel %{nil}
fb198857
ER
432%requires_releq_kernel_up %{nil}
433%requires_releq_kernel_smp %{nil}
1b2bbc99 434%requires_releq_kernel %{nil}
6b8134e3 435%requires_releq() %{nil}
bb01dee9 436%pyrequires_eq() %{nil}
559d511f 437%requires_eq() %{nil}
c13be3d1 438%requires_eq_to() %{nil}
fb198857
ER
439%releq_kernel_up ERROR
440%releq_kernel_smp ERROR
1b2bbc99 441%releq_kernel ERROR
74d9fd14 442%kgcc_package ERROR
237bd3f1 443%_fontsdir ERROR
7141278d 444%ruby_version ERROR
445%ruby_ver_requires_eq() %{nil}
446%ruby_mod_ver_requires_eq() %{nil}
c13be3d1 447%__php_api_requires() %{nil}
7141278d 448%php_major_version ERROR
449%php_api_version ERROR
99f819cf
AM
450%requires_xorg_xserver_extension %{nil}
451%requires_xorg_xserver_xinput %{nil}
452%requires_xorg_xserver_font %{nil}
453%requires_xorg_xserver_videodrv %{nil}
7141278d 454%py_ver ERROR
41035426
ER
455%perl_vendorarch ERROR
456%perl_vendorlib ERROR
703ae20b
ER
457# damn. need it here! - copied from /usr/lib/rpm/macros.build
458%tmpdir %(echo "${TMPDIR:-/tmp}")
1f28fcb7
ER
459%patchset_source(f:b:) %(
460 base=%{-b*}%{!-b*:10000};
461 start=$(expr $base + %1);
462 end=$(expr $base + %{?2}%{!?2:%{1}});
463 # we need to call seq twice as it doesn't allow two formats
464 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
465 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
466 paste %{tmpdir}/__ps{1,2};
467 rm -f %{tmpdir}/__ps{1,2};
468) \
469%{nil}
fb198857 470EOF
3d12d055 471 if [ "$NOINIT" = "yes" ] ; then
20117088 472 cat >> $BUILDER_MACROS <<'EOF'
3d12d055
JR
473%_specdir ./
474%_sourcedir ./
475EOF
c039643c 476 fi
20117088 477 eval $RPMBUILD --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
ace3fd80
ER
478}
479
480cache_rpm_dump() {
481 if [ -n "$DEBUG" ]; then
482 set -x
483 set -v
484 fi
485
486 update_shell_title "cache_rpm_dump"
d1d24c14
ER
487 if [ -x /usr/bin/rpm-specdump ]; then
488 rpm_dump_cache=`rpm-specdump $BCOND $TARGET_SWITCH $SPECFILE`
489 else
490 local rpm_dump
491 rpm_dump=`
492 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
493 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
494 case "$RPMBUILD" in
495 rpm)
496 ARGS='-bp'
497 ;;
498 rpmbuild)
499 ARGS='--nodigest --nosignature --nobuild'
500 ;;
501 esac
502 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
503 `
504 if [ $? -gt 0 ]; then
505 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
506 echo "$error" >&2
507 Exit_error err_build_fail
508 fi
d05e8080 509
d1d24c14
ER
510 # make small dump cache
511 rpm_dump_cache=`echo "$rpm_dump" | awk '
512 $2 ~ /^SOURCEURL/ {print}
513 $2 ~ /^PATCHURL/ {print}
514 $2 ~ /^nosource/ {print}
515 $2 ~ /^PACKAGE_/ {print}
516 '`
517 fi
d05e8080 518
13974367 519 update_shell_title "cache_rpm_dump: OK!"
cd445739
AM
520}
521
ace3fd80 522rpm_dump() {
cd445739 523 if [ -z "$rpm_dump_cache" ] ; then
d7b4d36e 524 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
cd445739
AM
525 fi
526 echo "$rpm_dump_cache"
527}
528
d05e8080
ER
529get_icons()
530{
531 update_shell_title "get icons"
532 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
533 if [ -z "$ICONS" ]; then
534 return
535 fi
536
975d7b23 537 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
d05e8080
ER
538}
539
59398507 540parse_spec()
541{
af4d5315 542 update_shell_title "parsing specfile"
cd445739 543 if [ -n "$DEBUG" ]; then
518ff1fb
ER
544 set -x
545 set -v
cd445739 546 fi
b2975fc3 547
d05e8080 548 # icons are needed for successful spec parse
518ff1fb 549 get_icons
d05e8080 550
01fa66fc 551 cd $SPEC_DIR
cd445739 552 cache_rpm_dump
00fcec7e 553
cd445739
AM
554 if [ "$NOSRCS" != "yes" ]; then
555 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
556 fi
7cb24972 557
cd445739
AM
558 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
559 FAIL_IF_NO_SOURCES="no"
560 fi
561
562 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
563 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
dfe2b2d9
ER
564 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
565 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
566 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
78eab2a1 567
0b4119a2 568 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
7854d40c 569 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
0b4119a2
JR
570 fi
571
cd445739
AM
572 if [ -n "$BE_VERBOSE" ]; then
573 echo "- Sources : `nourl $SOURCES`"
574 if [ -n "$PATCHES" ]; then
575 echo "- Patches : `nourl $PATCHES`"
576 else
577 echo "- Patches : *no patches needed*"
578 fi
579 if [ -n "$ICONS" ]; then
580 echo "- Icon : `nourl $ICONS`"
581 else
582 echo "- Icon : *no package icon*"
583 fi
584 echo "- Name : $PACKAGE_NAME"
585 echo "- Version : $PACKAGE_VERSION"
586 echo "- Release : $PACKAGE_RELEASE"
587 fi
13974367
ER
588
589 update_shell_title "parse_spec: OK!"
cd445739
AM
590}
591
592Exit_error()
593{
594 if [ -n "$DEBUG" ]; then
518ff1fb
ER
595 set -x
596 set -v
cd445739
AM
597 fi
598
599 cd "$__PWD"
600
601 case "$1" in
602 "err_no_spec_in_cmdl" )
603 remove_build_requires
518ff1fb 604 echo "ERROR: spec file name not specified."
cd445739 605 exit 2 ;;
a08d92fc
ER
606 "err_invalid_cmdline" )
607 echo "ERROR: invalid command line arg ($2)."
608 exit 2 ;;
cd445739
AM
609 "err_no_spec_in_repo" )
610 remove_build_requires
518ff1fb 611 echo "Error: spec file not stored in CVS repo."
cd445739
AM
612 exit 3 ;;
613 "err_no_source_in_repo" )
614 remove_build_requires
518ff1fb 615 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"
cd445739
AM
616 exit 4 ;;
617 "err_build_fail" )
618 remove_build_requires
518ff1fb 619 echo "Error: package build failed. (${2:-no more info})"
cd445739 620 exit 5 ;;
78eab2a1
AM
621 "err_no_package_data" )
622 remove_build_requires
623 echo "Error: couldn't get out package name/version/release from spec file."
624 exit 6 ;;
ce40491a 625 "err_tag_exists" )
50321881 626 remove_build_requires
518ff1fb 627 echo "Tag ${2} already exists (spec release: ${3})."
50321881 628 exit 9 ;;
ce40491a 629 "err_fract_rel" )
50321881 630 remove_build_requires
518ff1fb 631 echo "Release ${2} not integer and not a snapshot."
50321881 632 exit 10 ;;
fb96e0b5
AM
633 "err_branch_exists" )
634 remove_build_requires
518ff1fb 635 echo "Tree branch already exists (${2})."
fb96e0b5 636 exit 11 ;;
cfc497c0
ER
637 "err_acl_deny" )
638 remove_build_requires
639 echo "Error: conditions reject building this spec (${2})."
640 exit 12 ;;
cd445739 641 esac
73848362
ER
642 echo "Unknown error."
643 exit 100
cd445739
AM
644}
645
646init_builder()
647{
648 if [ -n "$DEBUG" ]; then
518ff1fb
ER
649 set -x
650 set -v
0dd6320d 651 fi
cd445739 652
4aeb9973 653 if [ "$NOINIT" != "yes" ] ; then
a08cc47e
ER
654 local extra
655 if [ "$ASSUMED_NAME" ]; then
656 extra="--define 'name $ASSUMED_NAME'"
657 fi
658 SOURCE_DIR="`eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}'`"
01fa66fc 659 SPEC_DIR="`eval $RPM $RPMOPTS $extra --eval '%{_specdir}'`"
29e90b02
JR
660 else
661 SOURCE_DIR="."
01fa66fc 662 SPEC_DIR="."
29e90b02 663 fi
cd445739
AM
664
665 __PWD="`pwd`"
00fcec7e 666}
667
d6a77ddb 668get_spec()
1471f6d6 669{
c890b916 670
2e5be021 671 update_shell_title "get_spec"
c890b916 672
cd445739 673 if [ -n "$DEBUG" ]; then
518ff1fb
ER
674 set -x
675 set -v
cd445739
AM
676 fi
677
01fa66fc 678 cd "$SPEC_DIR"
049ab214 679 if [ ! -f "$SPECFILE" ]; then
518ff1fb 680 SPECFILE="`basename $SPECFILE .spec`.spec"
cd445739
AM
681 fi
682 if [ "$NOCVSSPEC" != "yes" ]; then
cd445739 683
049ab214
ER
684 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
685 echo "Warning: No CVS access defined - using local .spec file"
686 NOCVSSPEC="yes"
cd445739
AM
687 fi
688
049ab214 689 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
cd445739 690 fi
049ab214 691
cd445739 692 if [ ! -f "$SPECFILE" ]; then
518ff1fb 693 Exit_error err_no_spec_in_repo
cd445739
AM
694 fi
695
696 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
697 chmod $CHMOD_MODE $SPECFILE
698 fi
699 unset OPTIONS
a7eefc54 700 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
7e40520f 701
ce40491a 702 set_spec_target
cd445739
AM
703}
704
705find_mirror()
706{
01fa66fc 707 cd "$SPEC_DIR"
782518da 708 local url="$1"
cd445739
AM
709 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
710 cvs update mirrors >&2
711 fi
712
713 IFS="|"
782518da
ER
714 local origin mirror name rest ol prefix
715 while read origin mirror name rest; do
716 # skip comments and empty lines
717 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
718 continue
719 fi
cd445739
AM
720 ol=`echo -n "$origin"|wc -c`
721 prefix="`echo -n "$url" | head -c $ol`"
722 if [ "$prefix" = "$origin" ] ; then
782518da 723 suffix="`echo "$url"|cut -b $((ol+1))-`"
cd445739
AM
724 echo -n "$mirror$suffix"
725 return 0
726 fi
727 done < mirrors
728 echo "$url"
729}
730
e7e0d4ec 731# Warning: unpredictable results if same URL used twice
cd445739
AM
732src_no ()
733{
01fa66fc 734 cd $SPEC_DIR
cd445739
AM
735 rpm_dump | \
736 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
737 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
738 head -n 1 | xargs
1471f6d6 739}
740
e7e0d4ec 741src_md5()
8ba5cdda 742{
e7e0d4ec 743 [ "$NO5" = "yes" ] && return
cd445739
AM
744 no=$(src_no "$1")
745 [ -z "$no" ] && return
01fa66fc 746 cd $SPEC_DIR
e7e0d4ec
ER
747 local md5
748
749 if [ -f additional-md5sums ]; then
750 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
751 if [ -z "$spec_rev" ]; then
752 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
753 fi
754 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
755 md5=$(grep -s -v '^#' additional-md5sums | \
756 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
757 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
758 grep -E '^[0-9a-f]{32}$')
759
760 if [ "$md5" ]; then
761 if [ $(echo "$md5" | wc -l) != 1 ] ; then
762 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
763 fi
764 echo "$md5" | tail -n 1
765 return
766 fi
cd445739 767 fi
e7e0d4ec
ER
768
769 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
770 if [ -n "$source_md5" ]; then
771 echo $source_md5
cd445739 772 else
7805dcb4
PZ
773 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
774 if [ -n "$source_md5" ]; then
775 echo $source_md5
776 else
777 # we have empty SourceX-md5, but it is still possible
778 # that we have NoSourceX-md5 AND NoSource: X
779 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
780 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
781 echo $nosource_md5
782 fi
cd445739 783 fi
cd445739
AM
784 fi
785}
786
06541433
JR
787distfiles_path ()
788{
789 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
790}
791
cd445739
AM
792distfiles_url ()
793{
06541433 794 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
cd445739
AM
795}
796
797distfiles_attic_url ()
798{
06541433 799 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
cd445739
AM
800}
801
802good_md5 ()
803{
804 md5=$(src_md5 "$1")
805 [ "$md5" = "" ] || \
806 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
8ba5cdda
PG
807}
808
a4b50627
AF
809good_size ()
810{
ce40491a
ER
811 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
812 [ -n "$size" -a "$size" -gt 0 ]
a4b50627
AF
813}
814
947025e5 815cvsignore_df ()
816{
817 if [ "$CVSIGNORE_DF" != "yes" ]; then
818 return
819 fi
820 cvsignore=${SOURCE_DIR}/.cvsignore
821 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
822 echo "$1" >> $cvsignore
823 fi
824}
825
e7fa3b9f
ER
826cvsup()
827{
ce40491a
ER
828 update_shell_title "cvsup"
829 local OPTIONS="up "
830 if [ -n "$CVSROOT" ]; then
831 OPTIONS="-d $CVSROOT $OPTIONS"
832 fi
b1c6aace 833
ce40491a
ER
834 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
835 OPTIONS="$OPTIONS -A"
836 else
837 if [ -n "$CVSDATE" ]; then
838 OPTIONS="$OPTIONS -D $CVSDATE"
839 fi
840 if [ -n "$CVSTAG" ]; then
841 OPTIONS="$OPTIONS -r $CVSTAG"
842 fi
843 fi
e7fa3b9f 844
ce40491a
ER
845 local result=1
846 local retries_counter=0
847 if [ $# = 1 ]; then
848 update_shell_title "cvsup: $*"
849 else
850 update_shell_title "cvsup: $# files"
851 fi
852 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
853 retries_counter=$(( $retries_counter + 1 ))
854 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
855 result=$?
856 [ -n "$output" ] && echo "$output"
857 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
858 echo "Trying again [$*]... ($retries_counter)"
859 update_shell_title "cvsup: retry #$retries_counter"
860 sleep 2
861 continue
862 else
863 break
864 fi
865 done
866 update_shell_title "cvsup: done!"
867 return $result
e7fa3b9f
ER
868}
869
71f8e908
ER
870# returns true if "$1" is ftp, http or https protocol url
871is_url()
872{
873 case "$1" in
874 ftp://*|http://*|https://*)
875 return 0
876 ;;
877 esac
878 return 1
879}
880
ecba6ad5
ER
881update_md5()
882{
883 if [ $# -eq 0 ]; then
884 return
885 fi
886
887 update_shell_title "update md5"
888 if [ -n "$DEBUG" ]; then
518ff1fb
ER
889 set -x
890 set -v
ecba6ad5
ER
891 fi
892
893 cd "$SOURCE_DIR"
894
895 # pass 1: check files to be fetched
896 local todo
897 local need_files
898 for i in "$@"; do
899 local fp=$(nourl "$i")
900 local srcno=$(src_no "$i")
6392b5fd
ER
901 if [ -n "$ADD5" ]; then
902 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
01fa66fc 903 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
6c1b2e7d 904 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
6392b5fd 905 else
6c1b2e7d 906 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
ecba6ad5
ER
907 fi
908 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
909 need_files="$need_files $i"
910 fi
911 done
912
913 # pass 1a: get needed files
914 if [ "$need_files" ]; then
915 get_files $need_files
916 fi
917
918 # pass 2: proceed with md5 adding or updating
919 for i in "$@"; do
920 local fp=$(nourl "$i")
921 local srcno=$(src_no "$i")
01fa66fc 922 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
e19ad799 923 if [ -z "$md5" ]; then
6c1b2e7d
PZ
924 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
925 fi
71f8e908 926 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
6c1b2e7d 927 local tag="# Source$srcno-md5:\t"
71f8e908 928 if [[ "$md5" == *NoSource* ]]; then
6c1b2e7d
PZ
929 tag="# NoSource$srcno-md5:\t"
930 elif [ -n "$USEDIGEST" ]; then
931 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
71f8e908 932 fi
ecba6ad5 933 md5=$(md5sum "$fp" | cut -f1 -d' ')
15bf3e99 934 echo "Updating Source$srcno ($md5: $fp)."
ecba6ad5 935 perl -i -ne '
6c1b2e7d
PZ
936 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
937 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
ecba6ad5 938 ' \
01fa66fc 939 $SPEC_DIR/$SPECFILE
ecba6ad5
ER
940 fi
941 done
942}
943
944check_md5()
945{
946 update_shell_title "check md5"
947
948 for i in "$@"; do
949 if good_md5 "$i" && good_size "$i"; then
950 continue
951 fi
952
953 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
954 echo "or -5 to update md5 sums, if you're sure files are correct."
955 Exit_error err_no_source_in_repo $i
956 done
957}
958
cd445739
AM
959get_files()
960{
7cb24972 961 update_shell_title "get_files"
cd445739
AM
962
963 if [ -n "$DEBUG" ]; then
518ff1fb
ER
964 set -x
965 set -v
cd445739
AM
966 fi
967
f09c0772 968 if [ $# -gt 0 ]; then
cd445739
AM
969 cd "$SOURCE_DIR"
970
b1c6aace 971 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
049ab214 972 echo "Warning: No CVS access defined for SOURCES"
b1c6aace
ER
973 NOCVS="yes"
974 fi
975
f2e42a41 976 local nc=0
e7fa3b9f 977 local get_files_cvs=""
3815b69a 978 for i in "$@"; do
f2e42a41 979 nc=$((nc + 1))
dcebdffb 980 local cvsup=0
3815b69a 981 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
f2e42a41 982 update_shell_title "$i"
f09c0772 983 local fp=`nourl "$i"`
ecba6ad5 984 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
ce40491a 985 continue
18e5347d 986 fi
ecba6ad5 987
cd445739 988 FROM_DISTFILES=0
e7e0d4ec 989 local srcmd5=$(src_md5 "$i")
ecba6ad5
ER
990
991 # we know if source/patch is present in cvs/distfiles
992 # - has md5 (in distfiles)
993 # - in cvs... ideas?
994
995 # CHECK: local file didn't exist or always cvs up (first) requested.
f09c0772 996 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
cd445739
AM
997 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
998 echo "Warning: no URL given for $i"
999 fi
1000
e7e0d4ec 1001 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
a4b50627 1002 if good_md5 "$i" && good_size "$i"; then
e7e0d4ec 1003 echo "$fp having proper md5sum already exists"
cd445739
AM
1004 continue
1005 fi
4ea1c265 1006 target="$fp"
28b34560 1007
bc10f694 1008 # optionally prefer mirror over distfiles if there's mirror
28b34560 1009 # TODO: build url list and then try each url from the list
bc10f694 1010 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
28b34560
ER
1011 url="$im"
1012 else
1013 url=$(distfiles_url "$i")
1014 fi
1015
cd445739
AM
1016 url_attic=$(distfiles_attic_url "$i")
1017 FROM_DISTFILES=1
ecba6ad5
ER
1018 # is $url local file?
1019 if [[ "$url" = [./]* ]]; then
18a52930 1020 update_shell_title "${GETLOCAL%% *}: $url"
cd445739
AM
1021 ${GETLOCAL} $url $target
1022 else
1023 if [ -z "$NOMIRRORS" ]; then
9e9f8920 1024 url=$(find_mirror "$url")
cd445739 1025 fi
9e9f8920
ER
1026
1027 local uri=${url}
1028 # make shorter message for distfiles urls
1029 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1030 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1031 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1032 uri="df: $uri"
1033 fi
1034 update_shell_title "${GETURI%% *}: $uri"
ca2e6c31 1035 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 1036 if [ "`echo $url | grep -E 'ftp://'`" ]; then
18a52930 1037 update_shell_title "${GETURI2%% *}: $url"
ca2e6c31 1038 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739
AM
1039 fi
1040 fi
ecba6ad5
ER
1041
1042 # is it empty file?
1043 if [ ! -s "$target" ]; then
cd445739
AM
1044 rm -f "$target"
1045 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
18a52930 1046 update_shell_title "${GETLOCAL%% *}: $url_attic"
cd445739
AM
1047 ${GETLOCAL} $url_attic $target
1048 else
1049 if [ -z "$NOMIRRORS" ]; then
1050 url_attic="`find_mirror "$url_attic"`"
1051 fi
18a52930 1052 update_shell_title "${GETURI%% *}: $url_attic"
ca2e6c31 1053 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 1054 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
ce40491a 1055 update_shell_title "${GETURI2%% *}: $url_attic"
ca2e6c31 1056 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
1057 fi
1058 fi
1059 fi
ecba6ad5
ER
1060
1061 if [ -s "$target" ]; then
947025e5 1062 cvsignore_df $target
1063 else
cd445739
AM
1064 rm -f "$target"
1065 FROM_DISTFILES=0
1066 fi
e7e0d4ec 1067 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
d05e8080
ER
1068 if [ $# -gt 1 ]; then
1069 get_files_cvs="$get_files_cvs $fp"
1070 update_shell_title "$fp (will cvs up later)"
1071 cvsup=1
1072 else
1073 cvsup $fp
1074 fi
cd445739
AM
1075 fi
1076
f09c0772 1077 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
cd445739
AM
1078 if [ -z "$NOMIRRORS" ]; then
1079 im="`find_mirror "$i"`"
1080 else
1081 im="$i"
1082 fi
ce40491a 1083 update_shell_title "${GETURI%% *}: $im"
cd445739 1084 ${GETURI} "$im" || \
33da77c4 1085 if [ "`echo $im | grep -E 'ftp://'`" ]; then
ce40491a 1086 update_shell_title "${GETURI2%% *}: $im"
cd445739 1087 ${GETURI2} "$im"
7e365483 1088 fi
cd445739
AM
1089 fi
1090
dcebdffb
ER
1091 if [ "$cvsup" = 1 ]; then
1092 continue
1093 fi
1094
cd445739 1095 fi
ecba6ad5
ER
1096
1097 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
f09c0772 1098 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
cdbd30e8 1099 if [ -n "GREEDSRC" ]; then
1100 get_greed_sources $i
1101 else
1102 Exit_error err_no_source_in_repo $i
1103 fi
cd445739 1104 fi
2a5f078d 1105
ecba6ad5 1106 # we check md5 here just only to refetch immediately
a4b50627 1107 if good_md5 "$i" && good_size "$i"; then
cd445739
AM
1108 :
1109 elif [ "$FROM_DISTFILES" = 1 ]; then
deccc50e 1110 # wrong md5 from distfiles: remove the file and try again
cd445739 1111 # but only once ...
deccc50e 1112 echo "MD5 sum mismatch. Trying full fetch."
cd445739
AM
1113 FROM_DISTFILES=2
1114 rm -f $target
18a52930 1115 update_shell_title "${GETURI%% *}: $url"
ca2e6c31 1116 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 1117 if [ "`echo $url | grep -E 'ftp://'`" ]; then
ce40491a 1118 update_shell_title "${GETURI2%% *}: $url"
ca2e6c31 1119 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739 1120 fi
ecba6ad5 1121 if [ ! -s "$target" ]; then
cd445739 1122 rm -f "$target"
18a52930 1123 update_shell_title "${GETURI%% *}: $url_attic"
ca2e6c31 1124 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 1125 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
ce40491a 1126 update_shell_title "${GETURI2%% *}: $url_attic"
ca2e6c31 1127 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
1128 fi
1129 fi
1130 test -s "$target" || rm -f "$target"
1131 fi
cd445739 1132 done
e7fa3b9f
ER
1133 SHELL_TITLE_PREFIX=""
1134
1135 if [ "$get_files_cvs" ]; then
ce40491a 1136 cvsup $get_files_cvs
e7fa3b9f 1137 fi
cd445739
AM
1138
1139 if [ "$CHMOD" = "yes" ]; then
3815b69a 1140 CHMOD_FILES="`nourl "$@"`"
cd445739
AM
1141 if [ -n "$CHMOD_FILES" ]; then
1142 chmod $CHMOD_MODE $CHMOD_FILES
1143 fi
1144 fi
cd445739
AM
1145 fi
1146}
1147
1148make_tagver() {
ce40491a 1149 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1150 set -x
1151 set -v
ce40491a 1152 fi
78eab2a1 1153
ce40491a
ER
1154 # Check whether first character of PACKAGE_NAME is legal for tag name
1155 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1156 TAG_PREFIX=tag_
1157 fi
d712cc12
ER
1158
1159 # NOTE: CVS tags may must not contain the characters `$,.:;@'
392187d9 1160 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
d712cc12 1161
ce40491a
ER
1162 # Remove #kernel.version_release from TAGVER because tagging sources
1163 # could occur with different kernel-headers than kernel-headers used at build time.
d712cc12
ER
1164 # besides, %{_kernel_ver_str} is not expanded.
1165
1166 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1167 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1168
1169 TAGVER=${TAGVER%#*}
ce40491a 1170 echo -n "$TAGVER"
cd445739
AM
1171}
1172
c713aac3
AG
1173# bool is_tag_a_branch(tag)
1174#
1175# returns 1 if a tag is a branch set on SPECFILE
1176is_tag_a_branch() {
1177 if [ -n "$DEBUG" ]; then
1178 set -x
1179 set -v
1180 fi
1181
1182 if [ $# -ne 1 ]; then
1183 return 0;
1184 fi
1185
1186 TAG=$1
1187
1188 cd "$SPEC_DIR"
1189 cvs status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1190 return $?
1191}
1192
cd445739
AM
1193tag_files()
1194{
1195 TAG_FILES="$@"
1196
1197 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1198 set -x
1199 set -v
cd445739
AM
1200 fi
1201
73ef63d8
ER
1202 echo "Version: $PACKAGE_VERSION"
1203 echo "Release: $PACKAGE_RELEASE"
cd445739 1204
a18a9761 1205 local TAGVER
73ef63d8 1206 if [ "$TAG_VERSION" = "yes" ]; then
a18a9761 1207 TAGVER=`make_tagver`
73ef63d8
ER
1208 echo "CVS tag: $TAGVER"
1209 fi
1210 if [ -n "$TAG" ]; then
1211 echo "CVS tag: $TAG"
1212 fi
cd445739 1213
39dcc7de 1214 local OPTIONS="tag $CVS_FORCE"
73ef63d8
ER
1215 if [ -n "$CVSROOT" ]; then
1216 OPTIONS="-d $CVSROOT $OPTIONS"
1217 fi
cd445739 1218
c713aac3
AG
1219 # if a tagname we are about to set already exists
1220 # and happens to be a branch (common case with AC-branch)
1221 # pass -B (allows -F to disturb branch tag)
1222 local _tag=$TAG
1223 if [ "$TAG_VERSION" = "yes" ]; then
1224 _tag=$TAGVER
1225 fi;
1226 is_tag_a_branch $_tag
28c23a72 1227 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
c713aac3
AG
1228 OPTIONS="$OPTIONS -B"
1229 fi;
1230
73ef63d8
ER
1231 cd "$SOURCE_DIR"
1232 local tag_files
1233 for i in $TAG_FILES; do
1234 # don't tag files stored on distfiles
1235 [ -n "`src_md5 $i`" ] && continue
1236 local fp=`nourl "$i"`
1237 if [ -f "$fp" ]; then
1238 tag_files="$tag_files $fp"
cdbd30e8 1239 elif [ -n "GREEDSRC" ]; then
1240 get_greed_sources $i
73ef63d8
ER
1241 else
1242 Exit_error err_no_source_in_repo $i
03db3356 1243 fi
73ef63d8 1244 done
03db3356 1245
73ef63d8 1246 if [ "$tag_files" ]; then
cd445739 1247 if [ "$TAG_VERSION" = "yes" ]; then
73ef63d8 1248 update_shell_title "tag sources: $TAGVER"
19ca62ef 1249 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
c7e6ee9b 1250 cvs $OPTIONS $TAGVER $tag_files || exit
cd445739
AM
1251 fi
1252 if [ -n "$TAG" ]; then
73ef63d8 1253 update_shell_title "tag sources: $TAG"
c4ff623e
ER
1254
1255 while [ "$tag_files" ]; do
1256 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1257 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1258 cvs $OPTIONS $TAG $chunk || exit
1259 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1260 done
cd445739 1261 fi
73ef63d8
ER
1262 fi
1263
01fa66fc 1264 cd "$SPEC_DIR"
73ef63d8
ER
1265 if [ "$TAG_VERSION" = "yes" ]; then
1266 update_shell_title "tag spec: $TAGVER"
c7e6ee9b 1267 cvs $OPTIONS $TAGVER $SPECFILE || exit
73ef63d8
ER
1268 fi
1269 if [ -n "$TAG" ]; then
1270 update_shell_title "tag spec: $TAG"
c7e6ee9b 1271 cvs $OPTIONS $TAG $SPECFILE || exit
73ef63d8 1272 fi
cd445739
AM
1273}
1274
1275branch_files()
1276{
1277 TAG=$1
1278 echo "CVS branch tag: $TAG"
518ff1fb 1279 shift
cd445739
AM
1280
1281 TAG_FILES="$@"
1282
1283 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1284 set -x
1285 set -v
cd445739
AM
1286 fi
1287
78a5a506
ER
1288 local OPTIONS="tag $CVS_FORCE -b"
1289 if [ -n "$CVSROOT" ]; then
1290 OPTIONS="-d $CVSROOT $OPTIONS"
1291 fi
1292 cd "$SOURCE_DIR"
1293 local tag_files
1294 for i in $TAG_FILES; do
1295 local fp=`nourl "$i"`
1296 if [ -f "$fp" ]; then
1297 tag_files="$tag_files $fp"
cdbd30e8 1298 elif [ -n "GREEDSRC" ]; then
1299 get_greed_sources $i
78a5a506
ER
1300 else
1301 Exit_error err_no_source_in_repo $i
c10fa4fa 1302 fi
78a5a506
ER
1303 done
1304 if [ "$tag_files" ]; then
c7e6ee9b 1305 cvs $OPTIONS $TAG $tag_files || exit
78a5a506 1306 fi
c10fa4fa 1307
01fa66fc 1308 cd "$SPEC_DIR"
c7e6ee9b 1309 cvs $OPTIONS $TAG $SPECFILE || exit
cd445739
AM
1310}
1311
1312
3009b80d
ER
1313# this function should exit early if package can't be built for this arch
1314# this avoids unneccessary BR filling.
1315check_buildarch() {
1316 local out ret
13c3c336 1317 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
3009b80d
ER
1318 ret=$?
1319 if [ $ret -ne 0 ]; then
1320 echo >&2 "$out"
1321 exit $ret
1322 fi
1323}
1324
cd445739 1325
59398507 1326build_package()
1327{
2e5be021 1328 update_shell_title "build_package"
cd445739 1329 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1330 set -x
1331 set -v
cd445739 1332 fi
5a491465 1333
01fa66fc 1334 cd "$SPEC_DIR"
cd445739
AM
1335
1336 if [ -n "$TRY_UPGRADE" ]; then
ce40491a 1337 update_shell_title "build_package: try_upgrade"
cd445739 1338 if [ -n "$FLOAT_VERSION" ]; then
cc538c24 1339 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
cd445739 1340 else
cc538c24 1341 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
cd445739
AM
1342 fi
1343
1344 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1345
1346 if [ -n "$TNEWVER" ]; then
1347 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1348 echo "New version found, updating spec file to version " $TNEWVER
257af81b
ER
1349 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1350 cp -f $SPECFILE $SPECFILE.bak
1351 fi
cd445739
AM
1352 chmod +w $SPECFILE
1353 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
f7b91886 1354 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
518ff1fb
ER
1355 parse_spec
1356 NODIST="yes" get_files $SOURCES $PATCHES
6392b5fd 1357 update_md5 $SOURCES
975d7b23 1358
cd445739
AM
1359 unset TOLDVER TNEWVER TNOTIFY
1360 fi
1361 fi
01fa66fc 1362 cd "$SPEC_DIR"
2a5f078d 1363
cd445739
AM
1364 case "$COMMAND" in
1365 build )
1366 BUILD_SWITCH="-ba" ;;
1367 build-binary )
1368 BUILD_SWITCH="-bb" ;;
1369 build-source )
1370 BUILD_SWITCH="-bs --nodeps" ;;
1371 build-prep )
1372 BUILD_SWITCH="-bp --nodeps" ;;
6594293d
AG
1373 build-build )
1374 BUILD_SWITCH="-bc" ;;
1375 build-install )
1376 BUILD_SWITCH="-bi" ;;
1377 build-list )
1378 BUILD_SWITCH="-bl" ;;
1379
cd445739 1380 esac
c890b916 1381
2e5be021 1382 update_shell_title "build_package: $COMMAND"
cd445739
AM
1383 if [ -n "$LOGFILE" ]; then
1384 LOG=`eval echo $LOGFILE`
1385 if [ -d "$LOG" ]; then
1386 echo "Log file $LOG is a directory."
1387 echo "Parse error in the spec?"
518ff1fb 1388 Exit_error err_build_fail
cd445739
AM
1389 fi
1390 if [ -n "$LASTLOG_FILE" ]; then
1391 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1392 fi
1393 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
86aafdbe 1394 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
cd445739
AM
1395 RETVAL=`cat $RES_FILE`
1396 rm $RES_FILE
1397 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1398 if [ "$RETVAL" -eq "0" ]; then
1399 mv $LOG $LOGDIROK
1400 else
1401 mv $LOG $LOGDIRFAIL
1402 fi
1403 fi
8ba5cdda 1404 else
86aafdbe 1405 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
cd445739 1406 RETVAL=$?
8ba5cdda 1407 fi
cd445739
AM
1408 if [ "$RETVAL" -ne "0" ]; then
1409 if [ -n "$TRY_UPGRADE" ]; then
796a8a95 1410 echo "\n!!! Package with new version cannot be built automagically\n"
257af81b
ER
1411 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1412 mv -f $SPECFILE.bak $SPECFILE
1413 fi
cd445739 1414 fi
518ff1fb 1415 Exit_error err_build_fail
cd445739
AM
1416 fi
1417 unset BUILD_SWITCH
1418}
1419
1420nourl()
1421{
1422 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1423}
1424
cd445739
AM
1425install_required_packages()
1426{
1427 run_poldek -vi $1
1428 return $?
1429}
1430
fa4bf1df
ER
1431find_spec_bcond() {
1432 # taken from find-spec-bcond, but with just getting the list
1433 local SPEC="$1"
1434 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1435 awk -F"\n" '
1436 /^%changelog/ { exit }
1437 /_with(out)?_[_a-zA-Z0-9]+/{
1438 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1439 print substr($0, RSTART, RLENGTH);
1440 }
1441 /^%bcond_with/{
1442 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1443 bcond = substr($0, RSTART +5 , RLENGTH -5);
1444 gsub(/[ \t]+/,"_",bcond);
1445 print bcond
1446 }' $SPEC | LC_ALL=C sort -u
1447}
1448
117d9861 1449process_bcondrc() {
301cbfd4
ER
1450 # expand bconds from ~/.bcondrc
1451 # The file structure is like gentoo's package.use:
1452 # ---
1453 # * -selinux
1454 # samba -mysql -pgsql
47a8df12 1455 # w32codec-installer license_agreement
301cbfd4
ER
1456 # php +mysqli
1457 # ---
fa4bf1df 1458 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
117d9861
ER
1459 :
1460 else
1461 return
1462 fi
301cbfd4 1463
117d9861 1464 SN=${SPECFILE%%\.spec}
c8a3e2ac 1465
117d9861
ER
1466 local bcondrc=$HOME/.bcondrc
1467 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
301cbfd4 1468
117d9861 1469 local bcond_avail=$(find_spec_bcond $SPECFILE)
301cbfd4 1470
117d9861
ER
1471 while read pkg flags; do
1472 # ignore comments
1473 [[ "$pkg" == \#* ]] && continue
1474
1475 # any package or current package?
1476 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1477 for flag in $flags; do
1478 local opt=${flag#[+-]}
1479
1480 # use only flags which are in this package.
1481 if [[ $bcond_avail = *${opt}* ]]; then
1482 if [[ $flag = -* ]]; then
1483 if [[ $BCOND != *--with?${opt}* ]]; then
1484 BCOND="$BCOND --without $opt"
1485 fi
1486 else
1487 if [[ $BCOND != *--without?${opt}* ]]; then
1488 BCOND="$BCOND --with $opt"
301cbfd4
ER
1489 fi
1490 fi
117d9861
ER
1491 fi
1492 done
1493 fi
1494 done < $bcondrc
1495 update_shell_title "parse ~/.bcondrc: DONE!"
1496}
1497
1498set_bconds_values()
1499{
1500 update_shell_title "set bcond values"
1501
1502 AVAIL_BCONDS_WITHOUT=""
1503 AVAIL_BCONDS_WITH=""
1504 if `grep -q ^%bcond ${SPECFILE}`; then
1505 BCOND_VERSION="NEW"
1506 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1507 BCOND_VERSION="OLD"
1508 else
1509 return
301cbfd4
ER
1510 fi
1511
117d9861
ER
1512 local bcond_avail=$(find_spec_bcond $SPECFILE)
1513 process_bcondrc "$SPECFILE"
1514
fa4bf1df 1515 update_shell_title "parse bconds"
cd445739 1516 case "${BCOND_VERSION}" in
fa4bf1df 1517 NONE)
7e365483 1518 :
cd445739 1519 ;;
7e365483 1520 OLD)
cd445739 1521 echo "Warning: This spec has old style bconds. Fix it || die."
fa4bf1df 1522 for opt in `echo "$bcond_avail" | grep ^_without_`
cd445739 1523 do
fa4bf1df
ER
1524 AVAIL_BCOND_WITHOUT=${opt#_without_}
1525 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
cd445739
AM
1526 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1527 else
1528 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1529 fi
1530 done
2a5f078d 1531
fa4bf1df 1532 for opt in `echo "$bcond_avail" | grep ^_with_`
cd445739 1533 do
fa4bf1df
ER
1534 AVAIL_BCOND_WITH=${opt#_with_}
1535 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
cd445739
AM
1536 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1537 else
1538 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1539 fi
1540 done
1541 ;;
1542 NEW)
fa4bf1df
ER
1543 local cond_type="" # with || without
1544 for opt in $bcond_avail; do
cd445739
AM
1545 case "$opt" in
1546 _without)
1547 cond_type="without"
1548 ;;
1549 _with)
1550 cond_type="with"
1551 ;;
f8d24cee 1552 _without_*)
fa4bf1df
ER
1553 AVAIL_BCOND_WITHOUT=${opt#_without_}
1554 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
f8d24cee 1555 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1556 else
1557 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1558 fi
1559 ;;
1560 _with_*)
fa4bf1df
ER
1561 AVAIL_BCOND_WITH=${opt#_with_}
1562 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
f8d24cee 1563 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1564 else
1565 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1566 fi
1567 ;;
cd445739
AM
1568 *)
1569 case "$cond_type" in
1570 with)
1571 cond_type=''
1572 AVAIL_BCOND_WITH="$opt"
fa4bf1df 1573 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
cd445739
AM
1574 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1575 else
1576 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1577 fi
7e365483 1578 ;;
cd445739
AM
1579 without)
1580 cond_type=''
1581 AVAIL_BCOND_WITHOUT="$opt"
fa4bf1df 1582 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
cd445739
AM
1583 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1584 else
1585 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1586 fi
1587 ;;
1588 esac
1589 ;;
1590 esac
1591 done
1592 ;;
1593 esac
1594}
1595
1596run_sub_builder()
1597{
1598 package_name="${1}"
af6b168f 1599 update_shell_title "run_sub_builder $package_name"
cd445739
AM
1600 #
1601