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