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