]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - builder.sh
- for correct parsing (stdout in English)
[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%% *}
4062d64a 31VERSION="v0.22/$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"
947025e5 85CVSIGNORE_DF="no"
d287305c 86
87PATCHES=""
88SOURCES=""
cd445739 89ICONS=""
d287305c 90PACKAGE_RELEASE=""
91PACKAGE_VERSION=""
92PACKAGE_NAME=""
14bead22 93ASSUMED_NAME=""
cd445739
AM
94PROTOCOL="ftp"
95WGET_RETRIES=${MAX_WGET_RETRIES:-0}
96CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
97
98CVSTAG=""
99RES_FILE=""
39dcc7de 100CVS_FORCE=""
cd445739
AM
101
102CVS_SERVER="cvs.pld-linux.org"
103DISTFILES_SERVER="://distfiles.pld-linux.org"
d4730dae 104ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
cd445739 105
36d03934 106DEF_NICE_LEVEL=19
86aafdbe 107SCHEDTOOL="auto"
cd445739
AM
108
109FAIL_IF_NO_SOURCES="yes"
110
18e5347d
ER
111# let get_files skip over files which are present to get those damn files fetched
112SKIP_EXISTING_FILES="no"
113
975d7b23 114TRY_UPGRADE=""
257af81b
ER
115# should the specfile be restored if upgrade failed?
116REVERT_BROKEN_UPGRADE="yes"
117
90baf90b
ER
118if rpm --specsrpm 2>/dev/null; then
119 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
ce40491a 120 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
90baf90b
ER
121else
122 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
123 if [ -x /usr/bin/rpm-getdeps ]; then
124 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
125 else
126 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
127 fi
ab4a2b6e
ER
128fi
129
90baf90b 130
cd445739
AM
131# Here we load saved user environment used to
132# predefine options set above, or passed to builder
133# in command line.
134# This one reads global system environment settings:
135if [ -f ~/etc/builderrc ]; then
136 . ~/etc/builderrc
137fi
138# And this one cascades settings using user personal
139# builder settings.
140# Example of ~/.builderrc:
141#
142#UPDATE_POLDEK_INDEXES="yes"
143#FETCH_BUILD_REQUIRES="yes"
144#REMOVE_BUILD_REQUIRES="force"
145#GROUP_BCONDS="yes"
146#LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
982e358c 147#TITLECHANGE=no
cd445739 148#
a83e5405 149SU_SUDO=""
cd445739
AM
150if [ -n "$HOME_ETC" ]; then
151 USER_CFG="$HOME_ETC/.builderrc"
20117088 152 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
cd445739
AM
153else
154 USER_CFG=~/.builderrc
20117088 155 BUILDER_MACROS=~/.builder-rpmmacros
cd445739
AM
156fi
157
158[ -f "$USER_CFG" ] && . "$USER_CFG"
159
86aafdbe
ER
160if [ "$SCHEDTOOL" = "auto" ]; then
161 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
162 SCHEDTOOL="schedtool -B -e"
163 else
164 SCHEDTOOL="no"
165 fi
166fi
167
ca2e6c31 168if [ -n "$USE_PROZILLA" ]; then
7e365483
KK
169 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
170 GETURI2="$GETURI"
171 OUTFILEOPT="-O"
ca2e6c31 172elif [ -n "$USE_AXEL" ]; then
cede92b3 173 GETURI="axel -a $AXEL_OPTS"
7e365483
KK
174 GETURI2="$GETURI"
175 OUTFILEOPT="-o"
ca2e6c31 176else
5700ee32
ER
177 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
178 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
179 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
e3aa6f5e 180 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
6f9a5d76 181
7e365483
KK
182 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
183 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
184 OUTFILEOPT="-O"
2bc5451f 185fi
11468b23 186
11468b23
AM
187GETLOCAL="cp -a"
188
189if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
190 RPM="rpm"
191 RPMBUILD="rpm"
192else
193 RPM="rpm"
194 RPMBUILD="rpmbuild"
195fi
196
28c23a72
AG
197#
198# are we using cvs-nserver ?
199#
e21039da
AG
200CVS_NSERVER=0
201cvs --version 2>&1 | grep -q 'CVS-nserver'
202[ $? -eq 0 ] && CVS_NSERVER=1
28c23a72 203
a8c9a155 204POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
a83e5405 205POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
11468b23 206
cd445739
AM
207run_poldek()
208{
525bf240 209 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
cd445739
AM
210 if [ -n "$LOGFILE" ]; then
211 LOG=`eval echo $LOGFILE`
212 if [ -n "$LASTLOG_FILE" ]; then
213 echo "LASTLOG=$LOG" > $LASTLOG_FILE
214 fi
86aafdbe 215 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
cd445739
AM
216 return $exit_pldk
217 else
86aafdbe 218 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
cd445739
AM
219 return `cat ${RES_FILE}`
220 rm -rf ${RES_FILE}
221 fi
222}
223
cd445739
AM
224#---------------------------------------------
225# functions
da946cd6 226
5a491465 227usage()
228{
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
ER
408 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
409 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
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>}
fb198857 475EOF
3d12d055 476 if [ "$NOINIT" = "yes" ] ; then
20117088 477 cat >> $BUILDER_MACROS <<'EOF'
3d12d055
JR
478%_specdir ./
479%_sourcedir ./
480EOF
c039643c 481 fi
fff1b991 482 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
ace3fd80
ER
483}
484
485cache_rpm_dump() {
486 if [ -n "$DEBUG" ]; then
487 set -x
488 set -v
489 fi
490
d1d24c14 491 if [ -x /usr/bin/rpm-specdump ]; then
525bf240 492 update_shell_title "cache_rpm_dump using rpm-specdump command"
fff1b991 493 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
d1d24c14 494 else
525bf240 495 update_shell_title "cache_rpm_dump using rpmbuild command"
d1d24c14
ER
496 local rpm_dump
497 rpm_dump=`
498 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
499 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
500 case "$RPMBUILD" in
501 rpm)
502 ARGS='-bp'
503 ;;
504 rpmbuild)
505 ARGS='--nodigest --nosignature --nobuild'
506 ;;
507 esac
508 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
509 `
510 if [ $? -gt 0 ]; then
511 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
512 echo "$error" >&2
513 Exit_error err_build_fail
514 fi
d05e8080 515
d1d24c14
ER
516 # make small dump cache
517 rpm_dump_cache=`echo "$rpm_dump" | awk '
518 $2 ~ /^SOURCEURL/ {print}
519 $2 ~ /^PATCHURL/ {print}
520 $2 ~ /^nosource/ {print}
521 $2 ~ /^PACKAGE_/ {print}
522 '`
523 fi
d05e8080 524
13974367 525 update_shell_title "cache_rpm_dump: OK!"
cd445739
AM
526}
527
ace3fd80 528rpm_dump() {
cd445739 529 if [ -z "$rpm_dump_cache" ] ; then
45e2a818 530 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
cd445739
AM
531 fi
532 echo "$rpm_dump_cache"
533}
534
d05e8080
ER
535get_icons()
536{
537 update_shell_title "get icons"
a8c9a155 538 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
d05e8080
ER
539 if [ -z "$ICONS" ]; then
540 return
541 fi
542
975d7b23 543 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
d05e8080
ER
544}
545
59398507 546parse_spec()
547{
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
01fa66fc 557 cd $SPEC_DIR
cd445739 558 cache_rpm_dump
00fcec7e 559
cd445739 560 if [ "$NOSRCS" != "yes" ]; then
a8c9a155 561 SOURCES=$(rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}')
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
a8c9a155
ER
568 PATCHES=$(rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}')
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
598Exit_error()
599{
600 if [ -n "$DEBUG" ]; then
518ff1fb
ER
601 set -x
602 set -v
cd445739
AM
603 fi
604
605 cd "$__PWD"
606
607 case "$1" in
608 "err_no_spec_in_cmdl" )
609 remove_build_requires
45e2a818 610 echo >&2 "ERROR: spec file name not specified."
cd445739 611 exit 2 ;;
a08d92fc 612 "err_invalid_cmdline" )
45e2a818 613 echo >&2 "ERROR: invalid command line arg ($2)."
a08d92fc 614 exit 2 ;;
cd445739
AM
615 "err_no_spec_in_repo" )
616 remove_build_requires
45e2a818 617 echo >&2 "Error: spec file not stored in CVS repo."
cd445739
AM
618 exit 3 ;;
619 "err_no_source_in_repo" )
620 remove_build_requires
45e2a818 621 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
cd445739
AM
622 exit 4 ;;
623 "err_build_fail" )
624 remove_build_requires
45e2a818 625 echo >&2 "Error: package build failed. (${2:-no more info})"
cd445739 626 exit 5 ;;
78eab2a1
AM
627 "err_no_package_data" )
628 remove_build_requires
45e2a818 629 echo >&2 "Error: couldn't get out package name/version/release from spec file."
78eab2a1 630 exit 6 ;;
ce40491a 631 "err_tag_exists" )
50321881 632 remove_build_requires
45e2a818 633 echo >&2 "Tag ${2} already exists (spec release: ${3})."
50321881 634 exit 9 ;;
ce40491a 635 "err_fract_rel" )
50321881 636 remove_build_requires
45e2a818 637 echo >&2 "Release ${2} not integer and not a snapshot."
50321881 638 exit 10 ;;
fb96e0b5
AM
639 "err_branch_exists" )
640 remove_build_requires
45e2a818 641 echo >&2 "Tree branch already exists (${2})."
fb96e0b5 642 exit 11 ;;
cfc497c0
ER
643 "err_acl_deny" )
644 remove_build_requires
45e2a818 645 echo >&2 "Error: conditions reject building this spec (${2})."
cfc497c0 646 exit 12 ;;
cd445739 647 esac
45e2a818 648 echo >&2 "Unknown error."
73848362 649 exit 100
cd445739
AM
650}
651
652init_builder()
653{
654 if [ -n "$DEBUG" ]; then
518ff1fb
ER
655 set -x
656 set -v
0dd6320d 657 fi
cd445739 658
4aeb9973 659 if [ "$NOINIT" != "yes" ] ; then
a08cc47e
ER
660 local extra
661 if [ "$ASSUMED_NAME" ]; then
662 extra="--define 'name $ASSUMED_NAME'"
663 fi
a8c9a155
ER
664 SOURCE_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}')
665 SPEC_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_specdir}')
29e90b02
JR
666 else
667 SOURCE_DIR="."
01fa66fc 668 SPEC_DIR="."
29e90b02 669 fi
cd445739 670
a8c9a155 671 __PWD=$(pwd)
00fcec7e 672}
673
d6a77ddb 674get_spec()
1471f6d6 675{
c890b916 676
2e5be021 677 update_shell_title "get_spec"
c890b916 678
cd445739 679 if [ -n "$DEBUG" ]; then
518ff1fb
ER
680 set -x
681 set -v
cd445739
AM
682 fi
683
01fa66fc 684 cd "$SPEC_DIR"
049ab214 685 if [ ! -f "$SPECFILE" ]; then
a8c9a155 686 SPECFILE="$(basename $SPECFILE .spec).spec"
cd445739
AM
687 fi
688 if [ "$NOCVSSPEC" != "yes" ]; then
cd445739 689
049ab214
ER
690 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
691 echo "Warning: No CVS access defined - using local .spec file"
692 NOCVSSPEC="yes"
cd445739
AM
693 fi
694
049ab214 695 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
cd445739 696 fi
049ab214 697
cd445739 698 if [ ! -f "$SPECFILE" ]; then
518ff1fb 699 Exit_error err_no_spec_in_repo
cd445739
AM
700 fi
701
702 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
703 chmod $CHMOD_MODE $SPECFILE
704 fi
705 unset OPTIONS
a7eefc54 706 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
7e40520f 707
ce40491a 708 set_spec_target
cd445739
AM
709}
710
711find_mirror()
712{
01fa66fc 713 cd "$SPEC_DIR"
782518da 714 local url="$1"
cd445739
AM
715 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
716 cvs update mirrors >&2
717 fi
718
719 IFS="|"
782518da
ER
720 local origin mirror name rest ol prefix
721 while read origin mirror name rest; do
722 # skip comments and empty lines
723 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
724 continue
725 fi
a8c9a155
ER
726 ol=$(echo -n "$origin" | wc -c)
727 prefix=$(echo -n "$url" | head -c $ol)
cd445739 728 if [ "$prefix" = "$origin" ] ; then
a8c9a155 729 suffix=$(echo "$url" | cut -b $((ol+1))-)
cd445739
AM
730 echo -n "$mirror$suffix"
731 return 0
732 fi
733 done < mirrors
734 echo "$url"
735}
736
e7e0d4ec 737# Warning: unpredictable results if same URL used twice
cd445739
AM
738src_no ()
739{
01fa66fc 740 cd $SPEC_DIR
cd445739
AM
741 rpm_dump | \
742 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
743 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
744 head -n 1 | xargs
1471f6d6 745}
746
e7e0d4ec 747src_md5()
8ba5cdda 748{
e7e0d4ec 749 [ "$NO5" = "yes" ] && return
cd445739
AM
750 no=$(src_no "$1")
751 [ -z "$no" ] && return
01fa66fc 752 cd $SPEC_DIR
e7e0d4ec
ER
753 local md5
754
755 if [ -f additional-md5sums ]; then
756 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
757 if [ -z "$spec_rev" ]; then
a8c9a155 758 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
e7e0d4ec
ER
759 fi
760 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
761 md5=$(grep -s -v '^#' additional-md5sums | \
762 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
763 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
764 grep -E '^[0-9a-f]{32}$')
765
766 if [ "$md5" ]; then
767 if [ $(echo "$md5" | wc -l) != 1 ] ; then
768 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
769 fi
770 echo "$md5" | tail -n 1
771 return
772 fi
cd445739 773 fi
e7e0d4ec
ER
774
775 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
776 if [ -n "$source_md5" ]; then
777 echo $source_md5
cd445739 778 else
7805dcb4
PZ
779 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
780 if [ -n "$source_md5" ]; then
781 echo $source_md5
782 else
783 # we have empty SourceX-md5, but it is still possible
784 # that we have NoSourceX-md5 AND NoSource: X
785 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
786 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
787 echo $nosource_md5
788 fi
cd445739 789 fi
cd445739
AM
790 fi
791}
792
06541433
JR
793distfiles_path ()
794{
795 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
796}
797
cd445739
AM
798distfiles_url ()
799{
06541433 800 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
cd445739
AM
801}
802
803distfiles_attic_url ()
804{
06541433 805 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
cd445739
AM
806}
807
808good_md5 ()
809{
810 md5=$(src_md5 "$1")
811 [ "$md5" = "" ] || \
812 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
8ba5cdda
PG
813}
814
a4b50627
AF
815good_size ()
816{
a8c9a155 817 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
ce40491a 818 [ -n "$size" -a "$size" -gt 0 ]
a4b50627
AF
819}
820
947025e5 821cvsignore_df ()
822{
823 if [ "$CVSIGNORE_DF" != "yes" ]; then
824 return
825 fi
826 cvsignore=${SOURCE_DIR}/.cvsignore
827 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
828 echo "$1" >> $cvsignore
829 fi
830}
831
e7fa3b9f
ER
832cvsup()
833{
ce40491a
ER
834 update_shell_title "cvsup"
835 local OPTIONS="up "
836 if [ -n "$CVSROOT" ]; then
837 OPTIONS="-d $CVSROOT $OPTIONS"
838 fi
b1c6aace 839
ce40491a
ER
840 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
841 OPTIONS="$OPTIONS -A"
842 else
843 if [ -n "$CVSDATE" ]; then
844 OPTIONS="$OPTIONS -D $CVSDATE"
845 fi
846 if [ -n "$CVSTAG" ]; then
847 OPTIONS="$OPTIONS -r $CVSTAG"
848 fi
849 fi
e7fa3b9f 850
ce40491a
ER
851 local result=1
852 local retries_counter=0
853 if [ $# = 1 ]; then
854 update_shell_title "cvsup: $*"
855 else
856 update_shell_title "cvsup: $# files"
857 fi
858 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
859 retries_counter=$(( $retries_counter + 1 ))
860 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
861 result=$?
862 [ -n "$output" ] && echo "$output"
863 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
864 echo "Trying again [$*]... ($retries_counter)"
865 update_shell_title "cvsup: retry #$retries_counter"
866 sleep 2
867 continue
868 else
869 break
870 fi
871 done
872 update_shell_title "cvsup: done!"
873 return $result
e7fa3b9f
ER
874}
875
71f8e908
ER
876# returns true if "$1" is ftp, http or https protocol url
877is_url()
878{
879 case "$1" in
880 ftp://*|http://*|https://*)
881 return 0
882 ;;
883 esac
884 return 1
885}
886
ecba6ad5
ER
887update_md5()
888{
889 if [ $# -eq 0 ]; then
890 return
891 fi
892
893 update_shell_title "update md5"
894 if [ -n "$DEBUG" ]; then
518ff1fb
ER
895 set -x
896 set -v
ecba6ad5
ER
897 fi
898
899 cd "$SOURCE_DIR"
900
901 # pass 1: check files to be fetched
902 local todo
903 local need_files
904 for i in "$@"; do
905 local fp=$(nourl "$i")
906 local srcno=$(src_no "$i")
6392b5fd
ER
907 if [ -n "$ADD5" ]; then
908 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
01fa66fc 909 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
6c1b2e7d 910 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
6392b5fd 911 else
6c1b2e7d 912 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
ecba6ad5
ER
913 fi
914 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
915 need_files="$need_files $i"
916 fi
917 done
918
919 # pass 1a: get needed files
920 if [ "$need_files" ]; then
921 get_files $need_files
922 fi
923
924 # pass 2: proceed with md5 adding or updating
925 for i in "$@"; do
926 local fp=$(nourl "$i")
927 local srcno=$(src_no "$i")
01fa66fc 928 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
e19ad799 929 if [ -z "$md5" ]; then
6c1b2e7d
PZ
930 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
931 fi
71f8e908 932 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
6c1b2e7d 933 local tag="# Source$srcno-md5:\t"
71f8e908 934 if [[ "$md5" == *NoSource* ]]; then
6c1b2e7d
PZ
935 tag="# NoSource$srcno-md5:\t"
936 elif [ -n "$USEDIGEST" ]; then
937 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
71f8e908 938 fi
ecba6ad5 939 md5=$(md5sum "$fp" | cut -f1 -d' ')
15bf3e99 940 echo "Updating Source$srcno ($md5: $fp)."
ecba6ad5 941 perl -i -ne '
6c1b2e7d
PZ
942 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
943 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
ecba6ad5 944 ' \
01fa66fc 945 $SPEC_DIR/$SPECFILE
ecba6ad5
ER
946 fi
947 done
948}
949
950check_md5()
951{
3fbff8b8
ER
952 [ "$NO5" = "yes" ] && return
953
ecba6ad5
ER
954 update_shell_title "check md5"
955
956 for i in "$@"; do
957 if good_md5 "$i" && good_size "$i"; then
958 continue
959 fi
960
961 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
962 echo "or -5 to update md5 sums, if you're sure files are correct."
963 Exit_error err_no_source_in_repo $i
964 done
965}
966
cd445739
AM
967get_files()
968{
7cb24972 969 update_shell_title "get_files"
cd445739
AM
970
971 if [ -n "$DEBUG" ]; then
518ff1fb
ER
972 set -x
973 set -v
cd445739
AM
974 fi
975
f09c0772 976 if [ $# -gt 0 ]; then
cd445739
AM
977 cd "$SOURCE_DIR"
978
b1c6aace 979 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
049ab214 980 echo "Warning: No CVS access defined for SOURCES"
b1c6aace
ER
981 NOCVS="yes"
982 fi
983
f2e42a41 984 local nc=0
e7fa3b9f 985 local get_files_cvs=""
3815b69a 986 for i in "$@"; do
f2e42a41 987 nc=$((nc + 1))
dcebdffb 988 local cvsup=0
3815b69a 989 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
f2e42a41 990 update_shell_title "$i"
f09c0772 991 local fp=`nourl "$i"`
ecba6ad5 992 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
ce40491a 993 continue
18e5347d 994 fi
ecba6ad5 995
cd445739 996 FROM_DISTFILES=0
e7e0d4ec 997 local srcmd5=$(src_md5 "$i")
ecba6ad5
ER
998
999 # we know if source/patch is present in cvs/distfiles
1000 # - has md5 (in distfiles)
1001 # - in cvs... ideas?
1002
1003 # CHECK: local file didn't exist or always cvs up (first) requested.
f09c0772 1004 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
cd445739
AM
1005 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1006 echo "Warning: no URL given for $i"
1007 fi
1008
e7e0d4ec 1009 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
a4b50627 1010 if good_md5 "$i" && good_size "$i"; then
e7e0d4ec 1011 echo "$fp having proper md5sum already exists"
cd445739
AM
1012 continue
1013 fi
4ea1c265 1014 target="$fp"
28b34560 1015
bc10f694 1016 # optionally prefer mirror over distfiles if there's mirror
28b34560 1017 # TODO: build url list and then try each url from the list
bc10f694 1018 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
28b34560
ER
1019 url="$im"
1020 else
1021 url=$(distfiles_url "$i")
1022 fi
1023
cd445739
AM
1024 url_attic=$(distfiles_attic_url "$i")
1025 FROM_DISTFILES=1
ecba6ad5
ER
1026 # is $url local file?
1027 if [[ "$url" = [./]* ]]; then
18a52930 1028 update_shell_title "${GETLOCAL%% *}: $url"
cd445739
AM
1029 ${GETLOCAL} $url $target
1030 else
1031 if [ -z "$NOMIRRORS" ]; then
9e9f8920 1032 url=$(find_mirror "$url")
cd445739 1033 fi
9e9f8920
ER
1034
1035 local uri=${url}
1036 # make shorter message for distfiles urls
1037 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1038 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1039 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1040 uri="df: $uri"
1041 fi
1042 update_shell_title "${GETURI%% *}: $uri"
ca2e6c31 1043 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 1044 if [ "`echo $url | grep -E 'ftp://'`" ]; then
18a52930 1045 update_shell_title "${GETURI2%% *}: $url"
ca2e6c31 1046 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739
AM
1047 fi
1048 fi
ecba6ad5
ER
1049
1050 # is it empty file?
1051 if [ ! -s "$target" ]; then
cd445739
AM
1052 rm -f "$target"
1053 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
18a52930 1054 update_shell_title "${GETLOCAL%% *}: $url_attic"
cd445739
AM
1055 ${GETLOCAL} $url_attic $target
1056 else
1057 if [ -z "$NOMIRRORS" ]; then
a8c9a155 1058 url_attic=$(find_mirror "$url_attic")
cd445739 1059 fi
18a52930 1060 update_shell_title "${GETURI%% *}: $url_attic"
ca2e6c31 1061 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 1062 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
ce40491a 1063 update_shell_title "${GETURI2%% *}: $url_attic"
ca2e6c31 1064 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
1065 fi
1066 fi
1067 fi
ecba6ad5
ER
1068
1069 if [ -s "$target" ]; then
947025e5 1070 cvsignore_df $target
1071 else
cd445739
AM
1072 rm -f "$target"
1073 FROM_DISTFILES=0
1074 fi
e7e0d4ec 1075 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
d05e8080
ER
1076 if [ $# -gt 1 ]; then
1077 get_files_cvs="$get_files_cvs $fp"
1078 update_shell_title "$fp (will cvs up later)"
1079 cvsup=1
1080 else
1081 cvsup $fp
1082 fi
cd445739
AM
1083 fi
1084
f09c0772 1085 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
cd445739 1086 if [ -z "$NOMIRRORS" ]; then
a8c9a155 1087 im=$(find_mirror "$i")
cd445739
AM
1088 else
1089 im="$i"
1090 fi
ce40491a 1091 update_shell_title "${GETURI%% *}: $im"
cd445739 1092 ${GETURI} "$im" || \
33da77c4 1093 if [ "`echo $im | grep -E 'ftp://'`" ]; then
ce40491a 1094 update_shell_title "${GETURI2%% *}: $im"
cd445739 1095 ${GETURI2} "$im"
7e365483 1096 fi
cd445739
AM
1097 fi
1098
dcebdffb
ER
1099 if [ "$cvsup" = 1 ]; then
1100 continue
1101 fi
1102
cd445739 1103 fi
ecba6ad5
ER
1104
1105 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
f09c0772 1106 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
cdbd30e8 1107 if [ -n "GREEDSRC" ]; then
1108 get_greed_sources $i
1109 else
1110 Exit_error err_no_source_in_repo $i
1111 fi
cd445739 1112 fi
2a5f078d 1113
ecba6ad5 1114 # we check md5 here just only to refetch immediately
a4b50627 1115 if good_md5 "$i" && good_size "$i"; then
cd445739
AM
1116 :
1117 elif [ "$FROM_DISTFILES" = 1 ]; then
deccc50e 1118 # wrong md5 from distfiles: remove the file and try again
cd445739 1119 # but only once ...
deccc50e 1120 echo "MD5 sum mismatch. Trying full fetch."
cd445739
AM
1121 FROM_DISTFILES=2
1122 rm -f $target
18a52930 1123 update_shell_title "${GETURI%% *}: $url"
ca2e6c31 1124 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
33da77c4 1125 if [ "`echo $url | grep -E 'ftp://'`" ]; then
ce40491a 1126 update_shell_title "${GETURI2%% *}: $url"
ca2e6c31 1127 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
cd445739 1128 fi
ecba6ad5 1129 if [ ! -s "$target" ]; then
cd445739 1130 rm -f "$target"
18a52930 1131 update_shell_title "${GETURI%% *}: $url_attic"
ca2e6c31 1132 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
33da77c4 1133 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
ce40491a 1134 update_shell_title "${GETURI2%% *}: $url_attic"
ca2e6c31 1135 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
cd445739
AM
1136 fi
1137 fi
1138 test -s "$target" || rm -f "$target"
1139 fi
cd445739 1140 done
e7fa3b9f
ER
1141 SHELL_TITLE_PREFIX=""
1142
1143 if [ "$get_files_cvs" ]; then
ce40491a 1144 cvsup $get_files_cvs
e7fa3b9f 1145 fi
cd445739
AM
1146
1147 if [ "$CHMOD" = "yes" ]; then
a8c9a155 1148 CHMOD_FILES=$(nourl "$@")
cd445739
AM
1149 if [ -n "$CHMOD_FILES" ]; then
1150 chmod $CHMOD_MODE $CHMOD_FILES
1151 fi
1152 fi
cd445739
AM
1153 fi
1154}
1155
1156make_tagver() {
ce40491a 1157 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1158 set -x
1159 set -v
ce40491a 1160 fi
78eab2a1 1161
ce40491a
ER
1162 # Check whether first character of PACKAGE_NAME is legal for tag name
1163 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1164 TAG_PREFIX=tag_
1165 fi
d712cc12
ER
1166
1167 # NOTE: CVS tags may must not contain the characters `$,.:;@'
392187d9 1168 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
d712cc12 1169
ce40491a
ER
1170 # Remove #kernel.version_release from TAGVER because tagging sources
1171 # could occur with different kernel-headers than kernel-headers used at build time.
d712cc12
ER
1172 # besides, %{_kernel_ver_str} is not expanded.
1173
1174 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1175 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1176
1177 TAGVER=${TAGVER%#*}
ce40491a 1178 echo -n "$TAGVER"
cd445739
AM
1179}
1180
c713aac3
AG
1181# bool is_tag_a_branch(tag)
1182#
1183# returns 1 if a tag is a branch set on SPECFILE
1184is_tag_a_branch() {
1185 if [ -n "$DEBUG" ]; then
1186 set -x
1187 set -v
1188 fi
1189
1190 if [ $# -ne 1 ]; then
1191 return 0;
1192 fi
1193
1194 TAG=$1
f5141bbc 1195
c713aac3
AG
1196 cd "$SPEC_DIR"
1197 cvs status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1198 return $?
1199}
1200
cd445739
AM
1201tag_files()
1202{
1203 TAG_FILES="$@"
1204
1205 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1206 set -x
1207 set -v
cd445739
AM
1208 fi
1209
73ef63d8
ER
1210 echo "Version: $PACKAGE_VERSION"
1211 echo "Release: $PACKAGE_RELEASE"
cd445739 1212
a18a9761 1213 local TAGVER
73ef63d8 1214 if [ "$TAG_VERSION" = "yes" ]; then
a18a9761 1215 TAGVER=`make_tagver`
73ef63d8
ER
1216 echo "CVS tag: $TAGVER"
1217 fi
1218 if [ -n "$TAG" ]; then
1219 echo "CVS tag: $TAG"
1220 fi
cd445739 1221
39dcc7de 1222 local OPTIONS="tag $CVS_FORCE"
73ef63d8
ER
1223 if [ -n "$CVSROOT" ]; then
1224 OPTIONS="-d $CVSROOT $OPTIONS"
1225 fi
cd445739 1226
c713aac3
AG
1227 # if a tagname we are about to set already exists
1228 # and happens to be a branch (common case with AC-branch)
1229 # pass -B (allows -F to disturb branch tag)
1230 local _tag=$TAG
1231 if [ "$TAG_VERSION" = "yes" ]; then
1232 _tag=$TAGVER
1233 fi;
1234 is_tag_a_branch $_tag
28c23a72 1235 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
c713aac3
AG
1236 OPTIONS="$OPTIONS -B"
1237 fi;
1238
73ef63d8
ER
1239 cd "$SOURCE_DIR"
1240 local tag_files
1241 for i in $TAG_FILES; do
1242 # don't tag files stored on distfiles
1243 [ -n "`src_md5 $i`" ] && continue
1244 local fp=`nourl "$i"`
1245 if [ -f "$fp" ]; then
1246 tag_files="$tag_files $fp"
cdbd30e8 1247 elif [ -n "GREEDSRC" ]; then
1248 get_greed_sources $i
73ef63d8
ER
1249 else
1250 Exit_error err_no_source_in_repo $i
03db3356 1251 fi
73ef63d8 1252 done
03db3356 1253
73ef63d8 1254 if [ "$tag_files" ]; then
cd445739 1255 if [ "$TAG_VERSION" = "yes" ]; then
73ef63d8 1256 update_shell_title "tag sources: $TAGVER"
19ca62ef 1257 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
c7e6ee9b 1258 cvs $OPTIONS $TAGVER $tag_files || exit
cd445739
AM
1259 fi
1260 if [ -n "$TAG" ]; then
73ef63d8 1261 update_shell_title "tag sources: $TAG"
c4ff623e
ER
1262
1263 while [ "$tag_files" ]; do
1264 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1265 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1266 cvs $OPTIONS $TAG $chunk || exit
1267 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1268 done
cd445739 1269 fi
73ef63d8
ER
1270 fi
1271
01fa66fc 1272 cd "$SPEC_DIR"
73ef63d8
ER
1273 if [ "$TAG_VERSION" = "yes" ]; then
1274 update_shell_title "tag spec: $TAGVER"
c7e6ee9b 1275 cvs $OPTIONS $TAGVER $SPECFILE || exit
73ef63d8
ER
1276 fi
1277 if [ -n "$TAG" ]; then
1278 update_shell_title "tag spec: $TAG"
c7e6ee9b 1279 cvs $OPTIONS $TAG $SPECFILE || exit
73ef63d8 1280 fi
cd445739
AM
1281}
1282
1283branch_files()
1284{
1285 TAG=$1
1286 echo "CVS branch tag: $TAG"
518ff1fb 1287 shift
cd445739
AM
1288
1289 TAG_FILES="$@"
1290
1291 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1292 set -x
1293 set -v
cd445739
AM
1294 fi
1295
78a5a506 1296 local OPTIONS="tag $CVS_FORCE -b"
cc4d29c0
AG
1297
1298 # branch exists?
1299 is_tag_a_branch $TAG
1300 if [ $? -eq 1 ]; then
1301 OPTIONS="$OPTIONS -B"
1302 fi
1303
78a5a506
ER
1304 if [ -n "$CVSROOT" ]; then
1305 OPTIONS="-d $CVSROOT $OPTIONS"
1306 fi
1307 cd "$SOURCE_DIR"
1308 local tag_files
1309 for i in $TAG_FILES; do
1310 local fp=`nourl "$i"`
1311 if [ -f "$fp" ]; then
1312 tag_files="$tag_files $fp"
cdbd30e8 1313 elif [ -n "GREEDSRC" ]; then
1314 get_greed_sources $i
78a5a506
ER
1315 else
1316 Exit_error err_no_source_in_repo $i
c10fa4fa 1317 fi
78a5a506
ER
1318 done
1319 if [ "$tag_files" ]; then
c7e6ee9b 1320 cvs $OPTIONS $TAG $tag_files || exit
78a5a506 1321 fi
c10fa4fa 1322
01fa66fc 1323 cd "$SPEC_DIR"
c7e6ee9b 1324 cvs $OPTIONS $TAG $SPECFILE || exit
cd445739
AM
1325}
1326
1327
3009b80d
ER
1328# this function should exit early if package can't be built for this arch
1329# this avoids unneccessary BR filling.
1330check_buildarch() {
1331 local out ret
13c3c336 1332 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
3009b80d
ER
1333 ret=$?
1334 if [ $ret -ne 0 ]; then
1335 echo >&2 "$out"
1336 exit $ret
1337 fi
1338}
1339
cd445739 1340
59398507 1341build_package()
1342{
2e5be021 1343 update_shell_title "build_package"
cd445739 1344 if [ -n "$DEBUG" ]; then
518ff1fb
ER
1345 set -x
1346 set -v
cd445739 1347 fi
5a491465 1348
01fa66fc 1349 cd "$SPEC_DIR"
cd445739
AM
1350
1351 if [ -n "$TRY_UPGRADE" ]; then
ce40491a 1352 update_shell_title "build_package: try_upgrade"
cd445739 1353 if [ -n "$FLOAT_VERSION" ]; then
45e2a818 1354 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
cd445739 1355 else
45e2a818 1356 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
cd445739
AM
1357 fi
1358
45e2a818 1359 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
cd445739
AM
1360
1361 if [ -n "$TNEWVER" ]; then
1362 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1363 echo "New version found, updating spec file to version " $TNEWVER
257af81b
ER
1364 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1365 cp -f $SPECFILE $SPECFILE.bak
1366 fi
cd445739
AM
1367 chmod +w $SPECFILE
1368 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
f7b91886 1369 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
518ff1fb
ER
1370 parse_spec
1371 NODIST="yes" get_files $SOURCES $PATCHES
6392b5fd 1372 update_md5 $SOURCES
975d7b23 1373
cd445739
AM
1374 unset TOLDVER TNEWVER TNOTIFY
1375 fi
1376 fi
01fa66fc 1377 cd "$SPEC_DIR"
2a5f078d 1378
cd445739
AM
1379 case "$COMMAND" in
1380 build )
1381 BUILD_SWITCH="-ba" ;;
1382 build-binary )
1383 BUILD_SWITCH="-bb" ;;
1384 build-source )
1385 BUILD_SWITCH="-bs --nodeps" ;;
1386 build-prep )
1387 BUILD_SWITCH="-bp --nodeps" ;;
6594293d
AG
1388 build-build )
1389 BUILD_SWITCH="-bc" ;;
1390 build-install )
1391 BUILD_SWITCH="-bi" ;;
1392 build-list )
1393 BUILD_SWITCH="-bl" ;;
1394
cd445739 1395 esac
c890b916 1396
2e5be021 1397 update_shell_title "build_package: $COMMAND"
cd445739
AM
1398 if [ -n "$LOGFILE" ]; then
1399 LOG=`eval echo $LOGFILE`
1400 if [ -d "$LOG" ]; then
1401 echo "Log file $LOG is a directory."
1402 echo "Parse error in the spec?"
518ff1fb 1403 Exit_error err_build_fail
cd445739
AM
1404 fi
1405 if [ -n "$LASTLOG_FILE" ]; then
1406 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1407 fi
525bf240
ER
1408 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1409
fff1b991 1410 (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
1411 RETVAL=`cat $RES_FILE`
1412 rm $RES_FILE
1413 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1414 if [ "$RETVAL" -eq "0" ]; then
1415 mv $LOG $LOGDIROK
1416 else
1417 mv $LOG $LOGDIRFAIL
1418 fi
1419 fi
8ba5cdda 1420 else
fff1b991 1421 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE
cd445739 1422 RETVAL=$?
8ba5cdda 1423 fi
cd445739
AM
1424 if [ "$RETVAL" -ne "0" ]; then
1425 if [ -n "$TRY_UPGRADE" ]; then
796a8a95 1426 echo "\n!!! Package with new version cannot be built automagically\n"
257af81b
ER
1427 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1428 mv -f $SPECFILE.bak $SPECFILE
1429 fi
cd445739 1430 fi
518ff1fb 1431 Exit_error err_build_fail
cd445739
AM
1432 fi
1433 unset BUILD_SWITCH
1434}
1435
1436nourl()
1437{
1438 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1439}
1440
cd445739
AM
1441install_required_packages()
1442{
1443 run_poldek -vi $1
1444 return $?
1445}
1446
fa4bf1df
ER
1447find_spec_bcond() {
1448 # taken from find-spec-bcond, but with just getting the list
1449 local SPEC="$1"
fa4bf1df
ER
1450 awk -F"\n" '
1451 /^%changelog/ { exit }
1452 /_with(out)?_[_a-zA-Z0-9]+/{
1453 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1454 print substr($0, RSTART, RLENGTH);
1455 }
1456 /^%bcond_with/{
1457 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1458 bcond = substr($0, RSTART +5 , RLENGTH -5);
1459 gsub(/[ \t]+/,"_",bcond);
1460 print bcond
1461 }' $SPEC | LC_ALL=C sort -u
1462}
1463
117d9861 1464process_bcondrc() {
301cbfd4
ER
1465 # expand bconds from ~/.bcondrc
1466 # The file structure is like gentoo's package.use:
1467 # ---
1468 # * -selinux
1469 # samba -mysql -pgsql
47a8df12 1470 # w32codec-installer license_agreement
301cbfd4
ER
1471 # php +mysqli
1472 # ---
fa4bf1df 1473 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
117d9861
ER
1474 :
1475 else
1476 return
1477 fi
301cbfd4 1478
117d9861 1479 SN=${SPECFILE%%\.spec}
c8a3e2ac 1480
117d9861
ER
1481 local bcondrc=$HOME/.bcondrc
1482 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
301cbfd4 1483
117d9861 1484 local bcond_avail=$(find_spec_bcond $SPECFILE)
301cbfd4 1485
117d9861
ER
1486 while read pkg flags; do
1487 # ignore comments
1488 [[ "$pkg" == \#* ]] && continue
1489
1490 # any package or current package?
1491 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1492 for flag in $flags; do
1493 local opt=${flag#[+-]}
1494
1495 # use only flags which are in this package.
1496 if [[ $bcond_avail = *${opt}* ]]; then
1497 if [[ $flag = -* ]]; then
1498 if [[ $BCOND != *--with?${opt}* ]]; then
1499 BCOND="$BCOND --without $opt"
1500 fi
1501 else
1502 if [[ $BCOND != *--without?${opt}* ]]; then
1503 BCOND="$BCOND --with $opt"
301cbfd4
ER
1504 fi
1505 fi
117d9861
ER
1506 fi
1507 done
1508 fi
1509 done < $bcondrc
1510 update_shell_title "parse ~/.bcondrc: DONE!"
1511}
1512
1513set_bconds_values()
1514{
1515 update_shell_title "set bcond values"
1516
1517 AVAIL_BCONDS_WITHOUT=""
1518 AVAIL_BCONDS_WITH=""
1519 if `grep -q ^%bcond ${SPECFILE}`; then
1520 BCOND_VERSION="NEW"
1521 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1522 BCOND_VERSION="OLD"
1523 else
1524 return
301cbfd4
ER
1525 fi
1526
117d9861
ER
1527 local bcond_avail=$(find_spec_bcond $SPECFILE)
1528 process_bcondrc "$SPECFILE"
1529
fa4bf1df 1530 update_shell_title "parse bconds"
cd445739 1531 case "${BCOND_VERSION}" in
fa4bf1df 1532 NONE)
7e365483 1533 :
cd445739 1534 ;;
7e365483 1535 OLD)
cd445739 1536 echo "Warning: This spec has old style bconds. Fix it || die."
fa4bf1df 1537 for opt in `echo "$bcond_avail" | grep ^_without_`
cd445739 1538 do
fa4bf1df
ER
1539 AVAIL_BCOND_WITHOUT=${opt#_without_}
1540 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
cd445739
AM
1541 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1542 else
1543 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1544 fi
1545 done
2a5f078d 1546
fa4bf1df 1547 for opt in `echo "$bcond_avail" | grep ^_with_`
cd445739 1548 do
fa4bf1df
ER
1549 AVAIL_BCOND_WITH=${opt#_with_}
1550 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
cd445739
AM
1551 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1552 else
1553 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1554 fi
1555 done
1556 ;;
1557 NEW)
fa4bf1df
ER
1558 local cond_type="" # with || without
1559 for opt in $bcond_avail; do
cd445739
AM
1560 case "$opt" in
1561 _without)
1562 cond_type="without"
1563 ;;
1564 _with)
1565 cond_type="with"
1566 ;;
f8d24cee 1567 _without_*)
fa4bf1df
ER
1568 AVAIL_BCOND_WITHOUT=${opt#_without_}
1569 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
f8d24cee 1570 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1571 else
1572 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1573 fi
1574 ;;
1575 _with_*)
fa4bf1df
ER
1576 AVAIL_BCOND_WITH=${opt#_with_}
1577 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
f8d24cee 1578 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1579 else
1580 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1581 fi
1582 ;;
cd445739
AM
1583 *)
1584 case "$cond_type" in
1585 with)
1586 cond_type=''
1587 AVAIL_BCOND_WITH="$opt"
fa4bf1df 1588 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
cd445739
AM
1589 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1590 else
1591 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1592 fi
7e365483 1593 ;;
cd445739
AM
1594 without)
1595 cond_type=''
1596 AVAIL_BCOND_WITHOUT="$opt"
fa4bf1df 1597 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
cd445739
AM
1598 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1599 else
1600 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1601 fi
1602 ;;
1603 esac
1604 ;;
1605 esac
1606 done
1607 ;;
1608 esac
1609}
1610
1611run_sub_builder()
1612{
1613 package_name="${1}"
af6b168f 1614 update_shell_title "run_sub_builder $package_name"
cd445739
AM
1615 #
1616