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"
96 if [ -x /usr/bin/rpm-getdeps ]; then
97 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
99 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
102 # Here we load saved user environment used to
103 # predefine options set above, or passed to builder
105 # This one reads global system environment settings:
106 if [ -f ~/etc/builderrc ]; then
109 # And this one cascades settings using user personal
111 # Example of ~/.builderrc:
113 #UPDATE_POLDEK_INDEXES="yes"
114 #FETCH_BUILD_REQUIRES="yes"
115 #REMOVE_BUILD_REQUIRES="force"
117 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
121 if [ -n "$HOME_ETC" ]; then
122 USER_CFG="$HOME_ETC/.builderrc"
124 USER_CFG=~/.builderrc
127 [ -f "$USER_CFG" ] && . "$USER_CFG"
129 if [ "$SCHEDTOOL" = "auto" ]; then
130 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
131 SCHEDTOOL="schedtool -B -e"
137 if [ -n "$USE_PROZILLA" ]; then
138 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
141 elif [ -n "$USE_AXEL" ]; then
142 GETURI="axel -a $AXEL_OPTS"
146 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
147 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
148 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
150 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
151 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
157 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
165 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
166 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
170 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
171 if [ -n "$LOGFILE" ]; then
172 LOG=`eval echo $LOGFILE`
173 if [ -n "$LASTLOG_FILE" ]; then
174 echo "LASTLOG=$LOG" > $LASTLOG_FILE
176 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
179 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
180 return `cat ${RES_FILE}`
185 #---------------------------------------------
190 if [ -n "$DEBUG" ]; then set -xv; fi
192 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
193 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
194 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
195 [-g|--get] [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
196 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
197 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
198 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
199 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
200 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
202 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
203 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
204 -n5, --no-md5 - ignore md5 comments in spec
205 -D, --debug - enable builder script debugging mode,
206 -debug - produce rpm debug package (same as --opts -debug)
207 -V, --version - output builder version
208 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
209 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
211 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
212 only package from <package>.spec,
213 -bp, --build-prep - execute the %prep phase of <package>.spec,
214 -bc - reserved (not implemented)
215 -bi reserved (not implemented)
216 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
218 --short-circuit - reserved (not implemented)
219 -B, --branch - add branch
220 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
221 SPECS and \$RPM_BUILD_ROOT),
222 -cf, --cvs-force - use -F when tagging (useful when moving branches)
223 -d <cvsroot>, --cvsroot <cvsroot>
225 --define <macro> <value>
226 - define a macro <macro> with value <value>,
227 --nodeps - rpm won't check any dependences
228 -g, --get - get <package>.spec and all related files from CVS repo
230 -h, --help - this message,
231 --http - use http instead of ftp,
232 -l <logfile>, --logtofile <logfile>
234 -m, --mr-proper - only remove all files related to spec file and all work
236 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
238 - don't check specs in CVS
239 -nd, --no-distfiles - don't download from distfiles
240 -nm, --no-mirrors - don't download from mirror, if source URL is given,
241 -nu, --no-urls - don't try to download from FTP/HTTP location,
242 -ns, --no-srcs - don't download Sources
243 -ns0, --no-source0 - don't download Source0
244 -nn, --no-net - don't download anything from the net
245 --no-init - don't initialize builder paths (SPECS and SOURCES)
247 --skip-existing-files - skip existing files in get_files
248 --opts <rpm opts> - additional options for rpm
249 -q, --quiet - be quiet,
250 --date yyyy-mm-dd - build package using resources from specified CVS date,
251 -r <cvstag>, --cvstag <cvstag>
252 - build package using resources from specified CVS tag,
253 -R, --fetch-build-requires
254 - fetch what is BuildRequired,
255 -RB, --remove-build-requires
256 - remove all you fetched with -R or --fetch-build-requires
257 remember, this option requires confirmation,
258 -FRB, --force-remove-build-requires
259 - remove all you fetched with -R or --fetch-build-requires
260 remember, this option works without confirmation,
261 -sd, --source-distfiles - list sources available from distfiles (intended for offline
262 operations; does not work when Icon field is present
263 but icon file is absent),
264 -sdp, --source-distfiles-paths - list sources available from distfiles -
265 paths relative to distfiles directory (intended for offline
266 operations; does not work when Icon field is present
267 but icon file is absent),
268 -sf, --source-files - list sources - bare filenames (intended for offline
269 operations; does not work when Icon field is present
270 but icon file is absent),
271 -sp, --source-paths - list sources - filenames with full local paths (intended for
272 offline operations; does not work when Icon field is present
273 but icon file is absent),
274 -su, --source-urls - list urls - urls to sources and patches
275 intended for copying urls with spec with lots of macros in urls
276 -T <cvstag> , --tag <cvstag>
277 - add cvs tag <cvstag> for files,
278 -Tvs, --tag-version-stable
279 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
281 - add cvs tag STABLE for files,
283 - add cvs tag NAME-VERSION-RELEASE for files,
284 -Tp, --tag-prefix <prefix>
285 - add <prefix> to NAME-VERSION-RELEASE tags,
286 -tt, --test-tag <prefix>
287 - fail if tag is already present,
288 -ir, --integer-release-only
289 - allow only integer and snapshot releases
290 -v, --verbose - be verbose,
291 -u, --try-upgrade - check version, and try to upgrade package
292 -un, --try-upgrade-with-float-version
293 - as above, but allow float version
294 -U, --update - refetch sources, don't use distfiles, and update md5 comments
295 -Upi, --update-poldek-indexes
296 - refresh or make poldek package index files.
297 -np, --nopatch <patchnumber>
298 - don't apply <patchnumber>
299 --show-bconds - show available conditional builds, which can be used
300 - with --with and/or --without switches.
301 --with/--without <feature>
302 - conditional build package depending on %_with_<feature>/
303 %_without_<feature> macro switch. You may now use
304 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
305 constructions. Set GROUP_BCONDS to yes to make use of it.
306 --target <platform>, --target=<platform>
307 - build for platform <platform>.
308 --init-rpm-dir - initialize ~/rpm directory structure
312 update_shell_title() {
314 local len=${COLUMNS:-80}
315 local msg=$(echo "$*" | cut -c-$len)
317 if [ -n "$BE_VERBOSE" ]; then
318 echo >&2 "$(date +%s.%N) $*"
321 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
323 if [ -n "$PACKAGE_NAME" ]; then
324 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
329 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
330 msg="$(echo $msg | tr -d '\n\r')"
333 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
336 echo >&2 -ne "\033]0;$msg\007"
342 # set TARGET from BuildArch: from SPECFILE
344 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
345 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
350 TARGET_SWITCH="--target $TARGET" ;;
352 TARGET_SWITCH="--target=$TARGET" ;;
359 if [ -n "$DEBUG" ]; then
364 update_shell_title "cache_rpm_dump"
368 # we reset macros not to contain macros.build as all the %() macros are
369 # executed here, while none of them are actually needed.
370 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
371 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
372 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
373 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
374 # FIXME: better ideas than .rpmrc?
375 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
376 # TODO: move these to /usr/lib/rpm/macros
377 cat > .builder-rpmmacros <<'EOF'
378 %requires_releq_kernel_up %{nil}
379 %requires_releq_kernel_smp %{nil}
380 %requires_releq() %{nil}
381 %pyrequires_eq() %{nil}
382 %requires_eq() %{nil}
383 %requires_eq_to() %{nil}
384 %releq_kernel_up ERROR
385 %releq_kernel_smp ERROR
389 %ruby_ver_requires_eq() %{nil}
390 %ruby_mod_ver_requires_eq() %{nil}
391 %__php_api_requires() %{nil}
392 %php_major_version ERROR
393 %php_api_version ERROR
401 ARGS='--nodigest --nosignature --nobuild'
404 if [ "$NOINIT" = "yes" ] ; then
405 cat >> .builder-rpmmacros <<'EOF'
410 $RPMBUILD --rcfile .builder-rpmrc $ARGS $ARGDIRS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
412 if [ $? -gt 0 ]; then
413 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
415 Exit_error err_build_fail;
418 # make small dump cache
419 rpm_dump_cache=`echo "$rpm_dump" | awk '
420 $2 ~ /^SOURCEURL/ {print}
421 $2 ~ /^PATCHURL/ {print}
422 $2 ~ /^nosource/ {print}
423 $2 ~ /^PACKAGE_/ {print}
426 update_shell_title "cache_rpm_dump: OK!"
430 if [ -z "$rpm_dump_cache" ] ; then
431 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
433 echo "$rpm_dump_cache"
438 update_shell_title "get icons"
439 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
440 if [ -z "$ICONS" ]; then
444 rpm_dump_cache="kalasaba" NODIST="yes" UPDATE5= get_files $ICONS
449 update_shell_title "parsing specfile"
450 if [ -n "$DEBUG" ]; then
455 # icons are needed for successful spec parse
461 if [ "$NOSRCS" != "yes" ]; then
462 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
465 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
466 FAIL_IF_NO_SOURCES="no"
469 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
470 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
471 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
472 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
473 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
475 if [ -n "$BE_VERBOSE" ]; then
476 echo "- Sources : `nourl $SOURCES`"
477 if [ -n "$PATCHES" ]; then
478 echo "- Patches : `nourl $PATCHES`"
480 echo "- Patches : *no patches needed*"
482 if [ -n "$ICONS" ]; then
483 echo "- Icon : `nourl $ICONS`"
485 echo "- Icon : *no package icon*"
487 echo "- Name : $PACKAGE_NAME"
488 echo "- Version : $PACKAGE_VERSION"
489 echo "- Release : $PACKAGE_RELEASE"
492 update_shell_title "parse_spec: OK!"
497 if [ -n "$DEBUG" ]; then
505 "err_no_spec_in_cmdl" )
506 remove_build_requires
507 echo "ERROR: spec file name not specified.";
509 "err_no_spec_in_repo" )
510 remove_build_requires
511 echo "Error: spec file not stored in CVS repo.";
513 "err_no_source_in_repo" )
514 remove_build_requires
515 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
518 remove_build_requires
519 echo "Error: package build failed. (${2:-no more info})";
521 "err_no_package_data" )
522 remove_build_requires
523 echo "Error: couldn't get out package name/version/release from spec file."
526 remove_build_requires
527 echo "Tag ${2} already exists (spec release: ${3}).";
530 remove_build_requires
531 echo "Release ${2} not integer and not a snapshot.";
533 "err_branch_exists" )
534 remove_build_requires
535 echo "Tree branch already exists (${2}).";
539 echo "Unknown error."
545 if [ -n "$DEBUG" ]; then
550 if [ "$NOINIT" != "yes" ] ; then
551 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
552 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
564 update_shell_title "get_spec"
566 if [ -n "$DEBUG" ]; then
572 if [ ! -f "$SPECFILE" ]; then
573 SPECFILE="`basename $SPECFILE .spec`.spec";
575 if [ "$NOCVSSPEC" != "yes" ]; then
577 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
578 echo "Warning: No CVS access defined - using local .spec file"
582 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
585 if [ ! -f "$SPECFILE" ]; then
586 Exit_error err_no_spec_in_repo;
589 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
590 chmod $CHMOD_MODE $SPECFILE
593 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
602 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
603 cvs update mirrors >&2
607 local origin mirror name rest ol prefix
608 while read origin mirror name rest; do
609 # skip comments and empty lines
610 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
613 ol=`echo -n "$origin"|wc -c`
614 prefix="`echo -n "$url" | head -c $ol`"
615 if [ "$prefix" = "$origin" ] ; then
616 suffix="`echo "$url"|cut -b $((ol+1))-`"
617 echo -n "$mirror$suffix"
624 # Warning: unpredictable results if same URL used twice
629 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
630 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
636 [ "$NO5" = "yes" ] && return
638 [ -z "$no" ] && return
642 if [ -f additional-md5sums ]; then
643 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
644 if [ -z "$spec_rev" ]; then
645 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
647 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
648 md5=$(grep -s -v '^#' additional-md5sums | \
649 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
650 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
651 grep -E '^[0-9a-f]{32}$')
654 if [ $(echo "$md5" | wc -l) != 1 ] ; then
655 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
657 echo "$md5" | tail -n 1
662 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
663 if [ -n "$source_md5" ]; then
666 # we have empty SourceX-md5, but it is still possible
667 # that we have NoSourceX-md5 AND NoSource: X
668 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
669 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
677 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
682 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
685 distfiles_attic_url ()
687 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
694 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
699 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
700 [ -n "$size" -a "$size" -gt 0 ]
705 if [ "$CVSIGNORE_DF" != "yes" ]; then
708 cvsignore=${SOURCE_DIR}/.cvsignore
709 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
710 echo "$1" >> $cvsignore
716 update_shell_title "cvsup"
718 if [ -n "$CVSROOT" ]; then
719 OPTIONS="-d $CVSROOT $OPTIONS"
722 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
723 OPTIONS="$OPTIONS -A"
725 if [ -n "$CVSDATE" ]; then
726 OPTIONS="$OPTIONS -D $CVSDATE"
728 if [ -n "$CVSTAG" ]; then
729 OPTIONS="$OPTIONS -r $CVSTAG"
734 local retries_counter=0
736 update_shell_title "cvsup: $*"
738 update_shell_title "cvsup: $# files"
740 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
741 retries_counter=$(( $retries_counter + 1 ))
742 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
744 [ -n "$output" ] && echo "$output"
745 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
746 echo "Trying again [$*]... ($retries_counter)"
747 update_shell_title "cvsup: retry #$retries_counter"
754 update_shell_title "cvsup: done!"
760 if [ $# -eq 0 ]; then
764 update_shell_title "update md5"
765 if [ -n "$DEBUG" ]; then
772 # pass 1: check files to be fetched
776 local fp=$(nourl "$i")
777 local srcno=$(src_no "$i")
778 if [ -n "$UPDATE5" ]; then
779 if [ -n "$ADD5" ]; then
780 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
781 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
783 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
786 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
787 need_files="$need_files $i"
791 # pass 1a: get needed files
792 if [ "$need_files" ]; then
793 get_files $need_files
796 # pass 2: proceed with md5 adding or updating
798 local fp=$(nourl "$i")
799 local srcno=$(src_no "$i")
800 if [ -n "$UPDATE5" ] && \
801 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
802 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
803 grep -q -i -E '^#[ ]*source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
805 echo "Updating source-$srcno md5."
806 md5=$(md5sum "$fp" | cut -f1 -d' ')
808 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
809 print "# Source'$srcno'-md5:\t'$md5'\n"
810 if /^Source'$srcno'\s*:\s+/;
819 update_shell_title "check md5"
822 if good_md5 "$i" && good_size "$i"; then
826 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
827 echo "or -5 to update md5 sums, if you're sure files are correct."
828 Exit_error err_no_source_in_repo $i
834 update_shell_title "get_files"
836 if [ -n "$DEBUG" ]; then
841 if [ $# -gt 0 ]; then
844 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
845 echo "Warning: No CVS access defined for SOURCES"
850 local get_files_cvs=""
854 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
855 update_shell_title "$i"
856 local fp=`nourl "$i"`
857 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
862 local srcmd5=$(src_md5 "$i")
864 # we know if source/patch is present in cvs/distfiles
865 # - has md5 (in distfiles)
868 # CHECK: local file didn't exist or always cvs up (first) requested.
869 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
870 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
871 echo "Warning: no URL given for $i"
874 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
875 if good_md5 "$i" && good_size "$i"; then
876 echo "$fp having proper md5sum already exists"
880 url=$(distfiles_url "$i")
881 url_attic=$(distfiles_attic_url "$i")
883 # is $url local file?
884 if [[ "$url" = [./]* ]]; then
885 update_shell_title "${GETLOCAL%% *}: $url"
886 ${GETLOCAL} $url $target
888 if [ -z "$NOMIRRORS" ]; then
889 url="`find_mirror "$url"`"
891 update_shell_title "${GETURI%% *}: $url"
892 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
893 if [ "`echo $url | grep -E 'ftp://'`" ]; then
894 update_shell_title "${GETURI2%% *}: $url"
895 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
900 if [ ! -s "$target" ]; then
902 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
903 update_shell_title "${GETLOCAL%% *}: $url_attic"
904 ${GETLOCAL} $url_attic $target
906 if [ -z "$NOMIRRORS" ]; then
907 url_attic="`find_mirror "$url_attic"`"
909 update_shell_title "${GETURI%% *}: $url_attic"
910 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
911 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
912 update_shell_title "${GETURI2%% *}: $url_attic"
913 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
918 if [ -s "$target" ]; then
924 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
925 if [ $# -gt 1 ]; then
926 get_files_cvs="$get_files_cvs $fp"
927 update_shell_title "$fp (will cvs up later)"
934 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
935 if [ -z "$NOMIRRORS" ]; then
936 im="`find_mirror "$i"`"
940 update_shell_title "${GETURI%% *}: $im"
942 if [ "`echo $im | grep -E 'ftp://'`" ]; then
943 update_shell_title "${GETURI2%% *}: $im"
948 if [ "$cvsup" = 1 ]; then
954 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
955 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
956 Exit_error err_no_source_in_repo $i;
959 # we check md5 here just only to refetch immediately
960 if good_md5 "$i" && good_size "$i"; then
962 elif [ "$FROM_DISTFILES" = 1 ]; then
963 # wrong md5 from distfiles: remove the file and try again
965 echo "MD5 sum mismatch. Trying full fetch."
968 update_shell_title "${GETURI%% *}: $url"
969 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
970 if [ "`echo $url | grep -E 'ftp://'`" ]; then
971 update_shell_title "${GETURI2%% *}: $url"
972 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
974 if [ ! -s "$target" ]; then
976 update_shell_title "${GETURI%% *}: $url_attic"
977 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
978 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
979 update_shell_title "${GETURI2%% *}: $url_attic"
980 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
983 test -s "$target" || rm -f "$target"
986 SHELL_TITLE_PREFIX=""
988 if [ "$get_files_cvs" ]; then
992 if [ "$CHMOD" = "yes" ]; then
993 CHMOD_FILES="`nourl "$@"`"
994 if [ -n "$CHMOD_FILES" ]; then
995 chmod $CHMOD_MODE $CHMOD_FILES
1002 if [ -n "$DEBUG" ]; then
1007 # Check whether first character of PACKAGE_NAME is legal for tag name
1008 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1011 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"`
1012 # Remove #kernel.version_release from TAGVER because tagging sources
1013 # could occur with different kernel-headers than kernel-headers used at build time.
1014 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
1022 if [ -n "$DEBUG" ]; then
1027 echo "Version: $PACKAGE_VERSION"
1028 echo "Release: $PACKAGE_RELEASE"
1030 TAGVER=`make_tagver`
1032 if [ "$TAG_VERSION" = "yes" ]; then
1033 echo "CVS tag: $TAGVER"
1035 if [ -n "$TAG" ]; then
1036 echo "CVS tag: $TAG"
1039 local OPTIONS="tag $CVS_FORCE"
1040 if [ -n "$CVSROOT" ]; then
1041 OPTIONS="-d $CVSROOT $OPTIONS"
1046 for i in $TAG_FILES; do
1047 # don't tag files stored on distfiles
1048 [ -n "`src_md5 $i`" ] && continue
1049 local fp=`nourl "$i"`
1050 if [ -f "$fp" ]; then
1051 tag_files="$tag_files $fp"
1053 Exit_error err_no_source_in_repo $i
1057 if [ "$tag_files" ]; then
1058 if [ "$TAG_VERSION" = "yes" ]; then
1059 update_shell_title "tag sources: $TAGVER"
1060 cvs $OPTIONS $TAGVER $tag_files
1062 if [ -n "$TAG" ]; then
1063 update_shell_title "tag sources: $TAG"
1064 cvs $OPTIONS $TAG $tag_files
1069 if [ "$TAG_VERSION" = "yes" ]; then
1070 update_shell_title "tag spec: $TAGVER"
1071 cvs $OPTIONS $TAGVER $SPECFILE
1073 if [ -n "$TAG" ]; then
1074 update_shell_title "tag spec: $TAG"
1075 cvs $OPTIONS $TAG $SPECFILE
1082 echo "CVS branch tag: $TAG"
1087 if [ -n "$DEBUG" ]; then
1092 local OPTIONS="tag $CVS_FORCE -b"
1093 if [ -n "$CVSROOT" ]; then
1094 OPTIONS="-d $CVSROOT $OPTIONS"
1098 for i in $TAG_FILES; do
1099 local fp=`nourl "$i"`
1100 if [ -f "$fp" ]; then
1101 tag_files="$tag_files $fp"
1103 Exit_error err_no_source_in_repo $i
1106 if [ "$tag_files" ]; then
1107 cvs $OPTIONS $TAG $tag_files
1111 cvs $OPTIONS $TAG $SPECFILE
1118 update_shell_title "build_package"
1119 if [ -n "$DEBUG" ]; then
1126 if [ -n "$TRY_UPGRADE" ]; then
1127 update_shell_title "build_package: try_upgrade"
1128 if [ -n "$FLOAT_VERSION" ]; then
1129 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1131 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1134 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1136 if [ -n "$TNEWVER" ]; then
1137 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1138 echo "New version found, updating spec file to version " $TNEWVER
1139 cp -f $SPECFILE $SPECFILE.bak
1141 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1142 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1144 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1145 unset TOLDVER TNEWVER TNOTIFY
1152 BUILD_SWITCH="-ba" ;;
1154 BUILD_SWITCH="-bb" ;;
1156 BUILD_SWITCH="-bs --nodeps" ;;
1158 BUILD_SWITCH="-bp --nodeps" ;;
1161 update_shell_title "build_package: $COMMAND"
1162 if [ -n "$LOGFILE" ]; then
1163 LOG=`eval echo $LOGFILE`
1164 if [ -d "$LOG" ]; then
1165 echo "Log file $LOG is a directory."
1166 echo "Parse error in the spec?"
1167 Exit_error err_build_fail;
1169 if [ -n "$LASTLOG_FILE" ]; then
1170 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1172 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1173 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1174 RETVAL=`cat $RES_FILE`
1176 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1177 if [ "$RETVAL" -eq "0" ]; then
1184 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1187 if [ "$RETVAL" -ne "0" ]; then
1188 if [ -n "$TRY_UPGRADE" ]; then
1189 echo "\n!!! Package with new version cannot be built automagically\n"
1190 mv -f $SPECFILE.bak $SPECFILE
1192 Exit_error err_build_fail;
1199 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1202 install_required_packages()
1209 # taken from find-spec-bcond, but with just getting the list
1211 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1213 /^%changelog/ { exit }
1214 /_with(out)?_[_a-zA-Z0-9]+/{
1215 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1216 print substr($0, RSTART, RLENGTH);
1219 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1220 bcond = substr($0, RSTART +5 , RLENGTH -5);
1221 gsub(/[ \t]+/,"_",bcond);
1223 }' $SPEC | LC_ALL=C sort -u
1228 update_shell_title "set bcond values"
1230 AVAIL_BCONDS_WITHOUT=""
1231 AVAIL_BCONDS_WITH=""
1232 if `grep -q ^%bcond ${SPECFILE}`; then
1234 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1240 local bcond_avail=$(find_spec_bcond $SPECFILE)
1242 # expand bconds from ~/.bcondrc
1243 # The file structure is like gentoo's package.use:
1246 # samba -mysql -pgsql
1247 # w32codec-installer license_agreement
1250 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1251 SN=${SPECFILE%%\.spec}
1253 local bcondrc=$HOME/.bcondrc
1254 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1256 while read pkg flags; do
1258 [[ "$pkg" == \#* ]] && continue
1260 # any package or current package?
1261 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1262 for flag in $flags; do
1263 local opt=${flag#[+-]}
1265 # use only flags which are in this package.
1266 if [[ $bcond_avail = *${opt}* ]]; then
1267 if [[ $flag = -* ]]; then
1268 if [[ $BCOND != *--with?${opt}* ]]; then
1269 BCOND="$BCOND --without $opt"
1272 if [[ $BCOND != *--without?${opt}* ]]; then
1273 BCOND="$BCOND --with $opt"
1280 update_shell_title "parse ~/.bcondrc: DONE!"
1283 update_shell_title "parse bconds"
1284 case "${BCOND_VERSION}" in
1289 echo "Warning: This spec has old style bconds. Fix it || die."
1290 for opt in `echo "$bcond_avail" | grep ^_without_`
1292 AVAIL_BCOND_WITHOUT=${opt#_without_}
1293 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1294 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1296 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1300 for opt in `echo "$bcond_avail" | grep ^_with_`
1302 AVAIL_BCOND_WITH=${opt#_with_}
1303 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1304 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1306 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1311 local cond_type="" # with || without
1312 for opt in $bcond_avail; do
1321 AVAIL_BCOND_WITHOUT=${opt#_without_}
1322 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1323 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1325 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1329 AVAIL_BCOND_WITH=${opt#_with_}
1330 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1331 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1333 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1337 case "$cond_type" in
1340 AVAIL_BCOND_WITH="$opt"
1341 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1342 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1344 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1349 AVAIL_BCOND_WITHOUT="$opt"
1350 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1351 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1353 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1367 update_shell_title "run_sub_builder $package_name"
1369 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1370 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1371 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1372 # jakby nie bylo tego kawalka kodu.
1374 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1375 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1382 # Istnieje taki spec? ${package}.spec
1383 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1384 parent_spec_name=${package}.spec
1385 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1386 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1388 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1394 if [ "${parent_spec_name}" != "" ]; then
1395 spawn_sub_builder $parent_spec_name
1397 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1403 update_shell_title "spawn_sub_builder $package_name"
1406 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1407 sub_builder_opts="${sub_builder_opts} -R"
1409 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1410 sub_builder_opts="${sub_builder_opts} -RB"
1411 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1412 sub_builder_opts="${sub_builder_opts} -FRB"
1414 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1415 sub_builder_opts="${sub_builder_opts} -Upi"
1419 ./builder ${sub_builder_opts} "$@"
1422 remove_build_requires()
1424 if [ "$INSTALLED_PACKAGES" != "" ]; then
1425 case "$REMOVE_BUILD_REQUIRES" in
1427 run_poldek --noask -ve $INSTALLED_PACKAGES
1430 run_poldek --ask -ve $INSTALLED_PACKAGES
1433 echo You may want to manually remove following BuildRequires fetched:
1434 echo $INSTALLED_PACKAGES
1435 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1443 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1444 if [ "$BCOND" != "" ]; then
1445 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1448 echo -ne "\nNo conditional flags passed"
1450 echo -ne "\n\nfrom available:\n"
1451 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1457 if [ "$NOCVSSPEC" != "yes" ]; then
1458 echo -ne "Available branches: "
1459 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1463 # checks a given list of packages/files/provides agains current rpmdb.
1464 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1465 # input can be either STDIN or parameters
1470 if [ "$#" -gt 0 ]; then
1476 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1479 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1481 # other deps (files)
1482 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1485 # checks if given package/files/provides exists in rpmdb.
1486 # inout can be either stdin or parameters
1487 # returns packages wchi hare present in the rpmdb
1492 if [ "$#" -gt 0 ]; then
1498 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1501 fetch_build_requires()
1503 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1504 update_shell_title "fetch build requires"
1505 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1506 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1507 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1509 update_shell_title "poldek: update indexes"
1510 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1511 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1513 if [ -n "$CONF" ]; then
1514 update_shell_title "uninstall conflicting packages: $CONF"
1515 echo "Trying to uninstall conflicting packages ($CONF):"
1516 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1519 while [ "$DEPS" ]; do
1520 update_shell_title "install deps: $DEPS"
1521 echo "Trying to install dependencies ($DEPS):"
1522 local log=.${SPECFILE}_poldek.log
1523 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1524 failed=$(awk -F: '/^error:/{print $2}' $log)
1527 if [ -n "$failed" ]; then
1528 for package in $failed; do
1529 # FIXME: sanitise, deps could be not .spec files
1530 spawn_sub_builder -bb $package && ok="$ok $package"
1540 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1541 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1542 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1543 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1544 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1545 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`
1547 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`"
1549 package=`basename "$package_item"|sed -e "s/}$//g"`
1550 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1553 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1554 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1555 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
1560 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1563 if `echo $COND_TST|grep -q 'without_'`; then
1564 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1565 if `echo $COND_TST|grep -q !`; then
1570 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1571 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1572 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1578 elif `echo $COND_TST|grep -q 'with_'`; then
1579 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1580 if `echo $COND_TST|grep -q !`; then
1585 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1586 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1587 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1593 RESULT="${COND_STATE}-${COND_ARGV}"
1595 "with-wout" | "wout-with" )
1598 "wout-wout" | "with-with" )
1602 echo "Action '$RESULT' was not defined for package '$package_item'"
1608 if [ "$GO" = "yes" ]; then
1609 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1610 echo "Testing if $package has subrequirements..."
1611 run_poldek -t -i $package --dumpn=".$package-req.txt"
1612 if [ -f ".$package-req.txt" ]; then
1613 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1615 if [ "$package_name" = "$package" ]; then
1616 echo -ne "Installing BuildRequired package:\t$package_name\n"
1617 update_shell_title "Installing BuildRequired package: ${package_name}"
1618 install_required_packages $package;
1620 echo -ne "Installing (sub)Required package:\t$package_name\n"
1621 update_shell_title "Installing (sub)Required package: ${package_name}"
1622 install_required_packages $package_name;
1626 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1627 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1630 echo "Attempting to run spawn sub - builder..."
1631 echo -ne "Package installation failed:\t$package_name\n"
1632 run_sub_builder $package_name
1633 if [ $? -eq 0 ]; then
1634 install_required_packages $package_name;
1637 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1638 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1641 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1648 rm -f ".$package-req.txt"
1650 echo "Attempting to run spawn sub - builder..."
1651 echo -ne "Package installation failed:\t$package\n"
1652 run_sub_builder $package
1653 if [ $? -eq 0 ]; then
1654 install_required_packages $package;
1657 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1658 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1661 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1667 echo "Package $package is already installed. BuildRequirement satisfied."
1671 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1672 echo "Unable to install following packages and their dependencies:"
1673 for pkg in "$NOT_INSTALLED_PACKAGES"
1677 remove_build_requires
1685 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1686 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1688 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1690 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1694 echo "To checkout *all* .spec files:"
1695 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1696 echo "- run cvs up in $SPECS_DIR dir"
1699 echo "To commit with your developer account:"
1700 echo "- edit $SPECS_DIR/CVS/Root"
1701 echo "- edit $SOURCE_DIR/CVS/Root"
1704 #---------------------------------------------
1707 if [ "$#" = 0 ]; then
1716 COMMAND="update_md5";
1722 COMMAND="update_md5";
1733 DEBUG="yes"; shift ;;
1735 COMMAND="version"; shift ;;
1737 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1738 -b | -ba | --build )
1739 COMMAND="build"; shift ;;
1740 -bb | --build-binary )
1741 COMMAND="build-binary"; shift ;;
1742 -bs | --build-source )
1743 COMMAND="build-source"; shift ;;
1744 -bp | --build-prep )
1745 COMMAND="build-prep"; shift ;;
1747 COMMAND="branch"; shift; TAG="${1}"; shift;;
1749 CLEAN="--clean --rmspec --rmsource"; shift ;;
1751 CVS_FORCE="-F"; shift;;
1753 shift; CVSROOT="${1}"; shift ;;
1755 COMMAND="get"; shift ;;
1757 COMMAND="usage"; shift ;;
1759 PROTOCOL="http"; shift ;;
1761 shift; LOGFILE="${1}"; shift ;;
1763 shift; DEF_NICE_LEVEL=${1}; shift ;;
1764 -ske | --skip-existing-files)
1765 SKIP_EXISTING_FILES="yes"; shift ;;
1767 COMMAND="mr-proper"; shift ;;
1769 NOCVS="yes"; shift ;;
1770 -ncs | --no-cvs-specs )
1771 NOCVSSPEC="yes"; shift ;;
1772 -nd | --no-distfiles )
1773 NODIST="yes"; shift ;;
1774 -nm | --no-mirrors )
1775 NOMIRRORS="yes"; shift ;;
1777 NOURLS="yes"; shift ;;
1779 NOSRCS="yes"; shift ;;
1780 -ns0 | --no-source0 )
1781 NOSOURCE0="yes"; shift ;;
1795 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1797 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1798 --with | --without )
1799 case $GROUP_BCONDS in
1803 while ! `echo ${1}|grep -qE '(^-|spec)'`
1805 BCOND="$BCOND $COND $1"
1809 if [[ "$2" = *,* ]]; then
1810 for a in $(echo "$2" | tr , ' '); do
1811 BCOND="$BCOND $1 $a"
1814 BCOND="$BCOND $1 $2"
1820 shift; TARGET="${1}"; shift ;;
1822 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1824 QUIET="--quiet"; shift ;;
1826 CVSDATE="${2}"; shift 2 ;;
1828 shift; CVSTAG="${1}"; shift ;;
1829 -R | --fetch-build-requires)
1830 FETCH_BUILD_REQUIRES="yes"
1831 NOT_INSTALLED_PACKAGES=
1833 -RB | --remove-build-requires)
1834 REMOVE_BUILD_REQUIRES="nice"
1836 -FRB | --force-remove-build-requires)
1837 REMOVE_BUILD_REQUIRES="force"
1839 -sd | --sources-distfiles)
1840 COMMAND="list-sources-distfiles"
1842 -sdp | --sources-distfiles-paths)
1843 COMMAND="list-sources-distfiles-paths"
1845 -sf | --sources-files)
1846 COMMAND="list-sources-files"
1848 -sp | --sources-paths)
1849 COMMAND="list-sources-local-paths"
1851 -su | --sources-urls)
1852 COMMAND="list-sources-urls"
1854 -Tvs | --tag-version-stable )
1859 -Ts | --tag-stable )
1864 -Tv | --tag-version )
1869 -Tp | --tag-prefix )
1881 -ir | --integer-release-only )
1882 INTEGER_RELEASE="yes"
1885 COMMAND="update_md5"
1891 -Upi | --update-poldek-indexes )
1892 UPDATE_POLDEK_INDEXES="yes"
1895 COMMAND="init_rpm_dir";
1897 -u | --try-upgrade )
1898 TRY_UPGRADE="1"; shift ;;
1899 -un | --try-upgrade-with-float-version )
1900 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1902 BE_VERBOSE="1"; shift ;;
1907 if echo "${MACRO}" | grep -q '\W'; then
1908 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
1912 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1915 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1921 RPMOPTS="${RPMOPTS} --nodeps"
1924 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1927 # check if specname was passed as specname:cvstag
1928 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1929 CVSTAG="${SPECFILE##*:}";
1930 SPECFILE="${SPECFILE%%:*}";
1936 if [ -z "$CVSTAG" ]; then
1937 CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
1938 if [ "$CVSTAG" ]; then
1939 echo "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
1941 elif [ "$CVSTAG" = "HEAD" ]; then
1942 # assume -r HEAD is same as -A
1946 if [ -n "$DEBUG" ]; then
1951 if [ -n "$TARGET" ]; then
1954 TARGET_SWITCH="--target $TARGET" ;;
1956 TARGET_SWITCH="--target=$TARGET" ;;
1960 if [ "$SCHEDTOOL" != "no" ]; then
1961 NICE_COMMAND="$SCHEDTOOL"
1963 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
1966 update_shell_title "$COMMAND"
1968 "build" | "build-binary" | "build-source" | "build-prep" )
1970 if [ -n "$SPECFILE" ]; then
1976 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1977 fetch_build_requires;
1978 if [ "$INTEGER_RELEASE" = "yes" ]; then
1979 echo "Checking release $PACKAGE_RELEASE..."
1980 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1981 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1985 if [ -n "$TEST_TAG" ]; then
1986 TAGVER=`make_tagver`
1987 echo "Searching for tag $TAGVER..."
1988 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1989 if [ -n "$TAGREL" ]; then
1990 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1993 # - do not allow to build from HEAD when XX-branch exists
1994 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1995 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1996 TAG_BRANCH="${TREE_PREFIX}-branch"
1997 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1998 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1999 Exit_error err_branch_exists "$TAG_STATUS"
2004 if [ -n "$NOSOURCE0" ] ; then
2005 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2007 get_files $SOURCES $PATCHES
2010 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2011 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2013 remove_build_requires;
2015 Exit_error err_no_spec_in_cmdl;
2020 if [ -n "$SPECFILE" ]; then
2023 get_files $SOURCES $PATCHES
2025 branch_files $TAG $SOURCES $PATCHES $ICONS
2027 Exit_error err_no_spec_in_cmdl;
2032 if [ -n "$SPECFILE" ]; then
2036 if [ -n "$NOSOURCE0" ] ; then
2037 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2039 get_files $SOURCES $PATCHES
2042 Exit_error err_no_spec_in_cmdl;
2047 if [ -n "$SPECFILE" ]; then
2051 if [ -n "$NOSOURCE0" ] ; then
2052 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2056 Exit_error err_no_spec_in_cmdl;
2063 if [ -n "$SPECFILE" ]; then
2067 # don't fetch sources from remote locations
2069 for file in $SOURCES; do
2070 [ -n "`src_md5 $file`" ] && continue
2071 new_SOURCES="$new_SOURCES $file"
2073 SOURCES="$new_SOURCES"
2074 get_files $SOURCES $PATCHES
2076 tag_files $SOURCES $PATCHES $ICONS
2078 Exit_error err_no_spec_in_cmdl;
2082 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2084 "list-sources-files" )
2087 DONT_PRINT_REVISION="yes"
2090 for SAP in $SOURCES $PATCHES; do
2091 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2094 "list-sources-urls" )
2097 DONT_PRINT_REVISION="yes"
2100 SAPS="$SOURCES $PATCHES"
2101 for SAP in $SAPS ; do
2105 "list-sources-local-paths" )
2108 DONT_PRINT_REVISION="yes"
2111 for SAP in $SOURCES $PATCHES; do
2112 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2115 "list-sources-distfiles-paths" )
2118 DONT_PRINT_REVISION="yes"
2121 for SAP in $SOURCES $PATCHES; do
2122 if [ -n "$(src_md5 "$SAP")" ]; then
2123 distfiles_path "$SAP"
2127 "list-sources-distfiles" )
2130 DONT_PRINT_REVISION="yes"
2133 for SAP in $SOURCES $PATCHES; do
2134 if [ -n "$(src_md5 "$SAP")" ]; then
2135 distfiles_url "$SAP"
2147 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2148 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2152 # vi:syntax=sh:ts=4:sw=4:noet