7 # 2 - no spec file name in cmdl parameters
8 # 3 - spec file not stored in repo
9 # 4 - some source, patch or icon files not stored in repo
10 # 5 - package build failed
11 # 6 - spec file with errors
12 # 7 - wrong source in /etc/poldek.conf
13 # 8 - Failed installing buildrequirements and subrequirements
14 # 9 - Requested tag already exist
15 # 10 - Refused to build fractional release
16 # 100 - Unknown error (should not happen)
19 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
20 # - when Icon: field is present, -5 and -a5 doesn't work
21 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
24 Build package utility from PLD Linux CVS repository
25 v0.14 (C) 1999-2006 Free Penguins".
26 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
44 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
47 # It can be used i.e. in log file naming.
48 # See LOGFILE example.
49 DATE=`date +%Y-%m-%d_%H-%M-%S`
51 # Example: LOGFILE='../log.$PACKAGE_NAME'
52 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
53 # Yes, you can use variable name! Note _single_ quotes!
75 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
76 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
81 CVS_SERVER="cvs.pld-linux.org"
82 DISTFILES_SERVER="://distfiles.pld-linux.org"
83 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
87 FAIL_IF_NO_SOURCES="yes"
89 # let get_files skip over files which are present to get those damn files fetched
90 SKIP_EXISTING_FILES="no"
92 if [ -x /usr/bin/rpm-getdeps ]; then
93 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
95 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
98 # Here we load saved user environment used to
99 # predefine options set above, or passed to builder
101 # This one reads global system environment settings:
102 if [ -f ~/etc/builderrc ]; then
105 # And this one cascades settings using user personal
107 # Example of ~/.builderrc:
109 #UPDATE_POLDEK_INDEXES="yes"
110 #FETCH_BUILD_REQUIRES="yes"
111 #REMOVE_BUILD_REQUIRES="force"
113 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
116 if [ -n "$HOME_ETC" ]; then
117 USER_CFG="$HOME_ETC/.builderrc"
119 USER_CFG=~/.builderrc
122 [ -f "$USER_CFG" ] && . "$USER_CFG"
124 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
126 if [ -n "$USE_PROZILLA" ]; then
127 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
130 elif [ -n "$USE_AXEL" ]; then
131 GETURI="axel -a $AXEL_OPTS"
135 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
136 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
138 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
139 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
145 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
153 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
154 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
158 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
159 if [ -n "$LOGFILE" ]; then
160 LOG=`eval echo $LOGFILE`
161 if [ -n "$LASTLOG_FILE" ]; then
162 echo "LASTLOG=$LOG" > $LASTLOG_FILE
164 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
167 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
168 return `cat ${RES_FILE}`
173 #---------------------------------------------
178 if [ -n "$DEBUG" ]; then set -xv; fi
180 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
182 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
183 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
184 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
185 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
186 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
187 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
188 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
189 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
190 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
192 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
193 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
194 -n5, --no-md5 - ignore md5 comments in spec
195 -D, --debug - enable builder script debugging mode,
196 -debug - produce rpm debug package (same as --opts -debug)
197 -V, --version - output builder version
198 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
199 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
201 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
202 only package from <package>.spec,
203 -bp, --build-prep - execute the %prep phase of <package>.spec,
204 -bc - reserved (not implemented)
205 -bi reserved (not implemented)
206 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
208 --short-circuit - reserved (not implemented)
209 -B, --branch - add branch
210 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
211 SPECS and \$RPM_BUILD_ROOT),
212 -d <cvsroot>, --cvsroot <cvsroot>
214 --define <macro> <value>
215 - define a macro <macro> with value <value>,
216 --nodeps - rpm won't check any dependences
217 -g, --get - get <package>.spec and all related files from CVS repo
219 -h, --help - this message,
220 --http - use http instead of ftp,
221 -l <logfile>, --logtofile <logfile>
223 -m, --mr-proper - only remove all files related to spec file and all work
225 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
227 - don't check specs in CVS
228 -nd, --no-distfiles - don't download from distfiles
229 -nm, --no-mirrors - don't download from mirror, if source URL is given,
230 -nu, --no-urls - don't try to download from FTP/HTTP location,
231 -ns, --no-srcs - don't download Sources
232 -ns0, --no-source0 - don't download Source0
233 -nn, --no-net - don't download anything from the net
235 --skip-existing-files - skip existing files in get_files
236 --opts <rpm opts> - additional options for rpm
237 -q, --quiet - be quiet,
238 --date yyyy-mm-dd - build package using resources from specified CVS date,
239 -r <cvstag>, --cvstag <cvstag>
240 - build package using resources from specified CVS tag,
241 -R, --fetch-build-requires
242 - fetch what is BuildRequired,
243 -RB, --remove-build-requires
244 - remove all you fetched with -R or --fetch-build-requires
245 remember, this option requires confirmation,
246 -FRB, --force-remove-build-requires
247 - remove all you fetched with -R or --fetch-build-requires
248 remember, this option works without confirmation,
249 -sf, --source-files - list sources - bare filenames (intended for offline
250 operations; does not work when Icon field is present
251 but icon file is absent),
252 -sp, --source-paths - list sources - filenames with full local paths (intended for
253 offline operations; does not work when Icon field is present
254 but icon file is absent),
255 -su, --source-urls - list urls - urls to sources and patches
256 intended for copying urls with spec with lots of macros in urls
257 -T <cvstag> , --tag <cvstag>
258 - add cvs tag <cvstag> for files,
259 -Tvs, --tag-version-stable
260 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
261 -Tvn, --tag-version-nest
262 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
264 - add cvs tag STABLE for files,
266 - add cvs tag NEST for files,
268 - add cvs tag NAME-VERSION-RELEASE for files,
269 -Tp, --tag-prefix <prefix>
270 - add <prefix> to NAME-VERSION-RELEASE tags,
271 -tt, --test-tag <prefix>
272 - fail if tag is already present,
273 -ir, --integer-release-only
274 - allow only integer and snapshot releases
275 -v, --verbose - be verbose,
276 -u, --try-upgrade - check version, and try to upgrade package
277 -un, --try-upgrade-with-float-version
278 - as above, but allow float version
279 -U, --update - refetch sources, don't use distfiles, and update md5 comments
280 -Upi, --update-poldek-indexes
281 - refresh or make poldek package index files.
282 -np, --nopatch <patchnumber>
283 - don't apply <patchnumber>
284 --show-bconds - show available conditional builds, which can be used
285 - with --with and/or --without switches.
286 --with/--without <feature>
287 - conditional build package depending on %_with_<feature>/
288 %_without_<feature> macro switch. You may now use
289 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
290 constructions. Set GROUP_BCONDS to yes to make use of it.
291 --target <platform>, --target=<platform>
292 - build for platform <platform>.
296 update_shell_title() {
298 local len=${COLUMNS:-80}
299 local msg=$(echo "$*" | cut -c-$len)
301 echo >&2 "$(date +%s.%N) $*"
302 msg="builder[$SPECFILE] ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
305 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
308 echo >&2 -ne "\033]0;$msg\007"
313 # set TARGET from BuildArch: from SPECFILE
315 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
316 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
321 TARGET_SWITCH="--target $TARGET" ;;
323 TARGET_SWITCH="--target=$TARGET" ;;
330 if [ -n "$DEBUG" ]; then
335 update_shell_title "cache_rpm_dump"
337 # we reset macros not to contain macros.build as all the %() macros are
338 # executed here, while none of them are actually needed
339 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
340 # macros.build + macros contained at the time of this writing 70 %() macros
341 local macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
342 local dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
343 # FIXME: better ideas than .rpmrc?
344 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .rpmrc
345 # TODO: move these to /usr/lib/rpm/macros
346 cat > .rpmmacros <<'EOF'
347 %requires_releq_kernel_up %{nil}
348 %requires_releq_kernel_smp %{nil}
349 %pyrequires_eq() %{nil}
350 %releq_kernel_up ERROR
351 %releq_kernel_smp ERROR
355 rpm --rcfile .rpmrc -bp --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
358 rpmbuild --rcfile .rpmrc --nodigest --nodeps --nosignature --nobuild --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
361 if [ $? -gt 0 ]; then
362 echo "$rpm_dump_cache" | sed -ne '/^error:/,$p' >&2
363 Exit_error err_build_fail;
365 update_shell_title "cache_rpm_dump: OK!"
369 if [ -z "$rpm_dump_cache" ] ; then
370 echo "internal error: cache_rpm_dump not called!" 1>&2
372 echo "$rpm_dump_cache"
377 update_shell_title "parsing specfile"
378 if [ -n "$DEBUG" ]; then
386 if [ "$NOSRCS" != "yes" ]; then
387 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
390 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
391 FAIL_IF_NO_SOURCES="no"
394 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
395 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
396 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
397 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
398 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
400 if [ -n "$BE_VERBOSE" ]; then
401 echo "- Sources : `nourl $SOURCES`"
402 if [ -n "$PATCHES" ]; then
403 echo "- Patches : `nourl $PATCHES`"
405 echo "- Patches : *no patches needed*"
407 if [ -n "$ICONS" ]; then
408 echo "- Icon : `nourl $ICONS`"
410 echo "- Icon : *no package icon*"
412 echo "- Name : $PACKAGE_NAME"
413 echo "- Version : $PACKAGE_VERSION"
414 echo "- Release : $PACKAGE_RELEASE"
417 update_shell_title "parse_spec: OK!"
422 if [ -n "$DEBUG" ]; then
430 "err_no_spec_in_cmdl" )
431 remove_build_requires
432 echo "ERROR: spec file name not specified.";
434 "err_no_spec_in_repo" )
435 remove_build_requires
436 echo "Error: spec file not stored in CVS repo.";
438 "err_no_source_in_repo" )
439 remove_build_requires
440 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
443 remove_build_requires
444 echo "Error: package build failed. (${2:-no more info})";
446 "err_no_package_data" )
447 remove_build_requires
448 echo "Error: couldn't get out package name/version/release from spec file."
451 remove_build_requires
452 echo "Tag ${2} already exists (spec release: ${3}).";
455 remove_build_requires
456 echo "Release ${2} not integer and not a snapshot.";
458 "err_branch_exists" )
459 remove_build_requires
460 echo "Tree branch already exists (${2}).";
464 echo "Unknown error."
470 if [ -n "$DEBUG" ]; then
475 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
476 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
484 update_shell_title "get_spec"
486 if [ -n "$DEBUG" ]; then
492 if [ ! -f "$SPECFILE" ]; then
493 SPECFILE="`basename $SPECFILE .spec`.spec";
495 if [ "$NOCVSSPEC" != "yes" ]; then
497 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
498 echo "Warning: No CVS access defined - using local .spec file"
502 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
505 if [ ! -f "$SPECFILE" ]; then
506 Exit_error err_no_spec_in_repo;
509 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
510 chmod $CHMOD_MODE $SPECFILE
513 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
522 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
523 cvs update mirrors >&2
527 while read origin mirror name rest
529 ol=`echo -n "$origin"|wc -c`
530 prefix="`echo -n "$url" | head -c $ol`"
531 if [ "$prefix" = "$origin" ] ; then
532 suffix="`echo "$url"|cut -b $ol-`"
533 echo -n "$mirror$suffix"
544 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
545 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
551 [ X"$NO5" = X"yes" ] && return
553 [ -z "$no" ] && return
555 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
556 if [ -z "$spec_rev" ]; then
557 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
559 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
560 md5=$(grep -s -v '^#' additional-md5sums | \
561 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
562 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
563 grep -E '^[0-9a-f]{32}$')
564 if [ X"$md5" = X"" ] ; then
565 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
566 if [ ! -z "$source_md5" ] ; then
569 # we have empty SourceX-md5, but it is still possible
570 # that we have NoSourceX-md5 AND NoSource: X
571 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
572 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
577 if [ $(echo "$md5" | wc -l) != 1 ] ; then
578 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
580 echo "$md5" | tail -n 1
586 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
589 distfiles_attic_url ()
591 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
598 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
603 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
604 [ -n "$size" -a "$size" -gt 0 ]
609 if [ "$CVSIGNORE_DF" != "yes" ]; then
612 cvsignore=${SOURCE_DIR}/.cvsignore
613 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
614 echo "$1" >> $cvsignore
620 update_shell_title "cvsup"
622 if [ -n "$CVSROOT" ]; then
623 OPTIONS="-d $CVSROOT $OPTIONS"
626 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
627 OPTIONS="$OPTIONS -A"
629 if [ -n "$CVSDATE" ]; then
630 OPTIONS="$OPTIONS -D $CVSDATE"
632 if [ -n "$CVSTAG" ]; then
633 OPTIONS="$OPTIONS -r $CVSTAG"
638 local retries_counter=0
639 update_shell_title "cvsup: $# files"
640 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
641 retries_counter=$(( $retries_counter + 1 ))
642 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
644 [ -n "$output" ] && echo "$output"
645 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
646 echo "Trying again [$*]... ($retries_counter)"
647 update_shell_title "cvsup: retry #$retries_counter"
654 update_shell_title "cvsup: done!"
660 update_shell_title "get_files"
662 if [ -n "$DEBUG" ]; then
667 if [ $# -gt 0 ]; then
670 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
671 echo "Warning: No CVS access defined for SOURCES"
676 local get_files_cvs=""
680 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
681 update_shell_title "$i"
682 local fp=`nourl "$i"`
683 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
686 if [ -n "$UPDATE5" ]; then
687 if [ -n "$ADD5" ]; then
688 [ "$fp" = "$i" ] && continue
689 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
691 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
695 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
696 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
697 echo "Warning: no URL given for $i"
700 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
701 if good_md5 "$i" && good_size "$i"; then
702 echo "$(nourl "$i") having proper md5sum already exists"
706 url=$(distfiles_url "$i")
707 url_attic=$(distfiles_attic_url "$i")
709 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
710 update_shell_title "${GETLOCAL%% *}: $url"
711 ${GETLOCAL} $url $target
713 if [ -z "$NOMIRRORS" ]; then
714 url="`find_mirror "$url"`"
716 update_shell_title "${GETURI%% *}: $url"
717 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
718 if [ "`echo $url | grep -E 'ftp://'`" ]; then
719 update_shell_title "${GETURI2%% *}: $url"
720 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
723 if ! test -s "$target"; then
725 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
726 update_shell_title "${GETLOCAL%% *}: $url_attic"
727 ${GETLOCAL} $url_attic $target
729 if [ -z "$NOMIRRORS" ]; then
730 url_attic="`find_mirror "$url_attic"`"
732 update_shell_title "${GETURI%% *}: $url_attic"
733 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
734 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
735 update_shell_title "${GETURI2%% *}: $url_attic"
736 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
740 if test -s "$target"; then
746 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
747 get_files_cvs="$get_files_cvs $fp"
748 update_shell_title "$fp (will cvs up later)"
752 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
753 if [ -z "$NOMIRRORS" ]; then
754 im="`find_mirror "$i"`"
758 update_shell_title "${GETURI%% *}: $im"
760 if [ "`echo $im | grep -E 'ftp://'`" ]; then
761 update_shell_title "${GETURI2%% *}: $im"
766 if [ "$cvsup" = 1 ]; then
772 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
773 Exit_error err_no_source_in_repo $i;
774 elif [ -n "$UPDATE5" ] && \
775 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
776 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
777 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
779 echo "Updating source-$srcno md5."
780 md5=$(md5sum "$fp" | cut -f1 -d' ')
782 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
783 print "# Source'$srcno'-md5:\t'$md5'\n"
784 if /^Source'$srcno'\s*:\s+/;
789 if good_md5 "$i" && good_size "$i"; then
791 elif [ "$FROM_DISTFILES" = 1 ]; then
792 # wrong md5 from distfiles: remove the file and try again
794 echo "MD5 sum mismatch. Trying full fetch."
797 update_shell_title "${GETURI%% *}: $url"
798 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
799 if [ "`echo $url | grep -E 'ftp://'`" ]; then
800 update_shell_title "${GETURI2%% *}: $url"
801 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
803 if ! test -s "$target"; then
805 update_shell_title "${GETURI%% *}: $url_attic"
806 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
807 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
808 update_shell_title "${GETURI2%% *}: $url_attic"
809 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
812 test -s "$target" || rm -f "$target"
815 if good_md5 "$i" && good_size "$i" ; then
818 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
819 echo "or -5 to update md5 sums, if you're sure files are correct."
820 Exit_error err_no_source_in_repo $i
823 SHELL_TITLE_PREFIX=""
825 if [ "$get_files_cvs" ]; then
829 if [ "$CHMOD" = "yes" ]; then
830 CHMOD_FILES="`nourl "$@"`"
831 if [ -n "$CHMOD_FILES" ]; then
832 chmod $CHMOD_MODE $CHMOD_FILES
840 if [ -n "$DEBUG" ]; then
845 # Check whether first character of PACKAGE_NAME is legal for tag name
846 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
849 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"`
850 # Remove #kernel.version_release from TAGVER because tagging sources
851 # could occur with different kernel-headers than kernel-headers used at build time.
852 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
860 if [ -n "$DEBUG" ]; then
865 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
866 echo "Version: $PACKAGE_VERSION"
867 echo "Release: $PACKAGE_RELEASE"
871 if [ "$TAG_VERSION" = "yes" ]; then
872 echo "CVS tag: $TAGVER"
874 if [ -n "$TAG" ]; then
879 if [ -n "$CVSROOT" ]; then
880 OPTIONS="-d $CVSROOT $OPTIONS"
886 # don't tag files stored on distfiles
887 [ -n "`src_md5 $i`" ] && continue
888 if [ -f "`nourl $i`" ]; then
889 if [ "$TAG_VERSION" = "yes" ]; then
890 cvs $OPTIONS $TAGVER `nourl $i`
892 if [ -n "$TAG" ]; then
893 cvs $OPTIONS $TAG `nourl $i`
896 Exit_error err_no_source_in_repo $i
901 if [ "$TAG_VERSION" = "yes" ]; then
902 cvs $OPTIONS $TAGVER $SPECFILE
904 if [ -n "$TAG" ]; then
905 cvs $OPTIONS $TAG $SPECFILE
915 echo "CVS branch tag: $TAG"
920 if [ -n "$DEBUG" ]; then
925 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
928 if [ -n "$CVSROOT" ]; then
929 OPTIONS="-d $CVSROOT $OPTIONS"
934 if [ -f `nourl $i` ]; then
935 cvs $OPTIONS $TAG `nourl $i`
937 Exit_error err_no_source_in_repo $i
941 cvs $OPTIONS $TAG $SPECFILE
951 update_shell_title "build_package"
952 if [ -n "$DEBUG" ]; then
959 if [ -n "$TRY_UPGRADE" ]; then
960 update_shell_title "build_package: try_upgrade"
961 if [ -n "$FLOAT_VERSION" ]; then
962 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
964 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
967 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
969 if [ -n "$TNEWVER" ]; then
970 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
971 echo "New version found, updating spec file to version " $TNEWVER
972 cp -f $SPECFILE $SPECFILE.bak
974 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
975 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
977 if [ -n "$ICONS" ]; then
981 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
982 unset TOLDVER TNEWVER TNOTIFY
989 BUILD_SWITCH="-ba" ;;
991 BUILD_SWITCH="-bb" ;;
993 BUILD_SWITCH="-bs --nodeps" ;;
995 BUILD_SWITCH="-bp --nodeps" ;;
998 update_shell_title "build_package: $COMMAND"
999 if [ -n "$LOGFILE" ]; then
1000 LOG=`eval echo $LOGFILE`
1001 if [ -d "$LOG" ]; then
1002 echo "Log file $LOG is a directory."
1003 echo "Parse error in the spec?"
1004 Exit_error err_build_fail;
1006 if [ -n "$LASTLOG_FILE" ]; then
1007 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1009 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1010 (time eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1011 RETVAL=`cat $RES_FILE`
1013 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1014 if [ "$RETVAL" -eq "0" ]; then
1021 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
1024 if [ "$RETVAL" -ne "0" ]; then
1025 if [ -n "$TRY_UPGRADE" ]; then
1026 echo "\n!!! Package with new version cannot be build automagically\n"
1027 mv -f $SPECFILE.bak $SPECFILE
1029 Exit_error err_build_fail;
1036 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1039 install_required_packages()
1046 # taken from find-spec-bcond, but with just getting the list
1048 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1050 /^%changelog/ { exit }
1051 /_with(out)?_[_a-zA-Z0-9]+/{
1052 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1053 print substr($0, RSTART, RLENGTH);
1056 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1057 bcond = substr($0, RSTART +5 , RLENGTH -5);
1058 gsub(/[ \t]+/,"_",bcond);
1060 }' $SPEC | LC_ALL=C sort -u
1065 update_shell_title "set bcond values"
1067 AVAIL_BCONDS_WITHOUT=""
1068 AVAIL_BCONDS_WITH=""
1069 if `grep -q ^%bcond ${SPECFILE}`; then
1071 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1077 local bcond_avail=$(find_spec_bcond $SPECFILE)
1079 # expand bconds from ~/.bcondrc
1080 # The file structure is like gentoo's package.use:
1083 # samba -mysql -pgsql
1084 # w32codec-installer license_agreement
1087 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1088 SN=${SPECFILE%%\.spec}
1090 local bcondrc=$HOME/.bcondrc
1091 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1093 while read pkg flags; do
1095 [[ "$pkg" == \#* ]] && continue
1097 # any package or current package?
1098 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1099 for flag in $flags; do
1100 local opt=${flag#[+-]}
1102 # use only flags which are in this package.
1103 if [[ $bcond_avail = *${opt}* ]]; then
1104 if [[ $flag = -* ]]; then
1105 BCOND="$BCOND --without $opt"
1107 BCOND="$BCOND --with $opt"
1113 update_shell_title "parse ~/.bcondrc: DONE!"
1116 update_shell_title "parse bconds"
1117 case "${BCOND_VERSION}" in
1122 echo "Warning: This spec has old style bconds. Fix it || die."
1123 for opt in `echo "$bcond_avail" | grep ^_without_`
1125 AVAIL_BCOND_WITHOUT=${opt#_without_}
1126 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1127 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1129 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1133 for opt in `echo "$bcond_avail" | grep ^_with_`
1135 AVAIL_BCOND_WITH=${opt#_with_}
1136 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1137 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1139 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1144 local cond_type="" # with || without
1145 for opt in $bcond_avail; do
1154 AVAIL_BCOND_WITHOUT=${opt#_without_}
1155 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1156 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1158 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1162 AVAIL_BCOND_WITH=${opt#_with_}
1163 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1164 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1166 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1170 case "$cond_type" in
1173 AVAIL_BCOND_WITH="$opt"
1174 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1175 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1177 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1182 AVAIL_BCOND_WITHOUT="$opt"
1183 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1184 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1186 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1200 update_shell_title "run_sub_builder $package_name"
1202 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1203 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1204 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1205 # jakby nie bylo tego kawalka kodu.
1207 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1208 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1215 # Istnieje taki spec? ${package}.spec
1216 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1217 parent_spec_name=${package}.spec
1218 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1219 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1221 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1227 if [ "${parent_spec_name}" != "" ]; then
1228 spawn_sub_builder $parent_spec_name
1230 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1236 update_shell_title "spawn_sub_builder $package_name"
1239 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1240 sub_builder_opts="${sub_builder_opts} -R"
1242 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1243 sub_builder_opts="${sub_builder_opts} -RB"
1244 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1245 sub_builder_opts="${sub_builder_opts} -FRB"
1247 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1248 sub_builder_opts="${sub_builder_opts} -Upi"
1252 ./builder ${sub_builder_opts} "$@"
1255 remove_build_requires()
1257 if [ "$INSTALLED_PACKAGES" != "" ]; then
1258 case "$REMOVE_BUILD_REQUIRES" in
1260 run_poldek --noask -ve $INSTALLED_PACKAGES
1263 run_poldek --ask -ve $INSTALLED_PACKAGES
1266 echo You may want to manually remove following BuildRequires fetched:
1267 echo $INSTALLED_PACKAGES
1268 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1276 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1277 if [ "$BCOND" != "" ]; then
1278 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1281 echo -ne "\nNo conditional flags passed"
1283 echo -ne "\n\nfrom available:\n"
1284 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1290 if [ "$NOCVSSPEC" != "yes" ]; then
1291 echo -ne "Available branches: "
1292 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1296 # checks a given list of packages/files/provides agains current rpmdb.
1297 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1298 # input can be either STDIN or parameters
1303 if [ "$#" -gt 0 ]; then
1309 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1312 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1314 # other deps (files)
1315 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1318 # checks if given package/files/provides exists in rpmdb.
1319 # inout can be either stdin or parameters
1320 # returns packages wchi hare present in the rpmdb
1325 if [ "$#" -gt 0 ]; then
1331 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1334 fetch_build_requires()
1336 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1337 update_shell_title "fetch build requires"
1338 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1339 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1340 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1342 update_shell_title "poldek: update indexes"
1343 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1344 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1346 if [ -n "$CONF" ]; then
1347 update_shell_title "uninstall conflicting packages: $CONF"
1348 echo "Trying to uninstall conflicting packages ($CONF):"
1349 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1352 while [ "$DEPS" ]; do
1353 update_shell_title "install deps: $DEPS"
1354 echo "Trying to install dependencies ($DEPS):"
1355 local log=.${SPECFILE}_poldek.log
1356 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1357 failed=$(awk -F: '/^error:/{print $2}' $log)
1360 if [ -n "$failed" ]; then
1361 for package in $failed; do
1362 # FIXME: sanitise, deps could be not .spec files
1363 spawn_sub_builder -bb $package && ok="$ok $package"
1373 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1374 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1375 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1376 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1377 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1378 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`
1380 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`"
1382 package=`basename "$package_item"|sed -e "s/}$//g"`
1383 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1386 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1387 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1388 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
1393 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1396 if `echo $COND_TST|grep -q 'without_'`; then
1397 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1398 if `echo $COND_TST|grep -q !`; then
1403 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1404 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1405 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1411 elif `echo $COND_TST|grep -q 'with_'`; then
1412 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1413 if `echo $COND_TST|grep -q !`; then
1418 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1419 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1420 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1426 RESULT="${COND_STATE}-${COND_ARGV}"
1428 "with-wout" | "wout-with" )
1431 "wout-wout" | "with-with" )
1435 echo "Action '$RESULT' was not defined for package '$package_item'"
1441 if [ "$GO" = "yes" ]; then
1442 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1443 echo "Testing if $package has subrequirements..."
1444 run_poldek -t -i $package --dumpn=".$package-req.txt"
1445 if [ -f ".$package-req.txt" ]; then
1446 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1448 if [ "$package_name" = "$package" ]; then
1449 echo -ne "Installing BuildRequired package:\t$package_name\n"
1450 update_shell_title "Installing BuildRequired package: ${package_name}"
1451 install_required_packages $package;
1453 echo -ne "Installing (sub)Required package:\t$package_name\n"
1454 update_shell_title "Installing (sub)Required package: ${package_name}"
1455 install_required_packages $package_name;
1459 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1460 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1463 echo "Attempting to run spawn sub - builder..."
1464 echo -ne "Package installation failed:\t$package_name\n"
1465 run_sub_builder $package_name
1466 if [ $? -eq 0 ]; then
1467 install_required_packages $package_name;
1470 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1471 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1474 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1481 rm -f ".$package-req.txt"
1483 echo "Attempting to run spawn sub - builder..."
1484 echo -ne "Package installation failed:\t$package\n"
1485 run_sub_builder $package
1486 if [ $? -eq 0 ]; then
1487 install_required_packages $package;
1490 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1491 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1494 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1500 echo "Package $package is already installed. BuildRequirement satisfied."
1504 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1505 echo "Unable to install following packages and their dependencies:"
1506 for pkg in "$NOT_INSTALLED_PACKAGES"
1510 remove_build_requires
1516 #---------------------------------------------
1519 if [ "$#" = 0 ]; then
1545 DEBUG="yes"; shift ;;
1547 COMMAND="version"; shift ;;
1549 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1550 -b | -ba | --build )
1551 COMMAND="build"; shift ;;
1552 -bb | --build-binary )
1553 COMMAND="build-binary"; shift ;;
1554 -bs | --build-source )
1555 COMMAND="build-source"; shift ;;
1556 -bp | --build-prep )
1557 COMMAND="build-prep"; shift ;;
1559 COMMAND="branch"; shift; TAG="${1}"; shift;;
1561 CLEAN="--clean --rmspec --rmsource"; shift ;;
1563 shift; CVSROOT="${1}"; shift ;;
1565 COMMAND="get"; shift ;;
1567 COMMAND="usage"; shift ;;
1569 PROTOCOL="http"; shift ;;
1571 shift; LOGFILE="${1}"; shift ;;
1573 shift; DEF_NICE_LEVEL=${1}; shift ;;
1574 -ske | --skip-existing-files)
1575 SKIP_EXISTING_FILES="yes"; shift ;;
1577 COMMAND="mr-proper"; shift ;;
1579 NOCVS="yes"; shift ;;
1580 -ncs | --no-cvs-specs )
1581 NOCVSSPEC="yes"; shift ;;
1582 -nd | --no-distfiles )
1583 NODIST="yes"; shift ;;
1584 -nm | --no-mirrors )
1585 NOMIRRORS="yes"; shift ;;
1587 NOURLS="yes"; shift ;;
1589 NOSRCS="yes"; shift ;;
1590 -ns0 | --no-source0 )
1591 NOSOURCE0="yes"; shift ;;
1602 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1604 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1605 --with | --without )
1606 case $GROUP_BCONDS in
1610 while ! `echo ${1}|grep -qE '(^-|spec)'`
1612 BCOND="$BCOND $COND $1"
1616 if [[ "$2" = *,* ]]; then
1617 for a in $(echo "$2" | tr , ' '); do
1618 BCOND="$BCOND $1 $a"
1621 BCOND="$BCOND $1 $2"
1627 shift; TARGET="${1}"; shift ;;
1629 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1631 QUIET="--quiet"; shift ;;
1633 CVSDATE="${2}"; shift 2 ;;
1635 shift; CVSTAG="${1}"; shift ;;
1636 -R | --fetch-build-requires)
1637 FETCH_BUILD_REQUIRES="yes"
1638 NOT_INSTALLED_PACKAGES=
1640 -RB | --remove-build-requires)
1641 REMOVE_BUILD_REQUIRES="nice"
1643 -FRB | --force-remove-build-requires)
1644 REMOVE_BUILD_REQUIRES="force"
1646 -sf | --sources-files)
1647 COMMAND="list-sources-files"
1649 -sp | --sources-paths)
1650 COMMAND="list-sources-local-paths"
1652 -su | --sources-urls)
1653 COMMAND="list-sources-urls"
1655 -Tvs | --tag-version-stable )
1660 -Tvn | --tag-version-nest )
1665 -Ts | --tag-stable )
1675 -Tv | --tag-version )
1680 -Tp | --tag-prefix )
1692 -ir | --integer-release-only )
1693 INTEGER_RELEASE="yes"
1702 -Upi | --update-poldek-indexes )
1703 UPDATE_POLDEK_INDEXES="yes"
1705 -u | --try-upgrade )
1706 TRY_UPGRADE="1"; shift ;;
1707 -un | --try-upgrade-with-float-version )
1708 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1710 BE_VERBOSE="1"; shift ;;
1716 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1718 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1724 RPMOPTS="${RPMOPTS} --nodeps"
1727 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1730 # check if specname was passed as specname:cvstag
1731 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1732 CVSTAG="${SPECFILE##*:}";
1733 SPECFILE="${SPECFILE%%:*}";
1739 if [ -n "$DEBUG" ]; then
1744 if [ -n "$TARGET" ]; then
1747 TARGET_SWITCH="--target $TARGET" ;;
1749 TARGET_SWITCH="--target=$TARGET" ;;
1753 update_shell_title "$COMMAND"
1755 "build" | "build-binary" | "build-source" | "build-prep" )
1757 if [ -n "$SPECFILE" ]; then
1763 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1764 fetch_build_requires;
1765 if [ "$INTEGER_RELEASE" = "yes" ]; then
1766 echo "Checking release $PACKAGE_RELEASE..."
1767 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1768 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1772 if [ -n "$TEST_TAG" ]; then
1773 TAGVER=`make_tagver`
1774 echo "Searching for tag $TAGVER..."
1775 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1776 if [ -n "$TAGREL" ]; then
1777 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1780 # - do not allow to build from HEAD when XX-branch exists
1781 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1782 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1783 TAG_BRANCH="${TREE_PREFIX}-branch"
1784 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1785 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1786 Exit_error err_branch_exists "$TAG_STATUS"
1792 if [ -n "$ICONS" ]; then
1796 if [ -n "$NOSOURCE0" ] ; then
1797 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1799 get_files $SOURCES $PATCHES;
1801 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1802 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1804 remove_build_requires;
1806 Exit_error err_no_spec_in_cmdl;
1811 if [ -n "$SPECFILE" ]; then
1814 if [ -n "$ICONS" ]; then
1818 get_files $SOURCES $PATCHES;
1819 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1821 Exit_error err_no_spec_in_cmdl;
1826 if [ -n "$SPECFILE" ]; then
1829 if [ -n "$ICONS" ]; then
1830 OLD_UPDATE5=$UPDATE5
1831 UPDATE5= get_files $ICONS
1832 UPDATE5=$OLD_UPDATE5
1835 if [ -n "$NOSOURCE0" ] ; then
1836 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1838 get_files $SOURCES $PATCHES
1840 Exit_error err_no_spec_in_cmdl;
1847 if [ -n "$SPECFILE" ]; then
1850 if [ -n "$ICONS" ]; then
1854 # don't fetch sources from remote locations
1856 for file in $SOURCES
1858 [ -n "`src_md5 $file`" ] && continue
1859 new_SOURCES="$new_SOURCES $file"
1861 SOURCES="$new_SOURCES"
1862 get_files $SOURCES $PATCHES;
1863 tag_files "$SOURCES $PATCHES $ICONS";
1865 Exit_error err_no_spec_in_cmdl;
1869 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1871 "list-sources-files" )
1874 DONT_PRINT_REVISION="yes"
1877 SAPS="$SOURCES $PATCHES"
1878 for SAP in $SAPS ; do
1879 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1882 "list-sources-urls" )
1885 DONT_PRINT_REVISION="yes"
1888 SAPS="$SOURCES $PATCHES"
1889 for SAP in $SAPS ; do
1893 "list-sources-local-paths" )
1896 DONT_PRINT_REVISION="yes"
1899 SAPS="$SOURCES $PATCHES"
1900 for SAP in $SAPS ; do
1901 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1909 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1910 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1914 # vi:syntax=sh:ts=4:sw=4