]>
Commit | Line | Data |
---|---|---|
cd445739 AM |
1 | #!/bin/sh |
2 | # ----------- | |
3 | # $Id$ | |
4 | # Exit codes: | |
2a5f078d | 5 | # 0 - succesful |
6 | # 1 - help displayed | |
7 | # 2 - no spec file name in cmdl parameters | |
8 | # 3 - spec file not stored in repo | |
9 | # 4 - some source, patch or icon files not stored in repo | |
10 | # 5 - package build failed | |
11 | # 6 - spec file with errors | |
12 | # 7 - wrong source in /etc/poldek.conf | |
13 | # 8 - Failed installing buildrequirements and subrequirements | |
14 | # 9 - Requested tag already exist | |
15 | # 10 - Refused to build fractional release | |
16 | # 100 - Unknown error (should not happen) | |
cd445739 AM |
17 | |
18 | # Notes (todo): | |
19 | # - builder -u fetches current version first | |
20 | # - tries to get new version from distfiles without new md5 | |
21 | # - after fetching new version doesn't update md5 | |
22 | # - doesn't get sources for specs with %include /usr/lib/rpm/macros.python | |
23 | # when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway) | |
24 | # - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov | |
25 | # - when Icon: field is present, -5 and -a5 doesn't work | |
931a4acf | 26 | |
4003ad8c | 27 | VERSION="\ |
28 | Build package utility from PLD CVS repository | |
ca2e6c31 | 29 | V 0.12 (C) 1999-2005 Free Penguins". |
d6a77ddb | 30 | PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" |
b03f053b | 31 | |
cd445739 | 32 | COMMAND="build" |
64ea5308 | 33 | TARGET="" |
cd445739 | 34 | |
bde1c404 | 35 | SPECFILE="" |
d287305c | 36 | BE_VERBOSE="" |
4003ad8c | 37 | QUIET="" |
cd445739 AM |
38 | CLEAN="" |
39 | DEBUG="" | |
40 | NOURLS="" | |
41 | NOCVS="" | |
42 | NOCVSSPEC="" | |
43 | NODIST="" | |
44 | UPDATE="" | |
45 | UPDATE5="" | |
46 | ADD5="" | |
47 | NO5="" | |
48 | ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"} | |
c8f50498 | 49 | CVSROOT="" |
cd445739 AM |
50 | |
51 | # It can be used i.e. in log file naming. | |
52 | # See LOGFILE example. | |
53 | DATE=`date +%Y-%m-%d_%H-%M-%S` | |
54 | ||
55 | # Example: LOGFILE='../log.$PACKAGE_NAME' | |
56 | # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE' | |
57 | # Yes, you can use variable name! Note _single_ quotes! | |
58 | LOGFILE='' | |
59 | ||
60 | LOGDIR="" | |
61 | LOGDIROK="" | |
62 | LOGDIRFAIL="" | |
63 | LASTLOG_FILE="" | |
64 | ||
65 | CHMOD="no" | |
66 | CHMOD_MODE="0444" | |
67 | RPMOPTS="" | |
68 | BCOND="" | |
69 | GROUP_BCONDS="no" | |
947025e5 | 70 | CVSIGNORE_DF="no" |
d287305c | 71 | |
72 | PATCHES="" | |
73 | SOURCES="" | |
cd445739 | 74 | ICONS="" |
d287305c | 75 | PACKAGE_RELEASE="" |
76 | PACKAGE_VERSION="" | |
77 | PACKAGE_NAME="" | |
cd445739 AM |
78 | PROTOCOL="ftp" |
79 | WGET_RETRIES=${MAX_WGET_RETRIES:-0} | |
80 | CVS_RETRIES=${MAX_CVS_RETRIES:-1000} | |
81 | ||
82 | CVSTAG="" | |
83 | RES_FILE="" | |
84 | ||
85 | CVS_SERVER="cvs.pld-linux.org" | |
86 | DISTFILES_SERVER="://distfiles.pld-linux.org" | |
d4730dae | 87 | ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org" |
cd445739 | 88 | |
36d03934 | 89 | DEF_NICE_LEVEL=19 |
cd445739 AM |
90 | |
91 | FAIL_IF_NO_SOURCES="yes" | |
92 | ||
cd445739 AM |
93 | # Here we load saved user environment used to |
94 | # predefine options set above, or passed to builder | |
95 | # in command line. | |
96 | # This one reads global system environment settings: | |
97 | if [ -f ~/etc/builderrc ]; then | |
98 | . ~/etc/builderrc | |
99 | fi | |
100 | # And this one cascades settings using user personal | |
101 | # builder settings. | |
102 | # Example of ~/.builderrc: | |
103 | # | |
104 | #UPDATE_POLDEK_INDEXES="yes" | |
105 | #FETCH_BUILD_REQUIRES="yes" | |
106 | #REMOVE_BUILD_REQUIRES="force" | |
107 | #GROUP_BCONDS="yes" | |
108 | #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE' | |
109 | # | |
110 | if [ -n "$HOME_ETC" ]; then | |
111 | USER_CFG="$HOME_ETC/.builderrc" | |
112 | else | |
113 | USER_CFG=~/.builderrc | |
114 | fi | |
115 | ||
116 | [ -f "$USER_CFG" ] && . "$USER_CFG" | |
117 | ||
ca2e6c31 AM |
118 | if [ -n "$USE_PROZILLA" ]; then |
119 | GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS" | |
120 | GETURI2="$GETURI" | |
121 | OUTFILEOPT="-O" | |
122 | elif [ -n "$USE_AXEL" ]; then | |
123 | GETURI="axel -n 4 -a $AXEL_OPTS" | |
124 | GETURI2="$GETURI" | |
125 | OUTFILEOPT="-o" | |
126 | else | |
2bc5451f AM |
127 | wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet" |
128 | wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused" | |
129 | ||
130 | GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS" | |
131 | GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS" | |
ca2e6c31 | 132 | OUTFILEOPT="-O" |
2bc5451f | 133 | fi |
11468b23 | 134 | |
11468b23 AM |
135 | GETLOCAL="cp -a" |
136 | ||
137 | if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then | |
138 | RPM="rpm" | |
139 | RPMBUILD="rpm" | |
140 | else | |
141 | RPM="rpm" | |
142 | RPMBUILD="rpmbuild" | |
143 | fi | |
144 | ||
145 | POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/" | |
11468b23 AM |
146 | POLDEK_CMD="/usr/bin/poldek --noask" |
147 | ||
cd445739 AM |
148 | run_poldek() |
149 | { | |
150 | RES_FILE=~/tmp/poldek-exit-status.$RANDOM | |
151 | if [ -n "$LOGFILE" ]; then | |
152 | LOG=`eval echo $LOGFILE` | |
153 | if [ -n "$LASTLOG_FILE" ]; then | |
154 | echo "LASTLOG=$LOG" > $LASTLOG_FILE | |
155 | fi | |
040282bb | 156 | (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG |
cd445739 AM |
157 | return $exit_pldk |
158 | else | |
159 | (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null | |
160 | return `cat ${RES_FILE}` | |
161 | rm -rf ${RES_FILE} | |
162 | fi | |
163 | } | |
164 | ||
cd445739 AM |
165 | #--------------------------------------------- |
166 | # functions | |
da946cd6 | 167 | |
5a491465 | 168 | usage() |
169 | { | |
cd445739 AM |
170 | if [ -n "$DEBUG" ]; then set -xv; fi |
171 | echo "\ | |
172 | Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] | |
81f85806 | 173 | |
cd445739 AM |
174 | [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade] |
175 | [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get] | |
176 | [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper] | |
177 | [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>] | |
178 | [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest] | |
179 | [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version] | |
180 | [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] | |
181 | [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] | |
182 | [--with/--without <feature>] [--define <macro> <value>] <package>[.spec] | |
2a5f078d | 183 | |
cd445739 AM |
184 | -5, --update-md5 - update md5 comments in spec, implies -nd -ncs |
185 | -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs | |
186 | -n5, --no-md5 - ignore md5 comments in spec | |
9243e80b ER |
187 | -D, --debug - enable builder script debugging mode, |
188 | -debug - produce rpm debug package (same as --opts -debug) | |
cd445739 AM |
189 | -V, --version - output builder version |
190 | -a, --as_anon - get files via pserver as cvs@$CVS_SERVER, | |
191 | -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package | |
192 | from <package>.spec, | |
193 | -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary | |
194 | only package from <package>.spec, | |
195 | -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack | |
196 | them into src.rpm, | |
197 | -bp, --build-prep - execute the %prep phase of <package>.spec, | |
198 | -B, --branch - add branch | |
199 | -c, --clean - clean all temporarily created files (in BUILD, SOURCES, | |
200 | SPECS and \$RPM_BUILD_ROOT), | |
2a5f078d | 201 | -d <cvsroot>, --cvsroot <cvsroot> |
cd445739 AM |
202 | - setup \$CVSROOT, |
203 | --define <macro> <value> | |
204 | - define a macro <macro> with value <value>, | |
205 | --nodeps - rpm won't check any dependences | |
206 | -g, --get - get <package>.spec and all related files from CVS repo | |
207 | or HTTP/FTP, | |
208 | -h, --help - this message, | |
209 | --http - use http instead of ftp, | |
210 | -l <logfile>, --logtofile <logfile> | |
211 | - log all to file, | |
212 | -m, --mr-proper - only remove all files related to spec file and all work | |
213 | resources, | |
214 | -nc, --no-cvs - don't download sources from CVS, if source URL is given, | |
215 | -ncs, --no-cvs-specs | |
216 | - don't check specs in CVS | |
217 | -nd, --no-distfiles - don't download from distfiles | |
218 | -nm, --no-mirrors - don't download from mirror, if source URL is given, | |
219 | -nu, --no-urls - don't try to download from FTP/HTTP location, | |
220 | -ns, --no-srcs - don't download Sources | |
221 | -ns0, --no-source0 - don't download Source0 | |
222 | -nn, --no-net - don't download anything from the net | |
223 | --opts <rpm opts> - additional options for rpm | |
224 | -q, --quiet - be quiet, | |
225 | --date yyyy-mm-dd - build package using resources from specified CVS date, | |
226 | -r <cvstag>, --cvstag <cvstag> | |
227 | - build package using resources from specified CVS tag, | |
228 | -R, --fetch-build-requires | |
229 | - fetch what is BuildRequired, | |
230 | -RB, --remove-build-requires | |
231 | - remove all you fetched with -R or --fetch-build-requires | |
232 | remember, this option requires confirmation, | |
233 | -FRB, --force-remove-build-requires | |
234 | - remove all you fetched with -R or --fetch-build-requires | |
235 | remember, this option works without confirmation, | |
a7eefc54 | 236 | -sf, --source-files - list sources - bare filenames (intended for offline |
237 | operations; does not work when Icon field is present | |
238 | but icon file is absent), | |
239 | -sp, --source-paths - list sources - filenames with full local paths (intended for | |
240 | offline operations; does not work when Icon field is present | |
241 | but icon file is absent), | |
cd445739 AM |
242 | -T <cvstag> , --tag <cvstag> |
243 | - add cvs tag <cvstag> for files, | |
244 | -Tvs, --tag-version-stable | |
094bd95b | 245 | - add cvs tags STABLE and NAME-VERSION-RELEASE for files, |
cd445739 | 246 | -Tvn, --tag-version-nest |
1691a37b | 247 | - add cvs tags NEST and NAME-VERSION-RELEASE for files, |
cd445739 AM |
248 | -Ts, --tag-stable |
249 | - add cvs tag STABLE for files, | |
250 | -Tn, --tag-nest | |
251 | - add cvs tag NEST for files, | |
252 | -Tv, --tag-version | |
1691a37b | 253 | - add cvs tag NAME-VERSION-RELEASE for files, |
cd445739 AM |
254 | -Tp, --tag-prefix <prefix> |
255 | - add <prefix> to NAME-VERSION-RELEASE tags, | |
256 | -tt, --test-tag <prefix> | |
257 | - fail if tag is already present, | |
50321881 JK |
258 | -ir, --integer-release-only |
259 | - allow only integer and snapshot releases | |
cd445739 AM |
260 | -v, --verbose - be verbose, |
261 | -u, --try-upgrade - check version, and try to upgrade package | |
262 | -un, --try-upgrade-with-float-version | |
263 | - as above, but allow float version | |
deccc50e | 264 | -U, --update - refetch sources, don't use distfiles, and update md5 comments |
cd445739 AM |
265 | -Upi, --update-poldek-indexes |
266 | - refresh or make poldek package index files. | |
267 | --with/--without <feature> | |
268 | - conditional build package depending on %_with_<feature>/ | |
269 | %_without_<feature> macro switch. You may now use | |
270 | --with feat1 feat2 feat3 --without feat4 feat5 --with feat6 | |
271 | constructions. Set GROUP_BCONDS to yes to make use of it. | |
6dd19291 | 272 | --target <platform>, --target=<platform> |
64ea5308 | 273 | - build for platform <platform>. |
5a491465 | 274 | " |
275 | } | |
276 | ||
cd445739 | 277 | cache_rpm_dump () { |
b2aeec7d AM |
278 | if [ -n "$DEBUG" ]; then |
279 | set -x; | |
280 | set -v; | |
281 | fi | |
cd445739 AM |
282 | rpm_dump_cache=` |
283 | case "$RPMBUILD" in | |
284 | rpm ) | |
2a5f078d | 285 | rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1 |
cd445739 AM |
286 | ;; |
287 | rpmbuild ) | |
288 | rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1 | |
289 | ;; | |
290 | esac` | |
291 | } | |
292 | ||
293 | rpm_dump () { | |
294 | if [ -z "$rpm_dump_cache" ] ; then | |
295 | echo "internal error: cache_rpm_dump not called!" 1>&2 | |
296 | fi | |
297 | echo "$rpm_dump_cache" | |
298 | } | |
299 | ||
59398507 | 300 | parse_spec() |
301 | { | |
cd445739 AM |
302 | if [ -n "$DEBUG" ]; then |
303 | set -x; | |
304 | set -v; | |
305 | fi | |
b2975fc3 | 306 | |
cd445739 | 307 | cd $SPECS_DIR |
4ca52257 | 308 | |
cd445739 | 309 | cache_rpm_dump |
00fcec7e | 310 | |
cd445739 AM |
311 | if [ "$NOSRCS" != "yes" ]; then |
312 | SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`" | |
313 | fi | |
314 | if (rpm_dump | grep -qEi ":.*nosource.*1"); then | |
315 | FAIL_IF_NO_SOURCES="no" | |
316 | fi | |
317 | ||
318 | PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`" | |
319 | ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`" | |
320 | PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`" | |
321 | PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`" | |
322 | PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`" | |
323 | ||
341603cf | 324 | # These variables may be unset after first cache_rpm_dump call |
325 | # (because of not-yet-retrieved icon file) | |
326 | # | |
327 | # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then | |
328 | # Exit_error err_no_package_data; | |
329 | # fi | |
78eab2a1 | 330 | |
cd445739 AM |
331 | if [ -n "$BE_VERBOSE" ]; then |
332 | echo "- Sources : `nourl $SOURCES`" | |
333 | if [ -n "$PATCHES" ]; then | |
334 | echo "- Patches : `nourl $PATCHES`" | |
335 | else | |
336 | echo "- Patches : *no patches needed*" | |
337 | fi | |
338 | if [ -n "$ICONS" ]; then | |
339 | echo "- Icon : `nourl $ICONS`" | |
340 | else | |
341 | echo "- Icon : *no package icon*" | |
342 | fi | |
343 | echo "- Name : $PACKAGE_NAME" | |
344 | echo "- Version : $PACKAGE_VERSION" | |
345 | echo "- Release : $PACKAGE_RELEASE" | |
346 | fi | |
347 | } | |
348 | ||
349 | Exit_error() | |
350 | { | |
351 | if [ -n "$DEBUG" ]; then | |
352 | set -x; | |
353 | set -v; | |
354 | fi | |
355 | ||
356 | cd "$__PWD" | |
357 | ||
358 | case "$1" in | |
359 | "err_no_spec_in_cmdl" ) | |
360 | remove_build_requires | |
361 | echo "ERROR: spec file name not specified."; | |
362 | exit 2 ;; | |
363 | "err_no_spec_in_repo" ) | |
364 | remove_build_requires | |
365 | echo "Error: spec file not stored in CVS repo."; | |
366 | exit 3 ;; | |
367 | "err_no_source_in_repo" ) | |
368 | remove_build_requires | |
369 | echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"; | |
370 | exit 4 ;; | |
371 | "err_build_fail" ) | |
372 | remove_build_requires | |
373 | echo "Error: package build failed. (${2:-no more info})"; | |
374 | exit 5 ;; | |
78eab2a1 AM |
375 | "err_no_package_data" ) |
376 | remove_build_requires | |
377 | echo "Error: couldn't get out package name/version/release from spec file." | |
378 | exit 6 ;; | |
50321881 JK |
379 | "err_tag_exists" ) |
380 | remove_build_requires | |
381 | echo "Tag ${2} already exists (spec release: ${3})."; | |
382 | exit 9 ;; | |
383 | "err_fract_rel" ) | |
384 | remove_build_requires | |
385 | echo "Release ${2} not integer and not a snapshot."; | |
386 | exit 10 ;; | |
387 | ||
cd445739 | 388 | esac |
50321881 | 389 | echo "Unknown error." |
2a5f078d | 390 | exit 100 |
cd445739 AM |
391 | } |
392 | ||
393 | init_builder() | |
394 | { | |
395 | if [ -n "$DEBUG" ]; then | |
396 | set -x; | |
397 | set -v; | |
0dd6320d | 398 | fi |
cd445739 AM |
399 | |
400 | SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`" | |
401 | SPECS_DIR="`$RPM --eval '%{_specdir}'`" | |
402 | ||
403 | __PWD="`pwd`" | |
00fcec7e | 404 | } |
405 | ||
d6a77ddb | 406 | get_spec() |
1471f6d6 | 407 | { |
cd445739 AM |
408 | if [ -n "$DEBUG" ]; then |
409 | set -x; | |
410 | set -v; | |
411 | fi | |
412 | ||
413 | cd "$SPECS_DIR" | |
414 | if [ \! -f "$SPECFILE" ]; then | |
415 | SPECFILE="`basename $SPECFILE .spec`.spec"; | |
416 | fi | |
417 | if [ "$NOCVSSPEC" != "yes" ]; then | |
418 | OPTIONS="up " | |
419 | ||
420 | if [ -n "$CVSROOT" ]; then | |
421 | OPTIONS="-d $CVSROOT $OPTIONS" | |
422 | else | |
423 | if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then | |
424 | echo "warning: No cvs access defined - using local .spec file" | |
425 | NOCVSSPEC="yes" | |
426 | fi | |
427 | fi | |
428 | ||
429 | if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then | |
430 | OPTIONS="$OPTIONS -A" | |
431 | else | |
432 | if [ -n "$CVSDATE" ]; then | |
433 | OPTIONS="$OPTIONS -D $CVSDATE" | |
434 | fi | |
435 | if [ -n "$CVSTAG" ]; then | |
436 | OPTIONS="$OPTIONS -r $CVSTAG" | |
437 | fi | |
438 | fi | |
439 | ||
440 | result=1 | |
441 | retries_counter=0 | |
442 | while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ] | |
443 | do | |
444 | retries_counter=$(( $retries_counter + 1 )) | |
445 | output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1) | |
446 | result=$? | |
447 | [ -n "$output" ] && echo "$output" | |
448 | if [ "$result" -ne "0" ]; then | |
449 | if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$retries_counter" -le "$CVS_RETRIES" ]; then | |
450 | echo "Trying again [$SPECFILE]... ($retries_counter)" | |
451 | sleep 2 | |
452 | continue | |
453 | fi | |
454 | Exit_error err_no_spec_in_repo; | |
455 | fi | |
456 | done | |
457 | fi | |
458 | if [ ! -f "$SPECFILE" ]; then | |
459 | Exit_error err_no_spec_in_repo; | |
460 | fi | |
461 | ||
462 | if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then | |
463 | chmod $CHMOD_MODE $SPECFILE | |
464 | fi | |
465 | unset OPTIONS | |
a7eefc54 | 466 | [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE |
cd445739 AM |
467 | } |
468 | ||
469 | find_mirror() | |
470 | { | |
471 | cd "$SPECS_DIR" | |
472 | url="$1" | |
473 | if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then | |
474 | cvs update mirrors >&2 | |
475 | fi | |
476 | ||
477 | IFS="|" | |
478 | while read origin mirror name rest | |
479 | do | |
480 | ol=`echo -n "$origin"|wc -c` | |
481 | prefix="`echo -n "$url" | head -c $ol`" | |
482 | if [ "$prefix" = "$origin" ] ; then | |
483 | suffix="`echo "$url"|cut -b $ol-`" | |
484 | echo -n "$mirror$suffix" | |
485 | return 0 | |
486 | fi | |
487 | done < mirrors | |
488 | echo "$url" | |
489 | } | |
490 | ||
491 | src_no () | |
492 | { | |
493 | cd $SPECS_DIR | |
494 | rpm_dump | \ | |
495 | grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \ | |
496 | sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \ | |
497 | head -n 1 | xargs | |
1471f6d6 | 498 | } |
499 | ||
cd445739 | 500 | src_md5 () |
8ba5cdda | 501 | { |
cd445739 AM |
502 | [ X"$NO5" = X"yes" ] && return |
503 | no=$(src_no "$1") | |
504 | [ -z "$no" ] && return | |
505 | cd $SPECS_DIR | |
506 | spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::) | |
507 | if [ -z "$spec_rev" ]; then | |
508 | spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')" | |
509 | fi | |
510 | spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')" | |
511 | md5=$(grep -s -v '^#' additional-md5sums | \ | |
512 | grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \ | |
513 | sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \ | |
514 | grep -E '^[0-9a-f]{32}$') | |
515 | if [ X"$md5" = X"" ] ; then | |
6203ea52 AG |
516 | source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'` |
517 | if [ ! -z "$source_md5" ] ; then | |
6203ea52 AG |
518 | echo $source_md5; |
519 | else | |
520 | # we have empty SourceX-md5, but it is still possible | |
521 | # that we have NoSourceX-md5 AND NoSource: X | |
522 | nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'` | |
6203ea52 AG |
523 | if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then |
524 | echo $nosource_md5; | |
525 | fi; | |
526 | fi; | |
cd445739 AM |
527 | else |
528 | if [ $(echo "$md5" | wc -l) != 1 ] ; then | |
529 | echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2 | |
530 | fi | |
531 | echo "$md5" | tail -n 1 | |
532 | fi | |
533 | } | |
534 | ||
535 | distfiles_url () | |
536 | { | |
1246dc2a | 537 | echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")" |
cd445739 AM |
538 | } |
539 | ||
540 | distfiles_attic_url () | |
541 | { | |
1246dc2a | 542 | echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")" |
cd445739 AM |
543 | } |
544 | ||
545 | good_md5 () | |
546 | { | |
547 | md5=$(src_md5 "$1") | |
548 | [ "$md5" = "" ] || \ | |
549 | [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ] | |
8ba5cdda PG |
550 | } |
551 | ||
a4b50627 AF |
552 | good_size () |
553 | { | |
deccc50e AM |
554 | size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)" |
555 | [ -n "$size" -a "$size" -gt 0 ] | |
a4b50627 AF |
556 | } |
557 | ||
947025e5 | 558 | cvsignore_df () |
559 | { | |
560 | if [ "$CVSIGNORE_DF" != "yes" ]; then | |
561 | return | |
562 | fi | |
563 | cvsignore=${SOURCE_DIR}/.cvsignore | |
564 | if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then | |
565 | echo "$1" >> $cvsignore | |
566 | fi | |
567 | } | |
568 | ||
cd445739 AM |
569 | get_files() |
570 | { | |
571 | GET_FILES="$@" | |
572 | ||
573 | if [ -n "$DEBUG" ]; then | |
574 | set -x; | |
575 | set -v; | |
576 | fi | |
577 | ||
578 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then | |
579 | cd "$SOURCE_DIR" | |
580 | ||
581 | OPTIONS="up " | |
582 | if [ -n "$CVSROOT" ]; then | |
583 | OPTIONS="-d $CVSROOT $OPTIONS" | |
584 | else | |
585 | if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then | |
586 | echo "warning: No cvs access defined for SOURCES" | |
587 | NOCVS="yes" | |
588 | fi | |
589 | fi | |
590 | if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then | |
591 | OPTIONS="$OPTIONS -A" | |
592 | else | |
593 | if [ -n "$CVSDATE" ]; then | |
594 | OPTIONS="$OPTIONS -D $CVSDATE" | |
595 | fi | |
596 | if [ -n "$CVSTAG" ]; then | |
597 | OPTIONS="$OPTIONS -r $CVSTAG" | |
598 | fi | |
599 | fi | |
600 | for i in $GET_FILES | |
601 | do | |
602 | if [ -n "$UPDATE5" ]; then | |
603 | if [ -n "$ADD5" ]; then | |
604 | [ `nourl $i` = "$i" ] && continue | |
605 | grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue | |
606 | else | |
607 | grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue | |
608 | fi | |
609 | fi | |
610 | FROM_DISTFILES=0 | |
611 | if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then | |
612 | if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then | |
613 | echo "Warning: no URL given for $i" | |
614 | fi | |
615 | ||
616 | if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then | |
a4b50627 | 617 | if good_md5 "$i" && good_size "$i"; then |
deccc50e | 618 | echo "$(nourl "$i") having proper md5sum already exists" |
cd445739 AM |
619 | continue |
620 | fi | |
621 | target=$(nourl "$i") | |
622 | url=$(distfiles_url "$i") | |
623 | url_attic=$(distfiles_attic_url "$i") | |
624 | FROM_DISTFILES=1 | |
625 | if [ `echo $url | grep -E '^(\.|/)'` ]; then | |
626 | ${GETLOCAL} $url $target | |
627 | else | |
628 | if [ -z "$NOMIRRORS" ]; then | |
629 | url="`find_mirror "$url"`" | |
630 | fi | |
ca2e6c31 | 631 | ${GETURI} ${OUTFILEOPT} "$target" "$url" || \ |
cd445739 | 632 | if [ `echo $url | grep -E 'ftp://'` ]; then |
ca2e6c31 | 633 | ${GETURI2} ${OUTFILEOPT} "$target" "$url" |
cd445739 AM |
634 | fi |
635 | fi | |
636 | if ! test -s "$target"; then | |
637 | rm -f "$target" | |
638 | if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then | |
639 | ${GETLOCAL} $url_attic $target | |
640 | else | |
641 | if [ -z "$NOMIRRORS" ]; then | |
642 | url_attic="`find_mirror "$url_attic"`" | |
643 | fi | |
ca2e6c31 | 644 | ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \ |
cd445739 | 645 | if [ `echo $url_attic | grep -E 'ftp://'` ]; then |
ca2e6c31 | 646 | ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic" |
cd445739 AM |
647 | fi |
648 | fi | |
649 | fi | |
947025e5 | 650 | if test -s "$target"; then |
651 | cvsignore_df $target | |
652 | else | |
cd445739 AM |
653 | rm -f "$target" |
654 | FROM_DISTFILES=0 | |
655 | fi | |
656 | elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then | |
657 | # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred | |
658 | result=1 | |
659 | retries_counter=0 | |
660 | while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ] | |
661 | do | |
662 | retries_counter=$(( $retries_counter + 1 )) | |
663 | output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1) | |
664 | result=$? | |
665 | [ -n "$output" ] && echo "$output" | |
666 | 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 | |
667 | echo "Trying again [`nourl $i`]... ($retries_counter)" | |
668 | sleep 2 | |
669 | continue | |
670 | else | |
671 | break | |
672 | fi | |
673 | done | |
674 | fi | |
675 | ||
676 | if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then | |
677 | if [ -z "$NOMIRRORS" ]; then | |
678 | im="`find_mirror "$i"`" | |
679 | else | |
680 | im="$i" | |
681 | fi | |
682 | ${GETURI} "$im" || \ | |
683 | if [ `echo $im | grep -E 'ftp://'` ]; then | |
684 | ${GETURI2} "$im" | |
685 | fi | |
686 | fi | |
687 | ||
688 | fi | |
689 | srcno=$(src_no $i) | |
690 | if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then | |
691 | Exit_error err_no_source_in_repo $i; | |
692 | elif [ -n "$UPDATE5" ] && \ | |
693 | ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \ | |
694 | [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \ | |
695 | grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE ) | |
696 | then | |
deccc50e | 697 | echo "Updating source-$srcno md5." |
cd445739 AM |
698 | md5=$(md5sum `nourl $i` | cut -f1 -d' ') |
699 | perl -i -ne ' | |
deccc50e AM |
700 | print unless /^\s*#\s*Source'$srcno'-md5\s*:/i; |
701 | print "# Source'$srcno'-md5:\t'$md5'\n" | |
cd445739 AM |
702 | if /^Source'$srcno'\s*:\s+/; |
703 | ' \ | |
704 | $SPECS_DIR/$SPECFILE | |
705 | fi | |
2a5f078d | 706 | |
a4b50627 | 707 | if good_md5 "$i" && good_size "$i"; then |
cd445739 AM |
708 | : |
709 | elif [ "$FROM_DISTFILES" = 1 ]; then | |
deccc50e | 710 | # wrong md5 from distfiles: remove the file and try again |
cd445739 | 711 | # but only once ... |
deccc50e | 712 | echo "MD5 sum mismatch. Trying full fetch." |
cd445739 AM |
713 | FROM_DISTFILES=2 |
714 | rm -f $target | |
ca2e6c31 | 715 | ${GETURI} ${OUTFILEOPT} "$target" "$url" || \ |
cd445739 | 716 | if [ `echo $url | grep -E 'ftp://'` ]; then |
ca2e6c31 | 717 | ${GETURI2} ${OUTFILEOPT} "$target" "$url" |
cd445739 AM |
718 | fi |
719 | if ! test -s "$target"; then | |
720 | rm -f "$target" | |
ca2e6c31 | 721 | ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \ |
cd445739 | 722 | if [ `echo $url_attic | grep -E 'ftp://'` ]; then |
ca2e6c31 | 723 | ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic" |
cd445739 AM |
724 | fi |
725 | fi | |
726 | test -s "$target" || rm -f "$target" | |
727 | fi | |
728 | ||
a4b50627 | 729 | if good_md5 "$i" && good_size "$i" ; then |
cd445739 AM |
730 | : |
731 | else | |
deccc50e AM |
732 | echo "MD5 sum mismatch or 0 size. Use -U to refetch sources," |
733 | echo "or -5 to update md5 sums, if you're sure files are correct." | |
cd445739 AM |
734 | Exit_error err_no_source_in_repo $i |
735 | fi | |
736 | done | |
737 | ||
738 | if [ "$CHMOD" = "yes" ]; then | |
739 | CHMOD_FILES="`nourl $GET_FILES`" | |
740 | if [ -n "$CHMOD_FILES" ]; then | |
741 | chmod $CHMOD_MODE $CHMOD_FILES | |
742 | fi | |
743 | fi | |
744 | unset OPTIONS | |
745 | fi | |
746 | } | |
747 | ||
748 | make_tagver() { | |
78eab2a1 AM |
749 | |
750 | if [ -n "$DEBUG" ]; then | |
751 | set -x; | |
752 | set -v; | |
753 | fi | |
2a5f078d | 754 | |
cd445739 AM |
755 | # Check whether first character of PACKAGE_NAME is legal for tag name |
756 | if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then | |
757 | TAG_PREFIX=tag_ | |
758 | fi | |
759 | TAGVER=$TAG_PREFIX$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"` | |
760 | # Remove #kernel.version_release from TAGVER because tagging sources | |
761 | # could occur with different kernel-headers than kernel-headers used at build time. | |
762 | TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g') | |
763 | echo -n "$TAGVER" | |
764 | } | |
765 | ||
766 | tag_files() | |
767 | { | |
768 | TAG_FILES="$@" | |
769 | ||
770 | if [ -n "$DEBUG" ]; then | |
771 | set -x; | |
772 | set -v; | |
773 | fi | |
774 | ||
775 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then | |
776 | echo "Version: $PACKAGE_VERSION" | |
777 | echo "Release: $PACKAGE_RELEASE" | |
778 | ||
779 | TAGVER=`make_tagver` | |
780 | ||
781 | if [ "$TAG_VERSION" = "yes" ]; then | |
782 | echo "CVS tag: $TAGVER" | |
783 | fi | |
784 | if [ -n "$TAG" ]; then | |
785 | echo "CVS tag: $TAG" | |
786 | fi | |
787 | ||
788 | OPTIONS="tag -F" | |
789 | if [ -n "$CVSROOT" ]; then | |
790 | OPTIONS="-d $CVSROOT $OPTIONS" | |
791 | fi | |
792 | ||
793 | cd "$SOURCE_DIR" | |
794 | for i in $TAG_FILES | |
795 | do | |
796 | # don't tag files stored on distfiles | |
797 | [ -n "`src_md5 $i`" ] && continue | |
798 | if [ -f "`nourl $i`" ]; then | |
799 | if [ "$TAG_VERSION" = "yes" ]; then | |
800 | cvs $OPTIONS $TAGVER `nourl $i` | |
801 | fi | |
802 | if [ -n "$TAG" ]; then | |
803 | cvs $OPTIONS $TAG `nourl $i` | |
804 | fi | |
805 | else | |
806 | Exit_error err_no_source_in_repo $i | |
807 | fi | |
808 | done | |
809 | ||
810 | cd "$SPECS_DIR" | |
811 | if [ "$TAG_VERSION" = "yes" ]; then | |
812 | cvs $OPTIONS $TAGVER $SPECFILE | |
813 | fi | |
814 | if [ -n "$TAG" ]; then | |
815 | cvs $OPTIONS $TAG $SPECFILE | |
816 | fi | |
817 | ||
818 | unset OPTIONS | |
819 | fi | |
820 | } | |
821 | ||
822 | branch_files() | |
823 | { | |
824 | TAG=$1 | |
825 | echo "CVS branch tag: $TAG" | |
826 | shift; | |
827 | ||
828 | TAG_FILES="$@" | |
829 | ||
830 | if [ -n "$DEBUG" ]; then | |
831 | set -x; | |
832 | set -v; | |
833 | fi | |
834 | ||
835 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then | |
836 | ||
837 | OPTIONS="tag -b" | |
838 | if [ -n "$CVSROOT" ]; then | |
839 | OPTIONS="-d $CVSROOT $OPTIONS" | |
840 | fi | |
841 | cd "$SOURCE_DIR" | |
842 | for i in $TAG_FILES | |
843 | do | |
844 | if [ -f `nourl $i` ]; then | |
845 | cvs $OPTIONS $TAG `nourl $i` | |
846 | else | |
847 | Exit_error err_no_source_in_repo $i | |
848 | fi | |
849 | done | |
850 | cd "$SPECS_DIR" | |
851 | cvs $OPTIONS $TAG $SPECFILE | |
852 | ||
853 | unset OPTIONS | |
854 | fi | |
855 | } | |
856 | ||
857 | ||
858 | ||
59398507 | 859 | build_package() |
860 | { | |
cd445739 AM |
861 | if [ -n "$DEBUG" ]; then |
862 | set -x; | |
863 | set -v; | |
864 | fi | |
5a491465 | 865 | |
cd445739 AM |
866 | cd "$SPECS_DIR" |
867 | ||
868 | if [ -n "$TRY_UPGRADE" ]; then | |
869 | if [ -n "$FLOAT_VERSION" ]; then | |
870 | TNOTIFY=`./pldnotify.awk $SPECFILE -n` | |
871 | else | |
872 | TNOTIFY=`./pldnotify.awk $SPECFILE` | |
873 | fi | |
874 | ||
875 | TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'` | |
876 | ||
877 | if [ -n "$TNEWVER" ]; then | |
878 | TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'` | |
879 | echo "New version found, updating spec file to version " $TNEWVER | |
880 | cp -f $SPECFILE $SPECFILE.bak | |
881 | chmod +w $SPECFILE | |
882 | eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE" | |
883 | eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE" | |
884 | parse_spec; | |
7f347798 | 885 | if [ -n "$ICONS" ]; then |
886 | get_files $ICONS; | |
887 | parse_spec; | |
888 | fi | |
cd445739 AM |
889 | get_files "$SOURCES $PATCHES"; |
890 | unset TOLDVER TNEWVER TNOTIFY | |
891 | fi | |
892 | fi | |
893 | cd "$SPECS_DIR" | |
2a5f078d | 894 | |
cd445739 AM |
895 | case "$COMMAND" in |
896 | build ) | |
897 | BUILD_SWITCH="-ba" ;; | |
898 | build-binary ) | |
899 | BUILD_SWITCH="-bb" ;; | |
900 | build-source ) | |
901 | BUILD_SWITCH="-bs --nodeps" ;; | |
902 | build-prep ) | |
903 | BUILD_SWITCH="-bp --nodeps" ;; | |
904 | esac | |
905 | if [ -n "$LOGFILE" ]; then | |
906 | LOG=`eval echo $LOGFILE` | |
907 | if [ -d "$LOG" ]; then | |
908 | echo "Log file $LOG is a directory." | |
909 | echo "Parse error in the spec?" | |
910 | Exit_error err_build_fail; | |
911 | fi | |
912 | if [ -n "$LASTLOG_FILE" ]; then | |
913 | echo "LASTLOG=$LOG" > $LASTLOG_FILE | |
914 | fi | |
915 | RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM | |
8f96ab6c | 916 | (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG |
cd445739 AM |
917 | RETVAL=`cat $RES_FILE` |
918 | rm $RES_FILE | |
919 | if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then | |
920 | if [ "$RETVAL" -eq "0" ]; then | |
921 | mv $LOG $LOGDIROK | |
922 | else | |
923 | mv $LOG $LOGDIRFAIL | |
924 | fi | |
925 | fi | |
8ba5cdda | 926 | else |
8f96ab6c | 927 | eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE |
cd445739 | 928 | RETVAL=$? |
8ba5cdda | 929 | fi |
cd445739 AM |
930 | if [ "$RETVAL" -ne "0" ]; then |
931 | if [ -n "$TRY_UPGRADE" ]; then | |
932 | echo "\n!!! Package with new version cannot be build automagically\n" | |
933 | mv -f $SPECFILE.bak $SPECFILE | |
934 | fi | |
935 | Exit_error err_build_fail; | |
936 | fi | |
937 | unset BUILD_SWITCH | |
938 | } | |
939 | ||
940 | nourl() | |
941 | { | |
942 | echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g' | |
943 | } | |
944 | ||
cd445739 AM |
945 | install_required_packages() |
946 | { | |
947 | run_poldek -vi $1 | |
948 | return $? | |
949 | } | |
950 | ||
951 | set_bconds_values() | |
952 | { | |
953 | AVAIL_BCONDS_WITHOUT="" | |
954 | AVAIL_BCONDS_WITH="" | |
955 | if `grep -q ^%bcond ${SPECFILE}`; then | |
956 | BCOND_VERSION="NEW" | |
36d03934 | 957 | elif `egrep -q ^#\ *_with ${SPECFILE}`; then |
cd445739 AM |
958 | BCOND_VERSION="OLD" |
959 | else | |
960 | BCOND_VERSION="NONE" | |
961 | fi | |
301cbfd4 ER |
962 | |
963 | # expand bconds from ~/.bcondrc | |
964 | # The file structure is like gentoo's package.use: | |
965 | # --- | |
966 | # * -selinux | |
967 | # samba -mysql -pgsql | |
968 | # w32codec license_agreement | |
969 | # php +mysqli | |
970 | # --- | |
c8a3e2ac | 971 | if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then |
301cbfd4 ER |
972 | # This takes package name, first defined in spec. |
973 | # so consider that when defining flags for package. | |
974 | PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1` | |
975 | AVAIL=`$RPMBUILD --bcond $SPECFILE` | |
976 | ||
c8a3e2ac AG |
977 | BCONDRC=$HOME/.bcondrc |
978 | [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc | |
979 | ||
301cbfd4 ER |
980 | while read pkg flags; do |
981 | # ignore comments | |
982 | [[ "$pkg" == \#* ]] && continue | |
983 | ||
984 | # any package or current package? | |
985 | if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ]; then | |
986 | for flag in $flags; do | |
987 | opt=${flag#[+-]} | |
988 | ||
989 | # use only flags which are in this package. | |
990 | if [[ $AVAIL = *${opt}* ]]; then | |
3b5101f0 ER |
991 | if [[ $flag = -* ]]; then |
992 | BCOND="$BCOND --without $opt" | |
301cbfd4 | 993 | else |
3b5101f0 | 994 | BCOND="$BCOND --with $opt" |
301cbfd4 ER |
995 | fi |
996 | fi | |
997 | done | |
998 | fi | |
c8a3e2ac | 999 | done < $BCONDRC |
301cbfd4 ER |
1000 | fi |
1001 | ||
cd445739 AM |
1002 | case "${BCOND_VERSION}" in |
1003 | NONE) | |
1004 | : | |
1005 | ;; | |
1006 | OLD) | |
1007 | echo "Warning: This spec has old style bconds. Fix it || die." | |
1008 | for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_` | |
1009 | do | |
1010 | AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"` | |
1011 | if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then | |
1012 | AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>" | |
1013 | else | |
1014 | AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT" | |
1015 | fi | |
1016 | done | |
2a5f078d | 1017 | |
cd445739 AM |
1018 | for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_` |
1019 | do | |
1020 | AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"` | |
1021 | if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then | |
1022 | AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>" | |
1023 | else | |
1024 | AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH" | |
1025 | fi | |
1026 | done | |
1027 | ;; | |
1028 | NEW) | |
1029 | cond_type="" # with || without | |
1030 | for opt in `$RPMBUILD --bcond $SPECFILE` | |
1031 | do | |
1032 | case "$opt" in | |
1033 | _without) | |
1034 | cond_type="without" | |
1035 | ;; | |
1036 | _with) | |
1037 | cond_type="with" | |
1038 | ;; | |
1039 | *) | |
1040 | case "$cond_type" in | |
1041 | with) | |
1042 | cond_type='' | |
1043 | AVAIL_BCOND_WITH="$opt" | |
1044 | if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then | |
1045 | AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>" | |
1046 | else | |
1047 | AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH" | |
1048 | fi | |
1049 | ;; | |
1050 | without) | |
1051 | cond_type='' | |
1052 | AVAIL_BCOND_WITHOUT="$opt" | |
1053 | if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then | |
1054 | AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>" | |
1055 | else | |
1056 | AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT" | |
1057 | fi | |
1058 | ;; | |
1059 | esac | |
1060 | ;; | |
1061 | esac | |
1062 | done | |
1063 | ;; | |
1064 | esac | |
1065 | } | |
1066 | ||
1067 | run_sub_builder() | |
1068 | { | |
1069 | package_name="${1}" | |
1070 | echo -ne "Package installation failed:\t$package_name\n" | |
1071 | # | |
1072 |