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.16 (C) 1999-2006 Free Penguins".
26 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
45 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
48 # It can be used i.e. in log file naming.
49 # See LOGFILE example.
50 DATE=`date +%Y-%m-%d_%H-%M-%S`
52 # Example: LOGFILE='../log.$PACKAGE_NAME'
53 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
54 # Yes, you can use variable name! Note _single_ quotes!
77 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
78 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
84 CVS_SERVER="cvs.pld-linux.org"
85 DISTFILES_SERVER="://distfiles.pld-linux.org"
86 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
91 FAIL_IF_NO_SOURCES="yes"
93 # let get_files skip over files which are present to get those damn files fetched
94 SKIP_EXISTING_FILES="no"
97 # should the specfile be restored if upgrade failed?
98 REVERT_BROKEN_UPGRADE="yes"
100 if [ -x /usr/bin/rpm-getdeps ]; then
101 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
103 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
106 # Here we load saved user environment used to
107 # predefine options set above, or passed to builder
109 # This one reads global system environment settings:
110 if [ -f ~/etc/builderrc ]; then
113 # And this one cascades settings using user personal
115 # Example of ~/.builderrc:
117 #UPDATE_POLDEK_INDEXES="yes"
118 #FETCH_BUILD_REQUIRES="yes"
119 #REMOVE_BUILD_REQUIRES="force"
121 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
125 if [ -n "$HOME_ETC" ]; then
126 USER_CFG="$HOME_ETC/.builderrc"
128 USER_CFG=~/.builderrc
131 [ -f "$USER_CFG" ] && . "$USER_CFG"
133 if [ "$SCHEDTOOL" = "auto" ]; then
134 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
135 SCHEDTOOL="schedtool -B -e"
141 if [ -n "$USE_PROZILLA" ]; then
142 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
145 elif [ -n "$USE_AXEL" ]; then
146 GETURI="axel -a $AXEL_OPTS"
150 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
151 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
152 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
154 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
155 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
161 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
169 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
170 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
174 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
175 if [ -n "$LOGFILE" ]; then
176 LOG=`eval echo $LOGFILE`
177 if [ -n "$LASTLOG_FILE" ]; then
178 echo "LASTLOG=$LOG" > $LASTLOG_FILE
180 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
183 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
184 return `cat ${RES_FILE}`
189 #---------------------------------------------
194 if [ -n "$DEBUG" ]; then set -xv; fi
196 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
197 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
198 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
199 [-g|--get] [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
200 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
201 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
202 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
203 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
204 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
206 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
207 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
208 -n5, --no-md5 - ignore md5 comments in spec
209 -D, --debug - enable builder script debugging mode,
210 -debug - produce rpm debug package (same as --opts -debug)
211 -V, --version - output builder version
212 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
213 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
215 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
216 only package from <package>.spec,
217 -bp, --build-prep - execute the %prep phase of <package>.spec,
218 -bc - reserved (not implemented)
219 -bi reserved (not implemented)
220 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
222 --short-circuit - reserved (not implemented)
223 -B, --branch - add branch
224 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
225 SPECS and \$RPM_BUILD_ROOT),
226 -cf, --cvs-force - use -F when tagging (useful when moving branches)
227 -d <cvsroot>, --cvsroot <cvsroot>
229 --define <macro> <value>
230 - define a macro <macro> with value <value>,
231 --nodeps - rpm won't check any dependences
232 -g, --get - get <package>.spec and all related files from CVS repo
234 -h, --help - this message,
235 --http - use http instead of ftp,
236 -l <logfile>, --logtofile <logfile>
238 -m, --mr-proper - only remove all files related to spec file and all work
240 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
242 - don't check specs in CVS
243 -nd, --no-distfiles - don't download from distfiles
244 -nm, --no-mirrors - don't download from mirror, if source URL is given,
245 -nu, --no-urls - don't try to download from FTP/HTTP location,
246 -ns, --no-srcs - don't download Sources
247 -ns0, --no-source0 - don't download Source0
248 -nn, --no-net - don't download anything from the net
249 --no-init - don't initialize builder paths (SPECS and SOURCES)
251 --skip-existing-files - skip existing files in get_files
252 --opts <rpm opts> - additional options for rpm
253 -q, --quiet - be quiet,
254 --date yyyy-mm-dd - build package using resources from specified CVS date,
255 -r <cvstag>, --cvstag <cvstag>
256 - build package using resources from specified CVS tag,
257 -R, --fetch-build-requires
258 - fetch what is BuildRequired,
259 -RB, --remove-build-requires
260 - remove all you fetched with -R or --fetch-build-requires
261 remember, this option requires confirmation,
262 -FRB, --force-remove-build-requires
263 - remove all you fetched with -R or --fetch-build-requires
264 remember, this option works without confirmation,
265 -sd, --source-distfiles - list sources available from distfiles (intended for offline
266 operations; does not work when Icon field is present
267 but icon file is absent),
268 -sdp, --source-distfiles-paths - list sources available from distfiles -
269 paths relative to distfiles directory (intended for offline
270 operations; does not work when Icon field is present
271 but icon file is absent),
272 -sf, --source-files - list sources - bare filenames (intended for offline
273 operations; does not work when Icon field is present
274 but icon file is absent),
275 -sp, --source-paths - list sources - filenames with full local paths (intended for
276 offline operations; does not work when Icon field is present
277 but icon file is absent),
278 -su, --source-urls - list urls - urls to sources and patches
279 intended for copying urls with spec with lots of macros in urls
280 -T <cvstag> , --tag <cvstag>
281 - add cvs tag <cvstag> for files,
282 -Tvs, --tag-version-stable
283 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
285 - add cvs tag STABLE for files,
287 - add cvs tag NAME-VERSION-RELEASE for files,
288 -Tp, --tag-prefix <prefix>
289 - add <prefix> to NAME-VERSION-RELEASE tags,
290 -tt, --test-tag <prefix>
291 - fail if tag is already present,
292 -ir, --integer-release-only
293 - allow only integer and snapshot releases
294 -v, --verbose - be verbose,
295 -u, --try-upgrade - check version, and try to upgrade package
296 -un, --try-upgrade-with-float-version
297 - as above, but allow float version
298 -U, --update - refetch sources, don't use distfiles, and update md5 comments
299 -Upi, --update-poldek-indexes
300 - refresh or make poldek package index files.
301 -np, --nopatch <patchnumber>
302 - don't apply <patchnumber>
303 --show-bconds - show available conditional builds, which can be used
304 - with --with and/or --without switches.
305 --with/--without <feature>
306 - conditional build package depending on %_with_<feature>/
307 %_without_<feature> macro switch. You may now use
308 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
309 constructions. Set GROUP_BCONDS to yes to make use of it.
310 --target <platform>, --target=<platform>
311 - build for platform <platform>.
312 --init-rpm-dir - initialize ~/rpm directory structure
316 update_shell_title() {
318 local len=${COLUMNS:-80}
319 local msg=$(echo "$*" | cut -c-$len)
321 if [ -n "$BE_VERBOSE" ]; then
322 echo >&2 "$(date +%s.%N) $*"
325 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
327 if [ -n "$PACKAGE_NAME" ]; then
328 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
333 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
334 msg="$(echo $msg | tr -d '\n\r')"
337 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
340 echo >&2 -ne "\033]0;$msg\007"
346 # set TARGET from BuildArch: from SPECFILE
348 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
349 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
354 TARGET_SWITCH="--target $TARGET" ;;
356 TARGET_SWITCH="--target=$TARGET" ;;
363 if [ -n "$DEBUG" ]; then
368 update_shell_title "cache_rpm_dump"
372 # we reset macros not to contain macros.build as all the %() macros are
373 # executed here, while none of them are actually needed.
374 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
375 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
376 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
377 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
378 # FIXME: better ideas than .rpmrc?
379 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
380 # TODO: move these to /usr/lib/rpm/macros
381 cat > .builder-rpmmacros <<'EOF'
382 %requires_releq_kernel_up %{nil}
383 %requires_releq_kernel_smp %{nil}
384 %requires_releq() %{nil}
385 %pyrequires_eq() %{nil}
386 %requires_eq() %{nil}
387 %requires_eq_to() %{nil}
388 %releq_kernel_up ERROR
389 %releq_kernel_smp ERROR
393 %ruby_ver_requires_eq() %{nil}
394 %ruby_mod_ver_requires_eq() %{nil}
395 %__php_api_requires() %{nil}
396 %php_major_version ERROR
397 %php_api_version ERROR
399 %perl_vendorarch ERROR
400 %perl_vendorlib ERROR
407 ARGS='--nodigest --nosignature --nobuild'
410 if [ "$NOINIT" = "yes" ] ; then
411 cat >> .builder-rpmmacros <<'EOF'
416 $RPMBUILD --rcfile .builder-rpmrc $ARGS $ARGDIRS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
418 if [ $? -gt 0 ]; then
419 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
421 Exit_error err_build_fail;
424 # make small dump cache
425 rpm_dump_cache=`echo "$rpm_dump" | awk '
426 $2 ~ /^SOURCEURL/ {print}
427 $2 ~ /^PATCHURL/ {print}
428 $2 ~ /^nosource/ {print}
429 $2 ~ /^PACKAGE_/ {print}
432 update_shell_title "cache_rpm_dump: OK!"
436 if [ -z "$rpm_dump_cache" ] ; then
437 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
439 echo "$rpm_dump_cache"
444 update_shell_title "get icons"
445 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
446 if [ -z "$ICONS" ]; then
450 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
455 update_shell_title "parsing specfile"
456 if [ -n "$DEBUG" ]; then
461 # icons are needed for successful spec parse
467 if [ "$NOSRCS" != "yes" ]; then
468 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
471 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
472 FAIL_IF_NO_SOURCES="no"
475 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
476 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
477 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
478 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
479 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
481 if [ -n "$BE_VERBOSE" ]; then
482 echo "- Sources : `nourl $SOURCES`"
483 if [ -n "$PATCHES" ]; then
484 echo "- Patches : `nourl $PATCHES`"
486 echo "- Patches : *no patches needed*"
488 if [ -n "$ICONS" ]; then
489 echo "- Icon : `nourl $ICONS`"
491 echo "- Icon : *no package icon*"
493 echo "- Name : $PACKAGE_NAME"
494 echo "- Version : $PACKAGE_VERSION"
495 echo "- Release : $PACKAGE_RELEASE"
498 update_shell_title "parse_spec: OK!"
503 if [ -n "$DEBUG" ]; then
511 "err_no_spec_in_cmdl" )
512 remove_build_requires
513 echo "ERROR: spec file name not specified.";
515 "err_no_spec_in_repo" )
516 remove_build_requires
517 echo "Error: spec file not stored in CVS repo.";
519 "err_no_source_in_repo" )
520 remove_build_requires
521 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
524 remove_build_requires
525 echo "Error: package build failed. (${2:-no more info})";
527 "err_no_package_data" )
528 remove_build_requires
529 echo "Error: couldn't get out package name/version/release from spec file."
532 remove_build_requires
533 echo "Tag ${2} already exists (spec release: ${3}).";
536 remove_build_requires
537 echo "Release ${2} not integer and not a snapshot.";
539 "err_branch_exists" )
540 remove_build_requires
541 echo "Tree branch already exists (${2}).";
545 echo "Unknown error."
551 if [ -n "$DEBUG" ]; then
556 if [ "$NOINIT" != "yes" ] ; then
557 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
558 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
570 update_shell_title "get_spec"
572 if [ -n "$DEBUG" ]; then
578 if [ ! -f "$SPECFILE" ]; then
579 SPECFILE="`basename $SPECFILE .spec`.spec";
581 if [ "$NOCVSSPEC" != "yes" ]; then
583 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
584 echo "Warning: No CVS access defined - using local .spec file"
588 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
591 if [ ! -f "$SPECFILE" ]; then
592 Exit_error err_no_spec_in_repo;
595 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
596 chmod $CHMOD_MODE $SPECFILE
599 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
608 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
609 cvs update mirrors >&2
613 local origin mirror name rest ol prefix
614 while read origin mirror name rest; do
615 # skip comments and empty lines
616 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
619 ol=`echo -n "$origin"|wc -c`
620 prefix="`echo -n "$url" | head -c $ol`"
621 if [ "$prefix" = "$origin" ] ; then
622 suffix="`echo "$url"|cut -b $((ol+1))-`"
623 echo -n "$mirror$suffix"
630 # Warning: unpredictable results if same URL used twice
635 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
636 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
642 [ "$NO5" = "yes" ] && return
644 [ -z "$no" ] && return
648 if [ -f additional-md5sums ]; then
649 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
650 if [ -z "$spec_rev" ]; then
651 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
653 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
654 md5=$(grep -s -v '^#' additional-md5sums | \
655 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
656 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
657 grep -E '^[0-9a-f]{32}$')
660 if [ $(echo "$md5" | wc -l) != 1 ] ; then
661 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
663 echo "$md5" | tail -n 1
668 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
669 if [ -n "$source_md5" ]; then
672 # we have empty SourceX-md5, but it is still possible
673 # that we have NoSourceX-md5 AND NoSource: X
674 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
675 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
683 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
688 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
691 distfiles_attic_url ()
693 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
700 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
705 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
706 [ -n "$size" -a "$size" -gt 0 ]
711 if [ "$CVSIGNORE_DF" != "yes" ]; then
714 cvsignore=${SOURCE_DIR}/.cvsignore
715 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
716 echo "$1" >> $cvsignore
722 update_shell_title "cvsup"
724 if [ -n "$CVSROOT" ]; then
725 OPTIONS="-d $CVSROOT $OPTIONS"
728 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
729 OPTIONS="$OPTIONS -A"
731 if [ -n "$CVSDATE" ]; then
732 OPTIONS="$OPTIONS -D $CVSDATE"
734 if [ -n "$CVSTAG" ]; then
735 OPTIONS="$OPTIONS -r $CVSTAG"
740 local retries_counter=0
742 update_shell_title "cvsup: $*"
744 update_shell_title "cvsup: $# files"
746 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
747 retries_counter=$(( $retries_counter + 1 ))
748 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
750 [ -n "$output" ] && echo "$output"
751 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
752 echo "Trying again [$*]... ($retries_counter)"
753 update_shell_title "cvsup: retry #$retries_counter"
760 update_shell_title "cvsup: done!"
766 if [ $# -eq 0 ]; then
770 update_shell_title "update md5"
771 if [ -n "$DEBUG" ]; then
778 # pass 1: check files to be fetched
782 local fp=$(nourl "$i")
783 local srcno=$(src_no "$i")
784 if [ -n "$UPDATE5" ]; then
785 if [ -n "$ADD5" ]; then
786 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
787 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
789 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
792 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
793 need_files="$need_files $i"
797 # pass 1a: get needed files
798 if [ "$need_files" ]; then
799 get_files $need_files
802 # pass 2: proceed with md5 adding or updating
804 local fp=$(nourl "$i")
805 local srcno=$(src_no "$i")
806 if [ -n "$UPDATE5" ] && \
807 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
808 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
809 grep -q -i -E '^#[ ]*source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
811 echo "Updating source-$srcno md5."
812 md5=$(md5sum "$fp" | cut -f1 -d' ')
814 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
815 print "# Source'$srcno'-md5:\t'$md5'\n"
816 if /^Source'$srcno'\s*:\s+/;
825 update_shell_title "check md5"
828 if good_md5 "$i" && good_size "$i"; then
832 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
833 echo "or -5 to update md5 sums, if you're sure files are correct."
834 Exit_error err_no_source_in_repo $i
840 update_shell_title "get_files"
842 if [ -n "$DEBUG" ]; then
847 if [ $# -gt 0 ]; then
850 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
851 echo "Warning: No CVS access defined for SOURCES"
856 local get_files_cvs=""
860 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
861 update_shell_title "$i"
862 local fp=`nourl "$i"`
863 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
868 local srcmd5=$(src_md5 "$i")
870 # we know if source/patch is present in cvs/distfiles
871 # - has md5 (in distfiles)
874 # CHECK: local file didn't exist or always cvs up (first) requested.
875 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
876 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
877 echo "Warning: no URL given for $i"
880 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
881 if good_md5 "$i" && good_size "$i"; then
882 echo "$fp having proper md5sum already exists"
886 url=$(distfiles_url "$i")
887 url_attic=$(distfiles_attic_url "$i")
889 # is $url local file?
890 if [[ "$url" = [./]* ]]; then
891 update_shell_title "${GETLOCAL%% *}: $url"
892 ${GETLOCAL} $url $target
894 if [ -z "$NOMIRRORS" ]; then
895 url="`find_mirror "$url"`"
897 update_shell_title "${GETURI%% *}: $url"
898 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
899 if [ "`echo $url | grep -E 'ftp://'`" ]; then
900 update_shell_title "${GETURI2%% *}: $url"
901 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
906 if [ ! -s "$target" ]; then
908 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
909 update_shell_title "${GETLOCAL%% *}: $url_attic"
910 ${GETLOCAL} $url_attic $target
912 if [ -z "$NOMIRRORS" ]; then
913 url_attic="`find_mirror "$url_attic"`"
915 update_shell_title "${GETURI%% *}: $url_attic"
916 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
917 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
918 update_shell_title "${GETURI2%% *}: $url_attic"
919 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
924 if [ -s "$target" ]; then
930 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
931 if [ $# -gt 1 ]; then
932 get_files_cvs="$get_files_cvs $fp"
933 update_shell_title "$fp (will cvs up later)"
940 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
941 if [ -z "$NOMIRRORS" ]; then
942 im="`find_mirror "$i"`"
946 update_shell_title "${GETURI%% *}: $im"
948 if [ "`echo $im | grep -E 'ftp://'`" ]; then
949 update_shell_title "${GETURI2%% *}: $im"
954 if [ "$cvsup" = 1 ]; then
960 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
961 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
962 Exit_error err_no_source_in_repo $i;
965 # we check md5 here just only to refetch immediately
966 if good_md5 "$i" && good_size "$i"; then
968 elif [ "$FROM_DISTFILES" = 1 ]; then
969 # wrong md5 from distfiles: remove the file and try again
971 echo "MD5 sum mismatch. Trying full fetch."
974 update_shell_title "${GETURI%% *}: $url"
975 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
976 if [ "`echo $url | grep -E 'ftp://'`" ]; then
977 update_shell_title "${GETURI2%% *}: $url"
978 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
980 if [ ! -s "$target" ]; then
982 update_shell_title "${GETURI%% *}: $url_attic"
983 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
984 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
985 update_shell_title "${GETURI2%% *}: $url_attic"
986 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
989 test -s "$target" || rm -f "$target"
992 SHELL_TITLE_PREFIX=""
994 if [ "$get_files_cvs" ]; then
998 if [ "$CHMOD" = "yes" ]; then
999 CHMOD_FILES="`nourl "$@"`"
1000 if [ -n "$CHMOD_FILES" ]; then
1001 chmod $CHMOD_MODE $CHMOD_FILES
1008 if [ -n "$DEBUG" ]; then
1013 # Check whether first character of PACKAGE_NAME is legal for tag name
1014 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1017 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"`
1018 # Remove #kernel.version_release from TAGVER because tagging sources
1019 # could occur with different kernel-headers than kernel-headers used at build time.
1020 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
1028 if [ -n "$DEBUG" ]; then
1033 echo "Version: $PACKAGE_VERSION"
1034 echo "Release: $PACKAGE_RELEASE"
1036 TAGVER=`make_tagver`
1038 if [ "$TAG_VERSION" = "yes" ]; then
1039 echo "CVS tag: $TAGVER"
1041 if [ -n "$TAG" ]; then
1042 echo "CVS tag: $TAG"
1045 local OPTIONS="tag $CVS_FORCE"
1046 if [ -n "$CVSROOT" ]; then
1047 OPTIONS="-d $CVSROOT $OPTIONS"
1052 for i in $TAG_FILES; do
1053 # don't tag files stored on distfiles
1054 [ -n "`src_md5 $i`" ] && continue
1055 local fp=`nourl "$i"`
1056 if [ -f "$fp" ]; then
1057 tag_files="$tag_files $fp"
1059 Exit_error err_no_source_in_repo $i
1063 if [ "$tag_files" ]; then
1064 if [ "$TAG_VERSION" = "yes" ]; then
1065 update_shell_title "tag sources: $TAGVER"
1066 cvs $OPTIONS $TAGVER $tag_files
1068 if [ -n "$TAG" ]; then
1069 update_shell_title "tag sources: $TAG"
1070 cvs $OPTIONS $TAG $tag_files
1075 if [ "$TAG_VERSION" = "yes" ]; then
1076 update_shell_title "tag spec: $TAGVER"
1077 cvs $OPTIONS $TAGVER $SPECFILE
1079 if [ -n "$TAG" ]; then
1080 update_shell_title "tag spec: $TAG"
1081 cvs $OPTIONS $TAG $SPECFILE
1088 echo "CVS branch tag: $TAG"
1093 if [ -n "$DEBUG" ]; then
1098 local OPTIONS="tag $CVS_FORCE -b"
1099 if [ -n "$CVSROOT" ]; then
1100 OPTIONS="-d $CVSROOT $OPTIONS"
1104 for i in $TAG_FILES; do
1105 local fp=`nourl "$i"`
1106 if [ -f "$fp" ]; then
1107 tag_files="$tag_files $fp"
1109 Exit_error err_no_source_in_repo $i
1112 if [ "$tag_files" ]; then
1113 cvs $OPTIONS $TAG $tag_files
1117 cvs $OPTIONS $TAG $SPECFILE
1124 update_shell_title "build_package"
1125 if [ -n "$DEBUG" ]; then
1132 if [ -n "$TRY_UPGRADE" ]; then
1133 update_shell_title "build_package: try_upgrade"
1134 if [ -n "$FLOAT_VERSION" ]; then
1135 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1137 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1140 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1142 if [ -n "$TNEWVER" ]; then
1143 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1144 echo "New version found, updating spec file to version " $TNEWVER
1145 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1146 cp -f $SPECFILE $SPECFILE.bak
1149 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1150 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1152 NODIST="yes" get_files $SOURCES $PATCHES;
1153 UPDATE5="yes" update_md5 $SOURCES
1155 unset TOLDVER TNEWVER TNOTIFY
1162 BUILD_SWITCH="-ba" ;;
1164 BUILD_SWITCH="-bb" ;;
1166 BUILD_SWITCH="-bs --nodeps" ;;
1168 BUILD_SWITCH="-bp --nodeps" ;;
1171 update_shell_title "build_package: $COMMAND"
1172 if [ -n "$LOGFILE" ]; then
1173 LOG=`eval echo $LOGFILE`
1174 if [ -d "$LOG" ]; then
1175 echo "Log file $LOG is a directory."
1176 echo "Parse error in the spec?"
1177 Exit_error err_build_fail;
1179 if [ -n "$LASTLOG_FILE" ]; then
1180 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1182 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1183 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1184 RETVAL=`cat $RES_FILE`
1186 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1187 if [ "$RETVAL" -eq "0" ]; then
1194 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1197 if [ "$RETVAL" -ne "0" ]; then
1198 if [ -n "$TRY_UPGRADE" ]; then
1199 echo "\n!!! Package with new version cannot be built automagically\n"
1200 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1201 mv -f $SPECFILE.bak $SPECFILE
1204 Exit_error err_build_fail;
1211 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1214 install_required_packages()
1221 # taken from find-spec-bcond, but with just getting the list
1223 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1225 /^%changelog/ { exit }
1226 /_with(out)?_[_a-zA-Z0-9]+/{
1227 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1228 print substr($0, RSTART, RLENGTH);
1231 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1232 bcond = substr($0, RSTART +5 , RLENGTH -5);
1233 gsub(/[ \t]+/,"_",bcond);
1235 }' $SPEC | LC_ALL=C sort -u
1240 update_shell_title "set bcond values"
1242 AVAIL_BCONDS_WITHOUT=""
1243 AVAIL_BCONDS_WITH=""
1244 if `grep -q ^%bcond ${SPECFILE}`; then
1246 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1252 local bcond_avail=$(find_spec_bcond $SPECFILE)
1254 # expand bconds from ~/.bcondrc
1255 # The file structure is like gentoo's package.use:
1258 # samba -mysql -pgsql
1259 # w32codec-installer license_agreement
1262 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1263 SN=${SPECFILE%%\.spec}
1265 local bcondrc=$HOME/.bcondrc
1266 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1268 while read pkg flags; do
1270 [[ "$pkg" == \#* ]] && continue
1272 # any package or current package?
1273 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1274 for flag in $flags; do
1275 local opt=${flag#[+-]}
1277 # use only flags which are in this package.
1278 if [[ $bcond_avail = *${opt}* ]]; then
1279 if [[ $flag = -* ]]; then
1280 if [[ $BCOND != *--with?${opt}* ]]; then
1281 BCOND="$BCOND --without $opt"
1284 if [[ $BCOND != *--without?${opt}* ]]; then
1285 BCOND="$BCOND --with $opt"
1292 update_shell_title "parse ~/.bcondrc: DONE!"
1295 update_shell_title "parse bconds"
1296 case "${BCOND_VERSION}" in
1301 echo "Warning: This spec has old style bconds. Fix it || die."
1302 for opt in `echo "$bcond_avail" | grep ^_without_`
1304 AVAIL_BCOND_WITHOUT=${opt#_without_}
1305 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1306 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1308 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1312 for opt in `echo "$bcond_avail" | grep ^_with_`
1314 AVAIL_BCOND_WITH=${opt#_with_}
1315 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1316 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1318 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1323 local cond_type="" # with || without
1324 for opt in $bcond_avail; do
1333 AVAIL_BCOND_WITHOUT=${opt#_without_}
1334 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1335 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1337 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1341 AVAIL_BCOND_WITH=${opt#_with_}
1342 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1343 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1345 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1349 case "$cond_type" in
1352 AVAIL_BCOND_WITH="$opt"
1353 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1354 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1356 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1361 AVAIL_BCOND_WITHOUT="$opt"
1362 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1363 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1365 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1379 update_shell_title "run_sub_builder $package_name"
1381 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1382 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1383 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1384 # jakby nie bylo tego kawalka kodu.
1386 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1387 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1394 # Istnieje taki spec? ${package}.spec
1395 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1396 parent_spec_name=${package}.spec
1397 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1398 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1400 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1406 if [ "${parent_spec_name}" != "" ]; then
1407 spawn_sub_builder $parent_spec_name
1409 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1415 update_shell_title "spawn_sub_builder $package_name"
1418 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1419 sub_builder_opts="${sub_builder_opts} -R"
1421 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1422 sub_builder_opts="${sub_builder_opts} -RB"
1423 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1424 sub_builder_opts="${sub_builder_opts} -FRB"
1426 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1427 sub_builder_opts="${sub_builder_opts} -Upi"
1431 ./builder ${sub_builder_opts} "$@"
1434 remove_build_requires()
1436 if [ "$INSTALLED_PACKAGES" != "" ]; then
1437 case "$REMOVE_BUILD_REQUIRES" in
1439 run_poldek --noask -ve $INSTALLED_PACKAGES
1442 run_poldek --ask -ve $INSTALLED_PACKAGES
1445 echo You may want to manually remove following BuildRequires fetched:
1446 echo $INSTALLED_PACKAGES
1447 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1455 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1456 if [ "$BCOND" != "" ]; then
1457 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1460 echo -ne "\nNo conditional flags passed"
1462 echo -ne "\n\nfrom available:\n"
1463 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1469 if [ "$NOCVSSPEC" != "yes" ]; then
1470 echo -ne "Available branches: "
1471 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1475 # checks a given list of packages/files/provides agains current rpmdb.
1476 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1477 # input can be either STDIN or parameters
1482 if [ "$#" -gt 0 ]; then
1488 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1491 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1493 # other deps (files)
1494 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1497 # checks if given package/files/provides exists in rpmdb.
1498 # inout can be either stdin or parameters
1499 # returns packages wchi hare present in the rpmdb
1504 if [ "$#" -gt 0 ]; then
1510 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1513 fetch_build_requires()
1515 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1516 update_shell_title "fetch build requires"
1517 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1518 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1519 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1521 update_shell_title "poldek: update indexes"
1522 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1523 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1525 if [ -n "$CONF" ]; then
1526 update_shell_title "uninstall conflicting packages: $CONF"
1527 echo "Trying to uninstall conflicting packages ($CONF):"
1528 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1531 while [ "$DEPS" ]; do
1532 update_shell_title "install deps: $DEPS"
1533 echo "Trying to install dependencies ($DEPS):"
1534 local log=.${SPECFILE}_poldek.log
1535 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1536 failed=$(awk -F: '/^error:/{print $2}' $log)
1539 if [ -n "$failed" ]; then
1540 for package in $failed; do
1541 # FIXME: sanitise, deps could be not .spec files
1542 spawn_sub_builder -bb $package && ok="$ok $package"
1552 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1553 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1554 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1555 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1556 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1557 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`
1559 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`"
1561 package=`basename "$package_item"|sed -e "s/}$//g"`
1562 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1565 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1566 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1567 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
1572 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1575 if `echo $COND_TST|grep -q 'without_'`; then
1576 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1577 if `echo $COND_TST|grep -q !`; then
1582 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1583 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1584 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1590 elif `echo $COND_TST|grep -q 'with_'`; then
1591 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1592 if `echo $COND_TST|grep -q !`; then
1597 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1598 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1599 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1605 RESULT="${COND_STATE}-${COND_ARGV}"
1607 "with-wout" | "wout-with" )
1610 "wout-wout" | "with-with" )
1614 echo "Action '$RESULT' was not defined for package '$package_item'"
1620 if [ "$GO" = "yes" ]; then
1621 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1622 echo "Testing if $package has subrequirements..."
1623 run_poldek -t -i $package --dumpn=".$package-req.txt"
1624 if [ -f ".$package-req.txt" ]; then
1625 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1627 if [ "$package_name" = "$package" ]; then
1628 echo -ne "Installing BuildRequired package:\t$package_name\n"
1629 update_shell_title "Installing BuildRequired package: ${package_name}"
1630 install_required_packages $package;
1632 echo -ne "Installing (sub)Required package:\t$package_name\n"
1633 update_shell_title "Installing (sub)Required package: ${package_name}"
1634 install_required_packages $package_name;
1638 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1639 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1642 echo "Attempting to run spawn sub - builder..."
1643 echo -ne "Package installation failed:\t$package_name\n"
1644 run_sub_builder $package_name
1645 if [ $? -eq 0 ]; then
1646 install_required_packages $package_name;
1649 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1650 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1653 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1660 rm -f ".$package-req.txt"
1662 echo "Attempting to run spawn sub - builder..."
1663 echo -ne "Package installation failed:\t$package\n"
1664 run_sub_builder $package
1665 if [ $? -eq 0 ]; then
1666 install_required_packages $package;
1669 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1670 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1673 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1679 echo "Package $package is already installed. BuildRequirement satisfied."
1683 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1684 echo "Unable to install following packages and their dependencies:"
1685 for pkg in "$NOT_INSTALLED_PACKAGES"
1689 remove_build_requires
1697 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1698 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1700 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1702 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1706 echo "To checkout *all* .spec files:"
1707 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1708 echo "- run cvs up in $SPECS_DIR dir"
1711 echo "To commit with your developer account:"
1712 echo "- edit $SPECS_DIR/CVS/Root"
1713 echo "- edit $SOURCE_DIR/CVS/Root"
1716 #---------------------------------------------
1719 if [ "$#" = 0 ]; then
1728 COMMAND="update_md5";
1734 COMMAND="update_md5";
1745 DEBUG="yes"; shift ;;
1747 COMMAND="version"; shift ;;
1749 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1750 -b | -ba | --build )
1751 COMMAND="build"; shift ;;
1752 -bb | --build-binary )
1753 COMMAND="build-binary"; shift ;;
1754 -bs | --build-source )
1755 COMMAND="build-source"; shift ;;
1756 -bp | --build-prep )
1757 COMMAND="build-prep"; shift ;;
1759 COMMAND="branch"; shift; TAG="${1}"; shift;;
1761 CLEAN="--clean --rmspec --rmsource"; shift ;;
1763 CVS_FORCE="-F"; shift;;
1765 shift; CVSROOT="${1}"; shift ;;
1767 COMMAND="get"; shift ;;
1769 COMMAND="usage"; shift ;;
1771 PROTOCOL="http"; shift ;;
1773 shift; LOGFILE="${1}"; shift ;;
1775 shift; DEF_NICE_LEVEL=${1}; shift ;;
1776 -ske | --skip-existing-files)
1777 SKIP_EXISTING_FILES="yes"; shift ;;
1779 COMMAND="mr-proper"; shift ;;
1781 NOCVS="yes"; shift ;;
1782 -ncs | --no-cvs-specs )
1783 NOCVSSPEC="yes"; shift ;;
1784 -nd | --no-distfiles )
1785 NODIST="yes"; shift ;;
1786 -nm | --no-mirrors )
1787 NOMIRRORS="yes"; shift ;;
1789 NOURLS="yes"; shift ;;
1791 NOSRCS="yes"; shift ;;
1792 -ns0 | --no-source0 )
1793 NOSOURCE0="yes"; shift ;;
1807 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
1809 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1810 --with | --without )
1811 case $GROUP_BCONDS in
1815 while ! `echo ${1}|grep -qE '(^-|spec)'`
1817 BCOND="$BCOND $COND $1"
1821 if [[ "$2" = *,* ]]; then
1822 for a in $(echo "$2" | tr , ' '); do
1823 BCOND="$BCOND $1 $a"
1826 BCOND="$BCOND $1 $2"
1832 shift; TARGET="${1}"; shift ;;
1834 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1836 QUIET="--quiet"; shift ;;
1838 CVSDATE="${2}"; shift 2 ;;
1840 shift; CVSTAG="${1}"; shift ;;
1841 -R | --fetch-build-requires)
1842 FETCH_BUILD_REQUIRES="yes"
1843 NOT_INSTALLED_PACKAGES=
1845 -RB | --remove-build-requires)
1846 REMOVE_BUILD_REQUIRES="nice"
1848 -FRB | --force-remove-build-requires)
1849 REMOVE_BUILD_REQUIRES="force"
1851 -sd | --sources-distfiles)
1852 COMMAND="list-sources-distfiles"
1854 -sdp | --sources-distfiles-paths)
1855 COMMAND="list-sources-distfiles-paths"
1857 -sf | --sources-files)
1858 COMMAND="list-sources-files"
1860 -sp | --sources-paths)
1861 COMMAND="list-sources-local-paths"
1863 -su | --sources-urls)
1864 COMMAND="list-sources-urls"
1866 -Tvs | --tag-version-stable )
1871 -Ts | --tag-stable )
1876 -Tv | --tag-version )
1881 -Tp | --tag-prefix )
1893 -ir | --integer-release-only )
1894 INTEGER_RELEASE="yes"
1897 COMMAND="update_md5"
1903 -Upi | --update-poldek-indexes )
1904 UPDATE_POLDEK_INDEXES="yes"
1907 COMMAND="init_rpm_dir";
1909 -u | --try-upgrade )
1910 TRY_UPGRADE="1"; shift ;;
1911 -un | --try-upgrade-with-float-version )
1912 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1914 BE_VERBOSE="1"; shift ;;
1919 if echo "${MACRO}" | grep -q '\W'; then
1920 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
1924 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1927 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1933 RPMOPTS="${RPMOPTS} --nodeps"
1936 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1939 # check if specname was passed as specname:cvstag
1940 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1941 CVSTAG="${SPECFILE##*:}";
1942 SPECFILE="${SPECFILE%%:*}";
1948 if [ -z "$CVSTAG" ]; then
1949 CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
1950 if [ "$CVSTAG" ]; then
1951 echo "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
1953 elif [ "$CVSTAG" = "HEAD" ]; then
1954 # assume -r HEAD is same as -A
1958 if [ -n "$DEBUG" ]; then
1963 if [ -n "$TARGET" ]; then
1966 TARGET_SWITCH="--target $TARGET" ;;
1968 TARGET_SWITCH="--target=$TARGET" ;;
1972 if [ "$SCHEDTOOL" != "no" ]; then
1973 NICE_COMMAND="$SCHEDTOOL"
1975 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
1978 update_shell_title "$COMMAND"
1980 "build" | "build-binary" | "build-source" | "build-prep" )
1982 if [ -n "$SPECFILE" ]; then
1988 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1989 fetch_build_requires;
1990 if [ "$INTEGER_RELEASE" = "yes" ]; then
1991 echo "Checking release $PACKAGE_RELEASE..."
1992 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1993 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1997 if [ -n "$TEST_TAG" ]; then
1998 TAGVER=`make_tagver`
1999 echo "Searching for tag $TAGVER..."
2000 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2001 if [ -n "$TAGREL" ]; then
2002 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2005 # - do not allow to build from HEAD when XX-branch exists
2006 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2007 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2008 TAG_BRANCH="${TREE_PREFIX}-branch"
2009 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2010 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2011 Exit_error err_branch_exists "$TAG_STATUS"
2016 if [ -n "$NOSOURCE0" ] ; then
2017 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2019 get_files $SOURCES $PATCHES
2022 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2023 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2025 remove_build_requires;
2027 Exit_error err_no_spec_in_cmdl;
2032 if [ -n "$SPECFILE" ]; then
2035 # don't fetch sources from remote locations
2037 for file in $SOURCES; do
2038 [ -n "`src_md5 $file`" ] && continue
2039 new_SOURCES="$new_SOURCES $file"
2041 SOURCES="$new_SOURCES"
2042 get_files $SOURCES $PATCHES
2044 branch_files $TAG $SOURCES $PATCHES $ICONS
2046 Exit_error err_no_spec_in_cmdl;
2051 if [ -n "$SPECFILE" ]; then
2055 if [ -n "$NOSOURCE0" ] ; then
2056 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2058 get_files $SOURCES $PATCHES
2061 Exit_error err_no_spec_in_cmdl;
2066 if [ -n "$SPECFILE" ]; then
2070 if [ -n "$NOSOURCE0" ] ; then
2071 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2075 Exit_error err_no_spec_in_cmdl;
2082 if [ -n "$SPECFILE" ]; then
2086 # don't fetch sources from remote locations
2088 for file in $SOURCES; do
2089 [ -n "`src_md5 $file`" ] && continue
2090 new_SOURCES="$new_SOURCES $file"
2092 SOURCES="$new_SOURCES"
2093 get_files $SOURCES $PATCHES
2095 tag_files $SOURCES $PATCHES $ICONS
2097 Exit_error err_no_spec_in_cmdl;
2101 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2103 "list-sources-files" )
2106 DONT_PRINT_REVISION="yes"
2109 for SAP in $SOURCES $PATCHES; do
2110 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2113 "list-sources-urls" )
2116 DONT_PRINT_REVISION="yes"
2119 SAPS="$SOURCES $PATCHES"
2120 for SAP in $SAPS ; do
2124 "list-sources-local-paths" )
2127 DONT_PRINT_REVISION="yes"
2130 for SAP in $SOURCES $PATCHES; do
2131 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2134 "list-sources-distfiles-paths" )
2137 DONT_PRINT_REVISION="yes"
2140 for SAP in $SOURCES $PATCHES; do
2141 if [ -n "$(src_md5 "$SAP")" ]; then
2142 distfiles_path "$SAP"
2146 "list-sources-distfiles" )
2149 DONT_PRINT_REVISION="yes"
2152 for SAP in $SOURCES $PATCHES; do
2153 if [ -n "$(src_md5 "$SAP")" ]; then
2154 distfiles_url "$SAP"
2166 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2167 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2171 # vi:syntax=sh:ts=4:sw=4:noet