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