]>
Commit | Line | Data |
---|---|---|
b054f772 | 1 | #!/bin/sh |
33f5276d | 2 | # ----------- |
25fa34fe | 3 | # $Id$ |
33f5276d | 4 | # Exit codes: |
5 | # 0 - succesful | |
10b4dd7f | 6 | # 1 - help displayed |
33f5276d | 7 | # 2 - no spec file name in cmdl parameters |
8 | # 3 - spec file not stored in repo | |
0ad50ce9 | 9 | # 4 - some source, patch or icon files not stored in repo |
10 | # 5 - package build failed | |
10b4dd7f | 11 | # 6 - spec file with errors |
da0048be | 12 | # 7 - wrong source in /etc/poldek.conf |
5a491465 | 13 | |
931a4acf TP |
14 | # Notes (todo): |
15 | # - builder -u fetches current version first | |
16 | # - tries to get new version from distfiles without new md5 | |
17 | # - after fetching new version doesn't update md5 | |
2837871a | 18 | # - doesn't get sources for specs with %include /usr/lib/rpm/macros.python |
9308ddd0 | 19 | # when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway) |
2837871a | 20 | # - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov |
82d4501c | 21 | # - when Icon: field is present, -5 and -a5 doesn't work |
931a4acf | 22 | |
4003ad8c | 23 | VERSION="\ |
24 | Build package utility from PLD CVS repository | |
6cb7df6d | 25 | V 0.11 (C) 1999-2003 Free Penguins". |
5a491465 | 26 | PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" |
a7af9862 | 27 | |
b03f053b | 28 | COMMAND="build" |
29 | ||
bde1c404 | 30 | SPECFILE="" |
d287305c | 31 | BE_VERBOSE="" |
4003ad8c | 32 | QUIET="" |
5dd89621 | 33 | CLEAN="" |
7c2dd1b2 | 34 | DEBUG="" |
cc97f1f3 | 35 | NOURLS="" |
157dc315 | 36 | NOCVS="" |
6fc910c7 | 37 | NOCVSSPEC="" |
fc0e5bb5 | 38 | NODIST="" |
b130abf2 | 39 | UPDATE="" |
a9d9a79a | 40 | UPDATE5="" |
de6b5b2a | 41 | ADD5="" |
81474543 | 42 | ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"} |
c8f50498 | 43 | CVSROOT="" |
d6a75d60 | 44 | # Example: LOGFILE='../log.$PACKAGE_NAME' |
45 | # Yes, you can use variable name! Note _single_ quotes! | |
46 | LOGFILE='' | |
00fcec7e | 47 | |
48 | LOGDIR="" | |
49 | LOGDIROK="" | |
50 | LOGDIRFAIL="" | |
51 | LASTLOG_FILE="" | |
79d76918 | 52 | CHMOD="no" |
d6a75d60 | 53 | CHMOD_MODE="0444" |
33a9d2d1 | 54 | RPMOPTS="" |
6049c3d1 | 55 | BCOND="" |
a6253cb6 | 56 | GROUP_BCONDS="no" |
d287305c | 57 | |
58 | PATCHES="" | |
59 | SOURCES="" | |
7053d3fd | 60 | ICONS="" |
d287305c | 61 | PACKAGE_RELEASE="" |
62 | PACKAGE_VERSION="" | |
63 | PACKAGE_NAME="" | |
d7f490f3 | 64 | PROTOCOL="ftp" |
34c911e6 | 65 | WGET_RETRIES=${MAX_WGET_RETRIES:-0} |
b92ecfc9 | 66 | CVS_RETRIES=${MAX_CVS_RETRIES:-1000} |
5a491465 | 67 | |
00fcec7e | 68 | CVSTAG="" |
69 | RES_FILE="" | |
70 | ||
62546902 | 71 | CVS_SERVER="cvs.pld-linux.org" |
d7f490f3 | 72 | DISTFILES_SERVER="://distfiles.pld-linux.org" |
ea15df77 | 73 | |
3ae81a20 | 74 | DEF_NICE_LEVEL=0 |
75 | ||
c6a390a1 AM |
76 | FAIL_IF_NO_SOURCES="yes" |
77 | ||
d8140aad AM |
78 | wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet" |
79 | wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused" | |
80 | ||
81 | GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS" | |
82 | GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS" | |
6aefe77b | 83 | GETLOCAL="cp -a" |
11f33a0c | 84 | |
7147050f AM |
85 | if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then |
86 | RPM="rpm" | |
87 | RPMBUILD="rpm" | |
88 | else | |
89 | RPM="rpm" | |
90 | RPMBUILD="rpmbuild" | |
91 | fi | |
92 | ||
c8740da7 | 93 | POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/" |
da0048be | 94 | POLDEK_SOURCE="cvs" |
95 | ||
6eb44b93 | 96 | if [ -f ~/etc/builderrc ]; then |
7922b3ec | 97 | . ~/etc/builderrc |
5aa0ef93 AF |
98 | fi |
99 | ||
541008f6 | 100 | if [ -n "$HOME_ETC" ]; then |
101 | USER_CFG=$HOME_ETC/.builderrc | |
102 | else | |
103 | USER_CFG=~/.builderrc | |
104 | fi | |
105 | ||
106 | [ -f $USER_CFG ] && . $USER_CFG | |
107 | ||
a9914892 | 108 | # Example grep cvs /etc/poldek.conf: |
109 | # source = cvs /home/users/yoshi/rpm/RPMS/ | |
110 | if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then | |
111 | POLDEK_SOURCE_VALIDITY="`grep ${POLDEK_SOURCE} /etc/poldek.conf|grep -v ^#`" | |
112 | if [ "${POLDEK_SOURCE_VALIDITY}" = "" ]; then | |
113 | echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf" | |
114 | echo "Fix it and try to continue" | |
115 | exit 7 | |
116 | fi | |
117 | fi | |
118 | ||
da946cd6 | 119 | #--------------------------------------------- |
120 | # functions | |
121 | ||
5a491465 | 122 | usage() |
123 | { | |
7c2dd1b2 | 124 | if [ -n "$DEBUG" ]; then set -xv; fi |
125 | echo "\ | |
7922b3ec | 126 | Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] |
81f85806 | 127 | |
128 | [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade] | |
129 | [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get] | |
d7f490f3 | 130 | [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper] |
00fcec7e | 131 | [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>] |
a2164135 | 132 | [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest] |
d71ea755 MM |
133 | [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version] |
134 | [{-Tp|--tag-prefix} <prefix>] | |
81f85806 | 135 | [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] |
c9ff8825 | 136 | [--with/--without <feature>] [--define <macro> <value>] <package>[.spec] |
5a491465 | 137 | |
de6b5b2a | 138 | -5, --update-md5 |
afade7dd JB |
139 | - update md5 comments in spec, implies -nd -ncs |
140 | -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs | |
a2a9c8df | 141 | -D, --debug - enable script debugging mode, |
5a491465 | 142 | -V, --version - output builder version |
62546902 | 143 | -a, --as_anon - get files via pserver as cvs@$CVS_SERVER, |
79b2ec0e | 144 | -b, -ba, |
cc97f1f3 | 145 | --build - get all files from CVS repo or HTTP/FTP and build |
5a491465 | 146 | package from <package>.spec, |
7922b3ec | 147 | -bb, --build-binary |
148 | - get all files from CVS repo or HTTP/FTP and build | |
79b2ec0e | 149 | binary only package from <package>.spec, |
150 | -bs, | |
cc97f1f3 SZ |
151 | --build-source - get all files from CVS repo or HTTP/FTP and only |
152 | pack them into src.rpm, | |
4fe34d83 | 153 | -bp, --build-prep |
154 | - execute the %prep phase of <package>.spec, | |
8ba5cdda | 155 | -B, --branch - add branch |
7922b3ec | 156 | -c, --clean - clean all temporarily created files (in BUILD, |
79b2ec0e | 157 | SOURCES, SPECS and \$RPM_BUILD_ROOT), |
7922b3ec | 158 | -d <cvsroot>, --cvsroot <cvsroot> |
159 | - setup \$CVSROOT, | |
e7bdc1b4 | 160 | --define <macro> <value> |
81f85806 | 161 | - define a macro <macro> with value <value>, |
11707eb9 | 162 | --nodeps - rpm won't check any dependences |
7922b3ec | 163 | -g, --get - get <package>.spec and all related files from |
cc97f1f3 | 164 | CVS repo or HTTP/FTP, |
5a491465 | 165 | -h, --help - this message, |
d7f490f3 | 166 | --http - use http instead of ftp, |
7922b3ec | 167 | -l <logfile>, --logtofile <logfile> |
168 | - log all to file, | |
ff45a501 | 169 | -m, --mr-proper - only remove all files related to spec file and |
8bc51224 | 170 | all work resources, |
6fc910c7 | 171 | -nc, --no-cvs - don't download sources from CVS, if source URL is |
172 | given, | |
173 | -ncs, --no-cvs-specs | |
174 | - don't check specs in CVS | |
fc0e5bb5 TP |
175 | -nd, --no-distfiles |
176 | - don't download from distfiles | |
4ca52257 | 177 | -nm, --no-mirrors - don't download from mirror, if source URL is given, |
157dc315 | 178 | -nu, --no-urls - don't try to download from FTP/HTTP location, |
0143ec80 | 179 | -ns, --no-srcs - don't download Sources |
fd2b5687 | 180 | -ns0, --no-source0 |
0143ec80 | 181 | - don't download Source0 |
7922b3ec | 182 | --opts <rpm opts> |
183 | - additional options for rpm | |
5a491465 | 184 | -q, --quiet - be quiet, |
448deaa0 | 185 | --date yyyy-mm-dd |
186 | - build package using resources from specified CVS | |
187 | date, | |
7922b3ec | 188 | -r <cvstag>, --cvstag <cvstag> |
189 | - build package using resources from specified CVS | |
67fcd1e4 | 190 | tag, |
da0048be | 191 | -R, --fetch-build-requires |
192 | - fetch what is BuildRequired, | |
a6253cb6 | 193 | -RB, --remove-build-requires |
194 | - remove all you fetched with -R or --fetch-build-requires | |
195 | remember, this option requires confirmation, | |
196 | -FRB, --force-remove-build-requires | |
197 | - remove all you fetched with -R or --fetch-build-requires | |
198 | remember, this option works without confirmation, | |
7922b3ec | 199 | -T <cvstag> , --tag <cvstag> |
200 | - add cvs tag <cvstag> for files, | |
78ce14b3 | 201 | -Tvs, --tag-version-stable |
202 | - add cvs tags STABLE and NAME-VERSION-RELESE for files, | |
a2164135 MM |
203 | -Tvn, --tag-version-nest |
204 | - add cvs tags NEST and NAME-VERSION-RELESE for files, | |
78ce14b3 | 205 | -Ts, --tag-stable |
206 | - add cvs tag STABLE for files, | |
a2164135 MM |
207 | -Tn, --tag-nest |
208 | - add cvs tag NEST for files, | |
7922b3ec | 209 | -Tv, --tag-version |
210 | - add cvs tag NAME-VERSION-RELESE for files, | |
d71ea755 MM |
211 | -Tp, --tag-prefix <prefix> |
212 | - add <prefix> to NAME-VERSION-RELEASE tags, | |
5a491465 | 213 | -v, --verbose - be verbose, |
81f85806 | 214 | -u, --try-upgrade |
215 | - check version, and try to upgrade package | |
b130abf2 TP |
216 | -un, --try-upgrade-with-float-version |
217 | - as above, but allow float version | |
218 | -U, --update | |
de6b5b2a MM |
219 | - refetch sources, don't use distfiles, and update md5 |
220 | comments | |
da0048be | 221 | -Upi, --update-poldek-indexes |
222 | - refresh or make poldek package index files. | |
d5787aec | 223 | --with/--without <feature> |
81f85806 | 224 | - conditional build package depending on |
d5787aec | 225 | %_with_<feature>/%_without_<feature> macro |
da0048be | 226 | switch. |
227 | You may now use --with feat1 feat2 feat3 --without feat4 | |
228 | feat5 --with feat6 constructions. | |
5a491465 | 229 | " |
230 | } | |
231 | ||
5f26c239 MM |
232 | cache_rpm_dump () { |
233 | rpm_dump_cache=` | |
ad6f43de MM |
234 | case "$RPMBUILD" in |
235 | rpm ) | |
ecfecee9 | 236 | rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1 |
ad6f43de MM |
237 | ;; |
238 | rpmbuild ) | |
5f26c239 | 239 | rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1 |
ad6f43de | 240 | ;; |
15a71f66 | 241 | esac` |
5f26c239 MM |
242 | } |
243 | ||
244 | rpm_dump () { | |
245 | if [ -z "$rpm_dump_cache" ] ; then | |
319a7f41 | 246 | echo "internal error: cache_rpm_dump not called!" 1>&2 |
15a71f66 MM |
247 | fi |
248 | echo "$rpm_dump_cache" | |
ad6f43de MM |
249 | } |
250 | ||
59398507 | 251 | parse_spec() |
252 | { | |
c3428d50 | 253 | if [ -n "$DEBUG" ]; then |
a7af9862 | 254 | set -x; |
255 | set -v; | |
71d62f04 | 256 | fi |
7c2dd1b2 | 257 | |
25fa34fe | 258 | cd $SPECS_DIR |
5f26c239 MM |
259 | |
260 | cache_rpm_dump | |
261 | ||
72fb89b5 | 262 | if [ "$NOSRCS" != "yes" ]; then |
ad6f43de | 263 | SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`" |
72fb89b5 | 264 | fi |
ad6f43de | 265 | if (rpm_dump | grep -qEi ":.*nosource.*1"); then |
a7af9862 | 266 | FAIL_IF_NO_SOURCES="no" |
c6a390a1 AM |
267 | fi |
268 | ||
ad6f43de | 269 | PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`" |
cc97f1f3 | 270 | ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`" |
7147050f AM |
271 | PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`" |
272 | PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`" | |
273 | PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`" | |
79379585 | 274 | |
9e06e5c3 | 275 | if [ -n "$BE_VERBOSE" ]; then |
00fcec7e | 276 | echo "- Sources : `nourl $SOURCES`" |
cc97f1f3 | 277 | if [ -n "$PATCHES" ]; then |
a7af9862 | 278 | echo "- Patches : `nourl $PATCHES`" |
cc97f1f3 | 279 | else |
a7af9862 | 280 | echo "- Patches : *no patches needed*" |
cc97f1f3 | 281 | fi |
7053d3fd | 282 | if [ -n "$ICONS" ]; then |
a7af9862 | 283 | echo "- Icon : `nourl $ICONS`" |
a3df415f | 284 | else |
a7af9862 | 285 | echo "- Icon : *no package icon*" |
a3df415f | 286 | fi |
9e06e5c3 | 287 | echo "- Name : $PACKAGE_NAME" |
288 | echo "- Version : $PACKAGE_VERSION" | |
39cbc282 | 289 | echo "- Release : $PACKAGE_RELEASE" |
d287305c | 290 | fi |
33f5276d | 291 | } |
292 | ||
293 | Exit_error() | |
294 | { | |
00fcec7e | 295 | if [ -n "$DEBUG" ]; then |
0dd6320d | 296 | set -x; |
00fcec7e | 297 | set -v; |
71d62f04 | 298 | fi |
7c2dd1b2 | 299 | |
33f5276d | 300 | cd $__PWD |
301 | ||
4849ca8d | 302 | case "$1" in |
33f5276d | 303 | "err_no_spec_in_cmdl" ) |
0e15d097 | 304 | remove_build_requires |
33f5276d | 305 | echo "ERROR: spec file name not specified."; |
306 | exit 2 ;; | |
307 | "err_no_spec_in_repo" ) | |
0e15d097 | 308 | remove_build_requires |
33f5276d | 309 | echo "Error: spec file not stored in CVS repo."; |
310 | exit 3 ;; | |
311 | "err_no_source_in_repo" ) | |
0e15d097 | 312 | remove_build_requires |
4849ca8d | 313 | echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"; |
33f5276d | 314 | exit 4 ;; |
315 | "err_build_fail" ) | |
0e15d097 | 316 | remove_build_requires |
298c753e | 317 | echo "Error: package build failed. (${2:-no more info})"; |
33f5276d | 318 | exit 5 ;; |
319 | esac | |
320 | } | |
bc8d444f | 321 | |
33f5276d | 322 | init_builder() |
323 | { | |
00fcec7e | 324 | if [ -n "$DEBUG" ]; then |
0dd6320d | 325 | set -x; |
00fcec7e | 326 | set -v; |
71d62f04 | 327 | fi |
7c2dd1b2 | 328 | |
7147050f AM |
329 | SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`" |
330 | SPECS_DIR="`$RPM --eval '%{_specdir}'`" | |
bc8d444f | 331 | |
33f5276d | 332 | __PWD=`pwd` |
59398507 | 333 | } |
334 | ||
335 | get_spec() | |
336 | { | |
00fcec7e | 337 | if [ -n "$DEBUG" ]; then |
0dd6320d | 338 | set -x; |
00fcec7e | 339 | set -v; |
71d62f04 | 340 | fi |
7c2dd1b2 | 341 | |
6fc910c7 | 342 | if [ "$NOCVSSPEC" != "yes" ]; then |
343 | cd $SPECS_DIR | |
5644bf7e | 344 | |
6fc910c7 | 345 | OPTIONS="up " |
67fcd1e4 | 346 | |
6fc910c7 | 347 | if [ -n "$CVSROOT" ]; then |
348 | OPTIONS="-d $CVSROOT $OPTIONS" | |
349 | else | |
350 | if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then | |
351 | echo "warning: No cvs access defined - using local .spec file" | |
352 | NOCVSSPEC="yes" | |
353 | fi | |
354 | fi | |
00fcec7e | 355 | |
72e08ca8 | 356 | if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then |
6fc910c7 | 357 | OPTIONS="$OPTIONS -A" |
72e08ca8 AM |
358 | else |
359 | if [ -n "$CVSDATE" ]; then | |
0dd6320d | 360 | OPTIONS="$OPTIONS -D $CVSDATE" |
72e08ca8 AM |
361 | fi |
362 | if [ -n "$CVSTAG" ]; then | |
0dd6320d | 363 | OPTIONS="$OPTIONS -r $CVSTAG" |
72e08ca8 | 364 | fi |
6fc910c7 | 365 | fi |
33f5276d | 366 | |
b92ecfc9 AM |
367 | result=1 |
368 | retries_counter=0 | |
369 | while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do | |
370 | retries_counter=$(( $retries_counter + 1 )) | |
371 | output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1) | |
372 | result=$? | |
fef1dc85 | 373 | [ -n "$output" ] && echo "$output" |
b92ecfc9 | 374 | if [ "$result" -ne "0" ]; then |
5f9b4a6d | 375 | if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$retries_counter" -le "$CVS_RETRIES" ]; then |
ee004885 | 376 | echo "Trying again [$SPECFILE]... ($retries_counter)" |
96686ae5 | 377 | sleep 2 |
b92ecfc9 | 378 | continue |
0dd6320d | 379 | fi |
380 | Exit_error err_no_spec_in_repo; | |
b92ecfc9 AM |
381 | fi |
382 | done | |
33f5276d | 383 | fi |
6fc910c7 | 384 | if [ ! -f "$SPECFILE" ]; then |
b857906d | 385 | Exit_error err_no_spec_in_repo; |
6fc910c7 | 386 | fi |
a7af9862 | 387 | |
d013b3df | 388 | if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then |
7922b3ec | 389 | chmod $CHMOD_MODE $SPECFILE |
5aa0ef93 | 390 | fi |
7c2dd1b2 | 391 | unset OPTIONS |
67da0368 | 392 | grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE |
59398507 | 393 | } |
394 | ||
4ca52257 JK |
395 | find_mirror(){ |
396 | ||
397 | cd "$SPECS_DIR" | |
00fcec7e | 398 | url="$1" |
6631fc57 | 399 | if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then |
00fcec7e | 400 | cvs update mirrors >&2 |
4ca52257 JK |
401 | fi |
402 | ||
403 | IFS="|" | |
404 | while read origin mirror name rest; do | |
00fcec7e | 405 | ol=`echo -n "$origin"|wc -c` |
4ca52257 JK |
406 | prefix="`echo -n "$url" | head -c $ol`" |
407 | if [ "$prefix" = "$origin" ] ; then | |
6fc910c7 | 408 | suffix="`echo "$url"|cut -b $ol-`" |
409 | echo -n "$mirror$suffix" | |
410 | return 0 | |
4ca52257 JK |
411 | fi |
412 | done < mirrors | |
413 | echo "$url" | |
414 | } | |
415 | ||
00fcec7e | 416 | src_no () |
417 | { | |
418 | cd $SPECS_DIR | |
ad6f43de | 419 | rpm_dump | \ |
0dd6320d | 420 | grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \ |
421 | sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \ | |
422 | head -1 | xargs | |
00fcec7e | 423 | } |
424 | ||
425 | src_md5 () | |
426 | { | |
427 | no=$(src_no "$1") | |
428 | [ -z "$no" ] && return | |
429 | cd $SPECS_DIR | |
0dd6320d | 430 | spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::) |
431 | if [ -z "$spec_rev" ]; then | |
432 | spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')" | |
433 | fi | |
434 | spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')" | |
80dcd8ed | 435 | md5=$(grep -s -v '^#' additional-md5sums | \ |
0dd6320d | 436 | grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \ |
437 | sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \ | |
438 | grep -E '^[0-9a-f]{32}$') | |
6d2b8f55 | 439 | if [ X"$md5" = X"" ] ; then |
0dd6320d | 440 | grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs |
6d2b8f55 | 441 | else |
0dd6320d | 442 | if [ $(echo "$md5" | wc -l) != 1 ] ; then |
443 | echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2 | |
444 | fi | |
445 | echo "$md5" | tail -1 | |
6d2b8f55 | 446 | fi |
00fcec7e | 447 | } |
448 | ||
449 | distfiles_url () | |
450 | { | |
d7f490f3 | 451 | echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")" |
00fcec7e | 452 | } |
453 | ||
d99ac371 MM |
454 | good_md5 () |
455 | { | |
456 | md5=$(src_md5 "$1") | |
457 | [ "$md5" = "" ] || \ | |
458 | [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ] | |
459 | } | |
460 | ||
25fa34fe | 461 | get_files() |
59398507 | 462 | { |
25fa34fe AM |
463 | GET_FILES="$@" |
464 | ||
00fcec7e | 465 | if [ -n "$DEBUG" ]; then |
0dd6320d | 466 | set -x; |
00fcec7e | 467 | set -v; |
71d62f04 | 468 | fi |
7c2dd1b2 | 469 | |
25fa34fe | 470 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then |
7053d3fd | 471 | cd $SOURCE_DIR |
33f5276d | 472 | |
82c46005 | 473 | OPTIONS="up " |
7053d3fd | 474 | if [ -n "$CVSROOT" ]; then |
c1e79fcd | 475 | OPTIONS="-d $CVSROOT $OPTIONS" |
6fc910c7 | 476 | else |
477 | if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then | |
478 | echo "warning: No cvs access defined for SOURCES" | |
479 | NOCVS="yes" | |
480 | fi | |
67fcd1e4 | 481 | fi |
0dd6320d | 482 | if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then |
483 | OPTIONS="$OPTIONS -A" | |
484 | else | |
485 | if [ -n "$CVSDATE" ]; then | |
486 | OPTIONS="$OPTIONS -D $CVSDATE" | |
487 | fi | |
488 | if [ -n "$CVSTAG" ]; then | |
489 | OPTIONS="$OPTIONS -r $CVSTAG" | |
490 | fi | |
491 | fi | |
25fa34fe | 492 | for i in $GET_FILES; do |
2daea751 TP |
493 | if [ -n "$UPDATE5" ]; then |
494 | if [ -n "$ADD5" ]; then | |
495 | [ `nourl $i` = "$i" ] && continue | |
496 | grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue | |
497 | else | |
498 | grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue | |
499 | fi | |
500 | fi | |
2837871a | 501 | FROM_DISTFILES=0 |
81474543 | 502 | if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then |
4a0bb672 | 503 | if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then |
6fc910c7 | 504 | echo "Warning: no URL given for $i" |
157dc315 | 505 | fi |
a7af9862 | 506 | |
fc0e5bb5 | 507 | if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then |
d99ac371 | 508 | if good_md5 "$i"; then |
f67349b7 | 509 | echo "$(nourl "$i") having proper md5sum already exists" |
510 | continue | |
511 | fi | |
00fcec7e | 512 | target=$(nourl "$i") |
513 | url=$(distfiles_url "$i") | |
2837871a | 514 | if [ `echo $url | grep -E '^(\.|/)'` ]; then |
6aefe77b JR |
515 | ${GETLOCAL} $url $target |
516 | else | |
2837871a | 517 | FROM_DISTFILES=1 |
518 | if [ -z "$NOMIRRORS" ]; then | |
6aefe77b | 519 | url="`find_mirror "$url"`" |
00fcec7e | 520 | fi |
6aefe77b JR |
521 | ${GETURI} -O "$target" "$url" || \ |
522 | if [ `echo $url | grep -E 'ftp://'` ]; then | |
523 | ${GETURI2} -O "$target" "$url" | |
524 | fi | |
57422365 | 525 | if ! test -s "$target"; then |
526 | rm -f "$target" | |
527 | FROM_DISTFILES=0 | |
528 | fi | |
6aefe77b | 529 | fi |
c3d441b0 JB |
530 | elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then |
531 | # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred | |
b92ecfc9 | 532 | result=1 |
0dd6320d | 533 | retries_counter=0 |
534 | while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do | |
535 | retries_counter=$(( $retries_counter + 1 )) | |
b92ecfc9 | 536 | output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1) |
0dd6320d | 537 | result=$? |
fef1dc85 | 538 | [ -n "$output" ] && echo "$output" |
5f9b4a6d | 539 | 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 |
ee004885 | 540 | echo "Trying again [`nourl $i`]... ($retries_counter)" |
96686ae5 | 541 | sleep 2 |
b92ecfc9 | 542 | continue |
711eb1e4 AM |
543 | else |
544 | break | |
b92ecfc9 AM |
545 | fi |
546 | done | |
157dc315 | 547 | fi |
a7af9862 | 548 | |
b130abf2 | 549 | if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then |
2837871a | 550 | if [ -z "$NOMIRRORS" ]; then |
3428d253 JB |
551 | im="`find_mirror "$i"`" |
552 | else | |
553 | im="$i" | |
6fc910c7 | 554 | fi |
3428d253 JB |
555 | ${GETURI} "$im" || \ |
556 | if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi | |
157dc315 SZ |
557 | fi |
558 | ||
de6b5b2a | 559 | |
422fbc56 TP |
560 | fi |
561 | srcno=$(src_no $i) | |
562 | if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then | |
563 | Exit_error err_no_source_in_repo $i; | |
564 | elif [ -n "$UPDATE5" ] && \ | |
565 | ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \ | |
566 | [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \ | |
567 | grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE ) | |
568 | then | |
569 | echo "Updating source-$srcno md5." | |
570 | md5=$(md5sum `nourl $i` | cut -f1 -d' ') | |
82db6b8d MM |
571 | perl -i -ne ' |
572 | print unless /^\s*#\s*Source'$srcno'-md5\s*:/i; | |
573 | print "# Source'$srcno'-md5:\t'$md5'\n" | |
574 | if /^Source'$srcno'\s*:\s+/; | |
575 | ' \ | |
422fbc56 TP |
576 | $SPECS_DIR/$SPECFILE |
577 | fi | |
578 | ||
2837871a | 579 | if good_md5 "$i"; then |
580 | : | |
581 | elif [ "$FROM_DISTFILES" = 1 ]; then | |
582 | # wrong md5 from distfiles: remove the file and try again | |
583 | # but only once ... | |
97c857d8 | 584 | echo "MD5 sum mismatch. Trying full fetch." |
2837871a | 585 | FROM_DISTFILES=2 |
586 | rm -f $target | |
587 | ${GETURI} -O "$target" "$url" || \ | |
588 | if [ `echo $url | grep -E 'ftp://'` ]; then | |
589 | ${GETURI2} -O "$target" "$url" | |
590 | fi | |
591 | test -s "$target" || rm -f "$target" | |
592 | fi | |
593 | ||
422fbc56 TP |
594 | if good_md5 "$i"; then |
595 | : | |
596 | else | |
597 | echo "MD5 sum mismatch. Use -U to refetch sources," | |
598 | echo "or -5 to update md5 sums, if you're sure files are correct." | |
599 | Exit_error err_no_source_in_repo $i | |
3ae81a20 | 600 | fi |
cc97f1f3 | 601 | done |
a7af9862 | 602 | |
5aa0ef93 | 603 | if [ "$CHMOD" = "yes" ]; then |
d013b3df AM |
604 | CHMOD_FILES="`nourl $GET_FILES`" |
605 | if [ -n "$CHMOD_FILES" ]; then | |
6fc910c7 | 606 | chmod $CHMOD_MODE $CHMOD_FILES |
d013b3df | 607 | fi |
5aa0ef93 | 608 | fi |
7c2dd1b2 | 609 | unset OPTIONS |
7053d3fd | 610 | fi |
59398507 | 611 | } |
612 | ||
1471f6d6 | 613 | tag_files() |
614 | { | |
615 | TAG_FILES="$@" | |
616 | ||
00fcec7e | 617 | if [ -n "$DEBUG" ]; then |
0dd6320d | 618 | set -x; |
00fcec7e | 619 | set -v; |
1471f6d6 | 620 | fi |
621 | ||
622 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then | |
0b9271b0 PG |
623 | echo "Version: $PACKAGE_VERSION" |
624 | echo "Release: $PACKAGE_RELEASE" | |
319a7f41 | 625 | # Check whether first character of PACKAGE_NAME is legal for tag name |
c7577806 | 626 | if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then |
627 | TAG_PREFIX=tag_ | |
628 | fi | |
d71ea755 | 629 | TAGVER=$TAG_PREFIX$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"` |
657983d5 AM |
630 | # Remove #kernel.version_release from TAGVER because tagging sources |
631 | # could occur with different kernel-headers than kernel-headers used at build time. | |
632 | TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g') | |
01de2036 JB |
633 | if [ "$TAG_VERSION" = "yes" ]; then |
634 | echo "CVS tag: $TAGVER" | |
635 | fi | |
636 | if [ -n "$TAG" ]; then | |
637 | echo "CVS tag: $TAG" | |
638 | fi | |
1471f6d6 | 639 | |
640 | OPTIONS="tag -F" | |
641 | if [ -n "$CVSROOT" ]; then | |
642 | OPTIONS="-d $CVSROOT $OPTIONS" | |
643 | fi | |
644 | ||
645 | cd $SOURCE_DIR | |
646 | for i in $TAG_FILES; do | |
c2a27ba0 AM |
647 | # don't tag non cvs files (ie. stored on distfiles) |
648 | [ "`nourl $i`" != "$i" ] && continue | |
649 | if [ -f "`nourl $i`" ]; then | |
f02788de JB |
650 | if [ "$TAG_VERSION" = "yes" ]; then |
651 | cvs $OPTIONS $TAGVER `nourl $i` | |
652 | fi | |
653 | if [ -n "$TAG" ]; then | |
654 | cvs $OPTIONS $TAG `nourl $i` | |
655 | fi | |
1471f6d6 | 656 | else |
4849ca8d | 657 | Exit_error err_no_source_in_repo $i |
1471f6d6 | 658 | fi |
659 | done | |
660 | ||
661 | cd $SPECS_DIR | |
f02788de JB |
662 | if [ "$TAG_VERSION" = "yes" ]; then |
663 | cvs $OPTIONS $TAGVER $SPECFILE | |
664 | fi | |
665 | if [ -n "$TAG" ]; then | |
666 | cvs $OPTIONS $TAG $SPECFILE | |
667 | fi | |
1471f6d6 | 668 | |
669 | unset OPTIONS | |
670 | fi | |
671 | } | |
672 | ||
8ba5cdda PG |
673 | branch_files() |
674 | { | |
a7af9862 | 675 | TAG=$1 |
676 | echo "CVS branch tag: $TAG" | |
677 | shift; | |
8ba5cdda | 678 | |
a7af9862 | 679 | TAG_FILES="$@" |
8ba5cdda | 680 | |
a7af9862 | 681 | if [ -n "$DEBUG" ]; then |
682 | set -x; | |
683 | set -v; | |
684 | fi | |
8ba5cdda | 685 | |
a7af9862 | 686 | if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then |
687 | ||
688 | OPTIONS="tag -b" | |
689 | if [ -n "$CVSROOT" ]; then | |
690 | OPTIONS="-d $CVSROOT $OPTIONS" | |
8ba5cdda | 691 | fi |
a7af9862 | 692 | cd $SOURCE_DIR |
693 | for i in $TAG_FILES; do | |
694 | if [ -f `nourl $i` ]; then | |
695 | cvs $OPTIONS $TAG `nourl $i` | |
696 | else | |
697 | Exit_error err_no_source_in_repo $i | |
698 | fi | |
699 | done | |
700 | cd $SPECS_DIR | |
701 | cvs $OPTIONS $TAG $SPECFILE | |
702 | ||
703 | unset OPTIONS | |
704 | fi | |
8ba5cdda PG |
705 | } |
706 | ||
f308b816 | 707 | |
708 | ||
59398507 | 709 | build_package() |
710 | { | |
00fcec7e | 711 | if [ -n "$DEBUG" ]; then |
7922b3ec | 712 | set -x; |
00fcec7e | 713 | set -v; |
71d62f04 | 714 | fi |
7c2dd1b2 | 715 | |
33f5276d | 716 | cd $SPECS_DIR |
3d97a432 | 717 | |
00fcec7e | 718 | if [ -n "$TRY_UPGRADE" ]; then |
a7af9862 | 719 | |
1acf51bc | 720 | if [ -n "$FLOAT_VERSION" ]; then |
a7af9862 | 721 | TNOTIFY=`./pldnotify.awk $SPECFILE -n` |
722 | else | |
723 | TNOTIFY=`./pldnotify.awk $SPECFILE` | |
724 | fi | |
725 | ||
3d97a432 | 726 | TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'` |
a7af9862 | 727 | |
0096b1ae | 728 | if [ -n "$TNEWVER" ]; then |
a7af9862 | 729 | |
3d97a432 | 730 | TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'` |
a7af9862 | 731 | |
3d97a432 | 732 | echo "New version found, updating spec file to version " $TNEWVER |
a7af9862 | 733 | |
3d97a432 | 734 | cp -f $SPECFILE $SPECFILE.bak |
a7af9862 | 735 | |
3d97a432 | 736 | chmod +w $SPECFILE |
a7af9862 | 737 | |
3d97a432 MK |
738 | eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE" |
739 | eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE" | |
a7af9862 | 740 | |
3d97a432 | 741 | parse_spec; |
a7af9862 | 742 | |
3d97a432 | 743 | get_files "$SOURCES $PATCHES"; |
a7af9862 | 744 | |
3d97a432 MK |
745 | unset TOLDVER TNEWVER TNOTIFY |
746 | fi | |
00fcec7e | 747 | |
3d97a432 MK |
748 | fi |
749 | ||
750 | ||
751 | cd $SPECS_DIR | |
752 | ||
79b2ec0e | 753 | case "$COMMAND" in |
754 | build ) | |
7922b3ec | 755 | BUILD_SWITCH="-ba" ;; |
79b2ec0e | 756 | build-binary ) |
757 | BUILD_SWITCH="-bb" ;; | |
758 | build-source ) | |
956d1492 | 759 | BUILD_SWITCH="-bs --nodeps" ;; |
4fe34d83 | 760 | build-prep ) |
761 | BUILD_SWITCH="-bp --nodeps" ;; | |
79b2ec0e | 762 | esac |
d6a75d60 | 763 | if [ -n "$LOGFILE" ]; then |
972bd3c3 | 764 | LOG=`eval echo $LOGFILE` |
00fcec7e | 765 | if [ -n "$LASTLOG_FILE" ]; then |
766 | echo "LASTLOG=$LOG" > $LASTLOG_FILE | |
767 | fi | |
768 | RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM | |
f32dfbda | 769 | (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG |
00fcec7e | 770 | RETVAL=`cat $RES_FILE` |
771 | rm $RES_FILE | |
772 | if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then | |
0dd6320d | 773 | if [ "$RETVAL" -eq "0" ]; then |
00fcec7e | 774 | mv $LOG $LOGDIROK |
0dd6320d | 775 | else |
776 | mv $LOG $LOGDIRFAIL | |
00fcec7e | 777 | fi |
778 | fi | |
d6a75d60 | 779 | else |
7147050f | 780 | eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE |
f308b816 | 781 | RETVAL=$? |
d6a75d60 | 782 | fi |
33f5276d | 783 | |
f308b816 | 784 | if [ "$RETVAL" -ne "0" ]; then |
a7af9862 | 785 | |
00fcec7e | 786 | if [ -n "$TRY_UPGRADE" ]; then |
3d97a432 | 787 | echo "\n!!! Package with new version cannot be build automagically\n" |
3d97a432 | 788 | mv -f $SPECFILE.bak $SPECFILE |
3d97a432 | 789 | fi |
a7af9862 | 790 | |
33f5276d | 791 | Exit_error err_build_fail; |
792 | fi | |
a7af9862 | 793 | |
79b2ec0e | 794 | unset BUILD_SWITCH |
59398507 | 795 | } |
796 | ||
cc97f1f3 SZ |
797 | nourl() |
798 | { | |
a7af9862 | 799 | echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g' |
cc97f1f3 | 800 | } |
2daea751 | 801 | |
da0048be | 802 | set_bconds_values() |
803 | { | |
804 | AVAIL_BCONDS_WITHOUT="" | |
805 | AVAIL_BCONDS_WITH="" | |
806 | for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_` | |
807 | do | |
808 | AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"` | |
809 | if [ "`echo $BCOND|grep -- "--without $AVAIL_BCOND_WITHOUT"`" != "" ];then | |
810 | AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>" | |
811 | else | |
812 | AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT" | |
813 | fi | |
814 | done | |
815 | ||
816 | for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_` | |
817 | do | |
818 | AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"` | |
819 | if [ "`echo $BCOND|grep -- "--with $AVAIL_BCOND_WITH"`" != "" ];then | |
820 | AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>" | |
821 | else | |
822 | AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH" | |
823 | fi | |
824 | done | |
825 | } | |
826 | ||
d79f7220 | 827 | run_sub_builder() |
828 | { | |
829 | package_name="${1}" | |
830 | echo -ne "Package installation failed:\t$package_name\n" | |
831 | # | |
832 | Content-type: text/html ]>