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 if [ -n "$BE_VERBOSE" ]; then
302 echo >&2 "$(date +%s.%N) $*"
305 msg="builder[$SPECFILE] ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
308 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
311 echo >&2 -ne "\033]0;$msg\007"
316 # set TARGET from BuildArch: from SPECFILE
318 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
319 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
324 TARGET_SWITCH="--target $TARGET" ;;
326 TARGET_SWITCH="--target=$TARGET" ;;
333 if [ -n "$DEBUG" ]; then
338 update_shell_title "cache_rpm_dump"
342 # we reset macros not to contain macros.build as all the %() macros are
343 # executed here, while none of them are actually needed.
344 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
345 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
346 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
347 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
348 # FIXME: better ideas than .rpmrc?
349 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .rpmrc
350 # TODO: move these to /usr/lib/rpm/macros
351 cat > .rpmmacros <<'EOF'
352 %requires_releq_kernel_up %{nil}
353 %requires_releq_kernel_smp %{nil}
354 %requires_releq() %{nil}
355 %pyrequires_eq() %{nil}
356 %requires_eq() %{nil}
357 %requires_eq_to() %{nil}
358 %releq_kernel_up ERROR
359 %releq_kernel_smp ERROR
363 %ruby_ver_requires_eq() %{nil}
364 %ruby_mod_ver_requires_eq() %{nil}
365 %__php_api_requires() %{nil}
366 %php_major_version ERROR
367 %php_api_version ERROR
375 ARGS='--nodigest --nosignature --nobuild'
378 $RPMBUILD --rcfile .rpmrc $ARGS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
380 if [ $? -gt 0 ]; then
381 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
383 Exit_error err_build_fail;
386 # make small dump cache
387 rpm_dump_cache=`echo "$rpm_dump" | awk '
388 $2 ~ /^SOURCEURL/ {print}
389 $2 ~ /^PATCHURL/ {print}
390 $2 ~ /^nosource/ {print}
391 $2 ~ /^PACKAGE_/ {print}
394 update_shell_title "cache_rpm_dump: OK!"
398 if [ -z "$rpm_dump_cache" ] ; then
399 echo "internal error: cache_rpm_dump not called!" 1>&2
401 echo "$rpm_dump_cache"
406 update_shell_title "get icons"
407 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
408 if [ -z "$ICONS" ]; then
412 rpm_dump_cache="böö" NODIST="yes" UPDATE5= get_files $ICONS
417 update_shell_title "parsing specfile"
418 if [ -n "$DEBUG" ]; then
423 # icons are needed for successful spec parse
429 if [ "$NOSRCS" != "yes" ]; then
430 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
433 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
434 FAIL_IF_NO_SOURCES="no"
437 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
438 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
439 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
440 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
441 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
443 if [ -n "$BE_VERBOSE" ]; then
444 echo "- Sources : `nourl $SOURCES`"
445 if [ -n "$PATCHES" ]; then
446 echo "- Patches : `nourl $PATCHES`"
448 echo "- Patches : *no patches needed*"
450 if [ -n "$ICONS" ]; then
451 echo "- Icon : `nourl $ICONS`"
453 echo "- Icon : *no package icon*"
455 echo "- Name : $PACKAGE_NAME"
456 echo "- Version : $PACKAGE_VERSION"
457 echo "- Release : $PACKAGE_RELEASE"
460 update_shell_title "parse_spec: OK!"
465 if [ -n "$DEBUG" ]; then
473 "err_no_spec_in_cmdl" )
474 remove_build_requires
475 echo "ERROR: spec file name not specified.";
477 "err_no_spec_in_repo" )
478 remove_build_requires
479 echo "Error: spec file not stored in CVS repo.";
481 "err_no_source_in_repo" )
482 remove_build_requires
483 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
486 remove_build_requires
487 echo "Error: package build failed. (${2:-no more info})";
489 "err_no_package_data" )
490 remove_build_requires
491 echo "Error: couldn't get out package name/version/release from spec file."
494 remove_build_requires
495 echo "Tag ${2} already exists (spec release: ${3}).";
498 remove_build_requires
499 echo "Release ${2} not integer and not a snapshot.";
501 "err_branch_exists" )
502 remove_build_requires
503 echo "Tree branch already exists (${2}).";
507 echo "Unknown error."
513 if [ -n "$DEBUG" ]; then
518 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
519 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
527 update_shell_title "get_spec"
529 if [ -n "$DEBUG" ]; then
535 if [ ! -f "$SPECFILE" ]; then
536 SPECFILE="`basename $SPECFILE .spec`.spec";
538 if [ "$NOCVSSPEC" != "yes" ]; then
540 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
541 echo "Warning: No CVS access defined - using local .spec file"
545 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
548 if [ ! -f "$SPECFILE" ]; then
549 Exit_error err_no_spec_in_repo;
552 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
553 chmod $CHMOD_MODE $SPECFILE
556 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
565 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
566 cvs update mirrors >&2
570 while read origin mirror name rest
572 ol=`echo -n "$origin"|wc -c`
573 prefix="`echo -n "$url" | head -c $ol`"
574 if [ "$prefix" = "$origin" ] ; then
575 suffix="`echo "$url"|cut -b $ol-`"
576 echo -n "$mirror$suffix"
587 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
588 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
594 [ X"$NO5" = X"yes" ] && return
596 [ -z "$no" ] && return
598 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
599 if [ -z "$spec_rev" ]; then
600 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
602 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
603 md5=$(grep -s -v '^#' additional-md5sums | \
604 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
605 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
606 grep -E '^[0-9a-f]{32}$')
607 if [ X"$md5" = X"" ] ; then
608 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
609 if [ ! -z "$source_md5" ] ; then
612 # we have empty SourceX-md5, but it is still possible
613 # that we have NoSourceX-md5 AND NoSource: X
614 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
615 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
620 if [ $(echo "$md5" | wc -l) != 1 ] ; then
621 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
623 echo "$md5" | tail -n 1
629 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
632 distfiles_attic_url ()
634 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
641 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
646 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
647 [ -n "$size" -a "$size" -gt 0 ]
652 if [ "$CVSIGNORE_DF" != "yes" ]; then
655 cvsignore=${SOURCE_DIR}/.cvsignore
656 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
657 echo "$1" >> $cvsignore
663 update_shell_title "cvsup"
665 if [ -n "$CVSROOT" ]; then
666 OPTIONS="-d $CVSROOT $OPTIONS"
669 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
670 OPTIONS="$OPTIONS -A"
672 if [ -n "$CVSDATE" ]; then
673 OPTIONS="$OPTIONS -D $CVSDATE"
675 if [ -n "$CVSTAG" ]; then
676 OPTIONS="$OPTIONS -r $CVSTAG"
681 local retries_counter=0
683 update_shell_title "cvsup: $*"
685 update_shell_title "cvsup: $# files"
687 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
688 retries_counter=$(( $retries_counter + 1 ))
689 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
691 [ -n "$output" ] && echo "$output"
692 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
693 echo "Trying again [$*]... ($retries_counter)"
694 update_shell_title "cvsup: retry #$retries_counter"
701 update_shell_title "cvsup: done!"
707 update_shell_title "get_files"
709 if [ -n "$DEBUG" ]; then
714 if [ $# -gt 0 ]; then
717 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
718 echo "Warning: No CVS access defined for SOURCES"
723 local get_files_cvs=""
727 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
728 update_shell_title "$i"
729 local fp=`nourl "$i"`
730 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
733 if [ -n "$UPDATE5" ]; then
734 if [ -n "$ADD5" ]; then
735 [ "$fp" = "$i" ] && continue
736 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
738 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
742 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
743 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
744 echo "Warning: no URL given for $i"
747 if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then
748 if good_md5 "$i" && good_size "$i"; then
749 echo "$(nourl "$i") having proper md5sum already exists"
753 url=$(distfiles_url "$i")
754 url_attic=$(distfiles_attic_url "$i")
756 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
757 update_shell_title "${GETLOCAL%% *}: $url"
758 ${GETLOCAL} $url $target
760 if [ -z "$NOMIRRORS" ]; then
761 url="`find_mirror "$url"`"
763 update_shell_title "${GETURI%% *}: $url"
764 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
765 if [ "`echo $url | grep -E 'ftp://'`" ]; then
766 update_shell_title "${GETURI2%% *}: $url"
767 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
770 if ! test -s "$target"; then
772 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
773 update_shell_title "${GETLOCAL%% *}: $url_attic"
774 ${GETLOCAL} $url_attic $target
776 if [ -z "$NOMIRRORS" ]; then
777 url_attic="`find_mirror "$url_attic"`"
779 update_shell_title "${GETURI%% *}: $url_attic"
780 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
781 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
782 update_shell_title "${GETURI2%% *}: $url_attic"
783 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
787 if test -s "$target"; then
793 elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then
794 if [ $# -gt 1 ]; then
795 get_files_cvs="$get_files_cvs $fp"
796 update_shell_title "$fp (will cvs up later)"
803 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
804 if [ -z "$NOMIRRORS" ]; then
805 im="`find_mirror "$i"`"
809 update_shell_title "${GETURI%% *}: $im"
811 if [ "`echo $im | grep -E 'ftp://'`" ]; then
812 update_shell_title "${GETURI2%% *}: $im"
817 if [ "$cvsup" = 1 ]; then
823 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
824 Exit_error err_no_source_in_repo $i;
825 elif [ -n "$UPDATE5" ] && \
826 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
827 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
828 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
830 echo "Updating source-$srcno md5."
831 md5=$(md5sum "$fp" | cut -f1 -d' ')
833 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
834 print "# Source'$srcno'-md5:\t'$md5'\n"
835 if /^Source'$srcno'\s*:\s+/;
840 if good_md5 "$i" && good_size "$i"; then
842 elif [ "$FROM_DISTFILES" = 1 ]; then
843 # wrong md5 from distfiles: remove the file and try again
845 echo "MD5 sum mismatch. Trying full fetch."
848 update_shell_title "${GETURI%% *}: $url"
849 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
850 if [ "`echo $url | grep -E 'ftp://'`" ]; then
851 update_shell_title "${GETURI2%% *}: $url"
852 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
854 if ! test -s "$target"; then
856 update_shell_title "${GETURI%% *}: $url_attic"
857 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
858 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
859 update_shell_title "${GETURI2%% *}: $url_attic"
860 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
863 test -s "$target" || rm -f "$target"
866 if good_md5 "$i" && good_size "$i" ; then
869 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
870 echo "or -5 to update md5 sums, if you're sure files are correct."
871 Exit_error err_no_source_in_repo $i
874 SHELL_TITLE_PREFIX=""
876 if [ "$get_files_cvs" ]; then
880 if [ "$CHMOD" = "yes" ]; then
881 CHMOD_FILES="`nourl "$@"`"
882 if [ -n "$CHMOD_FILES" ]; then
883 chmod $CHMOD_MODE $CHMOD_FILES
891 if [ -n "$DEBUG" ]; then
896 # Check whether first character of PACKAGE_NAME is legal for tag name
897 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
900 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"`
901 # Remove #kernel.version_release from TAGVER because tagging sources
902 # could occur with different kernel-headers than kernel-headers used at build time.
903 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
911 if [ -n "$DEBUG" ]; then
916 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
917 echo "Version: $PACKAGE_VERSION"
918 echo "Release: $PACKAGE_RELEASE"
922 if [ "$TAG_VERSION" = "yes" ]; then
923 echo "CVS tag: $TAGVER"
925 if [ -n "$TAG" ]; then
930 if [ -n "$CVSROOT" ]; then
931 OPTIONS="-d $CVSROOT $OPTIONS"
937 # don't tag files stored on distfiles
938 [ -n "`src_md5 $i`" ] && continue
939 if [ -f "`nourl $i`" ]; then
940 if [ "$TAG_VERSION" = "yes" ]; then
941 cvs $OPTIONS $TAGVER `nourl $i`
943 if [ -n "$TAG" ]; then
944 cvs $OPTIONS $TAG `nourl $i`
947 Exit_error err_no_source_in_repo $i
952 if [ "$TAG_VERSION" = "yes" ]; then
953 cvs $OPTIONS $TAGVER $SPECFILE
955 if [ -n "$TAG" ]; then
956 cvs $OPTIONS $TAG $SPECFILE
966 echo "CVS branch tag: $TAG"
971 if [ -n "$DEBUG" ]; then
976 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
979 if [ -n "$CVSROOT" ]; then
980 OPTIONS="-d $CVSROOT $OPTIONS"
985 if [ -f `nourl $i` ]; then
986 cvs $OPTIONS $TAG `nourl $i`
988 Exit_error err_no_source_in_repo $i
992 cvs $OPTIONS $TAG $SPECFILE
1002 update_shell_title "build_package"
1003 if [ -n "$DEBUG" ]; then
1010 if [ -n "$TRY_UPGRADE" ]; then
1011 update_shell_title "build_package: try_upgrade"
1012 if [ -n "$FLOAT_VERSION" ]; then
1013 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1015 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1018 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1020 if [ -n "$TNEWVER" ]; then
1021 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1022 echo "New version found, updating spec file to version " $TNEWVER
1023 cp -f $SPECFILE $SPECFILE.bak
1025 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1026 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1028 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1029 unset TOLDVER TNEWVER TNOTIFY
1036 BUILD_SWITCH="-ba" ;;
1038 BUILD_SWITCH="-bb" ;;
1040 BUILD_SWITCH="-bs --nodeps" ;;
1042 BUILD_SWITCH="-bp --nodeps" ;;
1045 update_shell_title "build_package: $COMMAND"
1046 if [ -n "$LOGFILE" ]; then
1047 LOG=`eval echo $LOGFILE`
1048 if [ -d "$LOG" ]; then
1049 echo "Log file $LOG is a directory."
1050 echo "Parse error in the spec?"
1051 Exit_error err_build_fail;
1053 if [ -n "$LASTLOG_FILE" ]; then
1054 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1056 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1057 (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
1058 RETVAL=`cat $RES_FILE`
1060 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1061 if [ "$RETVAL" -eq "0" ]; then
1068 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
1071 if [ "$RETVAL" -ne "0" ]; then
1072 if [ -n "$TRY_UPGRADE" ]; then
1073 echo "\n!!! Package with new version cannot be build automagically\n"
1074 mv -f $SPECFILE.bak $SPECFILE
1076 Exit_error err_build_fail;
1083 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1086 install_required_packages()
1093 # taken from find-spec-bcond, but with just getting the list
1095 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1097 /^%changelog/ { exit }
1098 /_with(out)?_[_a-zA-Z0-9]+/{
1099 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1100 print substr($0, RSTART, RLENGTH);
1103 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1104 bcond = substr($0, RSTART +5 , RLENGTH -5);
1105 gsub(/[ \t]+/,"_",bcond);
1107 }' $SPEC | LC_ALL=C sort -u
1112 update_shell_title "set bcond values"
1114 AVAIL_BCONDS_WITHOUT=""
1115 AVAIL_BCONDS_WITH=""
1116 if `grep -q ^%bcond ${SPECFILE}`; then
1118 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1124 local bcond_avail=$(find_spec_bcond $SPECFILE)
1126 # expand bconds from ~/.bcondrc
1127 # The file structure is like gentoo's package.use:
1130 # samba -mysql -pgsql
1131 # w32codec-installer license_agreement
1134 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1135 SN=${SPECFILE%%\.spec}
1137 local bcondrc=$HOME/.bcondrc
1138 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1140 while read pkg flags; do
1142 [[ "$pkg" == \#* ]] && continue
1144 # any package or current package?
1145 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1146 for flag in $flags; do
1147 local opt=${flag#[+-]}
1149 # use only flags which are in this package.
1150 if [[ $bcond_avail = *${opt}* ]]; then
1151 if [[ $flag = -* ]]; then
1152 BCOND="$BCOND --without $opt"
1154 BCOND="$BCOND --with $opt"
1160 update_shell_title "parse ~/.bcondrc: DONE!"
1163 update_shell_title "parse bconds"
1164 case "${BCOND_VERSION}" in
1169 echo "Warning: This spec has old style bconds. Fix it || die."
1170 for opt in `echo "$bcond_avail" | grep ^_without_`
1172 AVAIL_BCOND_WITHOUT=${opt#_without_}
1173 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1174 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1176 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1180 for opt in `echo "$bcond_avail" | grep ^_with_`
1182 AVAIL_BCOND_WITH=${opt#_with_}
1183 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1184 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1186 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1191 local cond_type="" # with || without
1192 for opt in $bcond_avail; do
1201 AVAIL_BCOND_WITHOUT=${opt#_without_}
1202 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1203 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1205 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1209 AVAIL_BCOND_WITH=${opt#_with_}
1210 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1211 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1213 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1217 case "$cond_type" in
1220 AVAIL_BCOND_WITH="$opt"
1221 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1222 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1224 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1229 AVAIL_BCOND_WITHOUT="$opt"
1230 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1231 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1233 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1247 update_shell_title "run_sub_builder $package_name"
1249 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1250 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1251 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1252 # jakby nie bylo tego kawalka kodu.
1254 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1255 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1262 # Istnieje taki spec? ${package}.spec
1263 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1264 parent_spec_name=${package}.spec
1265 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1266 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1268 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1274 if [ "${parent_spec_name}" != "" ]; then
1275 spawn_sub_builder $parent_spec_name
1277 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1283 update_shell_title "spawn_sub_builder $package_name"
1286 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1287 sub_builder_opts="${sub_builder_opts} -R"
1289 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1290 sub_builder_opts="${sub_builder_opts} -RB"
1291 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1292 sub_builder_opts="${sub_builder_opts} -FRB"
1294 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1295 sub_builder_opts="${sub_builder_opts} -Upi"
1299 ./builder ${sub_builder_opts} "$@"
1302 remove_build_requires()
1304 if [ "$INSTALLED_PACKAGES" != "" ]; then
1305 case "$REMOVE_BUILD_REQUIRES" in
1307 run_poldek --noask -ve $INSTALLED_PACKAGES
1310 run_poldek --ask -ve $INSTALLED_PACKAGES
1313 echo You may want to manually remove following BuildRequires fetched:
1314 echo $INSTALLED_PACKAGES
1315 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1323 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1324 if [ "$BCOND" != "" ]; then
1325 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1328 echo -ne "\nNo conditional flags passed"
1330 echo -ne "\n\nfrom available:\n"
1331 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1337 if [ "$NOCVSSPEC" != "yes" ]; then
1338 echo -ne "Available branches: "
1339 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1343 # checks a given list of packages/files/provides agains current rpmdb.
1344 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1345 # input can be either STDIN or parameters
1350 if [ "$#" -gt 0 ]; then
1356 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1359 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1361 # other deps (files)
1362 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1365 # checks if given package/files/provides exists in rpmdb.
1366 # inout can be either stdin or parameters
1367 # returns packages wchi hare present in the rpmdb
1372 if [ "$#" -gt 0 ]; then
1378 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1381 fetch_build_requires()
1383 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1384 update_shell_title "fetch build requires"
1385 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1386 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1387 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1389 update_shell_title "poldek: update indexes"
1390 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1391 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1393 if [ -n "$CONF" ]; then
1394 update_shell_title "uninstall conflicting packages: $CONF"
1395 echo "Trying to uninstall conflicting packages ($CONF):"
1396 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1399 while [ "$DEPS" ]; do
1400 update_shell_title "install deps: $DEPS"
1401 echo "Trying to install dependencies ($DEPS):"
1402 local log=.${SPECFILE}_poldek.log
1403 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1404 failed=$(awk -F: '/^error:/{print $2}' $log)
1407 if [ -n "$failed" ]; then
1408 for package in $failed; do
1409 # FIXME: sanitise, deps could be not .spec files
1410 spawn_sub_builder -bb $package && ok="$ok $package"
1420 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1421 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1422 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1423 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1424 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1425 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`
1427 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`"
1429 package=`basename "$package_item"|sed -e "s/}$//g"`
1430 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1433 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1434 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1435 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
1440 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1443 if `echo $COND_TST|grep -q 'without_'`; then
1444 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1445 if `echo $COND_TST|grep -q !`; then
1450 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1451 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1452 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1458 elif `echo $COND_TST|grep -q 'with_'`; then
1459 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1460 if `echo $COND_TST|grep -q !`; then
1465 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1466 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1467 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1473 RESULT="${COND_STATE}-${COND_ARGV}"
1475 "with-wout" | "wout-with" )
1478 "wout-wout" | "with-with" )
1482 echo "Action '$RESULT' was not defined for package '$package_item'"
1488 if [ "$GO" = "yes" ]; then
1489 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1490 echo "Testing if $package has subrequirements..."
1491 run_poldek -t -i $package --dumpn=".$package-req.txt"
1492 if [ -f ".$package-req.txt" ]; then
1493 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1495 if [ "$package_name" = "$package" ]; then
1496 echo -ne "Installing BuildRequired package:\t$package_name\n"
1497 update_shell_title "Installing BuildRequired package: ${package_name}"
1498 install_required_packages $package;
1500 echo -ne "Installing (sub)Required package:\t$package_name\n"
1501 update_shell_title "Installing (sub)Required package: ${package_name}"
1502 install_required_packages $package_name;
1506 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1507 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1510 echo "Attempting to run spawn sub - builder..."
1511 echo -ne "Package installation failed:\t$package_name\n"
1512 run_sub_builder $package_name
1513 if [ $? -eq 0 ]; then
1514 install_required_packages $package_name;
1517 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1518 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1521 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1528 rm -f ".$package-req.txt"
1530 echo "Attempting to run spawn sub - builder..."
1531 echo -ne "Package installation failed:\t$package\n"
1532 run_sub_builder $package
1533 if [ $? -eq 0 ]; then
1534 install_required_packages $package;
1537 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1538 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1541 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1547 echo "Package $package is already installed. BuildRequirement satisfied."
1551 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1552 echo "Unable to install following packages and their dependencies:"
1553 for pkg in "$NOT_INSTALLED_PACKAGES"
1557 remove_build_requires
1563 #---------------------------------------------
1566 if [ "$#" = 0 ]; then
1592 DEBUG="yes"; shift ;;
1594 COMMAND="version"; shift ;;
1596 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1597 -b | -ba | --build )
1598 COMMAND="build"; shift ;;
1599 -bb | --build-binary )
1600 COMMAND="build-binary"; shift ;;
1601 -bs | --build-source )
1602 COMMAND="build-source"; shift ;;
1603 -bp | --build-prep )
1604 COMMAND="build-prep"; shift ;;
1606 COMMAND="branch"; shift; TAG="${1}"; shift;;
1608 CLEAN="--clean --rmspec --rmsource"; shift ;;
1610 shift; CVSROOT="${1}"; shift ;;
1612 COMMAND="get"; shift ;;
1614 COMMAND="usage"; shift ;;
1616 PROTOCOL="http"; shift ;;
1618 shift; LOGFILE="${1}"; shift ;;
1620 shift; DEF_NICE_LEVEL=${1}; shift ;;
1621 -ske | --skip-existing-files)
1622 SKIP_EXISTING_FILES="yes"; shift ;;
1624 COMMAND="mr-proper"; shift ;;
1626 NOCVS="yes"; shift ;;
1627 -ncs | --no-cvs-specs )
1628 NOCVSSPEC="yes"; shift ;;
1629 -nd | --no-distfiles )
1630 NODIST="yes"; shift ;;
1631 -nm | --no-mirrors )
1632 NOMIRRORS="yes"; shift ;;
1634 NOURLS="yes"; shift ;;
1636 NOSRCS="yes"; shift ;;
1637 -ns0 | --no-source0 )
1638 NOSOURCE0="yes"; shift ;;
1649 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1651 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1652 --with | --without )
1653 case $GROUP_BCONDS in
1657 while ! `echo ${1}|grep -qE '(^-|spec)'`
1659 BCOND="$BCOND $COND $1"
1663 if [[ "$2" = *,* ]]; then
1664 for a in $(echo "$2" | tr , ' '); do
1665 BCOND="$BCOND $1 $a"
1668 BCOND="$BCOND $1 $2"
1674 shift; TARGET="${1}"; shift ;;
1676 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1678 QUIET="--quiet"; shift ;;
1680 CVSDATE="${2}"; shift 2 ;;
1682 shift; CVSTAG="${1}"; shift ;;
1683 -R | --fetch-build-requires)
1684 FETCH_BUILD_REQUIRES="yes"
1685 NOT_INSTALLED_PACKAGES=
1687 -RB | --remove-build-requires)
1688 REMOVE_BUILD_REQUIRES="nice"
1690 -FRB | --force-remove-build-requires)
1691 REMOVE_BUILD_REQUIRES="force"
1693 -sf | --sources-files)
1694 COMMAND="list-sources-files"
1696 -sp | --sources-paths)
1697 COMMAND="list-sources-local-paths"
1699 -su | --sources-urls)
1700 COMMAND="list-sources-urls"
1702 -Tvs | --tag-version-stable )
1707 -Tvn | --tag-version-nest )
1712 -Ts | --tag-stable )
1722 -Tv | --tag-version )
1727 -Tp | --tag-prefix )
1739 -ir | --integer-release-only )
1740 INTEGER_RELEASE="yes"
1749 -Upi | --update-poldek-indexes )
1750 UPDATE_POLDEK_INDEXES="yes"
1752 -u | --try-upgrade )
1753 TRY_UPGRADE="1"; shift ;;
1754 -un | --try-upgrade-with-float-version )
1755 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1757 BE_VERBOSE="1"; shift ;;
1763 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1765 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1771 RPMOPTS="${RPMOPTS} --nodeps"
1774 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1777 # check if specname was passed as specname:cvstag
1778 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1779 CVSTAG="${SPECFILE##*:}";
1780 SPECFILE="${SPECFILE%%:*}";
1786 if [ -n "$DEBUG" ]; then
1791 if [ -n "$TARGET" ]; then
1794 TARGET_SWITCH="--target $TARGET" ;;
1796 TARGET_SWITCH="--target=$TARGET" ;;
1800 update_shell_title "$COMMAND"
1802 "build" | "build-binary" | "build-source" | "build-prep" )
1804 if [ -n "$SPECFILE" ]; then
1810 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1811 fetch_build_requires;
1812 if [ "$INTEGER_RELEASE" = "yes" ]; then
1813 echo "Checking release $PACKAGE_RELEASE..."
1814 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1815 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1819 if [ -n "$TEST_TAG" ]; then
1820 TAGVER=`make_tagver`
1821 echo "Searching for tag $TAGVER..."
1822 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1823 if [ -n "$TAGREL" ]; then
1824 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1827 # - do not allow to build from HEAD when XX-branch exists
1828 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1829 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1830 TAG_BRANCH="${TREE_PREFIX}-branch"
1831 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1832 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1833 Exit_error err_branch_exists "$TAG_STATUS"
1839 if [ -n "$NOSOURCE0" ] ; then
1840 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1842 get_files $SOURCES $PATCHES;
1844 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1845 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1847 remove_build_requires;
1849 Exit_error err_no_spec_in_cmdl;
1854 if [ -n "$SPECFILE" ]; then
1857 get_files $SOURCES $PATCHES;
1858 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1860 Exit_error err_no_spec_in_cmdl;
1865 if [ -n "$SPECFILE" ]; then
1869 if [ -n "$NOSOURCE0" ] ; then
1870 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1872 get_files $SOURCES $PATCHES
1874 Exit_error err_no_spec_in_cmdl;
1881 if [ -n "$SPECFILE" ]; then
1885 # don't fetch sources from remote locations
1887 for file in $SOURCES
1889 [ -n "`src_md5 $file`" ] && continue
1890 new_SOURCES="$new_SOURCES $file"
1892 SOURCES="$new_SOURCES"
1893 get_files $SOURCES $PATCHES;
1894 tag_files "$SOURCES $PATCHES $ICONS";
1896 Exit_error err_no_spec_in_cmdl;
1900 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1902 "list-sources-files" )
1905 DONT_PRINT_REVISION="yes"
1908 SAPS="$SOURCES $PATCHES"
1909 for SAP in $SAPS ; do
1910 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1913 "list-sources-urls" )
1916 DONT_PRINT_REVISION="yes"
1919 SAPS="$SOURCES $PATCHES"
1920 for SAP in $SAPS ; do
1924 "list-sources-local-paths" )
1927 DONT_PRINT_REVISION="yes"
1930 SAPS="$SOURCES $PATCHES"
1931 for SAP in $SAPS ; do
1932 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1940 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1941 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1945 # vi:syntax=sh:ts=4:sw=4