6 # 2 - no spec file name in cmdl parameters
7 # 3 - spec file not stored in repo
8 # 4 - some source, patch or icon files not stored in repo
9 # 5 - package build failed
10 # 6 - spec file with errors
11 # 7 - wrong source in /etc/poldek.conf
12 # 8 - Failed installing buildrequirements and subrequirements
13 # 9 - Requested tag already exist
14 # 10 - Refused to build fractional release
15 # 100 - Unknown error (should not happen)
18 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
19 # - when Icon: field is present, -5 and -a5 doesn't work
20 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
27 Build package utility from PLD Linux CVS repository
28 $VERSION (C) 1999-2007 Free Penguins".
30 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
49 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
53 # user agent when fetching files
54 USER_AGENT="PLD/Builder($VERSION)"
56 # It can be used i.e. in log file naming.
57 # See LOGFILE example.
58 DATE=`date +%Y-%m-%d_%H-%M-%S`
60 # Example: LOGFILE='../log.$PACKAGE_NAME'
61 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
62 # Yes, you can use variable name! Note _single_ quotes!
86 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
87 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
93 CVS_SERVER="cvs.pld-linux.org"
94 DISTFILES_SERVER="://distfiles.pld-linux.org"
95 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
100 FAIL_IF_NO_SOURCES="yes"
102 # let get_files skip over files which are present to get those damn files fetched
103 SKIP_EXISTING_FILES="no"
106 # should the specfile be restored if upgrade failed?
107 REVERT_BROKEN_UPGRADE="yes"
109 if [ -x /usr/bin/rpm-getdeps ]; then
110 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
112 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
115 # Here we load saved user environment used to
116 # predefine options set above, or passed to builder
118 # This one reads global system environment settings:
119 if [ -f ~/etc/builderrc ]; then
122 # And this one cascades settings using user personal
124 # Example of ~/.builderrc:
126 #UPDATE_POLDEK_INDEXES="yes"
127 #FETCH_BUILD_REQUIRES="yes"
128 #REMOVE_BUILD_REQUIRES="force"
130 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
134 if [ -n "$HOME_ETC" ]; then
135 USER_CFG="$HOME_ETC/.builderrc"
136 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
138 USER_CFG=~/.builderrc
139 BUILDER_MACROS=~/.builder-rpmmacros
142 [ -f "$USER_CFG" ] && . "$USER_CFG"
144 if [ "$SCHEDTOOL" = "auto" ]; then
145 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
146 SCHEDTOOL="schedtool -B -e"
152 if [ -n "$USE_PROZILLA" ]; then
153 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
156 elif [ -n "$USE_AXEL" ]; then
157 GETURI="axel -a $AXEL_OPTS"
161 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
162 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
163 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
164 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
166 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
167 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
173 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
181 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
182 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
186 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
187 if [ -n "$LOGFILE" ]; then
188 LOG=`eval echo $LOGFILE`
189 if [ -n "$LASTLOG_FILE" ]; then
190 echo "LASTLOG=$LOG" > $LASTLOG_FILE
192 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
195 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
196 return `cat ${RES_FILE}`
201 #---------------------------------------------
206 if [ -n "$DEBUG" ]; then set -xv; fi
208 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
209 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
210 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
211 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
212 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
213 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
214 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
215 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
216 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
217 <package>[.spec][:cvstag]
219 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
220 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
221 -n5, --no-md5 - ignore md5 comments in spec
222 -D, --debug - enable builder script debugging mode,
223 -debug - produce rpm debug package (same as --opts -debug)
224 -V, --version - output builder version string
225 --short-version - output builder short version
226 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
227 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
229 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
230 only package from <package>.spec,
231 -bp, --build-prep - execute the %prep phase of <package>.spec,
232 -bc - execute the %build phase of <package>.spec,
233 -bi - execute the %install phase of <package>.spec
234 -bl - execute the %files phase of <package>.spec
235 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
237 --short-circuit - short-circuit build
238 -B, --branch - add branch
239 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
240 SPECS and \$RPM_BUILD_ROOT),
241 -cf, --cvs-force - use -F when tagging (useful when moving branches)
242 -d <cvsroot>, --cvsroot <cvsroot>
244 --define <macro> <value>
245 - define a macro <macro> with value <value>,
246 --nodeps - rpm won't check any dependences
247 -g, --get - get <package>.spec and all related files from CVS repo
249 -h, --help - this message,
250 --http - use http instead of ftp,
251 -l <logfile>, --logtofile <logfile>
253 -m, --mr-proper - only remove all files related to spec file and all work
255 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
257 - don't check specs in CVS
258 -nd, --no-distfiles - don't download from distfiles
259 -nm, --no-mirrors - don't download from mirror, if source URL is given,
260 -nu, --no-urls - don't try to download from FTP/HTTP location,
261 -ns, --no-srcs - don't download Sources
262 -ns0, --no-source0 - don't download Source0
263 -nn, --no-net - don't download anything from the net
264 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
265 --no-init - don't initialize builder paths (SPECS and SOURCES)
267 --skip-existing-files - skip existing files in get_files
268 --opts <rpm opts> - additional options for rpm
269 -q, --quiet - be quiet,
270 --date yyyy-mm-dd - build package using resources from specified CVS date,
271 -r <cvstag>, --cvstag <cvstag>
272 - build package using resources from specified CVS tag,
273 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
274 -R, --fetch-build-requires
275 - fetch what is BuildRequired,
276 -RB, --remove-build-requires
277 - remove all you fetched with -R or --fetch-build-requires
278 remember, this option requires confirmation,
279 -FRB, --force-remove-build-requires
280 - remove all you fetched with -R or --fetch-build-requires
281 remember, this option works without confirmation,
282 -sd, --source-distfiles - list sources available from distfiles (intended for offline
283 operations; does not work when Icon field is present
284 but icon file is absent),
285 -sc, --source-cvs - list sources available from CVS
286 -sdp, --source-distfiles-paths - list sources available from distfiles -
287 paths relative to distfiles directory (intended for offline
288 operations; does not work when Icon field is present
289 but icon file is absent),
290 -sf, --source-files - list sources - bare filenames (intended for offline
291 operations; does not work when Icon field is present
292 but icon file is absent),
293 -sp, --source-paths - list sources - filenames with full local paths (intended for
294 offline operations; does not work when Icon field is present
295 but icon file is absent),
296 -su, --source-urls - list urls - urls to sources and patches
297 intended for copying urls with spec with lots of macros in urls
298 -T <cvstag> , --tag <cvstag>
299 - add cvs tag <cvstag> for files,
300 -Tvs, --tag-version-stable
301 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
303 - add cvs tag STABLE for files,
305 - add cvs tag NAME-VERSION-RELEASE for files,
306 -Tp, --tag-prefix <prefix>
307 - add <prefix> to NAME-VERSION-RELEASE tags,
308 -tt, --test-tag <prefix>
309 - fail if tag is already present,
310 -ir, --integer-release-only
311 - allow only integer and snapshot releases
312 -v, --verbose - be verbose,
313 -u, --try-upgrade - check version, and try to upgrade package
314 -un, --try-upgrade-with-float-version
315 - as above, but allow float version
317 - try download source from tag head if don't find it in
319 -U, --update - refetch sources, don't use distfiles, and update md5 comments
320 -Upi, --update-poldek-indexes
321 - refresh or make poldek package index files.
322 -np, --nopatch <patchnumber>
323 - don't apply <patchnumber>
324 --show-bconds - show available conditional builds, which can be used
325 - with --with and/or --without switches.
326 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
327 ./repackage.sh script. in other words, the output is
328 parseable by scripts.
329 --with/--without <feature>
330 - conditional build package depending on %_with_<feature>/
331 %_without_<feature> macro switch. You may now use
332 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
333 constructions. Set GROUP_BCONDS to yes to make use of it.
334 --target <platform>, --target=<platform>
335 - build for platform <platform>.
336 --init-rpm-dir - initialize ~/rpm directory structure
340 update_shell_title() {
342 local len=${COLUMNS:-80}
343 local msg=$(echo "$*" | cut -c-$len)
345 if [ -n "$BE_VERBOSE" ]; then
346 echo >&2 "$(date +%s.%N) $*"
349 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
351 if [ -n "$PACKAGE_NAME" ]; then
352 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
357 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
358 msg="$(echo $msg | tr -d '\n\r')"
361 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
364 echo >&2 -ne "\033]0;$msg\007"
370 # set TARGET from BuildArch: from SPECFILE
372 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
373 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
375 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
379 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
381 TARGET_SWITCH="--target=$TARGET" ;;
387 # runs rpm with minimal macroset
389 # we reset macros not to contain macros.build as all the %() macros are
390 # executed here, while none of them are actually needed.
391 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
392 safe_macrofiles=$(rpm --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
394 # TODO: move these to /usr/lib/rpm/macros
395 cat > $BUILDER_MACROS <<'EOF'
396 %x8664 x86_64 amd64 ia32e
399 %requires_releq_kernel_up %{nil}
400 %requires_releq_kernel_smp %{nil}
401 %requires_releq_kernel %{nil}
402 %requires_releq() %{nil}
403 %pyrequires_eq() %{nil}
404 %requires_eq() %{nil}
405 %requires_eq_to() %{nil}
406 %releq_kernel_up ERROR
407 %releq_kernel_smp ERROR
412 %ruby_ver_requires_eq() %{nil}
413 %ruby_mod_ver_requires_eq() %{nil}
414 %__php_api_requires() %{nil}
415 %php_major_version ERROR
416 %php_api_version ERROR
418 %perl_vendorarch ERROR
419 %perl_vendorlib ERROR
420 # damn. need it here! - copied from /usr/lib/rpm/macros.build
421 %tmpdir %(echo "${TMPDIR:-/tmp}")
422 %patchset_source(f:b:) %(
423 base=%{-b*}%{!-b*:10000};
424 start=$(expr $base + %1);
425 end=$(expr $base + %{?2}%{!?2:%{1}});
426 # we need to call seq twice as it doesn't allow two formats
427 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
428 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
429 paste %{tmpdir}/__ps{1,2};
430 rm -f %{tmpdir}/__ps{1,2};
434 if [ "$NOINIT" = "yes" ] ; then
435 cat >> $BUILDER_MACROS <<'EOF'
440 eval $RPMBUILD --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
444 if [ -n "$DEBUG" ]; then
449 update_shell_title "cache_rpm_dump"
452 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
453 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
459 ARGS='--nodigest --nosignature --nobuild'
462 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
464 if [ $? -gt 0 ]; then
465 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
467 Exit_error err_build_fail
470 # make small dump cache
471 rpm_dump_cache=`echo "$rpm_dump" | awk '
472 $2 ~ /^SOURCEURL/ {print}
473 $2 ~ /^PATCHURL/ {print}
474 $2 ~ /^nosource/ {print}
475 $2 ~ /^PACKAGE_/ {print}
478 update_shell_title "cache_rpm_dump: OK!"
482 if [ -z "$rpm_dump_cache" ] ; then
483 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
485 echo "$rpm_dump_cache"
490 update_shell_title "get icons"
491 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
492 if [ -z "$ICONS" ]; then
496 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
501 update_shell_title "parsing specfile"
502 if [ -n "$DEBUG" ]; then
507 # icons are needed for successful spec parse
513 if [ "$NOSRCS" != "yes" ]; then
514 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
517 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
518 FAIL_IF_NO_SOURCES="no"
521 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
522 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
523 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
524 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
525 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
527 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
528 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
531 if [ -n "$BE_VERBOSE" ]; then
532 echo "- Sources : `nourl $SOURCES`"
533 if [ -n "$PATCHES" ]; then
534 echo "- Patches : `nourl $PATCHES`"
536 echo "- Patches : *no patches needed*"
538 if [ -n "$ICONS" ]; then
539 echo "- Icon : `nourl $ICONS`"
541 echo "- Icon : *no package icon*"
543 echo "- Name : $PACKAGE_NAME"
544 echo "- Version : $PACKAGE_VERSION"
545 echo "- Release : $PACKAGE_RELEASE"
548 update_shell_title "parse_spec: OK!"
553 if [ -n "$DEBUG" ]; then
561 "err_no_spec_in_cmdl" )
562 remove_build_requires
563 echo "ERROR: spec file name not specified."
565 "err_invalid_cmdline" )
566 echo "ERROR: invalid command line arg ($2)."
568 "err_no_spec_in_repo" )
569 remove_build_requires
570 echo "Error: spec file not stored in CVS repo."
572 "err_no_source_in_repo" )
573 remove_build_requires
574 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"
577 remove_build_requires
578 echo "Error: package build failed. (${2:-no more info})"
580 "err_no_package_data" )
581 remove_build_requires
582 echo "Error: couldn't get out package name/version/release from spec file."
585 remove_build_requires
586 echo "Tag ${2} already exists (spec release: ${3})."
589 remove_build_requires
590 echo "Release ${2} not integer and not a snapshot."
592 "err_branch_exists" )
593 remove_build_requires
594 echo "Tree branch already exists (${2})."
597 remove_build_requires
598 echo "Error: conditions reject building this spec (${2})."
601 echo "Unknown error."
607 if [ -n "$DEBUG" ]; then
612 if [ "$NOINIT" != "yes" ] ; then
613 SOURCE_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_sourcedir}'`"
614 SPECS_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_specdir}'`"
626 update_shell_title "get_spec"
628 if [ -n "$DEBUG" ]; then
634 if [ ! -f "$SPECFILE" ]; then
635 SPECFILE="`basename $SPECFILE .spec`.spec"
637 if [ "$NOCVSSPEC" != "yes" ]; then
639 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
640 echo "Warning: No CVS access defined - using local .spec file"
644 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
647 if [ ! -f "$SPECFILE" ]; then
648 Exit_error err_no_spec_in_repo
651 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
652 chmod $CHMOD_MODE $SPECFILE
655 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
664 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
665 cvs update mirrors >&2
669 local origin mirror name rest ol prefix
670 while read origin mirror name rest; do
671 # skip comments and empty lines
672 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
675 ol=`echo -n "$origin"|wc -c`
676 prefix="`echo -n "$url" | head -c $ol`"
677 if [ "$prefix" = "$origin" ] ; then
678 suffix="`echo "$url"|cut -b $((ol+1))-`"
679 echo -n "$mirror$suffix"
686 # Warning: unpredictable results if same URL used twice
691 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
692 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
698 [ "$NO5" = "yes" ] && return
700 [ -z "$no" ] && return
704 if [ -f additional-md5sums ]; then
705 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
706 if [ -z "$spec_rev" ]; then
707 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
709 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
710 md5=$(grep -s -v '^#' additional-md5sums | \
711 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
712 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
713 grep -E '^[0-9a-f]{32}$')
716 if [ $(echo "$md5" | wc -l) != 1 ] ; then
717 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
719 echo "$md5" | tail -n 1
724 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
725 if [ -n "$source_md5" ]; then
728 # we have empty SourceX-md5, but it is still possible
729 # that we have NoSourceX-md5 AND NoSource: X
730 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
731 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
739 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
744 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
747 distfiles_attic_url ()
749 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
756 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
761 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
762 [ -n "$size" -a "$size" -gt 0 ]
767 if [ "$CVSIGNORE_DF" != "yes" ]; then
770 cvsignore=${SOURCE_DIR}/.cvsignore
771 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
772 echo "$1" >> $cvsignore
778 update_shell_title "cvsup"
780 if [ -n "$CVSROOT" ]; then
781 OPTIONS="-d $CVSROOT $OPTIONS"
784 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
785 OPTIONS="$OPTIONS -A"
787 if [ -n "$CVSDATE" ]; then
788 OPTIONS="$OPTIONS -D $CVSDATE"
790 if [ -n "$CVSTAG" ]; then
791 OPTIONS="$OPTIONS -r $CVSTAG"
796 local retries_counter=0
798 update_shell_title "cvsup: $*"
800 update_shell_title "cvsup: $# files"
802 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
803 retries_counter=$(( $retries_counter + 1 ))
804 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
806 [ -n "$output" ] && echo "$output"
807 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
808 echo "Trying again [$*]... ($retries_counter)"
809 update_shell_title "cvsup: retry #$retries_counter"
816 update_shell_title "cvsup: done!"
820 # returns true if "$1" is ftp, http or https protocol url
824 ftp://*|http://*|https://*)
833 if [ $# -eq 0 ]; then
837 update_shell_title "update md5"
838 if [ -n "$DEBUG" ]; then
845 # pass 1: check files to be fetched
849 local fp=$(nourl "$i")
850 local srcno=$(src_no "$i")
851 if [ -n "$ADD5" ]; then
852 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
853 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
855 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
857 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
858 need_files="$need_files $i"
862 # pass 1a: get needed files
863 if [ "$need_files" ]; then
864 get_files $need_files
867 # pass 2: proceed with md5 adding or updating
869 local fp=$(nourl "$i")
870 local srcno=$(src_no "$i")
871 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
872 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
873 local tag="Source$srcno-md5"
874 if [[ "$md5" == *NoSource* ]]; then
875 tag="NoSource$srcno-md5"
877 md5=$(md5sum "$fp" | cut -f1 -d' ')
878 echo "Updating $tag ($md5: $fp)."
880 print unless /^\s*#\s*(No)?Source'$srcno'-md5\s*:/i;
881 print "# '$tag':\t'$md5'\n" if /^Source'$srcno'\s*:\s+/;
890 update_shell_title "check md5"
893 if good_md5 "$i" && good_size "$i"; then
897 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
898 echo "or -5 to update md5 sums, if you're sure files are correct."
899 Exit_error err_no_source_in_repo $i
905 update_shell_title "get_files"
907 if [ -n "$DEBUG" ]; then
912 if [ $# -gt 0 ]; then
915 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
916 echo "Warning: No CVS access defined for SOURCES"
921 local get_files_cvs=""
925 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
926 update_shell_title "$i"
927 local fp=`nourl "$i"`
928 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
933 local srcmd5=$(src_md5 "$i")
935 # we know if source/patch is present in cvs/distfiles
936 # - has md5 (in distfiles)
939 # CHECK: local file didn't exist or always cvs up (first) requested.
940 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
941 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
942 echo "Warning: no URL given for $i"
945 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
946 if good_md5 "$i" && good_size "$i"; then
947 echo "$fp having proper md5sum already exists"
952 # optionally prefer mirror over distfiles if there's mirror
953 # TODO: build url list and then try each url from the list
954 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
957 url=$(distfiles_url "$i")
960 url_attic=$(distfiles_attic_url "$i")
962 # is $url local file?
963 if [[ "$url" = [./]* ]]; then
964 update_shell_title "${GETLOCAL%% *}: $url"
965 ${GETLOCAL} $url $target
967 if [ -z "$NOMIRRORS" ]; then
968 url=$(find_mirror "$url")
972 # make shorter message for distfiles urls
973 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
974 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
975 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
978 update_shell_title "${GETURI%% *}: $uri"
979 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
980 if [ "`echo $url | grep -E 'ftp://'`" ]; then
981 update_shell_title "${GETURI2%% *}: $url"
982 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
987 if [ ! -s "$target" ]; then
989 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
990 update_shell_title "${GETLOCAL%% *}: $url_attic"
991 ${GETLOCAL} $url_attic $target
993 if [ -z "$NOMIRRORS" ]; then
994 url_attic="`find_mirror "$url_attic"`"
996 update_shell_title "${GETURI%% *}: $url_attic"
997 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
998 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
999 update_shell_title "${GETURI2%% *}: $url_attic"
1000 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1005 if [ -s "$target" ]; then
1006 cvsignore_df $target
1011 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1012 if [ $# -gt 1 ]; then
1013 get_files_cvs="$get_files_cvs $fp"
1014 update_shell_title "$fp (will cvs up later)"
1021 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1022 if [ -z "$NOMIRRORS" ]; then
1023 im="`find_mirror "$i"`"
1027 update_shell_title "${GETURI%% *}: $im"
1028 ${GETURI} "$im" || \
1029 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1030 update_shell_title "${GETURI2%% *}: $im"
1035 if [ "$cvsup" = 1 ]; then
1041 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1042 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1043 if [ -n "GREEDSRC" ]; then
1044 get_greed_sources $i
1046 Exit_error err_no_source_in_repo $i
1050 # we check md5 here just only to refetch immediately
1051 if good_md5 "$i" && good_size "$i"; then
1053 elif [ "$FROM_DISTFILES" = 1 ]; then
1054 # wrong md5 from distfiles: remove the file and try again
1056 echo "MD5 sum mismatch. Trying full fetch."
1059 update_shell_title "${GETURI%% *}: $url"
1060 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1061 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1062 update_shell_title "${GETURI2%% *}: $url"
1063 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1065 if [ ! -s "$target" ]; then
1067 update_shell_title "${GETURI%% *}: $url_attic"
1068 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1069 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1070 update_shell_title "${GETURI2%% *}: $url_attic"
1071 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1074 test -s "$target" || rm -f "$target"
1077 SHELL_TITLE_PREFIX=""
1079 if [ "$get_files_cvs" ]; then
1080 cvsup $get_files_cvs
1083 if [ "$CHMOD" = "yes" ]; then
1084 CHMOD_FILES="`nourl "$@"`"
1085 if [ -n "$CHMOD_FILES" ]; then
1086 chmod $CHMOD_MODE $CHMOD_FILES
1093 if [ -n "$DEBUG" ]; then
1098 # Check whether first character of PACKAGE_NAME is legal for tag name
1099 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1103 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1104 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1106 # Remove #kernel.version_release from TAGVER because tagging sources
1107 # could occur with different kernel-headers than kernel-headers used at build time.
1108 # besides, %{_kernel_ver_str} is not expanded.
1110 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1111 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1121 if [ -n "$DEBUG" ]; then
1126 echo "Version: $PACKAGE_VERSION"
1127 echo "Release: $PACKAGE_RELEASE"
1130 if [ "$TAG_VERSION" = "yes" ]; then
1131 TAGVER=`make_tagver`
1132 echo "CVS tag: $TAGVER"
1134 if [ -n "$TAG" ]; then
1135 echo "CVS tag: $TAG"
1138 local OPTIONS="tag $CVS_FORCE"
1139 if [ -n "$CVSROOT" ]; then
1140 OPTIONS="-d $CVSROOT $OPTIONS"
1145 for i in $TAG_FILES; do
1146 # don't tag files stored on distfiles
1147 [ -n "`src_md5 $i`" ] && continue
1148 local fp=`nourl "$i"`
1149 if [ -f "$fp" ]; then
1150 tag_files="$tag_files $fp"
1151 elif [ -n "GREEDSRC" ]; then
1152 get_greed_sources $i
1154 Exit_error err_no_source_in_repo $i
1158 if [ "$tag_files" ]; then
1159 if [ "$TAG_VERSION" = "yes" ]; then
1160 update_shell_title "tag sources: $TAGVER"
1161 cvs $OPTIONS $TAGVER $tag_files || exit
1163 if [ -n "$TAG" ]; then
1164 update_shell_title "tag sources: $TAG"
1165 cvs $OPTIONS $TAG $tag_files || exit
1170 if [ "$TAG_VERSION" = "yes" ]; then
1171 update_shell_title "tag spec: $TAGVER"
1172 cvs $OPTIONS $TAGVER $SPECFILE || exit
1174 if [ -n "$TAG" ]; then
1175 update_shell_title "tag spec: $TAG"
1176 cvs $OPTIONS $TAG $SPECFILE || exit
1183 echo "CVS branch tag: $TAG"
1188 if [ -n "$DEBUG" ]; then
1193 local OPTIONS="tag $CVS_FORCE -b"
1194 if [ -n "$CVSROOT" ]; then
1195 OPTIONS="-d $CVSROOT $OPTIONS"
1199 for i in $TAG_FILES; do
1200 local fp=`nourl "$i"`
1201 if [ -f "$fp" ]; then
1202 tag_files="$tag_files $fp"
1203 elif [ -n "GREEDSRC" ]; then
1204 get_greed_sources $i
1206 Exit_error err_no_source_in_repo $i
1209 if [ "$tag_files" ]; then
1210 cvs $OPTIONS $TAG $tag_files || exit
1214 cvs $OPTIONS $TAG $SPECFILE || exit
1218 # this function should exit early if package can't be built for this arch
1219 # this avoids unneccessary BR filling.
1222 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1224 if [ $ret -ne 0 ]; then
1233 update_shell_title "build_package"
1234 if [ -n "$DEBUG" ]; then
1241 if [ -n "$TRY_UPGRADE" ]; then
1242 update_shell_title "build_package: try_upgrade"
1243 if [ -n "$FLOAT_VERSION" ]; then
1244 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1246 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1249 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1251 if [ -n "$TNEWVER" ]; then
1252 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1253 echo "New version found, updating spec file to version " $TNEWVER
1254 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1255 cp -f $SPECFILE $SPECFILE.bak
1258 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1259 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1261 NODIST="yes" get_files $SOURCES $PATCHES
1264 unset TOLDVER TNEWVER TNOTIFY
1271 BUILD_SWITCH="-ba" ;;
1273 BUILD_SWITCH="-bb" ;;
1275 BUILD_SWITCH="-bs --nodeps" ;;
1277 BUILD_SWITCH="-bp --nodeps" ;;
1279 BUILD_SWITCH="-bc" ;;
1281 BUILD_SWITCH="-bi" ;;
1283 BUILD_SWITCH="-bl" ;;
1287 update_shell_title "build_package: $COMMAND"
1288 if [ -n "$LOGFILE" ]; then
1289 LOG=`eval echo $LOGFILE`
1290 if [ -d "$LOG" ]; then
1291 echo "Log file $LOG is a directory."
1292 echo "Parse error in the spec?"
1293 Exit_error err_build_fail
1295 if [ -n "$LASTLOG_FILE" ]; then
1296 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1298 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1299 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1300 RETVAL=`cat $RES_FILE`
1302 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1303 if [ "$RETVAL" -eq "0" ]; then
1310 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1313 if [ "$RETVAL" -ne "0" ]; then
1314 if [ -n "$TRY_UPGRADE" ]; then
1315 echo "\n!!! Package with new version cannot be built automagically\n"
1316 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1317 mv -f $SPECFILE.bak $SPECFILE
1320 Exit_error err_build_fail
1327 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1330 install_required_packages()
1337 # taken from find-spec-bcond, but with just getting the list
1339 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1341 /^%changelog/ { exit }
1342 /_with(out)?_[_a-zA-Z0-9]+/{
1343 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1344 print substr($0, RSTART, RLENGTH);
1347 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1348 bcond = substr($0, RSTART +5 , RLENGTH -5);
1349 gsub(/[ \t]+/,"_",bcond);
1351 }' $SPEC | LC_ALL=C sort -u
1355 # expand bconds from ~/.bcondrc
1356 # The file structure is like gentoo's package.use:
1359 # samba -mysql -pgsql
1360 # w32codec-installer license_agreement
1363 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1369 SN=${SPECFILE%%\.spec}
1371 local bcondrc=$HOME/.bcondrc
1372 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1374 local bcond_avail=$(find_spec_bcond $SPECFILE)
1376 while read pkg flags; do
1378 [[ "$pkg" == \#* ]] && continue
1380 # any package or current package?
1381 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1382 for flag in $flags; do
1383 local opt=${flag#[+-]}
1385 # use only flags which are in this package.
1386 if [[ $bcond_avail = *${opt}* ]]; then
1387 if [[ $flag = -* ]]; then
1388 if [[ $BCOND != *--with?${opt}* ]]; then
1389 BCOND="$BCOND --without $opt"
1392 if [[ $BCOND != *--without?${opt}* ]]; then
1393 BCOND="$BCOND --with $opt"
1400 update_shell_title "parse ~/.bcondrc: DONE!"
1405 update_shell_title "set bcond values"
1407 AVAIL_BCONDS_WITHOUT=""
1408 AVAIL_BCONDS_WITH=""
1409 if `grep -q ^%bcond ${SPECFILE}`; then
1411 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1417 local bcond_avail=$(find_spec_bcond $SPECFILE)
1418 process_bcondrc "$SPECFILE"
1420 update_shell_title "parse bconds"
1421 case "${BCOND_VERSION}" in
1426 echo "Warning: This spec has old style bconds. Fix it || die."
1427 for opt in `echo "$bcond_avail" | grep ^_without_`
1429 AVAIL_BCOND_WITHOUT=${opt#_without_}
1430 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1431 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1433 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1437 for opt in `echo "$bcond_avail" | grep ^_with_`
1439 AVAIL_BCOND_WITH=${opt#_with_}
1440 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1441 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1443 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1448 local cond_type="" # with || without
1449 for opt in $bcond_avail; do
1458 AVAIL_BCOND_WITHOUT=${opt#_without_}
1459 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1460 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1462 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1466 AVAIL_BCOND_WITH=${opt#_with_}
1467 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1468 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1470 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1474 case "$cond_type" in
1477 AVAIL_BCOND_WITH="$opt"
1478 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1479 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1481 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1486 AVAIL_BCOND_WITHOUT="$opt"
1487 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1488 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1490 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1504 update_shell_title "run_sub_builder $package_name"
1506 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1507 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1508 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1509 # jakby nie bylo tego kawalka kodu.
1511 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1512 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1519 # Istnieje taki spec? ${package}.spec
1520 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1521 parent_spec_name=${package}.spec
1522 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1523 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1525 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1531 if [ "${parent_spec_name}" != "" ]; then
1532 spawn_sub_builder $parent_spec_name
1534 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1540 update_shell_title "spawn_sub_builder $package_name"
1543 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1544 sub_builder_opts="${sub_builder_opts} -R"
1546 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1547 sub_builder_opts="${sub_builder_opts} -RB"
1548 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1549 sub_builder_opts="${sub_builder_opts} -FRB"
1551 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1552 sub_builder_opts="${sub_builder_opts} -Upi"
1556 ./builder ${sub_builder_opts} "$@"
1559 remove_build_requires()
1561 if [ "$INSTALLED_PACKAGES" != "" ]; then
1562 case "$REMOVE_BUILD_REQUIRES" in
1564 run_poldek --noask -ve $INSTALLED_PACKAGES
1567 run_poldek --ask -ve $INSTALLED_PACKAGES
1570 echo You may want to manually remove following BuildRequires fetched:
1571 echo $INSTALLED_PACKAGES
1572 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1580 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1581 if [ "$BCOND" != "" ]; then
1582 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1585 echo -ne "\nNo conditional flags passed"
1587 echo -ne "\n\nfrom available:\n"
1588 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1594 if [ "$NOCVSSPEC" != "yes" ]; then
1595 echo -ne "Available branches: "
1596 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1600 # checks a given list of packages/files/provides agains current rpmdb.
1601 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1602 # input can be either STDIN or parameters
1607 if [ "$#" -gt 0 ]; then
1613 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1616 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1618 # other deps (files)
1619 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1622 # checks if given package/files/provides exists in rpmdb.
1623 # inout can be either stdin or parameters
1624 # returns packages wchi hare present in the rpmdb
1629 if [ "$#" -gt 0 ]; then
1635 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1638 fetch_build_requires()
1640 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1641 update_shell_title "fetch build requires"
1642 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1643 # TODO: Conflicts list doesn't check versions
1644 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1645 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1647 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1648 echo "fetch builderequires: install [$DEPS]; remove [$CNFL]"
1649 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1650 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1652 if [ -n "$CNFL" ]; then
1653 update_shell_title "uninstall conflicting packages: $CNFL"
1654 echo "Trying to uninstall conflicting packages ($CNFL):"
1655 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1658 while [ "$DEPS" ]; do
1659 update_shell_title "install deps: $DEPS"
1660 echo "Trying to install dependencies ($DEPS):"
1661 local log=.${SPECFILE}_poldek.log
1662 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1663 failed=$(awk -F: '/^error:/{print $2}' $log)
1666 if [ -n "$failed" ]; then
1667 for package in $failed; do
1668 # FIXME: sanitise, deps could be not .spec files
1669 spawn_sub_builder -bb $package && ok="$ok $package"
1679 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1680 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1681 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1682 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1683 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1684 for package_item in `cat $SPECFILE|grep -B100000 ^%changelog|grep -v ^#|grep BuildRequires|grep -v ^-|sed -e "s/^.*BuildRequires://g"|awk '{print $1}'|sed -e s,perl\(,perl-,g -e s,::,-,g -e s,\(.*\),,g -e s,%{,,g -e s,},,g|grep -v OpenGL-devel|sed -e s,sh-utils,coreutils,g -e s,fileutils,coreutils,g -e s,textutils,coreutils,g -e s,kgcc_package,gcc,g -e s,\),,g`
1686 package_item="`echo $package_item|sed -e s,rpmbuild,rpm-build,g |sed -e s,__perl,perl,g |sed -e s,gasp,binutils-gasp,g -e s,binutils-binutils,binutils,g -e s,apxs,apache,g|sed -e s,apache\(EAPI\)-devel,apache-devel,g -e s,kernel-headers\(netfilter\),kernel-headers,g -e s,awk,mawk,g -e s,mmawk,mawk,g -e s,motif,openmotif,g -e s,openopenmotif,openmotif,g`"
1688 package=`basename "$package_item"|sed -e "s/}$//g"`
1689 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1692 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1693 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1694 if [ "$COND_ARCH_TST" != "" ] && [ "`echo $COND_ARCH_TST|sed -e "s/i.86/ix86/g"`" != "`echo $mach|sed -e "s/i.86/ix86/g"`" ]; then
1699 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1702 if `echo $COND_TST|grep -q 'without_'`; then
1703 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1704 if `echo $COND_TST|grep -q !`; then
1709 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1710 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1711 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1717 elif `echo $COND_TST|grep -q 'with_'`; then
1718 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1719 if `echo $COND_TST|grep -q !`; then
1724 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1725 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1726 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1732 RESULT="${COND_STATE}-${COND_ARGV}"
1734 "with-wout" | "wout-with" )
1737 "wout-wout" | "with-with" )
1741 echo "Action '$RESULT' was not defined for package '$package_item'"
1747 if [ "$GO" = "yes" ]; then
1748 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1749 echo "Testing if $package has subrequirements..."
1750 run_poldek -t -i $package --dumpn=".$package-req.txt"
1751 if [ -f ".$package-req.txt" ]; then
1752 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1754 if [ "$package_name" = "$package" ]; then
1755 echo -ne "Installing BuildRequired package:\t$package_name\n"
1756 update_shell_title "Installing BuildRequired package: ${package_name}"
1757 install_required_packages $package
1759 echo -ne "Installing (sub)Required package:\t$package_name\n"
1760 update_shell_title "Installing (sub)Required package: ${package_name}"
1761 install_required_packages $package_name
1765 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1766 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1769 echo "Attempting to run spawn sub - builder..."
1770 echo -ne "Package installation failed:\t$package_name\n"
1771 run_sub_builder $package_name
1772 if [ $? -eq 0 ]; then
1773 install_required_packages $package_name
1776 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1777 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1780 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1787 rm -f ".$package-req.txt"
1789 echo "Attempting to run spawn sub - builder..."
1790 echo -ne "Package installation failed:\t$package\n"
1791 run_sub_builder $package
1792 if [ $? -eq 0 ]; then
1793 install_required_packages $package
1796 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1797 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1800 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1806 echo "Package $package is already installed. BuildRequirement satisfied."
1810 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1811 echo "Unable to install following packages and their dependencies:"
1812 for pkg in "$NOT_INSTALLED_PACKAGES"
1816 remove_build_requires
1824 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1825 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1827 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1829 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1833 echo "To checkout *all* .spec files:"
1834 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1835 echo "- run cvs up in $SPECS_DIR dir"
1838 echo "To commit with your developer account:"
1839 echo "- edit $SPECS_DIR/CVS/Root"
1840 echo "- edit $SOURCE_DIR/CVS/Root"
1843 get_greed_sources() {
1844 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1845 if [ -n "BE_VERBOSE" ]; then
1846 echo "Try greed download: $1 from: $CVSROOT"
1848 cvs -d $CVSROOT get SOURCES/$1
1849 if [ $? != 0 ]; then
1850 Exit_error err_no_source_in_repo $1
1855 #---------------------------------------------
1863 while [ $# -gt 0 ]; do
1866 COMMAND="update_md5"
1871 COMMAND="update_md5"
1881 DEBUG="yes"; shift ;;
1883 COMMAND="version"; shift ;;
1885 COMMAND="short-version"; shift ;;
1887 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1888 -b | -ba | --build )
1889 COMMAND="build"; shift ;;
1890 -bb | --build-binary )
1891 COMMAND="build-binary"; shift ;;
1893 COMMAND="build-build"; shift ;;
1895 COMMAND="build-install"; shift ;;
1897 COMMAND="build-list"; shift ;;
1898 -bp | --build-prep )
1899 COMMAND="build-prep"; shift ;;
1900 -bs | --build-source )
1901 COMMAND="build-source"; shift ;;
1903 COMMAND="branch"; shift; TAG="${1}"; shift;;
1905 CLEAN="--clean --rmspec --rmsource"; shift ;;
1907 CVS_FORCE="-F"; shift;;
1909 shift; CVSROOT="${1}"; shift ;;
1911 COMMAND="get"; shift ;;
1913 COMMAND="usage"; shift ;;
1915 PROTOCOL="http"; shift ;;
1917 shift; LOGFILE="${1}"; shift ;;
1919 shift; DEF_NICE_LEVEL=${1}; shift ;;
1920 -ske | --skip-existing-files)
1921 SKIP_EXISTING_FILES="yes"; shift ;;
1923 COMMAND="mr-proper"; shift ;;
1925 NOCVS="yes"; shift ;;
1926 -ncs | --no-cvs-specs )
1927 NOCVSSPEC="yes"; shift ;;
1928 -nd | --no-distfiles )
1929 NODIST="yes"; shift ;;
1930 -nm | --no-mirrors )
1931 NOMIRRORS="yes"; shift ;;
1933 NOURLS="yes"; shift ;;
1935 NOSRCS="yes"; shift ;;
1936 -ns0 | --no-source0 )
1937 NOSOURCE0="yes"; shift ;;
1947 -pm | --prefer-mirrors )
1954 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
1956 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1957 --with | --without )
1958 case $GROUP_BCONDS in
1962 while ! `echo ${1}|grep -qE '(^-|spec)'`
1964 BCOND="$BCOND $COND $1"
1968 if [[ "$2" = *,* ]]; then
1969 for a in $(echo "$2" | tr , ' '); do
1970 BCOND="$BCOND $1 $a"
1973 BCOND="$BCOND $1 $2"
1979 shift; TARGET="${1}"; shift ;;
1981 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1983 QUIET="--quiet"; shift ;;
1985 CVSDATE="${2}"; shift 2 ;;
1987 shift; CVSTAG="${1}"; shift ;;
1989 shift; CVSTAG="HEAD"; ;;
1990 -R | --fetch-build-requires)
1991 FETCH_BUILD_REQUIRES="yes"
1992 NOT_INSTALLED_PACKAGES=
1994 -RB | --remove-build-requires)
1995 REMOVE_BUILD_REQUIRES="nice"
1997 -FRB | --force-remove-build-requires)
1998 REMOVE_BUILD_REQUIRES="force"
2000 -sc | --sources-cvs)
2001 COMMAND="list-sources-cvs"
2003 -sd | --sources-distfiles)
2004 COMMAND="list-sources-distfiles"
2006 -sdp | --sources-distfiles-paths)
2007 COMMAND="list-sources-distfiles-paths"
2009 -sf | --sources-files)
2010 COMMAND="list-sources-files"
2012 -sp | --sources-paths)
2013 COMMAND="list-sources-local-paths"
2015 -su | --sources-urls)
2016 COMMAND="list-sources-urls"
2018 -Tvs | --tag-version-stable )
2023 -Ts | --tag-stable )
2028 -Tv | --tag-version )
2033 -Tp | --tag-prefix )
2045 -ir | --integer-release-only )
2046 INTEGER_RELEASE="yes"
2049 COMMAND="update_md5"
2054 -Upi | --update-poldek-indexes )
2055 UPDATE_POLDEK_INDEXES="yes"
2058 COMMAND="init_rpm_dir"
2060 --use-greed-sources )
2063 -u | --try-upgrade )
2064 TRY_UPGRADE="1"; shift ;;
2065 -un | --try-upgrade-with-float-version )
2066 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2068 BE_VERBOSE="1"; shift ;;
2073 if echo "${MACRO}" | grep -q '\W'; then
2074 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2078 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2082 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2085 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2086 COMMAND="show_bconds"
2090 COMMAND="show_bcond_args"
2095 RPMOPTS="${RPMOPTS} --nodeps"
2098 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2101 Exit_error err_invalid_cmdline "$1"
2105 # check if specname was passed as specname:cvstag
2106 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2107 CVSTAG="${SPECFILE##*:}"
2108 SPECFILE="${SPECFILE%%:*}"
2110 ASSUMED_NAME="$(basename ${SPECFILE%%.spec})"
2115 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2116 CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2117 if [ "$CVSTAG" ]; then
2118 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2120 elif [ "$CVSTAG" = "HEAD" ]; then
2121 # assume -r HEAD is same as -A
2125 if [ -n "$DEBUG" ]; then
2130 if [ -n "$TARGET" ]; then
2133 TARGET_SWITCH="--target $TARGET" ;;
2135 TARGET_SWITCH="--target=$TARGET" ;;
2139 if [ "$SCHEDTOOL" != "no" ]; then
2140 NICE_COMMAND="$SCHEDTOOL"
2142 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2145 update_shell_title "$COMMAND"
2149 if [ -n "$SPECFILE" ]; then
2150 get_spec > /dev/null
2158 if [ -n "$SPECFILE" ]; then
2159 get_spec > /dev/null
2165 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2167 if [ -n "$SPECFILE" ]; then
2173 if [ "$COMMAND" != "build-source" ]; then
2176 fetch_build_requires
2177 if [ "$INTEGER_RELEASE" = "yes" ]; then
2178 echo "Checking release $PACKAGE_RELEASE..."
2179 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2180 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2184 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2185 if [ -n "$TEST_TAG" ]; then
2186 # - do not allow utf8 encoded specs on AC-branch
2187 if [ "$CVSTAG" = "AC-branch-disabled" ]; then
2189 t=$(grep '^Summary(.*\.UTF-8):' $SPECFILE)
2191 Exit_error err_acl_deny "UTF-8 .specs not allowed on $CVSTAG"
2195 local TAGVER=`make_tagver`
2196 echo "Searching for tag $TAGVER..."
2197 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2198 if [ -n "$TAGREL" ]; then
2199 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2202 # - do not allow to build from HEAD when XX-branch exists
2203 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2204 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2205 TAG_BRANCH="${TREE_PREFIX}-branch"
2206 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2207 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2208 Exit_error err_branch_exists "$TAG_STATUS"
2214 if [ -n "$NOSOURCE0" ] ; then
2215 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2217 get_files $SOURCES $PATCHES
2220 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2221 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2223 remove_build_requires
2225 Exit_error err_no_spec_in_cmdl
2230 if [ -n "$SPECFILE" ]; then
2233 # don't fetch sources from remote locations
2235 for file in $SOURCES; do
2236 [ -n "`src_md5 $file`" ] && continue
2237 new_SOURCES="$new_SOURCES $file"
2239 SOURCES="$new_SOURCES"
2240 get_files $SOURCES $PATCHES
2242 branch_files $TAG $SOURCES $PATCHES $ICONS
2244 Exit_error err_no_spec_in_cmdl
2249 if [ -n "$SPECFILE" ]; then
2253 if [ -n "$NOSOURCE0" ] ; then
2254 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2256 get_files $SOURCES $PATCHES
2259 Exit_error err_no_spec_in_cmdl
2264 if [ -n "$SPECFILE" ]; then
2268 if [ -n "$NOSOURCE0" ] ; then
2269 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2273 Exit_error err_no_spec_in_cmdl
2280 if [ -n "$SPECFILE" ]; then
2284 # don't fetch sources from remote locations
2286 for file in $SOURCES; do
2287 [ -n "`src_md5 $file`" ] && continue
2288 new_SOURCES="$new_SOURCES $file"
2290 SOURCES="$new_SOURCES"
2291 get_files $SOURCES $PATCHES
2293 tag_files $SOURCES $PATCHES $ICONS
2295 Exit_error err_no_spec_in_cmdl
2299 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2301 "list-sources-files" )
2304 DONT_PRINT_REVISION="yes"
2307 for SAP in $SOURCES $PATCHES; do
2308 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2311 "list-sources-urls" )
2314 DONT_PRINT_REVISION="yes"
2317 SAPS="$SOURCES $PATCHES"
2318 for SAP in $SAPS ; do
2322 "list-sources-local-paths" )
2325 DONT_PRINT_REVISION="yes"
2328 for SAP in $SOURCES $PATCHES; do
2329 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2332 "list-sources-distfiles-paths" )
2335 DONT_PRINT_REVISION="yes"
2338 for SAP in $SOURCES $PATCHES; do
2339 if [ -n "$(src_md5 "$SAP")" ]; then
2340 distfiles_path "$SAP"
2344 "list-sources-distfiles" )
2347 DONT_PRINT_REVISION="yes"
2350 for SAP in $SOURCES $PATCHES; do
2351 if [ -n "$(src_md5 "$SAP")" ]; then
2352 distfiles_url "$SAP"
2356 "list-sources-cvs" )
2359 DONT_PRINT_REVISION="yes"
2362 for SAP in $SOURCES $PATCHES; do
2363 if [ -z "$(src_md5 "$SAP")" ]; then
2364 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2378 echo "$VERSIONSTRING"
2381 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2382 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2386 # vi:syntax=sh:ts=4:sw=4:noet