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