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