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