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