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