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://github.com/draenog"
121 DISTFILES_SERVER="://distfiles.pld-linux.org"
122 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
127 FAIL_IF_NO_SOURCES="yes"
129 # let get_files skip over files which are present to get those damn files fetched
130 SKIP_EXISTING_FILES="no"
133 # should the specfile be restored if upgrade failed?
134 REVERT_BROKEN_UPGRADE="yes"
136 if rpm --specsrpm 2>/dev/null; then
137 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
138 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
140 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
141 if [ -x /usr/bin/rpm-getdeps ]; then
142 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
144 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
149 # Here we load saved user environment used to
150 # predefine options set above, or passed to builder
152 # This one reads global system environment settings:
153 if [ -f ~/etc/builderrc ]; then
156 # And this one cascades settings using user personal
158 # Example of ~/.builderrc:
160 #UPDATE_POLDEK_INDEXES="yes"
161 #FETCH_BUILD_REQUIRES="yes"
162 #REMOVE_BUILD_REQUIRES="force"
164 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
168 if [ -n "$HOME_ETC" ]; then
169 USER_CFG="$HOME_ETC/.builderrc"
170 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
172 USER_CFG=~/.builderrc
173 BUILDER_MACROS=~/.builder-rpmmacros
176 [ -f "$USER_CFG" ] && . "$USER_CFG"
178 if [ -n "$GIT_LOGINNAME" ]; then
179 GIT_SERVER="git@github.com:${GIT_LOGINNAME}"
182 if [ "$SCHEDTOOL" = "auto" ]; then
183 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
184 SCHEDTOOL="schedtool -B -e"
190 if [ -n "$USE_PROZILLA" ]; then
191 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
194 elif [ -n "$USE_AXEL" ]; then
195 GETURI="axel -a $AXEL_OPTS"
199 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
200 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
201 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
202 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
204 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
205 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
211 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
222 if [ -d $HOME/rpm/SOURCES ]; then
223 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
224 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
228 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
229 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
233 if [ -n "$LOGFILE" ]; then
234 LOG=`eval echo $LOGFILE`
235 if [ -n "$LASTLOG_FILE" ]; then
236 echo "LASTLOG=$LOG" > $LASTLOG_FILE
238 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
241 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
242 return `cat ${RES_FILE}`
247 #---------------------------------------------
251 if [ -n "$DEBUG" ]; then set -xv; fi
253 Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [-a|--add_cvs] [-b|-ba|--build]
254 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
255 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [--depth <number>]
256 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
257 [-q|--quiet] [--date <yyyy-mm-dd> [-r <tag>] [{-T|--tag <tag>]
258 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
259 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
260 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
261 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
262 <package>[.spec][:tag]
264 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
265 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
266 --all-branches - make shallow fetch of all branches; --depth required
267 -n5, --no-md5 - ignore md5 comments in spec
268 -D, --debug - enable builder script debugging mode,
269 -debug - produce rpm debug package (same as --opts -debug)
270 -V, --version - output builder version string
271 --short-version - output builder short version
272 -a, --add_vcs - try add new package to PLD repo.
273 -b, -ba, --build - get all files from PLD repo or HTTP/FTP and build package
275 -bb, --build-binary - get all files from PLD repo or HTTP/FTP and build binary
276 only package from <package>.spec,
277 -bp, --build-prep - execute the %prep phase of <package>.spec,
278 -bc - execute the %build phase of <package>.spec,
279 -bi - execute the %install phase of <package>.spec
280 -bl - execute the %files phase of <package>.spec
281 -bs, --build-source - get all files from PLD repo or HTTP/FTP and only pack
283 --short-circuit - short-circuit build
284 -B, --branch - add branch
285 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
286 may be used with building process.
287 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
288 SPECS and \$RPM_BUILD_ROOT). Doesn't run
290 -cf, --cvs-force - use -f when tagging
291 --define <macro> <value>
292 - define a macro <macro> with value <value>,
295 --alt_kernel <kernel>
296 - same as --define 'alt_kernel <kernel>'
297 --nodeps - rpm won't check any dependences
298 -g, --get - get <package>.spec and all related files from PLD repo
300 -h, --help - this message,
301 -jN, -j N - set %_smp_mflags to propagate concurrent jobs
302 --ftp, --http - use ftp or http protocol to access distfiles server
303 -l <logfile>, --logtofile <logfile>
306 - don't pull from PLD repo
307 -nd, --no-distfiles - don't download from distfiles
308 -nm, --no-mirrors - don't download from mirror, if source URL is given,
309 -nu, --no-urls - don't try to download from FTP/HTTP location,
310 -ns, --no-srcs - don't download Sources/Patches
311 -ns0, --no-source0 - don't download Source0
312 -nn, --no-net - don't download anything from the net
313 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
314 --no-init - don't initialize builder paths (SPECS and SOURCES)
316 --skip-existing-files - skip existing files in get_files
317 --opts <rpm opts> - additional options for rpm
318 -q, --quiet - be quiet,
319 --date yyyy-mm-dd - build package using resources from specified date,
320 -r <tag>, --cvstag <ref>
321 - build package using resources from specified branch/tag,
322 -A - build package using master branch as any sticky tags/branch/date being reset.
323 -R, --fetch-build-requires
324 - fetch what is BuildRequired,
325 -RB, --remove-build-requires
326 - remove all you fetched with -R or --fetch-build-requires
327 remember, this option requires confirmation,
328 -FRB, --force-remove-build-requires
329 - remove all you fetched with -R or --fetch-build-requires
330 remember, this option works without confirmation,
331 -sd, --source-distfiles - list sources available from distfiles (intended for offline
332 operations; does not work when Icon field is present
333 but icon file is absent),
334 -sc, --source-cvs - list sources available from PLD repo
335 -sdp, --source-distfiles-paths - list sources available from distfiles -
336 paths relative to distfiles directory (intended for offline
337 operations; does not work when Icon field is present
338 but icon file is absent),
339 -sf, --source-files - list sources - bare filenames (intended for offline
340 operations; does not work when Icon field is present
341 but icon file is absent),
342 -lsp, --source-paths - list sources - filenames with full local paths (intended for
343 offline operations; does not work when Icon field is present
344 but icon file is absent),
345 -su, --source-urls - list urls - urls to sources and patches
346 intended for copying urls with spec with lots of macros in urls
347 -T <tag> , --tag <tag>
348 - add git tag <tag> for files,
349 -Tvs, --tag-version-stable
350 - add git tags STABLE and NAME-VERSION-RELEASE for files,
352 - add git tag STABLE for files,
354 - add git tag NAME-VERSION-RELEASE for files,
355 -Tp, --tag-prefix <prefix>
356 - add <prefix> to NAME-VERSION-RELEASE tags,
357 -tt, --test-tag <prefix>
358 - fail if tag is already present,
359 -ir, --integer-release-only
360 - allow only integer and snapshot releases
361 -v, --verbose - be verbose,
362 -u, --try-upgrade - check version, and try to upgrade package
363 -un, --try-upgrade-with-float-version
364 - as above, but allow float version
365 php-pear-Services_Digg/
366 --upgrade-version - upgrade to specified version in try-upgrade
367 -U, --update - refetch sources, don't use distfiles, and update md5 comments
368 -Upi, --update-poldek-indexes
369 - refresh or make poldek package index files.
370 -sp, --skip-patch <patchnumber>
371 - don't apply <patchnumber>. may be repeated.
372 -np, --nopatch <patchnumber>
373 - abort instead of applying patch <patchnumber>
374 --show-bconds - show available conditional builds, which can be used
375 - with --with and/or --without switches.
376 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
377 ./repackage.sh script. in other words, the output is
378 parseable by scripts.
379 --show-avail-bconds - show available bconds
380 --with/--without <feature>
381 - conditional build package depending on %_with_<feature>/
382 %_without_<feature> macro switch. You may now use
383 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
384 constructions. Set GROUP_BCONDS to yes to make use of it.
385 --target <platform>, --target=<platform>
386 - build for platform <platform>.
387 --init-rpm-dir - initialize ~/rpm directory structure
391 # create tempfile. as secure as possible
393 mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
396 # inserts git log instead of %changelog
397 # outputs name of modified file created by tempfile
399 local SPECFILE=$1 specfile=$(tempfile) gitlog=$(tempfile) speclog=$(tempfile)
401 # allow this being customized
402 local log_entries=$(rpm -E '%{?_buildchangelogtruncate}')
404 # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997'
405 # otherwise i'd use --date=iso here
406 # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1
407 # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31
408 # NOTE: changelog date is always in UTC for rpmbuild
409 # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
410 git log -${log_entries:-20} --format=format:"* %ad %an <%ae> %h%n%s%n" --date=raw > $gitlog
411 gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
412 sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
417 rm -f $gitlog $speclog
421 # change dependency to specname
423 # - perl(Package::Name) -> perl-Package-Name
427 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
431 update_shell_title() {
433 local len=${COLUMNS:-80}
434 local msg="$(echo "$*" | cut -c-$len)"
436 if [ -n "$BE_VERBOSE" ]; then
437 echo >&2 "$(date +%s.%N) $*"
440 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
442 if [ -n "$PACKAGE_NAME" ]; then
443 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
448 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
449 msg=$(echo $msg | tr -d '\n\r')
452 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
455 echo >&2 -ne "\033]0;$msg\007"
461 # set TARGET from BuildArch: from SPECFILE
463 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
464 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
466 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
470 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
472 TARGET_SWITCH="--target=$TARGET" ;;
478 # runs rpm with minimal macroset
480 # we reset macros not to contain macros.build as all the %() macros are
481 # executed here, while none of them are actually needed.
482 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
483 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
485 # TODO: move these to /usr/lib/rpm/macros
486 cat > $BUILDER_MACROS <<'EOF'
487 %x8664 x86_64 amd64 ia32e
490 %bootstrap_release() %{1}
491 %requires_releq_kernel_up(s:n:) %{nil}
492 %requires_releq_kernel_smp(s:n:) %{nil}
493 %requires_releq_kernel(s:n:) %{nil}
494 %requires_releq() %{nil}
495 %pyrequires_eq() %{nil}
496 %requires_eq() %{nil}
497 %requires_eq_to() %{nil}
498 %requires_ge() %{nil}
499 %requires_ge_to() %{nil}
500 %requires_ge() %{nil}
501 %releq_kernel_up(n:) ERROR
502 %releq_kernel_smp(n:) ERROR
503 %releq_kernel(n:) ERROR
507 %ruby_ver_requires_eq() %{nil}
508 %ruby_mod_ver_requires_eq() %{nil}
509 %__php_api_requires() %{nil}
510 %php_major_version ERROR
511 %php_api_version ERROR
512 %requires_xorg_xserver_extension %{nil}
513 %requires_xorg_xserver_xinput %{nil}
514 %requires_xorg_xserver_font %{nil}
515 %requires_xorg_xserver_videodrv %{nil}
517 %perl_vendorarch ERROR
518 %perl_vendorlib ERROR
519 # damn. need it here! - copied from /usr/lib/rpm/macros.build
520 %tmpdir %(echo "${TMPDIR:-/tmp}")
521 %patchset_source(f:b:) %(
522 base=%{-b*}%{!-b*:10000};
523 start=$(expr $base + %1);
524 end=$(expr $base + %{?2}%{!?2:%{1}});
525 # we need to call seq twice as it doesn't allow two formats
526 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
527 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
528 paste %{tmpdir}/__ps{1,2};
529 rm -f %{tmpdir}/__ps{1,2};
532 %add_etc_shells(p) %{p:<lua>}
533 %remove_etc_shells(p) %{p:<lua>}
534 %lua_add_etc_shells() %{nil}
535 %lua_remove_etc_shells() %{nil}
537 %buildrequires_jdk %{nil}
538 %pear_package_print_optionalpackages %{nil}
540 if [ "$NOINIT" = "yes" ] ; then
541 cat >> $BUILDER_MACROS <<'EOF'
546 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
550 if [ -n "$DEBUG" ]; then
555 if [ -x /usr/bin/rpm-specdump ]; then
556 update_shell_title "cache_rpm_dump using rpm-specdump command"
557 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
559 update_shell_title "cache_rpm_dump using rpmbuild command"
562 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
563 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
569 ARGS='--nodigest --nosignature --nobuild'
572 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
574 if [ $? -gt 0 ]; then
575 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
577 Exit_error err_build_fail
580 # make small dump cache
581 rpm_dump_cache=`echo "$rpm_dump" | awk '
582 $2 ~ /^SOURCEURL/ {print}
583 $2 ~ /^PATCHURL/ {print}
584 $2 ~ /^nosource/ {print}
585 $2 ~ /^PACKAGE_/ {print}
589 update_shell_title "cache_rpm_dump: OK!"
593 if [ -z "$rpm_dump_cache" ] ; then
594 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
596 echo "$rpm_dump_cache"
600 update_shell_title "get icons"
601 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
602 if [ -z "$ICONS" ]; then
606 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
610 update_shell_title "parsing specfile"
611 if [ -n "$DEBUG" ]; then
616 # icons are needed for successful spec parse
622 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
623 FAIL_IF_NO_SOURCES="no"
626 if [ "$NOSRCS" != "yes" ]; then
627 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
628 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
629 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
632 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
633 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
634 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
636 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
637 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
640 if [ -n "$BE_VERBOSE" ]; then
641 echo "- Sources : `nourl $SOURCES`"
642 if [ -n "$PATCHES" ]; then
643 echo "- Patches : `nourl $PATCHES`"
645 echo "- Patches : *no patches needed*"
647 if [ -n "$ICONS" ]; then
648 echo "- Icon : `nourl $ICONS`"
650 echo "- Icon : *no package icon*"
652 echo "- Name : $PACKAGE_NAME"
653 echo "- Version : $PACKAGE_VERSION"
654 echo "- Release : $PACKAGE_RELEASE"
657 update_shell_title "parse_spec: OK!"
661 if [ -n "$DEBUG" ]; then
669 "err_no_spec_in_cmdl" )
670 remove_build_requires
671 echo >&2 "ERROR: spec file name not specified."
673 "err_invalid_cmdline" )
674 echo >&2 "ERROR: invalid command line arg ($2)."
676 "err_no_spec_in_repo" )
677 remove_build_requires
678 echo >&2 "Error: spec file not stored in PLD repo."
680 "err_no_source_in_repo" )
681 remove_build_requires
682 echo >&2 "Error: some source, patch or icon files not stored in PLD repo. ($2)"
684 "err_cvs_add_failed" )
685 echo >&2 "Error: failed to add package to PLD repo."
688 remove_build_requires
689 echo >&2 "Error: package build failed. (${2:-no more info})"
691 "err_no_package_data" )
692 remove_build_requires
693 echo >&2 "Error: couldn't get out package name/version/release from spec file."
696 remove_build_requires
697 echo >&2 "Tag ${2} already exists"
700 remove_build_requires
701 echo >&2 "Release ${2} not integer and not a snapshot."
703 "err_branch_exists" )
704 remove_build_requires
705 echo >&2 "Tree branch already exists (${2})."
708 remove_build_requires
709 echo >&2 "Error: conditions reject building this spec (${2})."
711 "err_remote_problem" )
712 remove_build_requires
713 echo >&2 "Error: problem with remote (${2})"
715 "err_not_implemented" )
716 remove_build_requires
717 echo >&2 "Error: functionality not yet imlemented"
720 echo >&2 "Unknown error."
725 if [ -n "$DEBUG" ]; then
730 if [ "$NOINIT" != "yes" ] ; then
731 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
733 local macros_ver=$(rpm -E %?rpm_build_macros)
734 if [ -z "$macros_ver" ]; then
735 REPO_DIR=$TOP_DIR/packages
736 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
738 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
739 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
743 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
749 export GIT_WORK_TREE=$PACKAGE_DIR
750 export GIT_DIR=$PACKAGE_DIR/.git
756 update_shell_title "add_package"
758 if [ -n "$DEBUG" ]; then
764 SPECFILE=$(basename $SPECFILE)
765 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
766 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
769 [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes
770 pldpkg.py add ${ASSUMED_NAME} || Exit_error err_cvs_add_failed
772 git remote add $REMOTE_PLD ${GIT_SERVER}/${ASSUMED_NAME}.git || Exit_error err_remote_problem $REMOTE_PLD
777 update_shell_title "get_spec"
779 if [ -n "$DEBUG" ]; then
785 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
787 SPECFILE=$(basename $SPECFILE)
790 if [ "$NOCVSSPEC" != "yes" ]; then
791 if [ -z "$DEPTH" ]; then
792 if [ -d "$ASSUMED_NAME/.git" ]; then
793 git fetch $REMOTE_PLD || Exit_error err_no_spec_in_repo
794 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
795 if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
796 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
799 Exit_error err_not_implemented
803 git clone -o $REMOTE_PLD ${GIT_SERVER}/${ASSUMED_NAME}.git || {
804 # softfail if new package, i.e not yet added to PLD rep
805 [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
806 echo "Warning: package not in CVS - assuming new package"
812 if [ ! -d "$ASSUMED_NAME/.git" ]; then
813 if [ ! -d "$ASSUMED_NAME" ]; then
817 git remote add $REMOTE_PLD ${GIT_SERVER}/${ASSUMED_NAME}.git
818 CVSTAG=${CVSTAG:-"master"}
821 if [ -z "$ALL_BRANCHES" ]; then
822 refs="${CVSTAG}:remotes/${REMOTE_PLD}/${CVSTAG}"
824 git fetch $DEPTH $REMOTE_PLD $refs || {
825 echo >&2 "Error: branch $CVSTAG does not exist"
830 cvsignore_df .gitignore
832 # add default log format to .gitignore if it is relative to package dir
833 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
834 # substitute known "macros" to glob
835 local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
836 if [ "$logfile" ]; then
837 cvsignore_df "$logfile"
841 # create symlinks for tools
842 if [ "$SYMLINK_TOOLS" != "no" ]; then
843 for a in dropin md5 adapter builder {relup,compile,repackage,pearize}.sh pldnotify.awk; do
844 [ -f $a ] || continue
845 ln -sf ../$a $ASSUMED_NAME
851 if [ -n "$CVSTAG" ]; then
852 git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "${REMOTE_PLD}/$CVSTAG" > /dev/null || exit
853 git symbolic-ref -q HEAD > /dev/null &&
855 if [ -n "$CVSDATE" ]; then
856 git checkout $(git rev-list -n1 --before="'$CVSDATE'" $CVSTAG) || exit 1
860 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
861 Exit_error err_no_spec_in_repo
864 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
865 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
868 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
876 if [ ! -f "mirrors" ] ; then
877 ln -s rpm-build-tools/mirrors .
881 local origin mirror name rest ol prefix
882 while read origin mirror name rest; do
883 # skip comments and empty lines
884 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
887 ol=$(echo -n "$origin" | wc -c)
888 prefix=$(echo -n "$url" | head -c $ol)
889 if [ "$prefix" = "$origin" ] ; then
890 suffix=$(echo "$url" | cut -b $((ol+1))-)
891 echo -n "$mirror$suffix"
898 # Warning: unpredictable results if same URL used twice
902 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
903 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
908 [ "$NO5" = "yes" ] && return
910 [ -z "$no" ] && return
914 if [ -f additional-md5sums ]; then
915 md5=$(grep -s -v '^#' additional-md5sums | \
916 grep -E "[ ]$(basename "$1")([ ,]|\$)" | \
917 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
918 grep -E '^[0-9a-f]{32}$')
921 if [ $(echo "$md5" | wc -l) != 1 ] ; then
922 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
924 echo "$md5" | tail -n 1
929 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
930 if [ -n "$source_md5" ]; then
933 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
934 if [ -n "$source_md5" ]; then
937 # we have empty SourceX-md5, but it is still possible
938 # that we have NoSourceX-md5 AND NoSource: X
939 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
940 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
948 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
952 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
955 distfiles_attic_url() {
956 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
962 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
966 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
967 [ -n "$size" -a "$size" -gt 0 ]
971 if [ "$CVSIGNORE_DF" != "yes" ]; then
974 cvsignore=${PACKAGE_DIR}/.gitignore
976 # add only if not yet there
977 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
978 echo "$1" >> $cvsignore
982 # returns true if "$1" is ftp, http or https protocol url
985 ftp://*|http://*|https://*)
993 if [ $# -eq 0 ]; then
997 update_shell_title "update md5"
998 if [ -n "$DEBUG" ]; then
1005 # pass 1: check files to be fetched
1009 local fp=$(nourl "$i")
1010 local srcno=$(src_no "$i")
1011 if [ -n "$ADD5" ]; then
1012 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
1013 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
1014 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
1016 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
1018 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1019 need_files="$need_files $i"
1023 # pass 1a: get needed files
1024 if [ "$need_files" ]; then
1025 get_files $need_files
1028 # pass 2: proceed with md5 adding or updating
1030 local fp=$(nourl "$i")
1031 local srcno=$(src_no "$i")
1032 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
1033 if [ -z "$md5" ]; then
1034 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
1036 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
1037 local tag="# Source$srcno-md5:\t"
1038 if [[ "$md5" == *NoSource* ]]; then
1039 tag="# NoSource$srcno-md5:\t"
1040 elif [ -n "$USEDIGEST" ]; then
1041 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
1043 md5=$(md5sum "$fp" | cut -f1 -d' ')
1044 echo "Updating Source$srcno ($md5: $fp)."
1046 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
1047 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
1049 $PACKAGE_DIR/$SPECFILE
1056 [ "$NO5" = "yes" ] && return
1058 update_shell_title "check md5"
1062 if ! good_md5 "$i"; then
1063 echo -n "MD5 sum mismatch."
1066 if ! good_size "$i"; then
1067 echo -n "0 sized file."
1071 if [ $bad -eq 1 ]; then
1072 echo " Use -U to refetch sources,"
1073 echo "or -5 to update md5 sums, if you're sure files are correct."
1074 Exit_error err_no_source_in_repo $i
1080 update_shell_title "get_files"
1082 if [ -n "$DEBUG" ]; then
1087 if [ $# -gt 0 ]; then
1091 local get_files_cvs=""
1095 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1096 update_shell_title "$i"
1097 local fp=`nourl "$i"`
1098 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1103 local srcmd5=$(src_md5 "$i")
1105 # we know if source/patch is present in cvs/distfiles
1106 # - has md5 (in distfiles)
1107 # - in cvs... ideas?
1109 # CHECK: local file didn't exist or always cvs up (first) requested.
1110 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1111 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1112 echo "Warning: no URL given for $i"
1116 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1117 if good_md5 "$i" && good_size "$i"; then
1118 echo "$fp having proper md5sum already exists"
1122 # optionally prefer mirror over distfiles if there's mirror
1123 # TODO: build url list and then try each url from the list
1124 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1127 url=$(distfiles_url "$i")
1130 url_attic=$(distfiles_attic_url "$i")
1132 # is $url local file?
1133 if [[ "$url" = [./]* ]]; then
1134 update_shell_title "${GETLOCAL%% *}: $url"
1135 ${GETLOCAL} $url $target
1137 if [ -z "$NOMIRRORS" ]; then
1138 url=$(find_mirror "$url")
1142 # make shorter message for distfiles urls
1143 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1144 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1145 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1148 update_shell_title "${GETURI%% *}: $uri"
1149 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1150 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1151 update_shell_title "${GETURI2%% *}: $url"
1152 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1157 if [ ! -s "$target" ]; then
1159 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1160 update_shell_title "${GETLOCAL%% *}: $url_attic"
1161 ${GETLOCAL} $url_attic $target
1163 if [ -z "$NOMIRRORS" ]; then
1164 url_attic=$(find_mirror "$url_attic")
1166 update_shell_title "${GETURI%% *}: $url_attic"
1167 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1168 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1169 update_shell_title "${GETURI2%% *}: $url_attic"
1170 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1172 test -s "$target" || rm -f "$target"
1176 if [ -s "$target" ]; then
1177 cvsignore_df $target
1184 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1185 if [ -z "$NOMIRRORS" ]; then
1186 im=$(find_mirror "$i")
1190 update_shell_title "${GETURI%% *}: $im"
1191 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1192 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1193 update_shell_title "${GETURI2%% *}: $im"
1194 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1196 test -s "$target" || rm -f "$target"
1199 if [ "$cvsup" = 1 ]; then
1205 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1206 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1207 Exit_error err_no_source_in_repo $i
1210 # we check md5 here just only to refetch immediately
1211 if good_md5 "$i" && good_size "$i"; then
1213 elif [ "$FROM_DISTFILES" = 1 ]; then
1214 # wrong md5 from distfiles: remove the file and try again
1216 echo "MD5 sum mismatch. Trying full fetch."
1219 update_shell_title "${GETURI%% *}: $url"
1220 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1221 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1222 update_shell_title "${GETURI2%% *}: $url"
1223 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1225 if [ ! -s "$target" ]; then
1227 update_shell_title "${GETURI%% *}: $url_attic"
1228 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1229 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1230 update_shell_title "${GETURI2%% *}: $url_attic"
1231 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1234 test -s "$target" || rm -f "$target"
1237 SHELL_TITLE_PREFIX=""
1240 if [ "$CHMOD" = "yes" ]; then
1241 CHMOD_FILES=$(nourl "$@")
1242 if [ -n "$CHMOD_FILES" ]; then
1243 chmod $CHMOD_MODE $CHMOD_FILES
1250 if [ -n "$DEBUG" ]; then
1255 # Check whether first character of PACKAGE_NAME is legal for tag name
1256 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1260 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1261 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1263 # Remove #kernel.version_release from TAGVER because tagging sources
1264 # could occur with different kernel-headers than kernel-headers used at build time.
1265 # besides, %{_kernel_ver_str} is not expanded.
1267 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1268 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1277 if [ -n "$DEBUG" ]; then
1282 echo "Version: $PACKAGE_VERSION"
1283 echo "Release: $PACKAGE_RELEASE"
1286 if [ "$TAG_VERSION" = "yes" ]; then
1287 TAGVER=`make_tagver`
1290 if [ -n "$TAG" ]; then
1294 local OPTIONS="tag $CVS_FORCE"
1297 if [ "$TAG_VERSION" = "yes" ]; then
1303 if [ "$TAG_VERSION" = "yes" ]; then
1304 update_shell_title "tag sources: $TAGVER"
1305 git $OPTIONS $TAGVER || exit
1306 git push $CVS_FORCE $REMOTE_PLD tag $TAGVER || Exit_error err_remote_problem $REMOTE_PLD
1308 if [ -n "$TAG" ]; then
1309 update_shell_title "tag sources: $TAG"
1310 git $OPTIONS $TAG $chunk || exit
1311 git push $CVS_FORCE $REMOTE_PLD tag $TAG || Exit_error err_remote_problem $REMOTE_PLD
1317 echo "Git branch: $TAG"
1320 if [ -n "$DEBUG" ]; then
1325 local OPTIONS="branch $CVS_FORCE"
1328 git $OPTIONS $TAG || exit
1332 # this function should exit early if package can't be built for this arch
1333 # this avoids unneccessary BR filling.
1336 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1338 if [ $ret -ne 0 ]; then
1350 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1351 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1357 local ver="$2" subver=$ver
1358 local newver="$3" newsubver=$newver
1360 # try handling subver, everything that's not numeric-dotted in version
1361 if grep -Eq '%define\s+subver' $specfile; then
1362 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1364 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1365 newver=${newver%$newsubver}
1368 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1369 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1370 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1375 if [ -n "$TRY_UPGRADE" ]; then
1376 local TNOTIFY TNEWVER TOLDVER
1377 update_shell_title "build_package: try_upgrade"
1381 if [ "$UPGRADE_VERSION" ]; then
1382 TNEWVER=$UPGRADE_VERSION
1384 if [ -n "$FLOAT_VERSION" ]; then
1385 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1387 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1390 # pldnotify.awk does not set exit codes, but it has match for ERROR
1391 # in output which means so.
1392 if [[ "$TNOTIFY" = *ERROR* ]]; then
1397 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1400 if [ -n "$TNEWVER" ]; then
1401 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1402 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1403 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1404 cp -f $SPECFILE $SPECFILE.bak
1407 set_release $SPECFILE $PACKAGE_RELEASE 1
1408 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1410 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1411 echo >&2 "Upgrading version failed, you need to update spec yourself"
1421 update_shell_title "build_package"
1422 if [ -n "$DEBUG" ]; then
1431 BUILD_SWITCH="-ba" ;;
1433 BUILD_SWITCH="-bb" ;;
1435 BUILD_SWITCH="-bs --nodeps" ;;
1437 BUILD_SWITCH="-bp --nodeps" ;;
1439 BUILD_SWITCH="-bc" ;;
1441 BUILD_SWITCH="-bi" ;;
1443 BUILD_SWITCH="-bl" ;;
1447 update_shell_title "build_package: $COMMAND"
1448 if [ -n "$LOGFILE" ]; then
1449 LOG=`eval echo $LOGFILE`
1450 if [ -d "$LOG" ]; then
1451 echo "Log file $LOG is a directory."
1452 echo "Parse error in the spec?"
1453 Exit_error err_build_fail
1455 if [ -n "$LASTLOG_FILE" ]; then
1456 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1458 RES_FILE=$(tempfile)
1459 local specfile=$(insert_gitlog $SPECFILE)
1461 (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
1462 RETVAL=`cat $RES_FILE`
1463 rm $RES_FILE $specfile
1464 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1465 if [ "$RETVAL" -eq "0" ]; then
1472 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1475 if [ "$RETVAL" -ne "0" ]; then
1476 if [ -n "$TRY_UPGRADE" ]; then
1477 echo "\nUpgrade package to new version failed."
1478 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1479 echo "Restoring old spec file."
1480 mv -f $SPECFILE.bak $SPECFILE
1484 Exit_error err_build_fail
1490 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1493 install_required_packages() {
1498 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1501 /^%changelog/ { exit }
1503 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1504 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1505 gsub(/[ \t]+/, "_", bcond);
1507 }' $SPEC | LC_ALL=C sort -u
1511 # expand bconds from ~/.bcondrc
1512 # The file structure is like gentoo's package.use:
1515 # samba -mysql -pgsql
1516 # w32codec-installer license_agreement
1519 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1525 SN=${SPECFILE%%\.spec}
1527 local bcondrc=$HOME/.bcondrc
1528 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1530 local bcond_avail=$(find_spec_bcond $SPECFILE)
1532 while read pkg flags; do
1534 [[ "$pkg" == \#* ]] && continue
1536 # any package or current package?
1537 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1538 for flag in $flags; do
1539 local opt=${flag#[+-]}
1541 # use only flags which are in this package.
1542 if [[ $bcond_avail = *${opt}* ]]; then
1543 if [[ $flag = -* ]]; then
1544 if [[ $BCOND != *--with?${opt}* ]]; then
1545 BCOND="$BCOND --without $opt"
1548 if [[ $BCOND != *--without?${opt}* ]]; then
1549 BCOND="$BCOND --with $opt"
1556 update_shell_title "parse ~/.bcondrc: DONE!"
1559 set_bconds_values() {
1560 update_shell_title "set bcond values"
1562 AVAIL_BCONDS_WITHOUT=""
1563 AVAIL_BCONDS_WITH=""
1565 if grep -Eq '^# *_with' ${SPECFILE}; then
1566 echo >&2 "ERROR: This spec has old style bconds."
1570 if ! grep -q '^%bcond' ${SPECFILE}; then
1574 local bcond_avail=$(find_spec_bcond $SPECFILE)
1575 process_bcondrc "$SPECFILE"
1577 update_shell_title "parse bconds"
1580 for opt in $bcond_avail; do
1583 bcond=${opt#without_}
1585 *--without?${bcond}*)
1586 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1589 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1597 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1600 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1605 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1614 update_shell_title "run_sub_builder $package_name"
1616 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1617 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1618 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1619 # jakby nie bylo tego kawalka kodu.
1621 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1622 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1626 # kurwa. translate that ^^^^
1630 # Istnieje taki spec? ${package}.spec
1631 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1632 parent_spec_name=${package}.spec
1633 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1634 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1636 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1641 if [ "${parent_spec_name}" != "" ]; then
1642 spawn_sub_builder $parent_spec_name
1644 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1647 spawn_sub_builder() {
1649 update_shell_title "spawn_sub_builder $package_name"
1652 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1653 sub_builder_opts="${sub_builder_opts} -R"
1655 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1656 sub_builder_opts="${sub_builder_opts} -RB"
1657 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1658 sub_builder_opts="${sub_builder_opts} -FRB"
1660 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1661 sub_builder_opts="${sub_builder_opts} -Upi"
1665 ./builder ${sub_builder_opts} "$@"
1668 remove_build_requires() {
1669 if [ "$INSTALLED_PACKAGES" != "" ]; then
1670 case "$REMOVE_BUILD_REQUIRES" in
1672 run_poldek --noask -ve $INSTALLED_PACKAGES
1675 run_poldek --ask -ve $INSTALLED_PACKAGES
1678 echo You may want to manually remove following BuildRequires fetched:
1679 echo $INSTALLED_PACKAGES
1680 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1687 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1688 if [ "$BCOND" ]; then
1690 echo "Building $SPECFILE with the following conditional flags:"
1694 echo "No conditional flags passed"
1697 echo "from available:"
1698 echo "--with :\t$AVAIL_BCONDS_WITH"
1699 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1704 display_branches() {
1705 echo -n "Available branches: "
1706 git branch -r | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs
1709 # checks a given list of packages/files/provides agains current rpmdb.
1710 # outputs all dependencies which current rpmdb doesn't satisfy.
1711 # input can be either STDIN or parameters
1715 if [ $# -gt 0 ]; then
1721 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1724 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1726 # other deps (files)
1727 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1730 # checks if given package/files/provides exists in rpmdb.
1731 # input can be either stdin or parameters
1732 # returns packages which are present in the rpmdb
1736 if [ $# -gt 0 ]; then
1742 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1745 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1746 install_build_requires_rpmdeps() {
1747 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1748 # TODO: Conflicts list doesn't check versions
1749 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1750 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1752 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1753 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1754 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1757 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1758 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1759 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1760 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1762 if [ -n "$CNFL" ]; then
1763 update_shell_title "uninstall conflicting packages: $CNFL"
1764 echo "Trying to uninstall conflicting packages ($CNFL):"
1765 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1768 while [ "$DEPS" ]; do
1769 update_shell_title "install deps: $DEPS"
1770 echo "Trying to install dependencies ($DEPS):"
1771 local log=.${SPECFILE}_poldek.log
1772 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1773 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1776 if [ -n "$failed" ]; then
1777 for package in $failed; do
1778 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1787 fetch_build_requires()
1789 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1793 update_shell_title "fetch build requires"
1794 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1795 install_build_requires_rpmdeps
1799 # XXX is this ugliest code written in human history still needed?
1800 echo "All packages installed by fetch_build_requires() are written to:"
1801 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1803 echo "If anything fails, you may get rid of them by executing:"
1804 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1806 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1807 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)
1809 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)
1811 package=$(basename "$package_item"|sed -e "s/}$//g")
1812 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1815 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1816 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1817 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
1822 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1825 if `echo $COND_TST|grep -q 'without_'`; then
1826 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1827 if `echo $COND_TST|grep -q !`; then
1832 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1833 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1834 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1840 elif `echo $COND_TST|grep -q 'with_'`; then
1841 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1842 if `echo $COND_TST|grep -q !`; then
1847 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1848 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1849 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1855 RESULT="${COND_STATE}-${COND_ARGV}"
1857 "with-wout" | "wout-with" )
1860 "wout-wout" | "with-with" )
1864 echo "Action '$RESULT' was not defined for package '$package_item'"
1870 if [ "$GO" = "yes" ]; then
1871 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1872 echo "Testing if $package has subrequirements..."
1873 run_poldek -t -i $package --dumpn=".$package-req.txt"
1874 if [ -f ".$package-req.txt" ]; then
1875 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1877 if [ "$package_name" = "$package" ]; then
1878 echo "Installing BuildRequired package:\t$package_name"
1879 update_shell_title "Installing BuildRequired package: ${package_name}"
1880 install_required_packages $package
1882 echo "Installing (sub)Required package:\t$package_name"
1883 update_shell_title "Installing (sub)Required package: ${package_name}"
1884 install_required_packages $package_name
1888 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1889 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1892 echo "Attempting to run spawn sub - builder..."
1893 echo "Package installation failed:\t$package_name"
1894 run_sub_builder $package_name
1895 if [ $? -eq 0 ]; then
1896 install_required_packages $package_name
1899 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1900 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1903 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1910 rm -f ".$package-req.txt"
1912 echo "Attempting to run spawn sub - builder..."
1913 echo "Package installation failed:\t$package"
1914 run_sub_builder $package
1915 if [ $? -eq 0 ]; then
1916 install_required_packages $package
1919 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1920 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1923 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1929 echo "Package $package is already installed. BuildRequirement satisfied."
1933 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1934 echo >&2 "Unable to install following packages and their dependencies:"
1935 for pkg in "$NOT_INSTALLED_PACKAGES"
1939 remove_build_requires
1945 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1946 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
1947 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
1948 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
1951 echo "Initializing rpm directories to $TOP_DIR from $GIT_SERVER"
1952 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
1955 if [ ! -e ../rpm-build-tools ]; then
1956 git clone ${GIT_SERVER}/rpm-build-tools.git ../rpm-build-tools
1958 for a in dropin md5 adapter builder mirrors {relup,compile,repackage,pearize}.sh pldnotify.awk; do
1959 ln -s ../rpm-build-tools/$a .
1967 DONT_PRINT_REVISION="yes"
1969 # remove spec and sources
1970 $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $PACKAGE_DIR/$SPECFILE
1971 rm -rf $PACKAGE_DIR/.git .gitignore
1972 rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
1975 #---------------------------------------------
1983 while [ $# -gt 0 ]; do
1986 COMMAND="update_md5"
1991 COMMAND="update_md5"
2000 DEBUG="yes"; shift ;;
2002 COMMAND="version"; shift ;;
2004 COMMAND="short-version"; 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;;
2036 COMMAND="get"; shift ;;
2038 COMMAND="usage"; shift ;;
2040 PROTOCOL="ftp"; shift ;;
2042 PROTOCOL="http"; shift ;;
2044 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
2048 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
2052 shift; LOGFILE="${1}"; shift ;;
2054 shift; DEF_NICE_LEVEL=${1}; shift ;;
2055 -ske | --skip-existing-files)
2056 SKIP_EXISTING_FILES="yes"; shift ;;
2058 COMMAND="mr-proper"; shift ;;
2059 -ncs | --no-cvs-specs )
2060 NOCVSSPEC="yes"; shift ;;
2061 -nd | --no-distfiles )
2062 NODIST="yes"; shift ;;
2063 -nm | --no-mirrors )
2064 NOMIRRORS="yes"; shift ;;
2066 NOURLS="yes"; shift ;;
2068 NOSRCS="yes"; shift ;;
2069 -ns0 | --no-source0 )
2070 NOSOURCE0="yes"; shift ;;
2079 -pm | --prefer-mirrors )
2086 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2088 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2089 --skip-patch | -sp )
2090 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2092 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2095 --with | --without )
2096 case $GROUP_BCONDS in
2100 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2101 while ! `echo ${1}|grep -qE '(^-|spec)'`
2103 BCOND="$BCOND $COND $1"
2107 if [[ "$2" = *,* ]]; then
2108 for a in $(echo "$2" | tr , ' '); do
2109 BCOND="$BCOND $1 $a"
2112 BCOND="$BCOND $1 $2"
2118 shift; TARGET="${1}"; shift ;;
2120 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2122 QUIET="--quiet"; shift ;;
2124 CVSDATE="${2}"; shift 2
2125 date -d "$CVSDATE" > /dev/null 2>&1 || { echo >&2 "No valid date specified"; exit 3; }
2135 -R | --fetch-build-requires)
2136 FETCH_BUILD_REQUIRES="yes"
2137 NOT_INSTALLED_PACKAGES=
2139 -RB | --remove-build-requires)
2140 REMOVE_BUILD_REQUIRES="nice"
2142 -FRB | --force-remove-build-requires)
2143 REMOVE_BUILD_REQUIRES="force"
2145 -sc | --sources-cvs)
2146 COMMAND="list-sources-cvs"
2148 -sd | --source-distfiles)
2149 COMMAND="list-sources-distfiles"
2151 -sdp | --source-distfiles-paths)
2152 COMMAND="list-sources-distfiles-paths"
2154 -sf | --source-files)
2155 COMMAND="list-sources-files"
2157 -lsp | --source-paths)
2158 COMMAND="list-sources-local-paths"
2160 -su | --source-urls)
2161 COMMAND="list-sources-urls"
2163 -Tvs | --tag-version-stable )
2168 -Ts | --tag-stable )
2173 -Tv | --tag-version )
2178 -Tp | --tag-prefix )
2190 -ir | --integer-release-only )
2191 INTEGER_RELEASE="yes"
2194 COMMAND="update_md5"
2199 -Upi | --update-poldek-indexes )
2200 UPDATE_POLDEK_INDEXES="yes"
2203 COMMAND="init_rpm_dir"
2205 -u | --try-upgrade )
2206 TRY_UPGRADE="1"; shift ;;
2208 shift; UPGRADE_VERSION="$1"; shift;;
2209 -un | --try-upgrade-with-float-version )
2210 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2212 BE_VERBOSE="1"; shift ;;
2217 if echo "${MACRO}" | grep -q '\W'; then
2218 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2222 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2227 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2231 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2234 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2235 COMMAND="show_bconds"
2239 COMMAND="show_bcond_args"
2242 --show-avail-bconds)
2243 COMMAND="show_avail_bconds"
2248 RPMOPTS="${RPMOPTS} --nodeps"
2251 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2254 Exit_error err_invalid_cmdline "$1"
2257 SPECFILE=${1%/}; shift
2258 # check if specname was passed as specname:cvstag
2259 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2260 CVSTAG="${SPECFILE##*:}"
2261 SPECFILE="${SPECFILE%%:*}"
2263 # always have SPECFILE ending with .spec extension
2264 SPECFILE=${SPECFILE%%.spec}.spec
2265 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2269 [ -d "$ASSUMED_NAME" ] && GIT_DIR="$ASSUMED_NAME/.git" || GIT_DIR=.git
2270 if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then
2271 if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then
2272 CVSTAG=${CVSTAG#refs/heads/}
2273 if [ "$CVSTAG" != "master" ]; then
2274 echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override"
2277 echo >&2 "On detached HEAD. Use -r BRANCHNAME to override"
2280 elif [ "$CVSTAG" = "HEAD" ]; then
2281 # assume -r HEAD is same as -A
2285 if [ "$CVSTAG" ]; then
2286 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2287 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2290 if [ -n "$ALL_BRANCHES" -a -z "$DEPTH" ]; then
2291 echo >&2 "--all branches requires --depth <number>"
2292 Exit_error err_invalid_cmdline
2295 if [ -n "$DEBUG" ]; then
2300 if [ -n "$TARGET" ]; then
2303 TARGET_SWITCH="--target $TARGET" ;;
2305 TARGET_SWITCH="--target=$TARGET" ;;
2309 if [ "$SCHEDTOOL" != "no" ]; then
2310 NICE_COMMAND="$SCHEDTOOL"
2312 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2315 update_shell_title "$COMMAND"
2319 if [ -z "$SPECFILE" ]; then
2320 Exit_error err_no_spec_in_cmdl
2322 get_spec > /dev/null
2329 if [ -z "$SPECFILE" ]; then
2330 Exit_error err_no_spec_in_cmdl
2332 get_spec > /dev/null
2337 "show_avail_bconds")
2339 if [ -z "$SPECFILE" ]; then
2340 Exit_error err_no_spec_in_cmdl
2343 get_spec > /dev/null
2345 local bcond_avail=$(find_spec_bcond $SPECFILE)
2346 local opt bcond bconds
2347 for opt in $bcond_avail; do
2350 bcond=${opt#without_}
2351 bconds="$bconds $bcond"
2355 bconds="$bconds $bcond"
2358 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2366 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2368 if [ -z "$SPECFILE" ]; then
2369 Exit_error err_no_spec_in_cmdl
2372 # display SMP make flags if set
2373 smp_mflags=$(rpm -E %{?_smp_mflags})
2374 if [ "$smp_mflags" ]; then
2375 echo "builder: SMP make flags are set to $smp_mflags"
2383 if [ "$COMMAND" != "build-source" ]; then
2386 fetch_build_requires
2387 if [ "$INTEGER_RELEASE" = "yes" ]; then
2388 echo "Checking release $PACKAGE_RELEASE..."
2389 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2390 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2394 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2395 if [ -n "$TEST_TAG" ]; then
2396 local TAGVER=`make_tagver`
2397 echo "Searching for tag $TAGVER..."
2398 if [ -n "$DEPTH" ]; then
2399 local ref=`git ls-remote $REMOTE_PLD "refs/tags/$TAGVER"`
2400 [ -n "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$TAGVER"
2402 git show-ref --verify "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER"
2404 # - do not allow to build from HEAD when XX-branch exists
2405 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2406 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2407 TAG_BRANCH="${TREE_PREFIX}-branch"
2408 if [ -n "$DEPTH" ]; then
2409 cmd_branches="git ls-remote --heads"
2410 ref_prefix=refs/heads
2412 cmd_branches="git show-ref"
2413 ref_prefix=refs/remotes/${REMOTE_PLD}
2415 TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$")
2416 if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != "$CVSTAG" ]; then
2417 Exit_error err_branch_exists "$TAG_STATUS"
2423 if [ -n "$NOSOURCE0" ] ; then
2424 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2429 get_files $SOURCES $PATCHES
2433 NODIST="yes" get_files $SOURCES $PATCHES
2438 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2439 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2441 remove_build_requires
2445 if [ -z "$SPECFILE" ]; then
2446 Exit_error err_no_spec_in_cmdl
2455 if [ -z "$SPECFILE" ]; then
2456 Exit_error err_no_spec_in_cmdl
2460 if [ -n "$NEW_REPO" ]; then
2463 for file in $SOURCES $PATCHES; do
2464 if [ -z $(src_md5 "$file") ]; then
2465 git add $file || Exit_error err_no_source_in_repo $file
2467 cvsignore_df `nourl $file`
2471 git commit -m 'Initial commit'
2472 git push --dry-run $REMOTE_PLD master || Exit_error err_cvs_add_failed
2474 echo "You had already git repository. Push chosen branches to remote: ${REMOTE_PLD}"
2479 if [ -z "$SPECFILE" ]; then
2480 Exit_error err_no_spec_in_cmdl
2486 if [ -n "$NOSOURCE0" ] ; then
2487 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2489 get_files $SOURCES $PATCHES
2494 if [ -z "$SPECFILE" ]; then
2495 Exit_error err_no_spec_in_cmdl
2501 if [ -n "$NOSOURCE0" ] ; then
2502 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2510 if [ -z "$SPECFILE" ]; then
2511 Exit_error err_no_spec_in_cmdl
2521 "list-sources-files" )
2524 DONT_PRINT_REVISION="yes"
2527 for SAP in $SOURCES $PATCHES; do
2528 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2531 "list-sources-urls" )
2534 DONT_PRINT_REVISION="yes"
2537 SAPS="$SOURCES $PATCHES"
2538 for SAP in $SAPS ; do
2542 "list-sources-local-paths" )
2545 DONT_PRINT_REVISION="yes"
2548 for SAP in $SOURCES $PATCHES; do
2549 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2552 "list-sources-distfiles-paths" )
2555 DONT_PRINT_REVISION="yes"
2558 for SAP in $SOURCES $PATCHES; do
2559 if [ -n "$(src_md5 "$SAP")" ]; then
2560 distfiles_path "$SAP"
2564 "list-sources-distfiles" )
2567 DONT_PRINT_REVISION="yes"
2570 for SAP in $SOURCES $PATCHES; do
2571 if [ -n "$(src_md5 "$SAP")" ]; then
2572 distfiles_url "$SAP"
2576 "list-sources-cvs" )
2579 DONT_PRINT_REVISION="yes"
2582 for SAP in $SOURCES $PATCHES; do
2583 if [ -z "$(src_md5 "$SAP")" ]; then
2584 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2598 echo "$VERSIONSTRING"
2601 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2602 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2606 # vi:syntax=sh:ts=4:sw=4:noet