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"}
67 # use rpm 4.4.6+ digest format instead of comments if non-zero
70 # user agent when fetching files
71 USER_AGENT="PLD/Builder($VERSION)"
73 # It can be used i.e. in log file naming.
74 # See LOGFILE example.
75 DATE=`date +%Y-%m-%d_%H-%M-%S`
77 # Example: LOGFILE='../log.$PACKAGE_NAME'
78 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
79 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
80 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
81 # Yes, you can use variable name! Note _single_ quotes!
96 # create symlinks for tools in PACKAGE_DIR, see get_spec()
107 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
112 GIT_SERVER="git@git.tld-linux.org"
113 PACKAGES_DIR="packages"
122 DISTFILES_SERVER="://df.tld-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 [ -n "$GIT_LOGINNAME" ]; then
180 GIT_SERVER="git@git.tld-linux.org"
183 if [ "$SCHEDTOOL" = "auto" ]; then
184 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
185 SCHEDTOOL="schedtool -B -e"
191 if [ -n "$USE_PROZILLA" ]; then
192 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
195 elif [ -n "$USE_AXEL" ]; then
196 GETURI="axel -a $AXEL_OPTS"
200 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
201 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
202 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
203 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
205 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
206 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
212 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
223 if [ -d $HOME/rpm/SOURCES ]; then
224 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
225 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
229 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
230 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
234 if [ -n "$LOGFILE" ]; then
235 LOG=`eval echo $LOGFILE`
236 if [ -n "$LASTLOG_FILE" ]; then
237 echo "LASTLOG=$LOG" > $LASTLOG_FILE
239 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
242 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
243 return `cat ${RES_FILE}`
248 #---------------------------------------------
252 if [ -n "$DEBUG" ]; then set -xv; fi
254 Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [-a|--add_cvs] [-b|-ba|--build]
255 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
256 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [--depth <number>]
257 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
258 [-q|--quiet] [--date <yyyy-mm-dd> [-r <tag>] [{-T|--tag <tag>]
259 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
260 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
261 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
262 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
263 <package>[.spec][:tag]
265 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
266 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
267 --all-branches - make shallow fetch of all branches; --depth required
268 -n5, --no-md5 - ignore md5 comments in spec
269 -D, --debug - enable builder script debugging mode,
270 -debug - produce rpm debug package (same as --opts -debug)
271 -V, --version - output builder version string
272 --short-version - output builder short version
273 -a, --add_vcs - try add new package to PLD repo.
274 -b, -ba, --build - get all files from PLD repo or HTTP/FTP and build package
276 -bb, --build-binary - get all files from PLD repo or HTTP/FTP and build binary
277 only package from <package>.spec,
278 -bp, --build-prep - execute the %prep phase of <package>.spec,
279 -bc - execute the %build phase of <package>.spec,
280 -bi - execute the %install phase of <package>.spec
281 -bl - execute the %files phase of <package>.spec
282 -bs, --build-source - get all files from PLD repo or HTTP/FTP and only pack
284 --short-circuit - short-circuit build
285 -B, --branch - add branch
286 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
287 may be used with building process.
288 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
289 SPECS and \$RPM_BUILD_ROOT). Doesn't run
291 -cf, --cvs-force - use -f when tagging
292 --define <macro> <value>
293 - define a macro <macro> with value <value>,
296 --alt_kernel <kernel>
297 - same as --define 'alt_kernel <kernel>'
298 --nodeps - rpm won't check any dependences
299 -g, --get - get <package>.spec and all related files from PLD repo
301 -h, --help - this message,
302 -jN, -j N - set %_smp_mflags to propagate concurrent jobs
303 --ftp, --http - use ftp or http protocol to access distfiles server
304 -l <logfile>, --logtofile <logfile>
307 - don't pull from PLD repo
308 -nd, --no-distfiles - don't download from distfiles
309 -nm, --no-mirrors - don't download from mirror, if source URL is given,
310 -nu, --no-urls - don't try to download from FTP/HTTP location,
311 -ns, --no-srcs - don't download Sources/Patches
312 -ns0, --no-source0 - don't download Source0
313 -nn, --no-net - don't download anything from the net
314 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
315 --no-init - don't initialize builder paths (SPECS and SOURCES)
317 --skip-existing-files - skip existing files in get_files
318 --opts <rpm opts> - additional options for rpm
319 -q, --quiet - be quiet,
320 --date yyyy-mm-dd - build package using resources from specified date,
321 -r <tag>, --cvstag <ref>
322 - build package using resources from specified branch/tag,
323 -A - build package using master branch as any sticky tags/branch/date being reset.
324 -R, --fetch-build-requires
325 - fetch what is BuildRequired,
326 -RB, --remove-build-requires
327 - remove all you fetched with -R or --fetch-build-requires
328 remember, this option requires confirmation,
329 -FRB, --force-remove-build-requires
330 - remove all you fetched with -R or --fetch-build-requires
331 remember, this option works without confirmation,
332 -sd, --source-distfiles - list sources available from distfiles (intended for offline
333 operations; does not work when Icon field is present
334 but icon file is absent),
335 -sc, --source-cvs - list sources available from PLD repo
336 -sdp, --source-distfiles-paths - list sources available from distfiles -
337 paths relative to distfiles directory (intended for offline
338 operations; does not work when Icon field is present
339 but icon file is absent),
340 -sf, --source-files - list sources - bare filenames (intended for offline
341 operations; does not work when Icon field is present
342 but icon file is absent),
343 -lsp, --source-paths - list sources - filenames with full local paths (intended for
344 offline operations; does not work when Icon field is present
345 but icon file is absent),
346 -su, --source-urls - list urls - urls to sources and patches
347 intended for copying urls with spec with lots of macros in urls
348 -T <tag> , --tag <tag>
349 - add git tag <tag> for files,
350 -Tvs, --tag-version-stable
351 - add git tags STABLE and NAME-VERSION-RELEASE for files,
353 - add git tag STABLE for files,
355 - add git tag NAME-VERSION-RELEASE for files,
356 -Tp, --tag-prefix <prefix>
357 - add <prefix> to NAME-VERSION-RELEASE tags,
358 -tt, --test-tag <prefix>
359 - fail if tag is already present,
360 -ir, --integer-release-only
361 - allow only integer and snapshot releases
362 -v, --verbose - be verbose,
363 -u, --try-upgrade - check version, and try to upgrade package
364 -un, --try-upgrade-with-float-version
365 - as above, but allow float version
366 php-pear-Services_Digg/
367 --upgrade-version - upgrade to specified version in try-upgrade
368 -U, --update - refetch sources, don't use distfiles, and update md5 comments
369 -Upi, --update-poldek-indexes
370 - refresh or make poldek package index files.
371 -sp, --skip-patch <patchnumber>
372 - don't apply <patchnumber>. may be repeated.
373 -np, --nopatch <patchnumber>
374 - abort instead of applying patch <patchnumber>
375 --show-bconds - show available conditional builds, which can be used
376 - with --with and/or --without switches.
377 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
378 ./repackage.sh script. in other words, the output is
379 parseable by scripts.
380 --show-avail-bconds - show available bconds
381 --with/--without <feature>
382 - conditional build package depending on %_with_<feature>/
383 %_without_<feature> macro switch. You may now use
384 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
385 constructions. Set GROUP_BCONDS to yes to make use of it.
386 --target <platform>, --target=<platform>
387 - build for platform <platform>.
388 --init-rpm-dir - initialize ~/rpm directory structure
392 # create tempfile. as secure as possible
394 mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
397 # inserts git log instead of %changelog
398 # outputs name of modified file created by tempfile
400 local SPECFILE=$1 specfile=$(tempfile) gitlog=$(tempfile) speclog=$(tempfile)
402 # allow this being customized
403 local log_entries=$(rpm -E '%{?_buildchangelogtruncate}')
405 # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997'
406 # otherwise i'd use --date=iso here
407 # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1
408 # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31
409 # NOTE: changelog date is always in UTC for rpmbuild
410 # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
411 git log -${log_entries:-20} --format=format:"* %ad %an <%ae> %h%n%s%n" --date=raw > $gitlog
412 gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
413 sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
418 rm -f $gitlog $speclog
422 # change dependency to specname
424 # - perl(Package::Name) -> perl-Package-Name
428 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
432 update_shell_title() {
434 local len=${COLUMNS:-80}
435 local msg="$(echo "$*" | cut -c-$len)"
437 if [ -n "$BE_VERBOSE" ]; then
438 echo >&2 "$(date +%s.%N) $*"
441 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
443 if [ -n "$PACKAGE_NAME" ]; then
444 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
449 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
450 msg=$(echo $msg | tr -d '\n\r')
453 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
456 echo >&2 -ne "\033]0;$msg\007"
462 # set TARGET from BuildArch: from SPECFILE
464 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
465 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
467 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
471 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
473 TARGET_SWITCH="--target=$TARGET" ;;
479 # runs rpm with minimal macroset
481 # we reset macros not to contain macros.build as all the %() macros are
482 # executed here, while none of them are actually needed.
483 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
484 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
486 # TODO: move these to /usr/lib/rpm/macros
487 cat > $BUILDER_MACROS <<'EOF'
488 %x8664 x86_64 amd64 ia32e
491 %bootstrap_release() %{1}
492 %requires_releq_kernel_up(s:n:) %{nil}
493 %requires_releq_kernel_smp(s:n:) %{nil}
494 %requires_releq_kernel(s:n:) %{nil}
495 %requires_releq() %{nil}
496 %pyrequires_eq() %{nil}
497 %requires_eq() %{nil}
498 %requires_eq_to() %{nil}
499 %requires_ge() %{nil}
500 %requires_ge_to() %{nil}
501 %requires_ge() %{nil}
502 %releq_kernel_up(n:) ERROR
503 %releq_kernel_smp(n:) ERROR
504 %releq_kernel(n:) ERROR
508 %ruby_ver_requires_eq() %{nil}
509 %ruby_mod_ver_requires_eq() %{nil}
510 %__php_api_requires() %{nil}
511 %php_major_version ERROR
512 %php_api_version ERROR
513 %requires_xorg_xserver_extension %{nil}
514 %requires_xorg_xserver_xinput %{nil}
515 %requires_xorg_xserver_font %{nil}
516 %requires_xorg_xserver_videodrv %{nil}
518 %perl_vendorarch ERROR
519 %perl_vendorlib ERROR
520 # damn. need it here! - copied from /usr/lib/rpm/macros.build
521 %tmpdir %(echo "${TMPDIR:-/tmp}")
522 %patchset_source(f:b:) %(
523 base=%{-b*}%{!-b*:10000};
524 start=$(expr $base + %1);
525 end=$(expr $base + %{?2}%{!?2:%{1}});
526 # we need to call seq twice as it doesn't allow two formats
527 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
528 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
529 paste %{tmpdir}/__ps{1,2};
530 rm -f %{tmpdir}/__ps{1,2};
533 %add_etc_shells(p) %{p:<lua>}
534 %remove_etc_shells(p) %{p:<lua>}
535 %lua_add_etc_shells() %{nil}
536 %lua_remove_etc_shells() %{nil}
538 %buildrequires_jdk %{nil}
539 %pear_package_print_optionalpackages %{nil}
541 if [ "$NOINIT" = "yes" ] ; then
542 cat >> $BUILDER_MACROS <<'EOF'
547 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
551 if [ -n "$DEBUG" ]; then
556 if [ -x /usr/bin/rpm-specdump ]; then
557 update_shell_title "cache_rpm_dump using rpm-specdump command"
558 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
560 update_shell_title "cache_rpm_dump using rpmbuild command"
563 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
564 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
570 ARGS='--nodigest --nosignature --nobuild'
573 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
575 if [ $? -gt 0 ]; then
576 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
578 Exit_error err_build_fail
581 # make small dump cache
582 rpm_dump_cache=`echo "$rpm_dump" | awk '
583 $2 ~ /^SOURCEURL/ {print}
584 $2 ~ /^PATCHURL/ {print}
585 $2 ~ /^nosource/ {print}
586 $2 ~ /^PACKAGE_/ {print}
590 update_shell_title "cache_rpm_dump: OK!"
594 if [ -z "$rpm_dump_cache" ] ; then
595 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
597 echo "$rpm_dump_cache"
601 update_shell_title "get icons"
602 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
603 if [ -z "$ICONS" ]; then
607 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
611 update_shell_title "parsing specfile"
612 if [ -n "$DEBUG" ]; then
617 # icons are needed for successful spec parse
623 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
624 FAIL_IF_NO_SOURCES="no"
627 if [ "$NOSRCS" != "yes" ]; then
628 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
629 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
630 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
633 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
634 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
635 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
637 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
638 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
641 if [ -n "$BE_VERBOSE" ]; then
642 echo "- Sources : `nourl $SOURCES`"
643 if [ -n "$PATCHES" ]; then
644 echo "- Patches : `nourl $PATCHES`"
646 echo "- Patches : *no patches needed*"
648 if [ -n "$ICONS" ]; then
649 echo "- Icon : `nourl $ICONS`"
651 echo "- Icon : *no package icon*"
653 echo "- Name : $PACKAGE_NAME"
654 echo "- Version : $PACKAGE_VERSION"
655 echo "- Release : $PACKAGE_RELEASE"
658 update_shell_title "parse_spec: OK!"
662 if [ -n "$DEBUG" ]; then
670 "err_no_spec_in_cmdl" )
671 remove_build_requires
672 echo >&2 "ERROR: spec file name not specified."
674 "err_invalid_cmdline" )
675 echo >&2 "ERROR: invalid command line arg ($2)."
677 "err_no_spec_in_repo" )
678 remove_build_requires
679 echo >&2 "Error: spec file not stored in PLD repo."
681 "err_no_source_in_repo" )
682 remove_build_requires
683 echo >&2 "Error: some source, patch or icon files not stored in PLD repo. ($2)"
685 "err_cvs_add_failed" )
686 echo >&2 "Error: failed to add package to PLD repo."
689 remove_build_requires
690 echo >&2 "Error: package build failed. (${2:-no more info})"
692 "err_no_package_data" )
693 remove_build_requires
694 echo >&2 "Error: couldn't get out package name/version/release from spec file."
697 remove_build_requires
698 echo >&2 "Tag ${2} already exists"
701 remove_build_requires
702 echo >&2 "Release ${2} not integer and not a snapshot."
704 "err_branch_exists" )
705 remove_build_requires
706 echo >&2 "Tree branch already exists (${2})."
709 remove_build_requires
710 echo >&2 "Error: conditions reject building this spec (${2})."
712 "err_remote_problem" )
713 remove_build_requires
714 echo >&2 "Error: problem with remote (${2})"
716 "err_not_implemented" )
717 remove_build_requires
718 echo >&2 "Error: functionality not yet imlemented"
721 echo >&2 "Unknown error."
726 if [ -n "$DEBUG" ]; then
731 if [ "$NOINIT" != "yes" ] ; then
732 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
734 local macros_ver=$(rpm -E %?rpm_build_macros)
735 if [ -z "$macros_ver" ]; then
736 REPO_DIR=$TOP_DIR/packages
737 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
739 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
740 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
744 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
750 export GIT_WORK_TREE=$PACKAGE_DIR
751 export GIT_DIR=$PACKAGE_DIR/.git
753 if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then
754 if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then
755 CVSTAG=${CVSTAG#refs/heads/}
756 if [ "$CVSTAG" != "master" ]; then
757 echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override"
760 echo >&2 "On detached HEAD. Use -r BRANCHNAME to override"
763 elif [ "$CVSTAG" = "HEAD" ]; then
764 # assume -r HEAD is same as -A
772 update_shell_title "add_package"
774 if [ -n "$DEBUG" ]; then
780 SPECFILE=$(basename $SPECFILE)
781 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
782 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
785 [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes
786 ssh $GIT_SERVER create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed
788 git remote add $REMOTE_PLD ${GIT_SERVER}:${PACKAGES_DIR}/${ASSUMED_NAME}.git || Exit_error err_remote_problem $REMOTE_PLD
793 update_shell_title "get_spec"
795 if [ -n "$DEBUG" ]; then
801 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
803 SPECFILE=$(basename $SPECFILE)
806 if [ "$NOCVSSPEC" != "yes" ]; then
807 if [ -z "$DEPTH" ]; then
808 if [ -d "$ASSUMED_NAME/.git" ]; then
809 git fetch $REMOTE_PLD || Exit_error err_no_spec_in_repo
810 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
811 if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
812 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
815 Exit_error err_not_implemented
819 git clone -o $REMOTE_PLD ${GIT_SERVER}:${PACKAGES_DIR}/${ASSUMED_NAME}.git "$REPO_DIR/${ASSUMED_NAME}" || {
820 # softfail if new package, i.e not yet added to PLD rep
821 [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
822 echo "Warning: package not in CVS - assuming new package"
828 if [ ! -d "$ASSUMED_NAME/.git" ]; then
829 if [ ! -d "$ASSUMED_NAME" ]; then
833 git remote add $REMOTE_PLD ${GIT_SERVER}:${PACKAGES_DIR}/${ASSUMED_NAME}.git
834 CVSTAG=${CVSTAG:-"master"}
837 if [ -z "$ALL_BRANCHES" ]; then
838 refs="${CVSTAG}:remotes/${REMOTE_PLD}/${CVSTAG}"
840 git fetch $DEPTH $REMOTE_PLD $refs || {
841 echo >&2 "Error: branch $CVSTAG does not exist"
846 cvsignore_df .gitignore
848 # add default log format to .gitignore if it is relative to package dir
849 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
850 # substitute known "macros" to glob
851 local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
852 if [ "$logfile" ]; then
853 cvsignore_df "$logfile"
857 # create symlinks for tools
858 if [ "$SYMLINK_TOOLS" != "no" ]; then
859 for a in dropin md5 adapter builder {relup,compile,repackage,pearize}.sh pldnotify.awk; do
860 [ -f $a ] || continue
861 ln -sf ../$a $ASSUMED_NAME
867 if [ -n "$CVSTAG" ]; then
868 git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "${REMOTE_PLD}/$CVSTAG" > /dev/null || exit
869 git symbolic-ref -q HEAD > /dev/null &&
871 if [ -n "$CVSDATE" ]; then
872 git checkout $(git rev-list -n1 --before="'$CVSDATE'" $CVSTAG) || exit 1
876 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
877 Exit_error err_no_spec_in_repo
880 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
881 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
884 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
892 if [ ! -f "mirrors" ] ; then
893 ln -s scripts/mirrors .
897 local origin mirror name rest ol prefix
898 while read origin mirror name rest; do
899 # skip comments and empty lines
900 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
903 ol=$(echo -n "$origin" | wc -c)
904 prefix=$(echo -n "$url" | head -c $ol)
905 if [ "$prefix" = "$origin" ] ; then
906 suffix=$(echo "$url" | cut -b $((ol+1))-)
907 echo -n "$mirror$suffix"
914 # Warning: unpredictable results if same URL used twice
918 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
919 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
924 [ "$NO5" = "yes" ] && return
926 [ -z "$no" ] && return
930 if [ -f additional-md5sums ]; then
931 md5=$(grep -s -v '^#' additional-md5sums | \
932 grep -E "[ ]$(basename "$1")([ ,]|\$)" | \
933 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
934 grep -E '^[0-9a-f]{32}$')
937 if [ $(echo "$md5" | wc -l) != 1 ] ; then
938 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
940 echo "$md5" | tail -n 1
945 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
946 if [ -n "$source_md5" ]; then
949 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
950 if [ -n "$source_md5" ]; then
953 # we have empty SourceX-md5, but it is still possible
954 # that we have NoSourceX-md5 AND NoSource: X
955 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
956 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
964 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
968 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
971 distfiles_attic_url() {
972 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
978 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
982 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
983 [ -n "$size" -a "$size" -gt 0 ]
987 if [ "$CVSIGNORE_DF" != "yes" ]; then
990 cvsignore=${PACKAGE_DIR}/.gitignore
992 # add only if not yet there
993 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
994 echo "$1" >> $cvsignore
998 # returns true if "$1" is ftp, http or https protocol url
1001 ftp://*|http://*|https://*)
1009 if [ $# -eq 0 ]; then
1013 update_shell_title "update md5"
1014 if [ -n "$DEBUG" ]; then
1021 # pass 1: check files to be fetched
1025 local fp=$(nourl "$i")
1026 local srcno=$(src_no "$i")
1027 if [ -n "$ADD5" ]; then
1028 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
1029 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
1030 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
1032 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
1034 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1035 need_files="$need_files $i"
1039 # pass 1a: get needed files
1040 if [ "$need_files" ]; then
1041 get_files $need_files
1044 # pass 2: proceed with md5 adding or updating
1046 local fp=$(nourl "$i")
1047 local srcno=$(src_no "$i")
1048 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
1049 if [ -z "$md5" ]; then
1050 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
1052 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
1053 local tag="# Source$srcno-md5:\t"
1054 if [[ "$md5" == *NoSource* ]]; then
1055 tag="# NoSource$srcno-md5:\t"
1056 elif [ -n "$USEDIGEST" ]; then
1057 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
1059 md5=$(md5sum "$fp" | cut -f1 -d' ')
1060 echo "Updating Source$srcno ($md5: $fp)."
1062 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
1063 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
1065 $PACKAGE_DIR/$SPECFILE
1072 [ "$NO5" = "yes" ] && return
1074 update_shell_title "check md5"
1078 if ! good_md5 "$i"; then
1079 echo -n "MD5 sum mismatch."
1082 if ! good_size "$i"; then
1083 echo -n "0 sized file."
1087 if [ $bad -eq 1 ]; then
1088 echo " Use -U to refetch sources,"
1089 echo "or -5 to update md5 sums, if you're sure files are correct."
1090 Exit_error err_no_source_in_repo $i
1096 update_shell_title "get_files"
1098 if [ -n "$DEBUG" ]; then
1103 if [ $# -gt 0 ]; then
1107 local get_files_cvs=""
1111 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1112 update_shell_title "$i"
1113 local fp=`nourl "$i"`
1114 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1119 local srcmd5=$(src_md5 "$i")
1121 # we know if source/patch is present in cvs/distfiles
1122 # - has md5 (in distfiles)
1123 # - in cvs... ideas?
1125 # CHECK: local file didn't exist or always cvs up (first) requested.
1126 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1127 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1128 echo "Warning: no URL given for $i"
1132 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1133 if good_md5 "$i" && good_size "$i"; then
1134 echo "$fp having proper md5sum already exists"
1138 # optionally prefer mirror over distfiles if there's mirror
1139 # TODO: build url list and then try each url from the list
1140 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1143 url=$(distfiles_url "$i")
1146 url_attic=$(distfiles_attic_url "$i")
1148 # is $url local file?
1149 if [[ "$url" = [./]* ]]; then
1150 update_shell_title "${GETLOCAL%% *}: $url"
1151 ${GETLOCAL} $url $target
1153 if [ -z "$NOMIRRORS" ]; then
1154 url=$(find_mirror "$url")
1158 # make shorter message for distfiles urls
1159 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1160 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1161 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1164 update_shell_title "${GETURI%% *}: $uri"
1165 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1166 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1167 update_shell_title "${GETURI2%% *}: $url"
1168 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1173 if [ ! -s "$target" ]; then
1175 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1176 update_shell_title "${GETLOCAL%% *}: $url_attic"
1177 ${GETLOCAL} $url_attic $target
1179 if [ -z "$NOMIRRORS" ]; then
1180 url_attic=$(find_mirror "$url_attic")
1182 update_shell_title "${GETURI%% *}: $url_attic"
1183 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1184 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1185 update_shell_title "${GETURI2%% *}: $url_attic"
1186 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1188 test -s "$target" || rm -f "$target"
1192 if [ -s "$target" ]; then
1193 cvsignore_df $target
1200 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1201 if [ -z "$NOMIRRORS" ]; then
1202 im=$(find_mirror "$i")
1206 update_shell_title "${GETURI%% *}: $im"
1207 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1208 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1209 update_shell_title "${GETURI2%% *}: $im"
1210 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1212 test -s "$target" || rm -f "$target"
1215 if [ "$cvsup" = 1 ]; then
1221 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1222 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1223 Exit_error err_no_source_in_repo $i
1226 # we check md5 here just only to refetch immediately
1227 if good_md5 "$i" && good_size "$i"; then
1229 elif [ "$FROM_DISTFILES" = 1 ]; then
1230 # wrong md5 from distfiles: remove the file and try again
1232 echo "MD5 sum mismatch. Trying full fetch."
1235 update_shell_title "${GETURI%% *}: $url"
1236 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1237 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1238 update_shell_title "${GETURI2%% *}: $url"
1239 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1241 if [ ! -s "$target" ]; then
1243 update_shell_title "${GETURI%% *}: $url_attic"
1244 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1245 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1246 update_shell_title "${GETURI2%% *}: $url_attic"
1247 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1250 test -s "$target" || rm -f "$target"
1253 SHELL_TITLE_PREFIX=""
1256 if [ "$CHMOD" = "yes" ]; then
1257 CHMOD_FILES=$(nourl "$@")
1258 if [ -n "$CHMOD_FILES" ]; then
1259 chmod $CHMOD_MODE $CHMOD_FILES
1266 if [ -n "$DEBUG" ]; then
1271 # Check whether first character of PACKAGE_NAME is legal for tag name
1272 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1276 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1277 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1279 # Remove #kernel.version_release from TAGVER because tagging sources
1280 # could occur with different kernel-headers than kernel-headers used at build time.
1281 # besides, %{_kernel_ver_str} is not expanded.
1283 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1284 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1293 if [ -n "$DEBUG" ]; then
1298 echo "Version: $PACKAGE_VERSION"
1299 echo "Release: $PACKAGE_RELEASE"
1302 if [ "$TAG_VERSION" = "yes" ]; then
1303 TAGVER=`make_tagver`
1306 if [ -n "$TAG" ]; then
1310 local OPTIONS="tag $CVS_FORCE"
1313 if [ "$TAG_VERSION" = "yes" ]; then
1319 if [ "$TAG_VERSION" = "yes" ]; then
1320 update_shell_title "tag sources: $TAGVER"
1321 git $OPTIONS $TAGVER || exit
1322 git push $CVS_FORCE $REMOTE_PLD tag $TAGVER || Exit_error err_remote_problem $REMOTE_PLD
1324 if [ -n "$TAG" ]; then
1325 update_shell_title "tag sources: $TAG"
1326 git $OPTIONS $TAG $chunk || exit
1327 git push $CVS_FORCE $REMOTE_PLD tag $TAG || Exit_error err_remote_problem $REMOTE_PLD
1333 echo "Git branch: $TAG"
1336 if [ -n "$DEBUG" ]; then
1341 local OPTIONS="branch $CVS_FORCE"
1344 git $OPTIONS $TAG || exit
1348 # this function should exit early if package can't be built for this arch
1349 # this avoids unneccessary BR filling.
1352 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1354 if [ $ret -ne 0 ]; then
1366 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1367 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1373 local ver="$2" subver=$ver
1374 local newver="$3" newsubver=$newver
1376 # try handling subver, everything that's not numeric-dotted in version
1377 if grep -Eq '%define\s+subver' $specfile; then
1378 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1380 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1381 newver=${newver%$newsubver}
1384 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1385 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1386 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1391 if [ -n "$TRY_UPGRADE" ]; then
1392 local TNOTIFY TNEWVER TOLDVER
1393 update_shell_title "build_package: try_upgrade"
1397 if [ "$UPGRADE_VERSION" ]; then
1398 TNEWVER=$UPGRADE_VERSION
1400 if [ -n "$FLOAT_VERSION" ]; then
1401 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1403 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1406 # pldnotify.awk does not set exit codes, but it has match for ERROR
1407 # in output which means so.
1408 if [[ "$TNOTIFY" = *ERROR* ]]; then
1413 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1416 if [ -n "$TNEWVER" ]; then
1417 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1418 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1419 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1420 cp -f $SPECFILE $SPECFILE.bak
1423 set_release $SPECFILE $PACKAGE_RELEASE 1
1424 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1426 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1427 echo >&2 "Upgrading version failed, you need to update spec yourself"
1437 update_shell_title "build_package"
1438 if [ -n "$DEBUG" ]; then
1447 BUILD_SWITCH="-ba" ;;
1449 BUILD_SWITCH="-bb" ;;
1451 BUILD_SWITCH="-bs --nodeps" ;;
1453 BUILD_SWITCH="-bp --nodeps" ;;
1455 BUILD_SWITCH="-bc" ;;
1457 BUILD_SWITCH="-bi" ;;
1459 BUILD_SWITCH="-bl" ;;
1463 update_shell_title "build_package: $COMMAND"
1464 if [ -n "$LOGFILE" ]; then
1465 LOG=`eval echo $LOGFILE`
1466 if [ -d "$LOG" ]; then
1467 echo "Log file $LOG is a directory."
1468 echo "Parse error in the spec?"
1469 Exit_error err_build_fail
1471 if [ -n "$LASTLOG_FILE" ]; then
1472 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1474 RES_FILE=$(tempfile)
1475 local specfile=$(insert_gitlog $SPECFILE)
1477 (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
1478 RETVAL=`cat $RES_FILE`
1479 rm $RES_FILE $specfile
1480 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1481 if [ "$RETVAL" -eq "0" ]; then
1488 BRLISTFILE=$(tempfile)
1489 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1492 if [ "$RETVAL" -ne "0" ]; then
1493 if [ -n "$TRY_UPGRADE" ]; then
1494 echo "\nUpgrade package to new version failed."
1495 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1496 echo "Restoring old spec file."
1497 mv -f $SPECFILE.bak $SPECFILE
1501 # try to nicely show package list, to just copy&paste it to poldek or so...
1502 #eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE 2>$BRLISTFILE
1503 #BRLIST=$(awk 'BEGIN{ORS=" ";} NR>1 {print $1;}' $BRLISTFILE)
1505 #echo "To install packages type:"
1506 #echo "poldek -ivh $BRLIST"
1508 #echo "In poldek, copy these command:"
1509 #echo "install $BRLIST"
1512 Exit_error err_build_fail
1518 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1521 install_required_packages() {
1526 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1529 /^%changelog/ { exit }
1531 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1532 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1533 gsub(/[ \t]+/, "_", bcond);
1535 }' $SPEC | LC_ALL=C sort -u
1539 # expand bconds from ~/.bcondrc
1540 # The file structure is like gentoo's package.use:
1543 # samba -mysql -pgsql
1544 # w32codec-installer license_agreement
1547 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1553 SN=${SPECFILE%%\.spec}
1555 local bcondrc=$HOME/.bcondrc
1556 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1558 local bcond_avail=$(find_spec_bcond $SPECFILE)
1560 while read pkg flags; do
1562 [[ "$pkg" == \#* ]] && continue
1564 # any package or current package?
1565 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1566 for flag in $flags; do
1567 local opt=${flag#[+-]}
1569 # use only flags which are in this package.
1570 if [[ $bcond_avail = *${opt}* ]]; then
1571 if [[ $flag = -* ]]; then
1572 if [[ $BCOND != *--with?${opt}* ]]; then
1573 BCOND="$BCOND --without $opt"
1576 if [[ $BCOND != *--without?${opt}* ]]; then
1577 BCOND="$BCOND --with $opt"
1584 update_shell_title "parse ~/.bcondrc: DONE!"
1587 set_bconds_values() {
1588 update_shell_title "set bcond values"
1590 AVAIL_BCONDS_WITHOUT=""
1591 AVAIL_BCONDS_WITH=""
1593 if grep -Eq '^# *_with' ${SPECFILE}; then
1594 echo >&2 "ERROR: This spec has old style bconds."
1598 if ! grep -q '^%bcond' ${SPECFILE}; then
1602 local bcond_avail=$(find_spec_bcond $SPECFILE)
1603 process_bcondrc "$SPECFILE"
1605 update_shell_title "parse bconds"
1608 for opt in $bcond_avail; do
1611 bcond=${opt#without_}
1613 *--without?${bcond}*)
1614 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1617 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1625 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1628 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1633 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1642 update_shell_title "run_sub_builder $package_name"
1644 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1645 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1646 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1647 # jakby nie bylo tego kawalka kodu.
1649 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1650 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1654 # kurwa. translate that ^^^^
1658 # Istnieje taki spec? ${package}.spec
1659 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1660 parent_spec_name=${package}.spec
1661 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1662 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1664 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1669 if [ "${parent_spec_name}" != "" ]; then
1670 spawn_sub_builder $parent_spec_name
1672 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1675 spawn_sub_builder() {
1677 update_shell_title "spawn_sub_builder $package_name"
1680 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1681 sub_builder_opts="${sub_builder_opts} -R"
1683 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1684 sub_builder_opts="${sub_builder_opts} -RB"
1685 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1686 sub_builder_opts="${sub_builder_opts} -FRB"
1688 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1689 sub_builder_opts="${sub_builder_opts} -Upi"
1693 ./builder ${sub_builder_opts} "$@"
1696 remove_build_requires() {
1697 if [ "$INSTALLED_PACKAGES" != "" ]; then
1698 case "$REMOVE_BUILD_REQUIRES" in
1700 run_poldek --noask -ve $INSTALLED_PACKAGES
1703 run_poldek --ask -ve $INSTALLED_PACKAGES
1706 echo You may want to manually remove following BuildRequires fetched:
1707 echo $INSTALLED_PACKAGES
1708 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1715 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1716 if [ "$BCOND" ]; then
1718 echo "Building $SPECFILE with the following conditional flags:"
1722 echo "No conditional flags passed"
1725 echo "from available:"
1726 echo "--with :\t$AVAIL_BCONDS_WITH"
1727 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1732 display_branches() {
1733 echo -n "Available branches: "
1734 git branch -r | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs
1737 # checks a given list of packages/files/provides agains current rpmdb.
1738 # outputs all dependencies which current rpmdb doesn't satisfy.
1739 # input can be either STDIN or parameters
1743 if [ $# -gt 0 ]; then
1749 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1752 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1754 # other deps (files)
1755 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1758 # checks if given package/files/provides exists in rpmdb.
1759 # input can be either stdin or parameters
1760 # returns packages which are present in the rpmdb
1764 if [ $# -gt 0 ]; then
1770 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1773 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1774 install_build_requires_rpmdeps() {
1775 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1776 # TODO: Conflicts list doesn't check versions
1777 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1778 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1780 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1781 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1782 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1785 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1786 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1787 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1788 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1790 if [ -n "$CNFL" ]; then
1791 update_shell_title "uninstall conflicting packages: $CNFL"
1792 echo "Trying to uninstall conflicting packages ($CNFL):"
1793 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1796 while [ "$DEPS" ]; do
1797 update_shell_title "install deps: $DEPS"
1798 echo "Trying to install dependencies ($DEPS):"
1799 local log=.${SPECFILE}_poldek.log
1800 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1801 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1804 if [ -n "$failed" ]; then
1805 for package in $failed; do
1806 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1815 fetch_build_requires()
1817 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1821 update_shell_title "fetch build requires"
1822 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1823 install_build_requires_rpmdeps
1827 # XXX is this ugliest code written in human history still needed?
1828 echo "All packages installed by fetch_build_requires() are written to:"
1829 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1831 echo "If anything fails, you may get rid of them by executing:"
1832 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1834 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1835 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)
1837 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)
1839 package=$(basename "$package_item"|sed -e "s/}$//g")
1840 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1843 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1844 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1845 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
1850 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1853 if `echo $COND_TST|grep -q 'without_'`; then
1854 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1855 if `echo $COND_TST|grep -q !`; then
1860 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1861 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1862 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1868 elif `echo $COND_TST|grep -q 'with_'`; then
1869 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1870 if `echo $COND_TST|grep -q !`; then
1875 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1876 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1877 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1883 RESULT="${COND_STATE}-${COND_ARGV}"
1885 "with-wout" | "wout-with" )
1888 "wout-wout" | "with-with" )
1892 echo "Action '$RESULT' was not defined for package '$package_item'"
1898 if [ "$GO" = "yes" ]; then
1899 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1900 echo "Testing if $package has subrequirements..."
1901 run_poldek -t -i $package --dumpn=".$package-req.txt"
1902 if [ -f ".$package-req.txt" ]; then
1903 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1905 if [ "$package_name" = "$package" ]; then
1906 echo "Installing BuildRequired package:\t$package_name"
1907 update_shell_title "Installing BuildRequired package: ${package_name}"
1908 install_required_packages $package
1910 echo "Installing (sub)Required package:\t$package_name"
1911 update_shell_title "Installing (sub)Required package: ${package_name}"
1912 install_required_packages $package_name
1916 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1917 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1920 echo "Attempting to run spawn sub - builder..."
1921 echo "Package installation failed:\t$package_name"
1922 run_sub_builder $package_name
1923 if [ $? -eq 0 ]; then
1924 install_required_packages $package_name
1927 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1928 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1931 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1938 rm -f ".$package-req.txt"
1940 echo "Attempting to run spawn sub - builder..."
1941 echo "Package installation failed:\t$package"
1942 run_sub_builder $package
1943 if [ $? -eq 0 ]; then
1944 install_required_packages $package
1947 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1948 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1951 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1957 echo "Package $package is already installed. BuildRequirement satisfied."
1961 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1962 echo >&2 "Unable to install following packages and their dependencies:"
1963 for pkg in "$NOT_INSTALLED_PACKAGES"
1967 remove_build_requires
1973 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1974 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
1975 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
1976 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
1979 echo "Initializing rpm directories to $TOP_DIR from $GIT_SERVER"
1980 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
1983 if [ ! -e ../scripts ]; then
1984 git clone ${GIT_SERVER}:${PACKAGES_DIR}/scripts.git ../scripts
1986 for a in dropin md5 adapter builder mirrors {relup,compile,repackage,pearize}.sh pldnotify.awk; do
1987 ln -s ../scripts/$a .
1995 DONT_PRINT_REVISION="yes"
1997 # remove spec and sources
1998 $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $PACKAGE_DIR/$SPECFILE
1999 rm -rf $PACKAGE_DIR/.git .gitignore
2000 rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
2003 #---------------------------------------------
2011 while [ $# -gt 0 ]; do
2014 COMMAND="update_md5"
2019 COMMAND="update_md5"
2028 DEBUG="yes"; shift ;;
2030 COMMAND="version"; shift ;;
2032 COMMAND="short-version"; shift ;;
2039 -b | -ba | --build )
2040 COMMAND="build"; shift ;;
2041 -bb | --build-binary )
2042 COMMAND="build-binary"; shift ;;
2044 COMMAND="build-build"; shift ;;
2046 COMMAND="build-install"; shift ;;
2048 COMMAND="build-list"; shift ;;
2049 -bp | --build-prep )
2050 COMMAND="build-prep"; shift ;;
2051 -bs | --build-source )
2052 COMMAND="build-source"; shift ;;
2054 COMMAND="branch"; shift; TAG="${1}"; shift;;
2056 CLEAN="--clean"; shift ;;
2058 CVS_FORCE="-f"; shift;;
2064 COMMAND="get"; shift ;;
2066 COMMAND="usage"; shift ;;
2068 PROTOCOL="ftp"; shift ;;
2070 PROTOCOL="http"; shift ;;
2072 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
2076 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
2080 shift; LOGFILE="${1}"; shift ;;
2082 shift; DEF_NICE_LEVEL=${1}; shift ;;
2083 -ske | --skip-existing-files)
2084 SKIP_EXISTING_FILES="yes"; shift ;;
2086 COMMAND="mr-proper"; shift ;;
2087 -ncs | --no-cvs-specs )
2088 NOCVSSPEC="yes"; shift ;;
2089 -nd | --no-distfiles )
2090 NODIST="yes"; shift ;;
2091 -nm | --no-mirrors )
2092 NOMIRRORS="yes"; shift ;;
2094 NOURLS="yes"; shift ;;
2096 NOSRCS="yes"; shift ;;
2097 -ns0 | --no-source0 )
2098 NOSOURCE0="yes"; shift ;;
2107 -pm | --prefer-mirrors )
2114 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2116 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2117 --skip-patch | -sp )
2118 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2120 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2123 --with | --without )
2124 case $GROUP_BCONDS in
2128 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2129 while ! `echo ${1}|grep -qE '(^-|spec)'`
2131 BCOND="$BCOND $COND $1"
2135 if [[ "$2" = *,* ]]; then
2136 for a in $(echo "$2" | tr , ' '); do
2137 BCOND="$BCOND $1 $a"
2140 BCOND="$BCOND $1 $2"
2146 shift; TARGET="${1}"; shift ;;
2148 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2150 QUIET="--quiet"; shift ;;
2152 CVSDATE="${2}"; shift 2
2153 date -d "$CVSDATE" > /dev/null 2>&1 || { echo >&2 "No valid date specified"; exit 3; }
2163 -R | --fetch-build-requires)
2164 FETCH_BUILD_REQUIRES="yes"
2165 NOT_INSTALLED_PACKAGES=
2167 -RB | --remove-build-requires)
2168 REMOVE_BUILD_REQUIRES="nice"
2170 -FRB | --force-remove-build-requires)
2171 REMOVE_BUILD_REQUIRES="force"
2173 -sc | --sources-cvs)
2174 COMMAND="list-sources-cvs"
2176 -sd | --source-distfiles)
2177 COMMAND="list-sources-distfiles"
2179 -sdp | --source-distfiles-paths)
2180 COMMAND="list-sources-distfiles-paths"
2182 -sf | --source-files)
2183 COMMAND="list-sources-files"
2185 -lsp | --source-paths)
2186 COMMAND="list-sources-local-paths"
2188 -su | --source-urls)
2189 COMMAND="list-sources-urls"
2191 -Tvs | --tag-version-stable )
2196 -Ts | --tag-stable )
2201 -Tv | --tag-version )
2206 -Tp | --tag-prefix )
2218 -ir | --integer-release-only )
2219 INTEGER_RELEASE="yes"
2222 COMMAND="update_md5"
2227 -Upi | --update-poldek-indexes )
2228 UPDATE_POLDEK_INDEXES="yes"
2231 COMMAND="init_rpm_dir"
2233 -u | --try-upgrade )
2234 TRY_UPGRADE="1"; shift ;;
2236 shift; UPGRADE_VERSION="$1"; shift;;
2237 -un | --try-upgrade-with-float-version )
2238 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2240 BE_VERBOSE="1"; shift ;;
2245 if echo "${MACRO}" | grep -q '\W'; then
2246 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2250 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2255 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2259 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2262 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2263 COMMAND="show_bconds"
2267 COMMAND="show_bcond_args"
2270 --show-avail-bconds)
2271 COMMAND="show_avail_bconds"
2276 RPMOPTS="${RPMOPTS} --nodeps"
2279 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2282 Exit_error err_invalid_cmdline "$1"
2285 SPECFILE=${1%/}; shift
2286 # check if specname was passed as specname:cvstag
2287 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2288 CVSTAG="${SPECFILE##*:}"
2289 SPECFILE="${SPECFILE%%:*}"
2291 # always have SPECFILE ending with .spec extension
2292 SPECFILE=${SPECFILE%%.spec}.spec
2293 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2297 if [ "$CVSTAG" ]; then
2298 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2299 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2302 if [ -n "$ALL_BRANCHES" -a -z "$DEPTH" ]; then
2303 echo >&2 "--all branches requires --depth <number>"
2304 Exit_error err_invalid_cmdline
2307 if [ -n "$DEBUG" ]; then
2312 if [ -n "$TARGET" ]; then
2315 TARGET_SWITCH="--target $TARGET" ;;
2317 TARGET_SWITCH="--target=$TARGET" ;;
2321 if [ "$SCHEDTOOL" != "no" ]; then
2322 NICE_COMMAND="$SCHEDTOOL"
2324 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2327 update_shell_title "$COMMAND"
2331 if [ -z "$SPECFILE" ]; then
2332 Exit_error err_no_spec_in_cmdl
2334 get_spec > /dev/null
2341 if [ -z "$SPECFILE" ]; then
2342 Exit_error err_no_spec_in_cmdl
2344 get_spec > /dev/null
2349 "show_avail_bconds")
2351 if [ -z "$SPECFILE" ]; then
2352 Exit_error err_no_spec_in_cmdl
2355 get_spec > /dev/null
2357 local bcond_avail=$(find_spec_bcond $SPECFILE)
2358 local opt bcond bconds
2359 for opt in $bcond_avail; do
2362 bcond=${opt#without_}
2363 bconds="$bconds $bcond"
2367 bconds="$bconds $bcond"
2370 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2378 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2380 if [ -z "$SPECFILE" ]; then
2381 Exit_error err_no_spec_in_cmdl
2384 # display SMP make flags if set
2385 smp_mflags=$(rpm -E %{?_smp_mflags})
2386 if [ "$smp_mflags" ]; then
2387 echo "builder: SMP make flags are set to $smp_mflags"
2395 if [ "$COMMAND" != "build-source" ]; then
2398 fetch_build_requires
2399 if [ "$INTEGER_RELEASE" = "yes" ]; then
2400 echo "Checking release $PACKAGE_RELEASE..."
2401 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2402 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2406 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2407 if [ -n "$TEST_TAG" ]; then
2408 local TAGVER=`make_tagver`
2409 echo "Searching for tag $TAGVER..."
2410 if [ -n "$DEPTH" ]; then
2411 local ref=`git ls-remote $REMOTE_PLD "refs/tags/$TAGVER"`
2412 [ -n "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$TAGVER"
2414 git show-ref "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER"
2416 # - do not allow to build from HEAD when XX-branch exists
2417 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2418 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2419 TAG_BRANCH="${TREE_PREFIX}-branch"
2420 if [ -n "$DEPTH" ]; then
2421 cmd_branches="git ls-remote --heads"
2422 ref_prefix=refs/heads
2424 cmd_branches="git show-ref"
2425 ref_prefix=refs/remotes/${REMOTE_PLD}
2427 TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$")
2428 if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != "$CVSTAG" ]; then
2429 Exit_error err_branch_exists "$TAG_STATUS"
2435 if [ -n "$NOSOURCE0" ] ; then
2436 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2441 get_files $SOURCES $PATCHES
2445 NODIST="yes" get_files $SOURCES $PATCHES
2450 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2451 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2453 remove_build_requires
2457 if [ -z "$SPECFILE" ]; then
2458 Exit_error err_no_spec_in_cmdl
2467 if [ -z "$SPECFILE" ]; then
2468 Exit_error err_no_spec_in_cmdl
2472 if [ -n "$NEW_REPO" ]; then
2475 for file in $SOURCES $PATCHES; do
2476 if [ -z $(src_md5 "$file") ]; then
2477 git add $file || Exit_error err_no_source_in_repo $file
2479 cvsignore_df `nourl $file`
2483 git commit -m 'Initial commit'
2484 git push --dry-run $REMOTE_PLD master || Exit_error err_cvs_add_failed
2486 echo "You had already git repository. Push chosen branches to remote: ${REMOTE_PLD}"
2491 if [ -z "$SPECFILE" ]; then
2492 Exit_error err_no_spec_in_cmdl
2498 if [ -n "$NOSOURCE0" ] ; then
2499 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2501 get_files $SOURCES $PATCHES
2506 if [ -z "$SPECFILE" ]; then
2507 Exit_error err_no_spec_in_cmdl
2513 if [ -n "$NOSOURCE0" ] ; then
2514 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2522 if [ -z "$SPECFILE" ]; then
2523 Exit_error err_no_spec_in_cmdl
2527 if [ ! -d .git ]; then
2528 echo "No git reposiotory" >&2
2536 "list-sources-files" )
2539 DONT_PRINT_REVISION="yes"
2542 for SAP in $SOURCES $PATCHES; do
2543 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2546 "list-sources-urls" )
2549 DONT_PRINT_REVISION="yes"
2552 SAPS="$SOURCES $PATCHES"
2553 for SAP in $SAPS ; do
2557 "list-sources-local-paths" )
2560 DONT_PRINT_REVISION="yes"
2563 for SAP in $SOURCES $PATCHES; do
2564 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2567 "list-sources-distfiles-paths" )
2570 DONT_PRINT_REVISION="yes"
2573 for SAP in $SOURCES $PATCHES; do
2574 if [ -n "$(src_md5 "$SAP")" ]; then
2575 distfiles_path "$SAP"
2579 "list-sources-distfiles" )
2582 DONT_PRINT_REVISION="yes"
2585 for SAP in $SOURCES $PATCHES; do
2586 if [ -n "$(src_md5 "$SAP")" ]; then
2587 distfiles_url "$SAP"
2591 "list-sources-cvs" )
2594 DONT_PRINT_REVISION="yes"
2597 for SAP in $SOURCES $PATCHES; do
2598 if [ -z "$(src_md5 "$SAP")" ]; then
2599 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2613 echo "$VERSIONSTRING"
2616 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2617 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2621 # vi:syntax=sh:ts=4:sw=4:noet