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