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