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.15 (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'
117 if [ -n "$HOME_ETC" ]; then
118 USER_CFG="$HOME_ETC/.builderrc"
120 USER_CFG=~/.builderrc
123 [ -f "$USER_CFG" ] && . "$USER_CFG"
125 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
127 if [ -n "$USE_PROZILLA" ]; then
128 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
131 elif [ -n "$USE_AXEL" ]; then
132 GETURI="axel -a $AXEL_OPTS"
136 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
137 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
139 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
140 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
146 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
154 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
155 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
159 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
160 if [ -n "$LOGFILE" ]; then
161 LOG=`eval echo $LOGFILE`
162 if [ -n "$LASTLOG_FILE" ]; then
163 echo "LASTLOG=$LOG" > $LASTLOG_FILE
165 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
168 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
169 return `cat ${RES_FILE}`
174 #---------------------------------------------
179 if [ -n "$DEBUG" ]; then set -xv; fi
181 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
183 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
184 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
185 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
186 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
187 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
188 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
189 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
190 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
191 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
193 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
194 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
195 -n5, --no-md5 - ignore md5 comments in spec
196 -D, --debug - enable builder script debugging mode,
197 -debug - produce rpm debug package (same as --opts -debug)
198 -V, --version - output builder version
199 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
200 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
202 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
203 only package from <package>.spec,
204 -bp, --build-prep - execute the %prep phase of <package>.spec,
205 -bc - reserved (not implemented)
206 -bi reserved (not implemented)
207 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
209 --short-circuit - reserved (not implemented)
210 -B, --branch - add branch
211 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
212 SPECS and \$RPM_BUILD_ROOT),
213 -d <cvsroot>, --cvsroot <cvsroot>
215 --define <macro> <value>
216 - define a macro <macro> with value <value>,
217 --nodeps - rpm won't check any dependences
218 -g, --get - get <package>.spec and all related files from CVS repo
220 -h, --help - this message,
221 --http - use http instead of ftp,
222 -l <logfile>, --logtofile <logfile>
224 -m, --mr-proper - only remove all files related to spec file and all work
226 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
228 - don't check specs in CVS
229 -nd, --no-distfiles - don't download from distfiles
230 -nm, --no-mirrors - don't download from mirror, if source URL is given,
231 -nu, --no-urls - don't try to download from FTP/HTTP location,
232 -ns, --no-srcs - don't download Sources
233 -ns0, --no-source0 - don't download Source0
234 -nn, --no-net - don't download anything from the net
236 --skip-existing-files - skip existing files in get_files
237 --opts <rpm opts> - additional options for rpm
238 -q, --quiet - be quiet,
239 --date yyyy-mm-dd - build package using resources from specified CVS date,
240 -r <cvstag>, --cvstag <cvstag>
241 - build package using resources from specified CVS tag,
242 -R, --fetch-build-requires
243 - fetch what is BuildRequired,
244 -RB, --remove-build-requires
245 - remove all you fetched with -R or --fetch-build-requires
246 remember, this option requires confirmation,
247 -FRB, --force-remove-build-requires
248 - remove all you fetched with -R or --fetch-build-requires
249 remember, this option works without confirmation,
250 -sf, --source-files - list sources - bare filenames (intended for offline
251 operations; does not work when Icon field is present
252 but icon file is absent),
253 -sp, --source-paths - list sources - filenames with full local paths (intended for
254 offline operations; does not work when Icon field is present
255 but icon file is absent),
256 -su, --source-urls - list urls - urls to sources and patches
257 intended for copying urls with spec with lots of macros in urls
258 -T <cvstag> , --tag <cvstag>
259 - add cvs tag <cvstag> for files,
260 -Tvs, --tag-version-stable
261 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
262 -Tvn, --tag-version-nest
263 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
265 - add cvs tag STABLE for files,
267 - add cvs tag NEST for files,
269 - add cvs tag NAME-VERSION-RELEASE for files,
270 -Tp, --tag-prefix <prefix>
271 - add <prefix> to NAME-VERSION-RELEASE tags,
272 -tt, --test-tag <prefix>
273 - fail if tag is already present,
274 -ir, --integer-release-only
275 - allow only integer and snapshot releases
276 -v, --verbose - be verbose,
277 -u, --try-upgrade - check version, and try to upgrade package
278 -un, --try-upgrade-with-float-version
279 - as above, but allow float version
280 -U, --update - refetch sources, don't use distfiles, and update md5 comments
281 -Upi, --update-poldek-indexes
282 - refresh or make poldek package index files.
283 -np, --nopatch <patchnumber>
284 - don't apply <patchnumber>
285 --show-bconds - show available conditional builds, which can be used
286 - with --with and/or --without switches.
287 --with/--without <feature>
288 - conditional build package depending on %_with_<feature>/
289 %_without_<feature> macro switch. You may now use
290 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
291 constructions. Set GROUP_BCONDS to yes to make use of it.
292 --target <platform>, --target=<platform>
293 - build for platform <platform>.
294 --init-rpm-dir - initialize ~/rpm directory structure
298 update_shell_title() {
300 local len=${COLUMNS:-80}
301 local msg=$(echo "$*" | cut -c-$len)
303 if [ -n "$BE_VERBOSE" ]; then
304 echo >&2 "$(date +%s.%N) $*"
307 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
308 msg="builder[$SPECFILE] ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
311 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
314 echo >&2 -ne "\033]0;$msg\007"
320 # set TARGET from BuildArch: from SPECFILE
322 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
323 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
328 TARGET_SWITCH="--target $TARGET" ;;
330 TARGET_SWITCH="--target=$TARGET" ;;
337 if [ -n "$DEBUG" ]; then
342 update_shell_title "cache_rpm_dump"
346 # we reset macros not to contain macros.build as all the %() macros are
347 # executed here, while none of them are actually needed.
348 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
349 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
350 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
351 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
352 # FIXME: better ideas than .rpmrc?
353 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
354 # TODO: move these to /usr/lib/rpm/macros
355 cat > .builder-rpmmacros <<'EOF'
356 %requires_releq_kernel_up %{nil}
357 %requires_releq_kernel_smp %{nil}
358 %requires_releq() %{nil}
359 %pyrequires_eq() %{nil}
360 %requires_eq() %{nil}
361 %requires_eq_to() %{nil}
362 %releq_kernel_up ERROR
363 %releq_kernel_smp ERROR
367 %ruby_ver_requires_eq() %{nil}
368 %ruby_mod_ver_requires_eq() %{nil}
369 %__php_api_requires() %{nil}
370 %php_major_version ERROR
371 %php_api_version ERROR
379 ARGS='--nodigest --nosignature --nobuild'
382 $RPMBUILD --rcfile .builder-rpmrc $ARGS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
384 if [ $? -gt 0 ]; then
385 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
387 Exit_error err_build_fail;
390 # make small dump cache
391 rpm_dump_cache=`echo "$rpm_dump" | awk '
392 $2 ~ /^SOURCEURL/ {print}
393 $2 ~ /^PATCHURL/ {print}
394 $2 ~ /^nosource/ {print}
395 $2 ~ /^PACKAGE_/ {print}
398 update_shell_title "cache_rpm_dump: OK!"
402 if [ -z "$rpm_dump_cache" ] ; then
403 echo "internal error: cache_rpm_dump not called!" 1>&2
405 echo "$rpm_dump_cache"
410 update_shell_title "get icons"
411 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
412 if [ -z "$ICONS" ]; then
416 rpm_dump_cache="böö" NODIST="yes" UPDATE5= get_files $ICONS
421 update_shell_title "parsing specfile"
422 if [ -n "$DEBUG" ]; then
427 # icons are needed for successful spec parse
433 if [ "$NOSRCS" != "yes" ]; then
434 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
437 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
438 FAIL_IF_NO_SOURCES="no"
441 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
442 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
443 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
444 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
445 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
447 if [ -n "$BE_VERBOSE" ]; then
448 echo "- Sources : `nourl $SOURCES`"
449 if [ -n "$PATCHES" ]; then
450 echo "- Patches : `nourl $PATCHES`"
452 echo "- Patches : *no patches needed*"
454 if [ -n "$ICONS" ]; then
455 echo "- Icon : `nourl $ICONS`"
457 echo "- Icon : *no package icon*"
459 echo "- Name : $PACKAGE_NAME"
460 echo "- Version : $PACKAGE_VERSION"
461 echo "- Release : $PACKAGE_RELEASE"
464 update_shell_title "parse_spec: OK!"
469 if [ -n "$DEBUG" ]; then
477 "err_no_spec_in_cmdl" )
478 remove_build_requires
479 echo "ERROR: spec file name not specified.";
481 "err_no_spec_in_repo" )
482 remove_build_requires
483 echo "Error: spec file not stored in CVS repo.";
485 "err_no_source_in_repo" )
486 remove_build_requires
487 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
490 remove_build_requires
491 echo "Error: package build failed. (${2:-no more info})";
493 "err_no_package_data" )
494 remove_build_requires
495 echo "Error: couldn't get out package name/version/release from spec file."
498 remove_build_requires
499 echo "Tag ${2} already exists (spec release: ${3}).";
502 remove_build_requires
503 echo "Release ${2} not integer and not a snapshot.";
505 "err_branch_exists" )
506 remove_build_requires
507 echo "Tree branch already exists (${2}).";
511 echo "Unknown error."
517 if [ -n "$DEBUG" ]; then
522 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
523 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
531 update_shell_title "get_spec"
533 if [ -n "$DEBUG" ]; then
539 if [ ! -f "$SPECFILE" ]; then
540 SPECFILE="`basename $SPECFILE .spec`.spec";
542 if [ "$NOCVSSPEC" != "yes" ]; then
544 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
545 echo "Warning: No CVS access defined - using local .spec file"
549 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
552 if [ ! -f "$SPECFILE" ]; then
553 Exit_error err_no_spec_in_repo;
556 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
557 chmod $CHMOD_MODE $SPECFILE
560 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
569 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
570 cvs update mirrors >&2
574 while read origin mirror name rest
576 ol=`echo -n "$origin"|wc -c`
577 prefix="`echo -n "$url" | head -c $ol`"
578 if [ "$prefix" = "$origin" ] ; then
579 suffix="`echo "$url"|cut -b $ol-`"
580 echo -n "$mirror$suffix"
591 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
592 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
598 [ X"$NO5" = X"yes" ] && return
600 [ -z "$no" ] && return
602 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
603 if [ -z "$spec_rev" ]; then
604 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
606 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
607 md5=$(grep -s -v '^#' additional-md5sums | \
608 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
609 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
610 grep -E '^[0-9a-f]{32}$')
611 if [ X"$md5" = X"" ] ; then
612 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
613 if [ ! -z "$source_md5" ] ; then
616 # we have empty SourceX-md5, but it is still possible
617 # that we have NoSourceX-md5 AND NoSource: X
618 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
619 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
624 if [ $(echo "$md5" | wc -l) != 1 ] ; then
625 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
627 echo "$md5" | tail -n 1
633 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
636 distfiles_attic_url ()
638 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
645 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
650 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
651 [ -n "$size" -a "$size" -gt 0 ]
656 if [ "$CVSIGNORE_DF" != "yes" ]; then
659 cvsignore=${SOURCE_DIR}/.cvsignore
660 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
661 echo "$1" >> $cvsignore
667 update_shell_title "cvsup"
669 if [ -n "$CVSROOT" ]; then
670 OPTIONS="-d $CVSROOT $OPTIONS"
673 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
674 OPTIONS="$OPTIONS -A"
676 if [ -n "$CVSDATE" ]; then
677 OPTIONS="$OPTIONS -D $CVSDATE"
679 if [ -n "$CVSTAG" ]; then
680 OPTIONS="$OPTIONS -r $CVSTAG"
685 local retries_counter=0
687 update_shell_title "cvsup: $*"
689 update_shell_title "cvsup: $# files"
691 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
692 retries_counter=$(( $retries_counter + 1 ))
693 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
695 [ -n "$output" ] && echo "$output"
696 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
697 echo "Trying again [$*]... ($retries_counter)"
698 update_shell_title "cvsup: retry #$retries_counter"
705 update_shell_title "cvsup: done!"
711 update_shell_title "get_files"
713 if [ -n "$DEBUG" ]; then
718 if [ $# -gt 0 ]; then
721 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
722 echo "Warning: No CVS access defined for SOURCES"
727 local get_files_cvs=""
731 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
732 update_shell_title "$i"
733 local fp=`nourl "$i"`
734 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
737 if [ -n "$UPDATE5" ]; then
738 if [ -n "$ADD5" ]; then
739 [ "$fp" = "$i" ] && continue
740 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
742 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
746 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
747 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
748 echo "Warning: no URL given for $i"
751 if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then
752 if good_md5 "$i" && good_size "$i"; then
753 echo "$(nourl "$i") having proper md5sum already exists"
757 url=$(distfiles_url "$i")
758 url_attic=$(distfiles_attic_url "$i")
760 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
761 update_shell_title "${GETLOCAL%% *}: $url"
762 ${GETLOCAL} $url $target
764 if [ -z "$NOMIRRORS" ]; then
765 url="`find_mirror "$url"`"
767 update_shell_title "${GETURI%% *}: $url"
768 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
769 if [ "`echo $url | grep -E 'ftp://'`" ]; then
770 update_shell_title "${GETURI2%% *}: $url"
771 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
774 if ! test -s "$target"; then
776 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
777 update_shell_title "${GETLOCAL%% *}: $url_attic"
778 ${GETLOCAL} $url_attic $target
780 if [ -z "$NOMIRRORS" ]; then
781 url_attic="`find_mirror "$url_attic"`"
783 update_shell_title "${GETURI%% *}: $url_attic"
784 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
785 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
786 update_shell_title "${GETURI2%% *}: $url_attic"
787 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
791 if test -s "$target"; then
797 elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then
798 if [ $# -gt 1 ]; then
799 get_files_cvs="$get_files_cvs $fp"
800 update_shell_title "$fp (will cvs up later)"
807 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
808 if [ -z "$NOMIRRORS" ]; then
809 im="`find_mirror "$i"`"
813 update_shell_title "${GETURI%% *}: $im"
815 if [ "`echo $im | grep -E 'ftp://'`" ]; then
816 update_shell_title "${GETURI2%% *}: $im"
821 if [ "$cvsup" = 1 ]; then
827 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
828 Exit_error err_no_source_in_repo $i;
829 elif [ -n "$UPDATE5" ] && \
830 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
831 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
832 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
834 echo "Updating source-$srcno md5."
835 md5=$(md5sum "$fp" | cut -f1 -d' ')
837 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
838 print "# Source'$srcno'-md5:\t'$md5'\n"
839 if /^Source'$srcno'\s*:\s+/;
844 if good_md5 "$i" && good_size "$i"; then
846 elif [ "$FROM_DISTFILES" = 1 ]; then
847 # wrong md5 from distfiles: remove the file and try again
849 echo "MD5 sum mismatch. Trying full fetch."
852 update_shell_title "${GETURI%% *}: $url"
853 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
854 if [ "`echo $url | grep -E 'ftp://'`" ]; then
855 update_shell_title "${GETURI2%% *}: $url"
856 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
858 if ! test -s "$target"; then
860 update_shell_title "${GETURI%% *}: $url_attic"
861 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
862 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
863 update_shell_title "${GETURI2%% *}: $url_attic"
864 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
867 test -s "$target" || rm -f "$target"
870 if good_md5 "$i" && good_size "$i" ; then
873 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
874 echo "or -5 to update md5 sums, if you're sure files are correct."
875 Exit_error err_no_source_in_repo $i
878 SHELL_TITLE_PREFIX=""
880 if [ "$get_files_cvs" ]; then
884 if [ "$CHMOD" = "yes" ]; then
885 CHMOD_FILES="`nourl "$@"`"
886 if [ -n "$CHMOD_FILES" ]; then
887 chmod $CHMOD_MODE $CHMOD_FILES
895 if [ -n "$DEBUG" ]; then
900 # Check whether first character of PACKAGE_NAME is legal for tag name
901 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
904 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"`
905 # Remove #kernel.version_release from TAGVER because tagging sources
906 # could occur with different kernel-headers than kernel-headers used at build time.
907 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
915 if [ -n "$DEBUG" ]; then
920 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
921 echo "Version: $PACKAGE_VERSION"
922 echo "Release: $PACKAGE_RELEASE"
926 if [ "$TAG_VERSION" = "yes" ]; then
927 echo "CVS tag: $TAGVER"
929 if [ -n "$TAG" ]; then
934 if [ -n "$CVSROOT" ]; then
935 OPTIONS="-d $CVSROOT $OPTIONS"
941 # don't tag files stored on distfiles
942 [ -n "`src_md5 $i`" ] && continue
943 if [ -f "`nourl $i`" ]; then
944 if [ "$TAG_VERSION" = "yes" ]; then
945 cvs $OPTIONS $TAGVER `nourl $i`
947 if [ -n "$TAG" ]; then
948 cvs $OPTIONS $TAG `nourl $i`
951 Exit_error err_no_source_in_repo $i
956 if [ "$TAG_VERSION" = "yes" ]; then
957 cvs $OPTIONS $TAGVER $SPECFILE
959 if [ -n "$TAG" ]; then
960 cvs $OPTIONS $TAG $SPECFILE
970 echo "CVS branch tag: $TAG"
975 if [ -n "$DEBUG" ]; then
980 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
983 if [ -n "$CVSROOT" ]; then
984 OPTIONS="-d $CVSROOT $OPTIONS"
989 if [ -f `nourl $i` ]; then
990 cvs $OPTIONS $TAG `nourl $i`
992 Exit_error err_no_source_in_repo $i
996 cvs $OPTIONS $TAG $SPECFILE
1006 update_shell_title "build_package"
1007 if [ -n "$DEBUG" ]; then
1014 if [ -n "$TRY_UPGRADE" ]; then
1015 update_shell_title "build_package: try_upgrade"
1016 if [ -n "$FLOAT_VERSION" ]; then
1017 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1019 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1022 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1024 if [ -n "$TNEWVER" ]; then
1025 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1026 echo "New version found, updating spec file to version " $TNEWVER
1027 cp -f $SPECFILE $SPECFILE.bak
1029 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1030 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1032 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1033 unset TOLDVER TNEWVER TNOTIFY
1040 BUILD_SWITCH="-ba" ;;
1042 BUILD_SWITCH="-bb" ;;
1044 BUILD_SWITCH="-bs --nodeps" ;;
1046 BUILD_SWITCH="-bp --nodeps" ;;
1049 update_shell_title "build_package: $COMMAND"
1050 if [ -n "$LOGFILE" ]; then
1051 LOG=`eval echo $LOGFILE`
1052 if [ -d "$LOG" ]; then
1053 echo "Log file $LOG is a directory."
1054 echo "Parse error in the spec?"
1055 Exit_error err_build_fail;
1057 if [ -n "$LASTLOG_FILE" ]; then
1058 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1060 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1061 (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
1062 RETVAL=`cat $RES_FILE`
1064 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1065 if [ "$RETVAL" -eq "0" ]; then
1072 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
1075 if [ "$RETVAL" -ne "0" ]; then
1076 if [ -n "$TRY_UPGRADE" ]; then
1077 echo "\n!!! Package with new version cannot be built automagically\n"
1078 mv -f $SPECFILE.bak $SPECFILE
1080 Exit_error err_build_fail;
1087 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1090 install_required_packages()
1097 # taken from find-spec-bcond, but with just getting the list
1099 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1101 /^%changelog/ { exit }
1102 /_with(out)?_[_a-zA-Z0-9]+/{
1103 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1104 print substr($0, RSTART, RLENGTH);
1107 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1108 bcond = substr($0, RSTART +5 , RLENGTH -5);
1109 gsub(/[ \t]+/,"_",bcond);
1111 }' $SPEC | LC_ALL=C sort -u
1116 update_shell_title "set bcond values"
1118 AVAIL_BCONDS_WITHOUT=""
1119 AVAIL_BCONDS_WITH=""
1120 if `grep -q ^%bcond ${SPECFILE}`; then
1122 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1128 local bcond_avail=$(find_spec_bcond $SPECFILE)
1130 # expand bconds from ~/.bcondrc
1131 # The file structure is like gentoo's package.use:
1134 # samba -mysql -pgsql
1135 # w32codec-installer license_agreement
1138 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1139 SN=${SPECFILE%%\.spec}
1141 local bcondrc=$HOME/.bcondrc
1142 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1144 while read pkg flags; do
1146 [[ "$pkg" == \#* ]] && continue
1148 # any package or current package?
1149 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1150 for flag in $flags; do
1151 local opt=${flag#[+-]}
1153 # use only flags which are in this package.
1154 if [[ $bcond_avail = *${opt}* ]]; then
1155 if [[ $flag = -* ]]; then
1156 BCOND="$BCOND --without $opt"
1158 BCOND="$BCOND --with $opt"
1164 update_shell_title "parse ~/.bcondrc: DONE!"
1167 update_shell_title "parse bconds"
1168 case "${BCOND_VERSION}" in
1173 echo "Warning: This spec has old style bconds. Fix it || die."
1174 for opt in `echo "$bcond_avail" | grep ^_without_`
1176 AVAIL_BCOND_WITHOUT=${opt#_without_}
1177 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1178 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1180 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1184 for opt in `echo "$bcond_avail" | grep ^_with_`
1186 AVAIL_BCOND_WITH=${opt#_with_}
1187 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1188 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1190 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1195 local cond_type="" # with || without
1196 for opt in $bcond_avail; do
1205 AVAIL_BCOND_WITHOUT=${opt#_without_}
1206 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1207 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1209 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1213 AVAIL_BCOND_WITH=${opt#_with_}
1214 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1215 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1217 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1221 case "$cond_type" in
1224 AVAIL_BCOND_WITH="$opt"
1225 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1226 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1228 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1233 AVAIL_BCOND_WITHOUT="$opt"
1234 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1235 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1237 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1251 update_shell_title "run_sub_builder $package_name"
1253 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1254 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1255 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1256 # jakby nie bylo tego kawalka kodu.
1258 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1259 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1266 # Istnieje taki spec? ${package}.spec
1267 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1268 parent_spec_name=${package}.spec
1269 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1270 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1272 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1278 if [ "${parent_spec_name}" != "" ]; then
1279 spawn_sub_builder $parent_spec_name
1281 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1287 update_shell_title "spawn_sub_builder $package_name"
1290 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1291 sub_builder_opts="${sub_builder_opts} -R"
1293 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1294 sub_builder_opts="${sub_builder_opts} -RB"
1295 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1296 sub_builder_opts="${sub_builder_opts} -FRB"
1298 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1299 sub_builder_opts="${sub_builder_opts} -Upi"
1303 ./builder ${sub_builder_opts} "$@"
1306 remove_build_requires()
1308 if [ "$INSTALLED_PACKAGES" != "" ]; then
1309 case "$REMOVE_BUILD_REQUIRES" in
1311 run_poldek --noask -ve $INSTALLED_PACKAGES
1314 run_poldek --ask -ve $INSTALLED_PACKAGES
1317 echo You may want to manually remove following BuildRequires fetched:
1318 echo $INSTALLED_PACKAGES
1319 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1327 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1328 if [ "$BCOND" != "" ]; then
1329 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1332 echo -ne "\nNo conditional flags passed"
1334 echo -ne "\n\nfrom available:\n"
1335 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1341 if [ "$NOCVSSPEC" != "yes" ]; then
1342 echo -ne "Available branches: "
1343 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1347 # checks a given list of packages/files/provides agains current rpmdb.
1348 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1349 # input can be either STDIN or parameters
1354 if [ "$#" -gt 0 ]; then
1360 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1363 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1365 # other deps (files)
1366 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1369 # checks if given package/files/provides exists in rpmdb.
1370 # inout can be either stdin or parameters
1371 # returns packages wchi hare present in the rpmdb
1376 if [ "$#" -gt 0 ]; then
1382 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1385 fetch_build_requires()
1387 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1388 update_shell_title "fetch build requires"
1389 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1390 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1391 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1393 update_shell_title "poldek: update indexes"
1394 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1395 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1397 if [ -n "$CONF" ]; then
1398 update_shell_title "uninstall conflicting packages: $CONF"
1399 echo "Trying to uninstall conflicting packages ($CONF):"
1400 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1403 while [ "$DEPS" ]; do
1404 update_shell_title "install deps: $DEPS"
1405 echo "Trying to install dependencies ($DEPS):"
1406 local log=.${SPECFILE}_poldek.log
1407 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1408 failed=$(awk -F: '/^error:/{print $2}' $log)
1411 if [ -n "$failed" ]; then
1412 for package in $failed; do
1413 # FIXME: sanitise, deps could be not .spec files
1414 spawn_sub_builder -bb $package && ok="$ok $package"
1424 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1425 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1426 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1427 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1428 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1429 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`
1431 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`"
1433 package=`basename "$package_item"|sed -e "s/}$//g"`
1434 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1437 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1438 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1439 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
1444 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1447 if `echo $COND_TST|grep -q 'without_'`; then
1448 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1449 if `echo $COND_TST|grep -q !`; then
1454 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1455 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1456 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1462 elif `echo $COND_TST|grep -q 'with_'`; then
1463 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1464 if `echo $COND_TST|grep -q !`; then
1469 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1470 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1471 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1477 RESULT="${COND_STATE}-${COND_ARGV}"
1479 "with-wout" | "wout-with" )
1482 "wout-wout" | "with-with" )
1486 echo "Action '$RESULT' was not defined for package '$package_item'"
1492 if [ "$GO" = "yes" ]; then
1493 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1494 echo "Testing if $package has subrequirements..."
1495 run_poldek -t -i $package --dumpn=".$package-req.txt"
1496 if [ -f ".$package-req.txt" ]; then
1497 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1499 if [ "$package_name" = "$package" ]; then
1500 echo -ne "Installing BuildRequired package:\t$package_name\n"
1501 update_shell_title "Installing BuildRequired package: ${package_name}"
1502 install_required_packages $package;
1504 echo -ne "Installing (sub)Required package:\t$package_name\n"
1505 update_shell_title "Installing (sub)Required package: ${package_name}"
1506 install_required_packages $package_name;
1510 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1511 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1514 echo "Attempting to run spawn sub - builder..."
1515 echo -ne "Package installation failed:\t$package_name\n"
1516 run_sub_builder $package_name
1517 if [ $? -eq 0 ]; then
1518 install_required_packages $package_name;
1521 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1522 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1525 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1532 rm -f ".$package-req.txt"
1534 echo "Attempting to run spawn sub - builder..."
1535 echo -ne "Package installation failed:\t$package\n"
1536 run_sub_builder $package
1537 if [ $? -eq 0 ]; then
1538 install_required_packages $package;
1541 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1542 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1545 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1551 echo "Package $package is already installed. BuildRequirement satisfied."
1555 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1556 echo "Unable to install following packages and their dependencies:"
1557 for pkg in "$NOT_INSTALLED_PACKAGES"
1561 remove_build_requires
1569 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1570 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1572 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1574 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1578 echo "To checkout *all* .spec files:"
1579 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1580 echo "- run cvs up in $SPECS_DIR dir"
1583 echo "To commit with your developer account:"
1584 echo "- edit $SPECS_DIR/CVS/Root"
1585 echo "- edit $SOURCE_DIR/CVS/Root"
1588 #---------------------------------------------
1591 if [ "$#" = 0 ]; then
1617 DEBUG="yes"; shift ;;
1619 COMMAND="version"; shift ;;
1621 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1622 -b | -ba | --build )
1623 COMMAND="build"; shift ;;
1624 -bb | --build-binary )
1625 COMMAND="build-binary"; shift ;;
1626 -bs | --build-source )
1627 COMMAND="build-source"; shift ;;
1628 -bp | --build-prep )
1629 COMMAND="build-prep"; shift ;;
1631 COMMAND="branch"; shift; TAG="${1}"; shift;;
1633 CLEAN="--clean --rmspec --rmsource"; shift ;;
1635 shift; CVSROOT="${1}"; shift ;;
1637 COMMAND="get"; shift ;;
1639 COMMAND="usage"; shift ;;
1641 PROTOCOL="http"; shift ;;
1643 shift; LOGFILE="${1}"; shift ;;
1645 shift; DEF_NICE_LEVEL=${1}; shift ;;
1646 -ske | --skip-existing-files)
1647 SKIP_EXISTING_FILES="yes"; shift ;;
1649 COMMAND="mr-proper"; shift ;;
1651 NOCVS="yes"; shift ;;
1652 -ncs | --no-cvs-specs )
1653 NOCVSSPEC="yes"; shift ;;
1654 -nd | --no-distfiles )
1655 NODIST="yes"; shift ;;
1656 -nm | --no-mirrors )
1657 NOMIRRORS="yes"; shift ;;
1659 NOURLS="yes"; shift ;;
1661 NOSRCS="yes"; shift ;;
1662 -ns0 | --no-source0 )
1663 NOSOURCE0="yes"; shift ;;
1674 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1676 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1677 --with | --without )
1678 case $GROUP_BCONDS in
1682 while ! `echo ${1}|grep -qE '(^-|spec)'`
1684 BCOND="$BCOND $COND $1"
1688 if [[ "$2" = *,* ]]; then
1689 for a in $(echo "$2" | tr , ' '); do
1690 BCOND="$BCOND $1 $a"
1693 BCOND="$BCOND $1 $2"
1699 shift; TARGET="${1}"; shift ;;
1701 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1703 QUIET="--quiet"; shift ;;
1705 CVSDATE="${2}"; shift 2 ;;
1707 shift; CVSTAG="${1}"; shift ;;
1708 -R | --fetch-build-requires)
1709 FETCH_BUILD_REQUIRES="yes"
1710 NOT_INSTALLED_PACKAGES=
1712 -RB | --remove-build-requires)
1713 REMOVE_BUILD_REQUIRES="nice"
1715 -FRB | --force-remove-build-requires)
1716 REMOVE_BUILD_REQUIRES="force"
1718 -sf | --sources-files)
1719 COMMAND="list-sources-files"
1721 -sp | --sources-paths)
1722 COMMAND="list-sources-local-paths"
1724 -su | --sources-urls)
1725 COMMAND="list-sources-urls"
1727 -Tvs | --tag-version-stable )
1732 -Tvn | --tag-version-nest )
1737 -Ts | --tag-stable )
1747 -Tv | --tag-version )
1752 -Tp | --tag-prefix )
1764 -ir | --integer-release-only )
1765 INTEGER_RELEASE="yes"
1774 -Upi | --update-poldek-indexes )
1775 UPDATE_POLDEK_INDEXES="yes"
1778 COMMAND="init_rpm_dir";
1780 -u | --try-upgrade )
1781 TRY_UPGRADE="1"; shift ;;
1782 -un | --try-upgrade-with-float-version )
1783 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1785 BE_VERBOSE="1"; shift ;;
1791 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1793 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1799 RPMOPTS="${RPMOPTS} --nodeps"
1802 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1805 # check if specname was passed as specname:cvstag
1806 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1807 CVSTAG="${SPECFILE##*:}";
1808 SPECFILE="${SPECFILE%%:*}";
1814 if [ -n "$DEBUG" ]; then
1819 if [ -n "$TARGET" ]; then
1822 TARGET_SWITCH="--target $TARGET" ;;
1824 TARGET_SWITCH="--target=$TARGET" ;;
1828 update_shell_title "$COMMAND"
1830 "build" | "build-binary" | "build-source" | "build-prep" )
1832 if [ -n "$SPECFILE" ]; then
1838 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1839 fetch_build_requires;
1840 if [ "$INTEGER_RELEASE" = "yes" ]; then
1841 echo "Checking release $PACKAGE_RELEASE..."
1842 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1843 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1847 if [ -n "$TEST_TAG" ]; then
1848 TAGVER=`make_tagver`
1849 echo "Searching for tag $TAGVER..."
1850 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1851 if [ -n "$TAGREL" ]; then
1852 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1855 # - do not allow to build from HEAD when XX-branch exists
1856 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1857 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1858 TAG_BRANCH="${TREE_PREFIX}-branch"
1859 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1860 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1861 Exit_error err_branch_exists "$TAG_STATUS"
1867 if [ -n "$NOSOURCE0" ] ; then
1868 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1870 get_files $SOURCES $PATCHES;
1872 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1873 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1875 remove_build_requires;
1877 Exit_error err_no_spec_in_cmdl;
1882 if [ -n "$SPECFILE" ]; then
1885 get_files $SOURCES $PATCHES;
1886 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1888 Exit_error err_no_spec_in_cmdl;
1893 if [ -n "$SPECFILE" ]; then
1897 if [ -n "$NOSOURCE0" ] ; then
1898 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1900 get_files $SOURCES $PATCHES
1902 Exit_error err_no_spec_in_cmdl;
1909 if [ -n "$SPECFILE" ]; then
1913 # don't fetch sources from remote locations
1915 for file in $SOURCES
1917 [ -n "`src_md5 $file`" ] && continue
1918 new_SOURCES="$new_SOURCES $file"
1920 SOURCES="$new_SOURCES"
1921 get_files $SOURCES $PATCHES;
1922 tag_files "$SOURCES $PATCHES $ICONS";
1924 Exit_error err_no_spec_in_cmdl;
1928 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1930 "list-sources-files" )
1933 DONT_PRINT_REVISION="yes"
1936 SAPS="$SOURCES $PATCHES"
1937 for SAP in $SAPS ; do
1938 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1941 "list-sources-urls" )
1944 DONT_PRINT_REVISION="yes"
1947 SAPS="$SOURCES $PATCHES"
1948 for SAP in $SAPS ; do
1952 "list-sources-local-paths" )
1955 DONT_PRINT_REVISION="yes"
1958 SAPS="$SOURCES $PATCHES"
1959 for SAP in $SAPS ; do
1960 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1971 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1972 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1976 # vi:syntax=sh:ts=4:sw=4