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