3 # This program is free software, distributed under the terms of
4 # the GNU General Public License Version 2.
10 # 2 - no spec file name in cmdl parameters
11 # 3 - spec file not stored in repo
12 # 4 - some source, patch or icon files not stored in repo
13 # 5 - package build failed
14 # 6 - spec file with errors
15 # 7 - wrong source in /etc/poldek.conf
16 # 8 - Failed installing buildrequirements and subrequirements
17 # 9 - Requested tag already exist
18 # 10 - Refused to build fractional release
19 # 100 - Unknown error (should not happen)
20 # 110 - Functions not yet implemented
23 # - when Icon: field is present, -5 and -a5 doesn't work
24 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
25 # - does not respect NoSource: X, and tries to cvs up such files [ example: VirtualBox-bin.spec and its Source0 ]
27 # - ability to do ./builder -bb foo.spec foo2.spec foo3.spec
28 # - funny bug, if source-md5 is set then builder will download from distfiles even if there is no url present:
29 # Source10: forwardfix.pl
30 # # Source10-md5: 8bf85f7368933a4e0cb4f875bac28733
32 # basename: missing operand
33 # Try `basename --help' for more information.
34 # -- and the normal usage info --
37 APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d")
38 RCSID='$Id: builder,v 1.645 2011/02/13 17:54:10 glen Exp $' r=${RCSID#* * } rev=${r%% *}
41 Build package utility from PLD Linux Packages repository
42 $VERSION (C) 1999-2011 Free Penguins".
44 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
46 # required rpm-build-macros
65 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
68 # use rpm 4.4.6+ digest format instead of comments if non-zero
71 # user agent when fetching files
72 USER_AGENT="PLD/Builder($VERSION)"
74 # It can be used i.e. in log file naming.
75 # See LOGFILE example.
76 DATE=`date +%Y-%m-%d_%H-%M-%S`
78 # Example: LOGFILE='../log.$PACKAGE_NAME'
79 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
80 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
81 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
82 # Yes, you can use variable name! Note _single_ quotes!
97 # create symlinks for tools in PACKAGE_DIR, see get_spec()
108 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
110 CVS_COMMAND=${CVS_COMMAND:-cvs}
113 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
114 CVS_SERVER="cvs.pld-linux.org"
116 GIT_SERVER="git://github.com/draenog"
122 DISTFILES_SERVER="://distfiles.pld-linux.org"
123 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
128 FAIL_IF_NO_SOURCES="yes"
130 # let get_files skip over files which are present to get those damn files fetched
131 SKIP_EXISTING_FILES="no"
134 # should the specfile be restored if upgrade failed?
135 REVERT_BROKEN_UPGRADE="yes"
137 if rpm --specsrpm 2>/dev/null; then
138 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
139 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
141 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
142 if [ -x /usr/bin/rpm-getdeps ]; then
143 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
145 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
150 # Here we load saved user environment used to
151 # predefine options set above, or passed to builder
153 # This one reads global system environment settings:
154 if [ -f ~/etc/builderrc ]; then
157 # And this one cascades settings using user personal
159 # Example of ~/.builderrc:
161 #UPDATE_POLDEK_INDEXES="yes"
162 #FETCH_BUILD_REQUIRES="yes"
163 #REMOVE_BUILD_REQUIRES="force"
165 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
169 if [ -n "$HOME_ETC" ]; then
170 USER_CFG="$HOME_ETC/.builderrc"
171 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
173 USER_CFG=~/.builderrc
174 BUILDER_MACROS=~/.builder-rpmmacros
177 [ -f "$USER_CFG" ] && . "$USER_CFG"
179 if [ "$SCHEDTOOL" = "auto" ]; then
180 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
181 SCHEDTOOL="schedtool -B -e"
187 if [ -n "$USE_PROZILLA" ]; then
188 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
191 elif [ -n "$USE_AXEL" ]; then
192 GETURI="axel -a $AXEL_OPTS"
196 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
197 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
198 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
199 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
201 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
202 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
208 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
219 if [ -d $HOME/rpm/SOURCES ]; then
220 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
221 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
225 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
226 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
230 if [ -n "$LOGFILE" ]; then
231 LOG=`eval echo $LOGFILE`
232 if [ -n "$LASTLOG_FILE" ]; then
233 echo "LASTLOG=$LOG" > $LASTLOG_FILE
235 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
238 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
239 return `cat ${RES_FILE}`
244 #---------------------------------------------
248 if [ -n "$DEBUG" ]; then set -xv; fi
250 Usage: builder [-D|--debug] [-V|--version] [--short-version] [--as_anon] [-a|--add_cvs] [-b|-ba|--build]
251 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
252 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [--depth <number>]
253 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
254 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
255 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
256 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
257 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
258 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
259 <package>[.spec][:cvstag]
261 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
262 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
263 -n5, --no-md5 - ignore md5 comments in spec
264 -D, --debug - enable builder script debugging mode,
265 -debug - produce rpm debug package (same as --opts -debug)
266 -V, --version - output builder version string
267 --short-version - output builder short version
268 --as_anon - get files via pserver as cvs@$CVS_SERVER,
269 -a, --add_cvs - try add new package to CVS.
270 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
272 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
273 only package from <package>.spec,
274 -bp, --build-prep - execute the %prep phase of <package>.spec,
275 -bc - execute the %build phase of <package>.spec,
276 -bi - execute the %install phase of <package>.spec
277 -bl - execute the %files phase of <package>.spec
278 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
280 --short-circuit - short-circuit build
281 -B, --branch - add branch
282 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
283 may be used with building process.
284 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
285 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
287 -cf, --cvs-force - use -F when tagging (useful when moving branches)
288 -d <cvsroot>, --cvsroot <cvsroot>
290 --define <macro> <value>
291 - define a macro <macro> with value <value>,
294 --alt_kernel <kernel>
295 - same as --define 'alt_kernel <kernel>'
296 --nodeps - rpm won't check any dependences
297 -g, --get - get <package>.spec and all related files from CVS repo
299 -h, --help - this message,
300 -jN, -j N - set %_smp_mflags to propagate concurrent jobs
301 --ftp, --http - use ftp or http protocol to access distfiles server
302 -l <logfile>, --logtofile <logfile>
305 - don't check specs in CVS
306 -nd, --no-distfiles - don't download from distfiles
307 -nm, --no-mirrors - don't download from mirror, if source URL is given,
308 -nu, --no-urls - don't try to download from FTP/HTTP location,
309 -ns, --no-srcs - don't download Sources/Patches
310 -ns0, --no-source0 - don't download Source0
311 -nn, --no-net - don't download anything from the net
312 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
313 --no-init - don't initialize builder paths (SPECS and SOURCES)
315 --skip-existing-files - skip existing files in get_files
316 --opts <rpm opts> - additional options for rpm
317 -q, --quiet - be quiet,
318 --date yyyy-mm-dd - build package using resources from specified CVS date,
319 -r <cvstag>, --cvstag <cvstag>
320 - build package using resources from specified CVS tag,
321 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
322 -R, --fetch-build-requires
323 - fetch what is BuildRequired,
324 -RB, --remove-build-requires
325 - remove all you fetched with -R or --fetch-build-requires
326 remember, this option requires confirmation,
327 -FRB, --force-remove-build-requires
328 - remove all you fetched with -R or --fetch-build-requires
329 remember, this option works without confirmation,
330 -sd, --source-distfiles - list sources available from distfiles (intended for offline
331 operations; does not work when Icon field is present
332 but icon file is absent),
333 -sc, --source-cvs - list sources available from CVS
334 -sdp, --source-distfiles-paths - list sources available from distfiles -
335 paths relative to distfiles directory (intended for offline
336 operations; does not work when Icon field is present
337 but icon file is absent),
338 -sf, --source-files - list sources - bare filenames (intended for offline
339 operations; does not work when Icon field is present
340 but icon file is absent),
341 -lsp, --source-paths - list sources - filenames with full local paths (intended for
342 offline operations; does not work when Icon field is present
343 but icon file is absent),
344 -su, --source-urls - list urls - urls to sources and patches
345 intended for copying urls with spec with lots of macros in urls
346 -T <cvstag> , --tag <cvstag>
347 - add cvs tag <cvstag> for files,
348 -Tvs, --tag-version-stable
349 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
351 - add cvs tag STABLE for files,
353 - add cvs tag NAME-VERSION-RELEASE for files,
354 -Tp, --tag-prefix <prefix>
355 - add <prefix> to NAME-VERSION-RELEASE tags,
356 -tt, --test-tag <prefix>
357 - fail if tag is already present,
358 -ir, --integer-release-only
359 - allow only integer and snapshot releases
360 -v, --verbose - be verbose,
361 -u, --try-upgrade - check version, and try to upgrade package
362 -un, --try-upgrade-with-float-version
363 - as above, but allow float version
364 php-pear-Services_Digg/
365 --upgrade-version - upgrade to specified version in try-upgrade
366 -U, --update - refetch sources, don't use distfiles, and update md5 comments
367 -Upi, --update-poldek-indexes
368 - refresh or make poldek package index files.
369 -sp, --skip-patch <patchnumber>
370 - don't apply <patchnumber>. may be repeated.
371 -np, --nopatch <patchnumber>
372 - abort instead of applying patch <patchnumber>
373 --show-bconds - show available conditional builds, which can be used
374 - with --with and/or --without switches.
375 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
376 ./repackage.sh script. in other words, the output is
377 parseable by scripts.
378 --show-avail-bconds - show available bconds
379 --with/--without <feature>
380 - conditional build package depending on %_with_<feature>/
381 %_without_<feature> macro switch. You may now use
382 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
383 constructions. Set GROUP_BCONDS to yes to make use of it.
384 --target <platform>, --target=<platform>
385 - build for platform <platform>.
386 --init-rpm-dir - initialize ~/rpm directory structure
390 # create tempfile. as secure as possible
392 mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
395 # inserts git log instead of %changelog
396 # outputs name of modified file created by tempfile
398 local SPECFILE=$1 specfile=$(tempfile) gitlog=$(tempfile) speclog=$(tempfile)
400 # allow this being customized
401 local log_entries=$(rpm -E '%{?_buildchangelogtruncate}')
403 # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997'
404 # otherwise i'd use --date=iso here
405 # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1
406 # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31
407 # NOTE: changelog date is always in UTC for rpmbuild
408 # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
409 git log -${log_entries:-20} --format=format:"* %ad %an <%ae> %h%n%s%n" --date=raw > $gitlog
410 gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
411 sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
416 rm -f $gitlog $speclog
420 # change dependency to specname
422 # - perl(Package::Name) -> perl-Package-Name
426 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
430 update_shell_title() {
432 local len=${COLUMNS:-80}
433 local msg="$(echo "$*" | cut -c-$len)"
435 if [ -n "$BE_VERBOSE" ]; then
436 echo >&2 "$(date +%s.%N) $*"
439 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
441 if [ -n "$PACKAGE_NAME" ]; then
442 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
447 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
448 msg=$(echo $msg | tr -d '\n\r')
451 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
454 echo >&2 -ne "\033]0;$msg\007"
460 # set TARGET from BuildArch: from SPECFILE
462 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
463 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
465 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
469 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
471 TARGET_SWITCH="--target=$TARGET" ;;
477 # runs rpm with minimal macroset
479 # we reset macros not to contain macros.build as all the %() macros are
480 # executed here, while none of them are actually needed.
481 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
482 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
484 # TODO: move these to /usr/lib/rpm/macros
485 cat > $BUILDER_MACROS <<'EOF'
486 %x8664 x86_64 amd64 ia32e
489 %bootstrap_release() %{1}
490 %requires_releq_kernel_up(s:n:) %{nil}
491 %requires_releq_kernel_smp(s:n:) %{nil}
492 %requires_releq_kernel(s:n:) %{nil}
493 %requires_releq() %{nil}
494 %pyrequires_eq() %{nil}
495 %requires_eq() %{nil}
496 %requires_eq_to() %{nil}
497 %requires_ge() %{nil}
498 %requires_ge_to() %{nil}
499 %requires_ge() %{nil}
500 %releq_kernel_up(n:) ERROR
501 %releq_kernel_smp(n:) ERROR
502 %releq_kernel(n:) ERROR
506 %ruby_ver_requires_eq() %{nil}
507 %ruby_mod_ver_requires_eq() %{nil}
508 %__php_api_requires() %{nil}
509 %php_major_version ERROR
510 %php_api_version ERROR
511 %requires_xorg_xserver_extension %{nil}
512 %requires_xorg_xserver_xinput %{nil}
513 %requires_xorg_xserver_font %{nil}
514 %requires_xorg_xserver_videodrv %{nil}
516 %perl_vendorarch ERROR
517 %perl_vendorlib ERROR
518 # damn. need it here! - copied from /usr/lib/rpm/macros.build
519 %tmpdir %(echo "${TMPDIR:-/tmp}")
520 %patchset_source(f:b:) %(
521 base=%{-b*}%{!-b*:10000};
522 start=$(expr $base + %1);
523 end=$(expr $base + %{?2}%{!?2:%{1}});
524 # we need to call seq twice as it doesn't allow two formats
525 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
526 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
527 paste %{tmpdir}/__ps{1,2};
528 rm -f %{tmpdir}/__ps{1,2};
531 %add_etc_shells(p) %{p:<lua>}
532 %remove_etc_shells(p) %{p:<lua>}
533 %lua_add_etc_shells() %{nil}
534 %lua_remove_etc_shells() %{nil}
536 %buildrequires_jdk %{nil}
537 %pear_package_print_optionalpackages %{nil}
539 if [ "$NOINIT" = "yes" ] ; then
540 cat >> $BUILDER_MACROS <<'EOF'
545 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
549 if [ -n "$DEBUG" ]; then
554 if [ -x /usr/bin/rpm-specdump ]; then
555 update_shell_title "cache_rpm_dump using rpm-specdump command"
556 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
558 update_shell_title "cache_rpm_dump using rpmbuild command"
561 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
562 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
568 ARGS='--nodigest --nosignature --nobuild'
571 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
573 if [ $? -gt 0 ]; then
574 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
576 Exit_error err_build_fail
579 # make small dump cache
580 rpm_dump_cache=`echo "$rpm_dump" | awk '
581 $2 ~ /^SOURCEURL/ {print}
582 $2 ~ /^PATCHURL/ {print}
583 $2 ~ /^nosource/ {print}
584 $2 ~ /^PACKAGE_/ {print}
588 update_shell_title "cache_rpm_dump: OK!"
592 if [ -z "$rpm_dump_cache" ] ; then
593 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
595 echo "$rpm_dump_cache"
599 update_shell_title "get icons"
600 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
601 if [ -z "$ICONS" ]; then
605 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
609 update_shell_title "parsing specfile"
610 if [ -n "$DEBUG" ]; then
615 # icons are needed for successful spec parse
621 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
622 FAIL_IF_NO_SOURCES="no"
625 if [ "$NOSRCS" != "yes" ]; then
626 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
627 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
628 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
631 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
632 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
633 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
635 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
636 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
639 if [ -n "$BE_VERBOSE" ]; then
640 echo "- Sources : `nourl $SOURCES`"
641 if [ -n "$PATCHES" ]; then
642 echo "- Patches : `nourl $PATCHES`"
644 echo "- Patches : *no patches needed*"
646 if [ -n "$ICONS" ]; then
647 echo "- Icon : `nourl $ICONS`"
649 echo "- Icon : *no package icon*"
651 echo "- Name : $PACKAGE_NAME"
652 echo "- Version : $PACKAGE_VERSION"
653 echo "- Release : $PACKAGE_RELEASE"
656 update_shell_title "parse_spec: OK!"
660 if [ -n "$DEBUG" ]; then
668 "err_no_spec_in_cmdl" )
669 remove_build_requires
670 echo >&2 "ERROR: spec file name not specified."
672 "err_invalid_cmdline" )
673 echo >&2 "ERROR: invalid command line arg ($2)."
675 "err_no_spec_in_repo" )
676 remove_build_requires
677 echo >&2 "Error: spec file not stored in CVS repo."
679 "err_no_source_in_repo" )
680 remove_build_requires
681 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
683 "err_cvs_add_failed" )
684 echo >&2 "Error: failed to add package to CVS repo."
687 remove_build_requires
688 echo >&2 "Error: package build failed. (${2:-no more info})"
690 "err_no_package_data" )
691 remove_build_requires
692 echo >&2 "Error: couldn't get out package name/version/release from spec file."
695 remove_build_requires
696 echo >&2 "Tag ${2} already exists (spec release: ${3})."
699 remove_build_requires
700 echo >&2 "Release ${2} not integer and not a snapshot."
702 "err_branch_exists" )
703 remove_build_requires
704 echo >&2 "Tree branch already exists (${2})."
707 remove_build_requires
708 echo >&2 "Error: conditions reject building this spec (${2})."
710 "err_not_implemented" )
711 remove_build_requires
712 echo >&2 "Error: functionality not yet imlemented"
715 echo >&2 "Unknown error."
720 if [ -n "$DEBUG" ]; then
725 if [ "$NOINIT" != "yes" ] ; then
726 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
728 local macros_ver=$(rpm -E %?rpm_build_macros)
729 if [ -z "$macros_ver" ]; then
730 REPO_DIR=$TOP_DIR/packages
731 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
733 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
734 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
738 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
744 export GIT_WORK_TREE=$PACKAGE_DIR
745 export GIT_DIR=$PACKAGE_DIR/.git
752 update_shell_title "get_spec"
754 if [ -n "$DEBUG" ]; then
760 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
762 SPECFILE=$(basename $SPECFILE)
765 if [ "$NOCVSSPEC" != "yes" ]; then
766 if [ -z "$DEPTH" ]; then
767 if [ -d "$ASSUMED_NAME/.git" ]; then
768 git fetch origin || Exit_error err_no_spec_in_repo
769 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
770 if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
771 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
774 Exit_error err_not_implemented
778 git clone ${GIT_SERVER}/${ASSUMED_NAME}.git || {
779 # softfail if new package, i.e not yet added to cvs
780 [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
781 echo "Warning: package not in CVS - assuming new package"
787 if [ ! -d "$ASSUMED_NAME/.git" ]; then
788 if [ ! -d "$ASSUMED_NAME" ]; then
792 git remote add origin ${GIT_SERVER}/${ASSUMED_NAME}.git
794 git fetch "$DEPTH" origin ${CVSTAG}:remotes/origin/${CVSTAG} || {
795 echo >&2 "Error: branch $CVSTAG does not exist"
800 cvsignore_df .gitignore
802 # add default log format to .cvsignore if it is relative to package dir
803 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
804 # substitute known "macros" to glob
805 local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
806 if [ "$logfile" ]; then
807 cvsignore_df "$logfile"
811 # create symlinks for tools
812 if [ "$SYMLINK_TOOLS" != "no" ]; then
813 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
814 [ -f $a ] || continue
815 ln -sf ../$a $ASSUMED_NAME
821 if [ -n "$CVSTAG" ]; then
822 git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "origin/$CVSTAG" > /dev/null || exit
823 git symbolic-ref -q HEAD > /dev/null &&
825 if [ -n "$CVSDATE" ]; then
826 git checkout $(git rev-list -n1 --before="'$CVSDATE'" $CVSTAG) || exit 1
830 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
831 Exit_error err_no_spec_in_repo
834 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
835 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
838 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
846 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
847 $CVS_COMMAND update mirrors >&2
851 local origin mirror name rest ol prefix
852 while read origin mirror name rest; do
853 # skip comments and empty lines
854 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
857 ol=$(echo -n "$origin" | wc -c)
858 prefix=$(echo -n "$url" | head -c $ol)
859 if [ "$prefix" = "$origin" ] ; then
860 suffix=$(echo "$url" | cut -b $((ol+1))-)
861 echo -n "$mirror$suffix"
868 # Warning: unpredictable results if same URL used twice
872 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
873 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
878 [ "$NO5" = "yes" ] && return
880 [ -z "$no" ] && return
884 if [ -f additional-md5sums ]; then
885 md5=$(grep -s -v '^#' additional-md5sums | \
886 grep -E "[ ]$(basename "$1")([ ,]|\$)" | \
887 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
888 grep -E '^[0-9a-f]{32}$')
891 if [ $(echo "$md5" | wc -l) != 1 ] ; then
892 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
894 echo "$md5" | tail -n 1
899 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
900 if [ -n "$source_md5" ]; then
903 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
904 if [ -n "$source_md5" ]; then
907 # we have empty SourceX-md5, but it is still possible
908 # that we have NoSourceX-md5 AND NoSource: X
909 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
910 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
918 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
922 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
925 distfiles_attic_url() {
926 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
932 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
936 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
937 [ -n "$size" -a "$size" -gt 0 ]
941 if [ "$CVSIGNORE_DF" != "yes" ]; then
944 cvsignore=${PACKAGE_DIR}/.gitignore
946 # add only if not yet there
947 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
948 echo "$1" >> $cvsignore
952 # returns true if "$1" is ftp, http or https protocol url
955 ftp://*|http://*|https://*)
963 if [ $# -eq 0 ]; then
967 update_shell_title "update md5"
968 if [ -n "$DEBUG" ]; then
975 # pass 1: check files to be fetched
979 local fp=$(nourl "$i")
980 local srcno=$(src_no "$i")
981 if [ -n "$ADD5" ]; then
982 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
983 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
984 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
986 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
988 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
989 need_files="$need_files $i"
993 # pass 1a: get needed files
994 if [ "$need_files" ]; then
995 get_files $need_files
998 # pass 2: proceed with md5 adding or updating
1000 local fp=$(nourl "$i")
1001 local srcno=$(src_no "$i")
1002 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
1003 if [ -z "$md5" ]; then
1004 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
1006 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
1007 local tag="# Source$srcno-md5:\t"
1008 if [[ "$md5" == *NoSource* ]]; then
1009 tag="# NoSource$srcno-md5:\t"
1010 elif [ -n "$USEDIGEST" ]; then
1011 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
1013 md5=$(md5sum "$fp" | cut -f1 -d' ')
1014 echo "Updating Source$srcno ($md5: $fp)."
1016 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
1017 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
1019 $PACKAGE_DIR/$SPECFILE
1026 [ "$NO5" = "yes" ] && return
1028 update_shell_title "check md5"
1032 if ! good_md5 "$i"; then
1033 echo -n "MD5 sum mismatch."
1036 if ! good_size "$i"; then
1037 echo -n "0 sized file."
1041 if [ $bad -eq 1 ]; then
1042 echo " Use -U to refetch sources,"
1043 echo "or -5 to update md5 sums, if you're sure files are correct."
1044 Exit_error err_no_source_in_repo $i
1050 update_shell_title "get_files"
1052 if [ -n "$DEBUG" ]; then
1057 if [ $# -gt 0 ]; then
1061 local get_files_cvs=""
1065 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1066 update_shell_title "$i"
1067 local fp=`nourl "$i"`
1068 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1073 local srcmd5=$(src_md5 "$i")
1075 # we know if source/patch is present in cvs/distfiles
1076 # - has md5 (in distfiles)
1077 # - in cvs... ideas?
1079 # CHECK: local file didn't exist or always cvs up (first) requested.
1080 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1081 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1082 echo "Warning: no URL given for $i"
1086 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1087 if good_md5 "$i" && good_size "$i"; then
1088 echo "$fp having proper md5sum already exists"
1092 # optionally prefer mirror over distfiles if there's mirror
1093 # TODO: build url list and then try each url from the list
1094 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1097 url=$(distfiles_url "$i")
1100 url_attic=$(distfiles_attic_url "$i")
1102 # is $url local file?
1103 if [[ "$url" = [./]* ]]; then
1104 update_shell_title "${GETLOCAL%% *}: $url"
1105 ${GETLOCAL} $url $target
1107 if [ -z "$NOMIRRORS" ]; then
1108 url=$(find_mirror "$url")
1112 # make shorter message for distfiles urls
1113 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1114 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1115 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1118 update_shell_title "${GETURI%% *}: $uri"
1119 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1120 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1121 update_shell_title "${GETURI2%% *}: $url"
1122 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1127 if [ ! -s "$target" ]; then
1129 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1130 update_shell_title "${GETLOCAL%% *}: $url_attic"
1131 ${GETLOCAL} $url_attic $target
1133 if [ -z "$NOMIRRORS" ]; then
1134 url_attic=$(find_mirror "$url_attic")
1136 update_shell_title "${GETURI%% *}: $url_attic"
1137 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1138 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1139 update_shell_title "${GETURI2%% *}: $url_attic"
1140 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1142 test -s "$target" || rm -f "$target"
1146 if [ -s "$target" ]; then
1147 cvsignore_df $target
1154 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1155 if [ -z "$NOMIRRORS" ]; then
1156 im=$(find_mirror "$i")
1160 update_shell_title "${GETURI%% *}: $im"
1161 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1162 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1163 update_shell_title "${GETURI2%% *}: $im"
1164 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1166 test -s "$target" || rm -f "$target"
1169 if [ "$cvsup" = 1 ]; then
1175 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1176 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1177 Exit_error err_no_source_in_repo $i
1180 # we check md5 here just only to refetch immediately
1181 if good_md5 "$i" && good_size "$i"; then
1183 elif [ "$FROM_DISTFILES" = 1 ]; then
1184 # wrong md5 from distfiles: remove the file and try again
1186 echo "MD5 sum mismatch. Trying full fetch."
1189 update_shell_title "${GETURI%% *}: $url"
1190 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1191 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1192 update_shell_title "${GETURI2%% *}: $url"
1193 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1195 if [ ! -s "$target" ]; then
1197 update_shell_title "${GETURI%% *}: $url_attic"
1198 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1199 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1200 update_shell_title "${GETURI2%% *}: $url_attic"
1201 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1204 test -s "$target" || rm -f "$target"
1207 SHELL_TITLE_PREFIX=""
1210 if [ "$CHMOD" = "yes" ]; then
1211 CHMOD_FILES=$(nourl "$@")
1212 if [ -n "$CHMOD_FILES" ]; then
1213 chmod $CHMOD_MODE $CHMOD_FILES
1220 if [ -n "$DEBUG" ]; then
1225 # Check whether first character of PACKAGE_NAME is legal for tag name
1226 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1230 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1231 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1233 # Remove #kernel.version_release from TAGVER because tagging sources
1234 # could occur with different kernel-headers than kernel-headers used at build time.
1235 # besides, %{_kernel_ver_str} is not expanded.
1237 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1238 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1247 if [ -n "$DEBUG" ]; then
1252 echo "Version: $PACKAGE_VERSION"
1253 echo "Release: $PACKAGE_RELEASE"
1256 if [ "$TAG_VERSION" = "yes" ]; then
1257 TAGVER=`make_tagver`
1260 if [ -n "$TAG" ]; then
1264 local OPTIONS="tag $CVS_FORCE"
1267 if [ "$TAG_VERSION" = "yes" ]; then
1273 if [ "$TAG_VERSION" = "yes" ]; then
1274 update_shell_title "tag sources: $TAGVER"
1275 git $OPTIONS $TAGVER || exit
1277 if [ -n "$TAG" ]; then
1278 update_shell_title "tag sources: $TAG"
1279 git $OPTIONS $TAG $chunk || exit
1285 echo "Git branch: $TAG"
1288 if [ -n "$DEBUG" ]; then
1293 local OPTIONS="branch $CVS_FORCE"
1296 git $OPTIONS $TAG || exit
1300 # this function should exit early if package can't be built for this arch
1301 # this avoids unneccessary BR filling.
1304 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1306 if [ $ret -ne 0 ]; then
1318 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1319 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1325 local ver="$2" subver=$ver
1326 local newver="$3" newsubver=$newver
1328 # try handling subver, everything that's not numeric-dotted in version
1329 if grep -Eq '%define\s+subver' $specfile; then
1330 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1332 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1333 newver=${newver%$newsubver}
1336 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1337 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1338 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1343 if [ -n "$TRY_UPGRADE" ]; then
1344 local TNOTIFY TNEWVER TOLDVER
1345 update_shell_title "build_package: try_upgrade"
1349 if [ "$UPGRADE_VERSION" ]; then
1350 TNEWVER=$UPGRADE_VERSION
1352 if [ -n "$FLOAT_VERSION" ]; then
1353 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1355 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1358 # pldnotify.awk does not set exit codes, but it has match for ERROR
1359 # in output which means so.
1360 if [[ "$TNOTIFY" = *ERROR* ]]; then
1365 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1368 if [ -n "$TNEWVER" ]; then
1369 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1370 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1371 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1372 cp -f $SPECFILE $SPECFILE.bak
1375 set_release $SPECFILE $PACKAGE_RELEASE 1
1376 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1378 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1379 echo >&2 "Upgrading version failed, you need to update spec yourself"
1389 update_shell_title "build_package"
1390 if [ -n "$DEBUG" ]; then
1399 BUILD_SWITCH="-ba" ;;
1401 BUILD_SWITCH="-bb" ;;
1403 BUILD_SWITCH="-bs --nodeps" ;;
1405 BUILD_SWITCH="-bp --nodeps" ;;
1407 BUILD_SWITCH="-bc" ;;
1409 BUILD_SWITCH="-bi" ;;
1411 BUILD_SWITCH="-bl" ;;
1415 update_shell_title "build_package: $COMMAND"
1416 if [ -n "$LOGFILE" ]; then
1417 LOG=`eval echo $LOGFILE`
1418 if [ -d "$LOG" ]; then
1419 echo "Log file $LOG is a directory."
1420 echo "Parse error in the spec?"
1421 Exit_error err_build_fail
1423 if [ -n "$LASTLOG_FILE" ]; then
1424 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1426 RES_FILE=$(tempfile)
1427 local specfile=$(insert_gitlog $SPECFILE)
1429 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specfile; echo $? > $RES_FILE) 2>&1 |tee $LOG
1430 RETVAL=`cat $RES_FILE`
1431 rm $RES_FILE $specfile
1432 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1433 if [ "$RETVAL" -eq "0" ]; then
1440 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1443 if [ "$RETVAL" -ne "0" ]; then
1444 if [ -n "$TRY_UPGRADE" ]; then
1445 echo "\nUpgrade package to new version failed."
1446 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1447 echo "Restoring old spec file."
1448 mv -f $SPECFILE.bak $SPECFILE
1452 Exit_error err_build_fail
1458 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1461 install_required_packages() {
1466 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1469 /^%changelog/ { exit }
1471 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1472 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1473 gsub(/[ \t]+/, "_", bcond);
1475 }' $SPEC | LC_ALL=C sort -u
1479 # expand bconds from ~/.bcondrc
1480 # The file structure is like gentoo's package.use:
1483 # samba -mysql -pgsql
1484 # w32codec-installer license_agreement
1487 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1493 SN=${SPECFILE%%\.spec}
1495 local bcondrc=$HOME/.bcondrc
1496 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1498 local bcond_avail=$(find_spec_bcond $SPECFILE)
1500 while read pkg flags; do
1502 [[ "$pkg" == \#* ]] && continue
1504 # any package or current package?
1505 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1506 for flag in $flags; do
1507 local opt=${flag#[+-]}
1509 # use only flags which are in this package.
1510 if [[ $bcond_avail = *${opt}* ]]; then
1511 if [[ $flag = -* ]]; then
1512 if [[ $BCOND != *--with?${opt}* ]]; then
1513 BCOND="$BCOND --without $opt"
1516 if [[ $BCOND != *--without?${opt}* ]]; then
1517 BCOND="$BCOND --with $opt"
1524 update_shell_title "parse ~/.bcondrc: DONE!"
1527 set_bconds_values() {
1528 update_shell_title "set bcond values"
1530 AVAIL_BCONDS_WITHOUT=""
1531 AVAIL_BCONDS_WITH=""
1533 if grep -Eq '^# *_with' ${SPECFILE}; then
1534 echo >&2 "ERROR: This spec has old style bconds."
1538 if ! grep -q '^%bcond' ${SPECFILE}; then
1542 local bcond_avail=$(find_spec_bcond $SPECFILE)
1543 process_bcondrc "$SPECFILE"
1545 update_shell_title "parse bconds"
1548 for opt in $bcond_avail; do
1551 bcond=${opt#without_}
1553 *--without?${bcond}*)
1554 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1557 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1565 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1568 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1573 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1582 update_shell_title "run_sub_builder $package_name"
1584 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1585 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1586 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1587 # jakby nie bylo tego kawalka kodu.
1589 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1590 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1594 # kurwa. translate that ^^^^
1598 # Istnieje taki spec? ${package}.spec
1599 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1600 parent_spec_name=${package}.spec
1601 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1602 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1604 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1609 if [ "${parent_spec_name}" != "" ]; then
1610 spawn_sub_builder $parent_spec_name
1612 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1615 spawn_sub_builder() {
1617 update_shell_title "spawn_sub_builder $package_name"
1620 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1621 sub_builder_opts="${sub_builder_opts} -R"
1623 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1624 sub_builder_opts="${sub_builder_opts} -RB"
1625 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1626 sub_builder_opts="${sub_builder_opts} -FRB"
1628 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1629 sub_builder_opts="${sub_builder_opts} -Upi"
1633 ./builder ${sub_builder_opts} "$@"
1636 remove_build_requires() {
1637 if [ "$INSTALLED_PACKAGES" != "" ]; then
1638 case "$REMOVE_BUILD_REQUIRES" in
1640 run_poldek --noask -ve $INSTALLED_PACKAGES
1643 run_poldek --ask -ve $INSTALLED_PACKAGES
1646 echo You may want to manually remove following BuildRequires fetched:
1647 echo $INSTALLED_PACKAGES
1648 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1655 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1656 if [ "$BCOND" ]; then
1658 echo "Building $SPECFILE with the following conditional flags:"
1662 echo "No conditional flags passed"
1665 echo "from available:"
1666 echo "--with :\t$AVAIL_BCONDS_WITH"
1667 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1672 display_branches() {
1673 if [ "$NOCVSSPEC" != "yes" ]; then
1674 echo -n "Available branches: "
1675 git branch -r | grep '^ origin' | grep -v origin/HEAD | sed 's#^ *origin/##' | xargs
1679 # checks a given list of packages/files/provides agains current rpmdb.
1680 # outputs all dependencies which current rpmdb doesn't satisfy.
1681 # input can be either STDIN or parameters
1685 if [ $# -gt 0 ]; then
1691 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1694 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1696 # other deps (files)
1697 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1700 # checks if given package/files/provides exists in rpmdb.
1701 # input can be either stdin or parameters
1702 # returns packages which are present in the rpmdb
1706 if [ $# -gt 0 ]; then
1712 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1715 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1716 install_build_requires_rpmdeps() {
1717 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1718 # TODO: Conflicts list doesn't check versions
1719 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1720 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1722 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1723 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1724 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1727 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1728 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1729 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1730 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1732 if [ -n "$CNFL" ]; then
1733 update_shell_title "uninstall conflicting packages: $CNFL"
1734 echo "Trying to uninstall conflicting packages ($CNFL):"
1735 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1738 while [ "$DEPS" ]; do
1739 update_shell_title "install deps: $DEPS"
1740 echo "Trying to install dependencies ($DEPS):"
1741 local log=.${SPECFILE}_poldek.log
1742 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1743 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1746 if [ -n "$failed" ]; then
1747 for package in $failed; do
1748 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1757 fetch_build_requires()
1759 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1763 update_shell_title "fetch build requires"
1764 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1765 install_build_requires_rpmdeps
1769 # XXX is this ugliest code written in human history still needed?
1770 echo "All packages installed by fetch_build_requires() are written to:"
1771 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1773 echo "If anything fails, you may get rid of them by executing:"
1774 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1776 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1777 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)
1779 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)
1781 package=$(basename "$package_item"|sed -e "s/}$//g")
1782 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1785 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1786 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1787 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
1792 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1795 if `echo $COND_TST|grep -q 'without_'`; then
1796 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1797 if `echo $COND_TST|grep -q !`; then
1802 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1803 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1804 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1810 elif `echo $COND_TST|grep -q 'with_'`; then
1811 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1812 if `echo $COND_TST|grep -q !`; then
1817 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1818 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1819 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1825 RESULT="${COND_STATE}-${COND_ARGV}"
1827 "with-wout" | "wout-with" )
1830 "wout-wout" | "with-with" )
1834 echo "Action '$RESULT' was not defined for package '$package_item'"
1840 if [ "$GO" = "yes" ]; then
1841 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1842 echo "Testing if $package has subrequirements..."
1843 run_poldek -t -i $package --dumpn=".$package-req.txt"
1844 if [ -f ".$package-req.txt" ]; then
1845 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1847 if [ "$package_name" = "$package" ]; then
1848 echo "Installing BuildRequired package:\t$package_name"
1849 update_shell_title "Installing BuildRequired package: ${package_name}"
1850 install_required_packages $package
1852 echo "Installing (sub)Required package:\t$package_name"
1853 update_shell_title "Installing (sub)Required package: ${package_name}"
1854 install_required_packages $package_name
1858 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1859 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1862 echo "Attempting to run spawn sub - builder..."
1863 echo "Package installation failed:\t$package_name"
1864 run_sub_builder $package_name
1865 if [ $? -eq 0 ]; then
1866 install_required_packages $package_name
1869 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1870 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1873 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1880 rm -f ".$package-req.txt"
1882 echo "Attempting to run spawn sub - builder..."
1883 echo "Package installation failed:\t$package"
1884 run_sub_builder $package
1885 if [ $? -eq 0 ]; then
1886 install_required_packages $package
1889 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1890 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1893 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1899 echo "Package $package is already installed. BuildRequirement satisfied."
1903 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1904 echo >&2 "Unable to install following packages and their dependencies:"
1905 for pkg in "$NOT_INSTALLED_PACKAGES"
1909 remove_build_requires
1915 local CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1916 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1917 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
1918 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
1919 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
1922 echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
1923 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
1925 # need to checkout to tmp dir or we can't name our topdir
1926 tmp=$(TMPDIR= TEMPDIR= mktemp -p $TOP_DIR -d) || exit 1
1928 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh,ci,civim}
1930 mv $tmp/packages/* $TOP_DIR
1935 echo "To checkout *all* .spec files (read-only):"
1936 echo "- run cvs co SPECS"
1938 echo "To checkout *all* packages:"
1939 echo "- run cvs up -dP in $TOP_DIR dir"
1942 echo "To commit with your developer account:"
1943 echo "- edit $TOP_DIR/CVS/Root"
1946 # remove entries from CVS/Entries
1947 cvs_entry_remove() {
1948 local cvsdir="$1"; shift
1949 if [ ! -d "$cvsdir" ]; then
1950 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1954 for file in "$@"; do
1955 rm -f $cvsdir/CVS/Entries.new || return 1
1956 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1957 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1965 DONT_PRINT_REVISION="yes"
1969 # remove spec and sources
1970 $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $SPECFILE
1971 rm -rf $PACKAGE_DIR/.git .gitignore
1973 rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
1976 #---------------------------------------------
1984 while [ $# -gt 0 ]; do
1987 COMMAND="update_md5"
1992 COMMAND="update_md5"
2001 DEBUG="yes"; shift ;;
2003 COMMAND="version"; shift ;;
2005 COMMAND="short-version"; shift ;;
2007 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2011 -b | -ba | --build )
2012 COMMAND="build"; shift ;;
2013 -bb | --build-binary )
2014 COMMAND="build-binary"; shift ;;
2016 COMMAND="build-build"; shift ;;
2018 COMMAND="build-install"; shift ;;
2020 COMMAND="build-list"; shift ;;
2021 -bp | --build-prep )
2022 COMMAND="build-prep"; shift ;;
2023 -bs | --build-source )
2024 COMMAND="build-source"; shift ;;
2026 COMMAND="branch"; shift; TAG="${1}"; shift;;
2028 CLEAN="--clean"; shift ;;
2030 CVS_FORCE="-f"; shift;;
2032 shift; CVSROOT="${1}"; shift ;;
2038 COMMAND="get"; shift ;;
2040 COMMAND="usage"; shift ;;
2042 PROTOCOL="ftp"; shift ;;
2044 PROTOCOL="http"; shift ;;
2046 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
2050 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
2054 shift; LOGFILE="${1}"; shift ;;
2056 shift; DEF_NICE_LEVEL=${1}; shift ;;
2057 -ske | --skip-existing-files)
2058 SKIP_EXISTING_FILES="yes"; shift ;;
2060 COMMAND="mr-proper"; shift ;;
2061 -ncs | --no-cvs-specs )
2062 NOCVSSPEC="yes"; shift ;;
2063 -nd | --no-distfiles )
2064 NODIST="yes"; shift ;;
2065 -nm | --no-mirrors )
2066 NOMIRRORS="yes"; shift ;;
2068 NOURLS="yes"; shift ;;
2070 NOSRCS="yes"; shift ;;
2071 -ns0 | --no-source0 )
2072 NOSOURCE0="yes"; shift ;;
2081 -pm | --prefer-mirrors )
2088 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2090 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2091 --skip-patch | -sp )
2092 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2094 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2097 --with | --without )
2098 case $GROUP_BCONDS in
2102 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2103 while ! `echo ${1}|grep -qE '(^-|spec)'`
2105 BCOND="$BCOND $COND $1"
2109 if [[ "$2" = *,* ]]; then
2110 for a in $(echo "$2" | tr , ' '); do
2111 BCOND="$BCOND $1 $a"
2114 BCOND="$BCOND $1 $2"
2120 shift; TARGET="${1}"; shift ;;
2122 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2124 QUIET="--quiet"; shift ;;
2126 CVSDATE="${2}"; shift 2
2127 date -d "$CVSDATE" > /dev/null 2>&1 || { echo >&2 "No valid date specified"; exit 3; }
2137 -R | --fetch-build-requires)
2138 FETCH_BUILD_REQUIRES="yes"
2139 NOT_INSTALLED_PACKAGES=
2141 -RB | --remove-build-requires)
2142 REMOVE_BUILD_REQUIRES="nice"
2144 -FRB | --force-remove-build-requires)
2145 REMOVE_BUILD_REQUIRES="force"
2147 -sc | --sources-cvs)
2148 COMMAND="list-sources-cvs"
2150 -sd | --source-distfiles)
2151 COMMAND="list-sources-distfiles"
2153 -sdp | --source-distfiles-paths)
2154 COMMAND="list-sources-distfiles-paths"
2156 -sf | --source-files)
2157 COMMAND="list-sources-files"
2159 -lsp | --source-paths)
2160 COMMAND="list-sources-local-paths"
2162 -su | --source-urls)
2163 COMMAND="list-sources-urls"
2165 -Tvs | --tag-version-stable )
2170 -Ts | --tag-stable )
2175 -Tv | --tag-version )
2180 -Tp | --tag-prefix )
2192 -ir | --integer-release-only )
2193 INTEGER_RELEASE="yes"
2196 COMMAND="update_md5"
2201 -Upi | --update-poldek-indexes )
2202 UPDATE_POLDEK_INDEXES="yes"
2205 COMMAND="init_rpm_dir"
2207 -u | --try-upgrade )
2208 TRY_UPGRADE="1"; shift ;;
2210 shift; UPGRADE_VERSION="$1"; shift;;
2211 -un | --try-upgrade-with-float-version )
2212 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2214 BE_VERBOSE="1"; shift ;;
2219 if echo "${MACRO}" | grep -q '\W'; then
2220 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2224 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2229 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2233 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2236 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2237 COMMAND="show_bconds"
2241 COMMAND="show_bcond_args"
2244 --show-avail-bconds)
2245 COMMAND="show_avail_bconds"
2250 RPMOPTS="${RPMOPTS} --nodeps"
2253 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2256 Exit_error err_invalid_cmdline "$1"
2259 SPECFILE=${1%/}; shift
2260 # check if specname was passed as specname:cvstag
2261 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2262 CVSTAG="${SPECFILE##*:}"
2263 SPECFILE="${SPECFILE%%:*}"
2265 # always have SPECFILE ending with .spec extension
2266 SPECFILE=${SPECFILE%%.spec}.spec
2267 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2271 [ -d "$ASSUMED_NAME" ] && GIT_DIR="$ASSUMED_NAME/.git" || GIT_DIR=.git
2272 if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then
2273 if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then
2274 CVSTAG=${CVSTAG#refs/heads/}
2275 if [ "$CVSTAG" != "master" ]; then
2276 echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override"
2279 echo >&2 "On detached HEAD. Use -r BRANCHNAME to override"
2282 elif [ "$CVSTAG" = "HEAD" ]; then
2283 # assume -r HEAD is same as -A
2287 if [ "$CVSTAG" ]; then
2288 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2289 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2292 if [ -n "$DEBUG" ]; then
2297 if [ -n "$TARGET" ]; then
2300 TARGET_SWITCH="--target $TARGET" ;;
2302 TARGET_SWITCH="--target=$TARGET" ;;
2306 if [ "$SCHEDTOOL" != "no" ]; then
2307 NICE_COMMAND="$SCHEDTOOL"
2309 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2312 update_shell_title "$COMMAND"
2316 if [ -z "$SPECFILE" ]; then
2317 Exit_error err_no_spec_in_cmdl
2319 get_spec > /dev/null
2326 if [ -z "$SPECFILE" ]; then
2327 Exit_error err_no_spec_in_cmdl
2329 get_spec > /dev/null
2334 "show_avail_bconds")
2336 if [ -z "$SPECFILE" ]; then
2337 Exit_error err_no_spec_in_cmdl
2340 get_spec > /dev/null
2342 local bcond_avail=$(find_spec_bcond $SPECFILE)
2343 local opt bcond bconds
2344 for opt in $bcond_avail; do
2347 bcond=${opt#without_}
2348 bconds="$bconds $bcond"
2352 bconds="$bconds $bcond"
2355 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2363 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2365 if [ -z "$SPECFILE" ]; then
2366 Exit_error err_no_spec_in_cmdl
2369 # display SMP make flags if set
2370 smp_mflags=$(rpm -E %{?_smp_mflags})
2371 if [ "$smp_mflags" ]; then
2372 echo "builder: SMP make flags are set to $smp_mflags"
2380 if [ "$COMMAND" != "build-source" ]; then
2383 fetch_build_requires
2384 if [ "$INTEGER_RELEASE" = "yes" ]; then
2385 echo "Checking release $PACKAGE_RELEASE..."
2386 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2387 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2391 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2392 if [ -n "$TEST_TAG" ]; then
2393 local TAGVER=`make_tagver`
2394 echo "Searching for tag $TAGVER..."
2395 git show-ref --quiet --verify "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2397 # - do not allow to build from HEAD when XX-branch exists
2398 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2399 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2400 TAG_BRANCH="${TREE_PREFIX}-branch"
2401 TAG_STATUS=$(git branch -r | grep -i "origin/$TAG_BRANCH$" | sed 's# *origin/##')
2402 if [ -n "$TAG_STATUS" -a -z "$CVSTAG" ]; then
2403 Exit_error err_branch_exists "$TAG_STATUS"
2409 if [ -n "$NOSOURCE0" ] ; then
2410 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2415 get_files $SOURCES $PATCHES
2419 NODIST="yes" get_files $SOURCES $PATCHES
2424 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2425 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2427 remove_build_requires
2431 if [ -z "$SPECFILE" ]; then
2432 Exit_error err_no_spec_in_cmdl
2441 if [ -z "$SPECFILE" ]; then
2442 Exit_error err_no_spec_in_cmdl
2445 ADD_PACKAGE_CVS=yes get_spec
2448 if [ -n "$NOSOURCE0" ] ; then
2449 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2451 get_files $SOURCES $PATCHES
2456 if [ -z "$SPECFILE" ]; then
2457 Exit_error err_no_spec_in_cmdl
2463 if [ -n "$NOSOURCE0" ] ; then
2464 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2466 get_files $SOURCES $PATCHES
2471 if [ -z "$SPECFILE" ]; then
2472 Exit_error err_no_spec_in_cmdl
2478 if [ -n "$NOSOURCE0" ] ; then
2479 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2487 if [ -z "$SPECFILE" ]; then
2488 Exit_error err_no_spec_in_cmdl
2498 "list-sources-files" )
2501 DONT_PRINT_REVISION="yes"
2504 for SAP in $SOURCES $PATCHES; do
2505 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2508 "list-sources-urls" )
2511 DONT_PRINT_REVISION="yes"
2514 SAPS="$SOURCES $PATCHES"
2515 for SAP in $SAPS ; do
2519 "list-sources-local-paths" )
2522 DONT_PRINT_REVISION="yes"
2525 for SAP in $SOURCES $PATCHES; do
2526 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2529 "list-sources-distfiles-paths" )
2532 DONT_PRINT_REVISION="yes"
2535 for SAP in $SOURCES $PATCHES; do
2536 if [ -n "$(src_md5 "$SAP")" ]; then
2537 distfiles_path "$SAP"
2541 "list-sources-distfiles" )
2544 DONT_PRINT_REVISION="yes"
2547 for SAP in $SOURCES $PATCHES; do
2548 if [ -n "$(src_md5 "$SAP")" ]; then
2549 distfiles_url "$SAP"
2553 "list-sources-cvs" )
2556 DONT_PRINT_REVISION="yes"
2559 for SAP in $SOURCES $PATCHES; do
2560 if [ -z "$(src_md5 "$SAP")" ]; then
2561 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2575 echo "$VERSIONSTRING"
2578 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2579 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2583 # vi:syntax=sh:ts=4:sw=4:noet