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()
108 # use lftp by default when available
110 lftp --version > /dev/null 2>&1 && USE_LFTP=yes
112 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
117 GIT_SERVER="git://carme.pld-linux.org"
118 GIT_PUSH="draenog@carme.pld-linux.org"
119 PACKAGES_DIR="packages"
128 DISTFILES_SERVER="://distfiles.pld-linux.org"
129 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
134 FAIL_IF_NO_SOURCES="yes"
136 # let get_files skip over files which are present to get those damn files fetched
137 SKIP_EXISTING_FILES="no"
140 # should the specfile be restored if upgrade failed?
141 REVERT_BROKEN_UPGRADE="yes"
143 if rpm --specsrpm 2>/dev/null; then
144 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
145 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
147 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
148 if [ -x /usr/bin/rpm-getdeps ]; then
149 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
151 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
156 # Here we load saved user environment used to
157 # predefine options set above, or passed to builder
159 # This one reads global system environment settings:
160 if [ -f ~/etc/builderrc ]; then
163 # And this one cascades settings using user personal
165 # Example of ~/.builderrc:
167 #UPDATE_POLDEK_INDEXES="yes"
168 #FETCH_BUILD_REQUIRES="yes"
169 #REMOVE_BUILD_REQUIRES="force"
171 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
175 if [ -n "$HOME_ETC" ]; then
176 USER_CFG="$HOME_ETC/.builderrc"
177 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
179 USER_CFG=~/.builderrc
180 BUILDER_MACROS=~/.builder-rpmmacros
183 [ -f "$USER_CFG" ] && . "$USER_CFG"
185 if [ "$SCHEDTOOL" = "auto" ]; then
186 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
187 SCHEDTOOL="schedtool -B -e"
193 if [ -n "$USE_PROZILLA" ]; then
194 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
197 elif [ -n "$USE_AXEL" ]; then
198 GETURI="axel -a $AXEL_OPTS"
201 elif [ -n "$USE_LFTP" ]; then
206 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
207 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
208 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
209 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
211 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
212 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
218 if rpm --version 2>&1 | grep -q '4.0.[0-2]'; then
229 if [ -d $HOME/rpm/SOURCES ]; then
230 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
231 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
235 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
236 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
240 if [ -n "$LOGFILE" ]; then
241 LOG=`eval echo $LOGFILE`
242 if [ -n "$LASTLOG_FILE" ]; then
243 echo "LASTLOG=$LOG" > $LASTLOG_FILE
245 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
248 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
249 return `cat ${RES_FILE}`
254 #---------------------------------------------
258 local outfile=$1 url=$2 retval tmpfile
262 $([ "$DEBUG" = "yes" ] && echo "debug 5;")
263 set net:max-retries $WGET_RETRIES;
264 set http:user-agent \"$USER_AGENT\";
265 pget -n 10 -c \"$url\" -o \"$tmpfile\"
269 if [ $retval -eq 0 ]; then
270 mv -f "$tmpfile" "$outfile"
278 if [ -n "$DEBUG" ]; then set -xv; fi
280 Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [-a|--add_cvs] [-b|-ba|--build]
281 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
282 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [--depth <number>]
283 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
284 [-q|--quiet] [--date <yyyy-mm-dd> [-r <tag>] [{-T|--tag <tag>]
285 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
286 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
287 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
288 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
289 <package>[.spec][:tag]
291 -4 - force ipv4 when transferring files
292 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
293 -6 - force ipv6 when transferring files
294 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
295 --all-branches - make shallow fetch of all branches; --depth required
296 -n5, --no-md5 - ignore md5 comments in spec
297 -D, --debug - enable builder script debugging mode,
298 -debug - produce rpm debug package (same as --opts -debug)
299 -V, --version - output builder version string
300 --short-version - output builder short version
301 -a, --add_vcs - try add new package to PLD repo.
302 -b, -ba, --build - get all files from PLD repo or HTTP/FTP and build package
304 -bb, --build-binary - get all files from PLD repo or HTTP/FTP and build binary
305 only package from <package>.spec,
306 -bp, --build-prep - execute the %prep phase of <package>.spec,
307 -bc - execute the %build phase of <package>.spec,
308 -bi - execute the %install phase of <package>.spec
309 -bl - execute the %files phase of <package>.spec
310 -bs, --build-source - get all files from PLD repo or HTTP/FTP and only pack
312 --short-circuit - short-circuit build
313 -B, --branch - add branch
314 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
315 may be used with building process.
316 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
317 SPECS and \$RPM_BUILD_ROOT). Doesn't run any rpm building.
318 -cf, --cvs-force - use -f when tagging
319 --define <macro> <value>
320 - define a macro <macro> with value <value>,
321 --depth <number> - make shallow fetch
322 --alt_kernel <kernel>
323 - same as --define 'alt_kernel <kernel>'
324 --nodeps - rpm won't check any dependences
325 -g, --get - get <package>.spec and all related files from PLD repo
327 -h, --help - this message,
328 -jN, -j N - set %_smp_mflags to propagate concurrent jobs
329 --ftp, --http - use ftp or http protocol to access distfiles server
330 -l <logfile>, --logtofile <logfile>
333 - don't pull from PLD repo
334 -nd, --no-distfiles - don't download from distfiles
335 -nm, --no-mirrors - don't download from mirror, if source URL is given,
336 -nu, --no-urls - don't try to download from FTP/HTTP location,
337 -ns, --no-srcs - don't download Sources/Patches
338 -ns0, --no-source0 - don't download Source0
339 -nn, --no-net - don't download anything from the net
340 -pm, --prefer-mirrors
341 - prefer mirrors (if any) over distfiles for SOURCES
342 --no-init - don't initialize builder paths (SPECS and SOURCES)
344 --skip-existing-files
345 - skip existing files in get_files
346 --opts <rpm opts> - additional options for rpm
347 -q, --quiet - be quiet,
348 --date yyyy-mm-dd - build package using resources from specified date,
349 -r <tag>, --cvstag <ref>
350 - build package using resources from specified branch/tag,
351 -A - build package using master branch as any sticky tags/branch/date being reset.
352 -R, --fetch-build-requires
353 - fetch what is BuildRequired,
354 -RB, --remove-build-requires
355 - remove all you fetched with -R or --fetch-build-requires
356 remember, this option requires confirmation,
357 -FRB, --force-remove-build-requires
358 - remove all you fetched with -R or --fetch-build-requires
359 remember, this option works without confirmation,
360 -sd, --source-distfiles
361 - list sources available from distfiles (intended for offline
362 operations; does not work when Icon field is present
363 but icon file is absent),
364 -sc, --source-cvs - list sources available from PLD repo
365 -sdp, --source-distfiles-paths
366 - list sources available from distfiles -
367 paths relative to distfiles directory (intended for offline
368 operations; does not work when Icon field is present
369 but icon file is absent),
370 -sf, --source-files - list sources - bare filenames (intended for offline
371 operations; does not work when Icon field is present
372 but icon file is absent),
374 - list sources - filenames with full local paths (intended for
375 offline operations; does not work when Icon field is present
376 but icon file is absent),
377 -su, --source-urls - list urls - urls to sources and patches
378 intended for copying urls with spec with lots of macros in urls
379 -T <tag> , --tag <tag>
380 - add git tag <tag> for files,
381 -Tvs, --tag-version-stable
382 - add git tags STABLE and NAME-VERSION-RELEASE for files,
384 - add git tag STABLE for files,
386 - add git tag NAME-VERSION-RELEASE for files,
387 -Tp, --tag-prefix <prefix>
388 - add <prefix> to NAME-VERSION-RELEASE tags,
389 -tt, --test-tag <prefix>
390 - fail if tag is already present,
391 -ir, --integer-release-only
392 - allow only integer and snapshot releases
393 -v, --verbose - be verbose,
394 -u, --try-upgrade - check version, and try to upgrade package
395 -un, --try-upgrade-with-float-version
396 - as above, but allow float version
397 php-pear-Services_Digg/
398 --upgrade-version - upgrade to specified version in try-upgrade
399 -U, --update - refetch sources, don't use distfiles, and update md5 comments
400 -Upi, --update-poldek-indexes
401 - refresh or make poldek package index files.
402 -sp, --skip-patch <patchnumber>
403 - don't apply <patchnumber>. may be repeated.
404 -np, --nopatch <patchnumber>
405 - abort instead of applying patch <patchnumber>
406 --show-bconds - show available conditional builds, which can be used
407 - with --with and/or --without switches.
408 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by ./repackage.sh script.
409 In other words, the output is parseable by scripts.
410 --show-avail-bconds - show available bconds
411 --with/--without <feature>
412 - conditional build package depending on %_with_<feature>/
413 %_without_<feature> macro switch. You may now use
414 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
415 constructions. Set GROUP_BCONDS to yes to make use of it.
416 --target <platform>, --target=<platform>
417 - build for platform <platform>.
418 --init-rpm-dir - initialize ~/rpm directory structure
422 # create tempfile. as secure as possible
424 mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
427 # inserts git log instead of %changelog
428 # outputs name of modified file created by tempfile
430 local SPECFILE=$1 specfile=$(tempfile) gitlog=$(tempfile) speclog=$(tempfile)
432 # allow this being customized
433 local log_entries=$(rpm -E '%{?_buildchangelogtruncate}')
435 # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997'
436 # otherwise i'd use --date=iso here
437 # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1
438 # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31
439 # NOTE: changelog date is always in UTC for rpmbuild
440 # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
441 git rev-list -${log_entries:-20} HEAD | while read sha1; do
443 git notes list $sha1 &> /dev/null && logfmt=%N
444 git log -n 1 $sha1 --format=format:"* %ad %an <%ae> %h%n${logfmt}%n" --date=raw
446 gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
447 sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
452 rm -f $gitlog $speclog
456 # change dependency to specname
458 # - perl(Package::Name) -> perl-Package-Name
462 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
466 update_shell_title() {
468 local len=${COLUMNS:-80}
469 local msg="$(echo "$*" | cut -c-$len)"
471 if [ -n "$BE_VERBOSE" ]; then
472 echo >&2 "$(date +%s.%N) $*"
475 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
477 if [ -n "$PACKAGE_NAME" ]; then
478 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
483 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
484 msg=$(echo $msg | tr -d '\n\r')
487 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
490 echo >&2 -ne "\033]0;$msg\007"
496 # set TARGET from BuildArch: from SPECFILE
498 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
499 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
501 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
505 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
507 TARGET_SWITCH="--target=$TARGET" ;;
513 # runs rpm with minimal macroset
515 # we reset macros not to contain macros.build as all the %() macros are
516 # executed here, while none of them are actually needed.
517 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
518 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
520 # TODO: move these to /usr/lib/rpm/macros
521 cat > $BUILDER_MACROS <<'EOF'
522 %x8664 x86_64 amd64 ia32e
525 %bootstrap_release() %{1}
526 %requires_releq_kernel_up(s:n:) %{nil}
527 %requires_releq_kernel_smp(s:n:) %{nil}
528 %requires_releq_kernel(s:n:) %{nil}
529 %requires_releq() %{nil}
530 %pyrequires_eq() %{nil}
531 %requires_eq() %{nil}
532 %requires_eq_to() %{nil}
533 %requires_ge() %{nil}
534 %requires_ge_to() %{nil}
535 %requires_ge() %{nil}
536 %releq_kernel_up(n:) ERROR
537 %releq_kernel_smp(n:) ERROR
538 %releq_kernel(n:) ERROR
542 %ruby_ver_requires_eq() %{nil}
543 %ruby_mod_ver_requires_eq() %{nil}
544 %__php_api_requires() %{nil}
545 %php_major_version ERROR
546 %php_api_version ERROR
547 %requires_xorg_xserver_extension %{nil}
548 %requires_xorg_xserver_xinput %{nil}
549 %requires_xorg_xserver_font %{nil}
550 %requires_xorg_xserver_videodrv %{nil}
552 %perl_vendorarch ERROR
553 %perl_vendorlib ERROR
554 # damn. need it here! - copied from /usr/lib/rpm/macros.build
555 %tmpdir %(echo "${TMPDIR:-/tmp}")
556 %patchset_source(f:b:) %(
557 base=%{-b*}%{!-b*:10000};
558 start=$(expr $base + %1);
559 end=$(expr $base + %{?2}%{!?2:%{1}});
560 # we need to call seq twice as it doesn't allow two formats
561 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
562 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
563 paste %{tmpdir}/__ps{1,2};
564 rm -f %{tmpdir}/__ps{1,2};
567 %add_etc_shells(p) %{p:<lua>}
568 %remove_etc_shells(p) %{p:<lua>}
569 %lua_add_etc_shells() %{nil}
570 %lua_remove_etc_shells() %{nil}
572 %buildrequires_jdk %{nil}
573 %pear_package_print_optionalpackages %{nil}
575 if [ "$NOINIT" = "yes" ] ; then
576 cat >> $BUILDER_MACROS <<'EOF'
581 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
585 if [ -n "$DEBUG" ]; then
590 if [ -x /usr/bin/rpm-specdump ]; then
591 update_shell_title "cache_rpm_dump using rpm-specdump command"
592 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
594 update_shell_title "cache_rpm_dump using rpmbuild command"
597 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
598 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
604 ARGS='--nodigest --nosignature --nobuild'
607 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
609 if [ $? -gt 0 ]; then
610 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
612 Exit_error err_build_fail
615 # make small dump cache
616 rpm_dump_cache=`echo "$rpm_dump" | awk '
617 $2 ~ /^SOURCEURL/ {print}
618 $2 ~ /^PATCHURL/ {print}
619 $2 ~ /^nosource/ {print}
620 $2 ~ /^PACKAGE_/ {print}
624 update_shell_title "cache_rpm_dump: OK!"
628 if [ -z "$rpm_dump_cache" ] ; then
629 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
631 echo "$rpm_dump_cache"
635 update_shell_title "get icons"
636 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
637 if [ -z "$ICONS" ]; then
641 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
645 update_shell_title "parsing specfile"
646 if [ -n "$DEBUG" ]; then
651 # icons are needed for successful spec parse
657 if rpm_dump | grep -qEi ":.*nosource.*1"; then
658 FAIL_IF_NO_SOURCES="no"
661 if [ "$NOSRCS" != "yes" ]; then
662 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
663 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
664 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
667 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
668 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
669 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
671 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
672 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
675 if [ -n "$BE_VERBOSE" ]; then
676 echo "- Sources : `nourl $SOURCES`"
677 if [ -n "$PATCHES" ]; then
678 echo "- Patches : `nourl $PATCHES`"
680 echo "- Patches : *no patches needed*"
682 if [ -n "$ICONS" ]; then
683 echo "- Icon : `nourl $ICONS`"
685 echo "- Icon : *no package icon*"
687 echo "- Name : $PACKAGE_NAME"
688 echo "- Version : $PACKAGE_VERSION"
689 echo "- Release : $PACKAGE_RELEASE"
692 update_shell_title "parse_spec: OK!"
696 if [ -n "$DEBUG" ]; then
704 "err_no_spec_in_cmdl" )
705 remove_build_requires
706 echo >&2 "ERROR: spec file name not specified."
708 "err_invalid_cmdline" )
709 echo >&2 "ERROR: invalid command line arg ($2)."
711 "err_no_spec_in_repo" )
712 remove_build_requires
713 echo >&2 "Error: spec file not stored in PLD repo."
715 "err_no_source_in_repo" )
716 remove_build_requires
717 echo >&2 "Error: some source, patch or icon files not stored in PLD repo. ($2)"
719 "err_cvs_add_failed" )
720 echo >&2 "Error: failed to add package to PLD repo."
723 remove_build_requires
724 echo >&2 "Error: package build failed. (${2:-no more info})"
726 "err_no_package_data" )
727 remove_build_requires
728 echo >&2 "Error: couldn't get out package name/version/release from spec file."
731 remove_build_requires
732 echo >&2 "Tag ${2} already exists"
735 remove_build_requires
736 echo >&2 "Release ${2} not integer and not a snapshot."
738 "err_branch_exists" )
739 remove_build_requires
740 echo >&2 "Tree branch already exists (${2})."
743 remove_build_requires
744 echo >&2 "Error: conditions reject building this spec (${2})."
746 "err_remote_problem" )
747 remove_build_requires
748 echo >&2 "Error: problem with remote (${2})"
750 "err_not_implemented" )
751 remove_build_requires
752 echo >&2 "Error: functionality not yet imlemented"
755 echo >&2 "Unknown error."
760 if [ -n "$DEBUG" ]; then
765 if [ "$NOINIT" != "yes" ] ; then
766 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
768 local macros_ver=$(rpm -E %?rpm_build_macros)
769 if [ -z "$macros_ver" ]; then
770 REPO_DIR=$TOP_DIR/packages
771 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
773 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
774 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
778 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
784 export GIT_WORK_TREE=$PACKAGE_DIR
785 export GIT_DIR=$PACKAGE_DIR/.git
787 if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then
788 if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then
789 CVSTAG=${CVSTAG#refs/heads/}
790 if [ "$CVSTAG" != "master" ]; then
791 echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override"
794 echo >&2 "On detached HEAD. Use -r BRANCHNAME to override"
797 elif [ "$CVSTAG" = "HEAD" ]; then
798 # assume -r HEAD is same as -A
806 update_shell_title "add_package"
808 if [ -n "$DEBUG" ]; then
814 SPECFILE=$(basename $SPECFILE)
815 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
816 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
819 [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes
820 # ssh $GIT_SERVER create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed
822 git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git && \
823 git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} \
824 || Exit_error err_remote_problem $REMOTE_PLD
829 update_shell_title "get_spec"
831 if [ -n "$DEBUG" ]; then
837 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
839 SPECFILE=$(basename $SPECFILE)
842 if [ "$NOCVSSPEC" != "yes" ]; then
843 if [ -z "$DEPTH" ]; then
844 if [ -d "$ASSUMED_NAME/.git" ]; then
845 git fetch $REMOTE_PLD || Exit_error err_no_spec_in_repo
846 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
847 if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
848 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
851 Exit_error err_not_implemented
855 git clone -o $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git || {
856 # softfail if new package, i.e not yet added to PLD rep
857 [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
858 echo "Warning: package not in CVS - assuming new package"
861 git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME}
865 if [ ! -d "$ASSUMED_NAME/.git" ]; then
866 if [ ! -d "$ASSUMED_NAME" ]; then
870 git remote add $REMOTE_PLD ${GIT_SERVER}:${PACKAGES_DIR}/${ASSUMED_NAME}.git
871 CVSTAG=${CVSTAG:-"master"}
874 if [ -z "$ALL_BRANCHES" ]; then
875 refs="${CVSTAG}:remotes/${REMOTE_PLD}/${CVSTAG}"
877 git fetch $DEPTH $REMOTE_PLD $refs || {
878 echo >&2 "Error: branch $CVSTAG does not exist"
882 git fetch $REMOTE_PLD 'refs/notes/*:refs/notes/*'
884 cvsignore_df .gitignore
886 # add default log format to .gitignore if it is relative to package dir
887 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
888 # substitute known "macros" to glob
889 local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
890 if [ "$logfile" ]; then
891 cvsignore_df "$logfile"
895 # create symlinks for tools
896 if [ "$SYMLINK_TOOLS" != "no" ]; then
897 for a in dropin md5 adapter builder {relup,compile,repackage,pearize}.sh pldnotify.awk; do
898 # skip tools that don't exist in top dir
899 [ -f $a ] || continue
900 # skip tools that already exist
901 [ -f $ASSUMED_NAME/$a ] && continue
902 ln -s ../$a $ASSUMED_NAME
908 if [ -n "$CVSTAG" ]; then
909 git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "${REMOTE_PLD}/$CVSTAG" > /dev/null || exit
910 git symbolic-ref -q HEAD > /dev/null &&
912 if [ -n "$CVSDATE" ]; then
913 git checkout $(git rev-list -n1 --before="'$CVSDATE'" $CVSTAG) || exit 1
917 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
918 Exit_error err_no_spec_in_repo
921 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
922 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
925 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
933 if [ ! -f "mirrors" ] ; then
934 ln -s rpm-build-tools/mirrors .
938 local origin mirror name rest ol prefix
939 while read origin mirror name rest; do
940 # skip comments and empty lines
941 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
944 ol=$(echo -n "$origin" | wc -c)
945 prefix=$(echo -n "$url" | head -c $ol)
946 if [ "$prefix" = "$origin" ] ; then
947 suffix=$(echo "$url" | cut -b $((ol+1))-)
948 echo -n "$mirror$suffix"
955 # Warning: unpredictable results if same URL used twice
958 # escape some regexp characters if part of file name
959 file=$(echo "$file" | sed -e 's#\([\+\*\.\&\#\?]\)#\\\1#g')
962 grep -E "(SOURCE|PATCH)URL[0-9]*[ ]*${file}""[ ]*$" | \
963 sed -e 's/.*\(SOURCE\|PATCH\)URL\([0-9][0-9]*\).*/\1\2/' | \
964 head -n 1 | tr OURCEATH ourceath | xargs
968 [ "$NO5" = "yes" ] && return
970 [ -z "$no" ] && return
974 if [ -f additional-md5sums ]; then
975 md5=$(grep -s -v '^#' additional-md5sums | \
976 grep -E "[ ]$(basename "$1")([ ,]|\$)" | \
977 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
978 grep -E '^[0-9a-f]{32}$')
981 if [ $(echo "$md5" | wc -l) != 1 ] ; then
982 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
984 echo "$md5" | tail -n 1
989 source_md5=`grep -i "^#[ ]*$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
990 if [ -n "$source_md5" ]; then
993 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
994 if [ -n "$source_md5" ]; then
997 # we have empty SourceX-md5, but it is still possible
998 # that we have NoSourceX-md5 AND NoSource: X
999 nosource_md5=`grep -i "^#[ ]*No$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
1000 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
1008 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
1012 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
1015 distfiles_attic_url() {
1016 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
1021 [ "$md5" = "" ] || \
1022 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
1026 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
1027 [ -n "$size" -a "$size" -gt 0 ]
1031 if [ "$CVSIGNORE_DF" != "yes" ]; then
1034 cvsignore=${PACKAGE_DIR}/.gitignore
1036 # add only if not yet there
1037 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
1038 echo "$1" >> $cvsignore
1042 # returns true if "$1" is ftp, http or https protocol url
1045 ftp://*|http://*|https://*)
1053 if [ $# -eq 0 ]; then
1057 update_shell_title "update md5"
1058 if [ -n "$DEBUG" ]; then
1065 # pass 1: check files to be fetched
1069 local fp=$(nourl "$i")
1070 local srcno=$(src_no "$i")
1071 if [ -n "$ADD5" ]; then
1072 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
1073 grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
1074 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
1076 grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
1078 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1079 need_files="$need_files $i"
1083 # pass 1a: get needed files
1084 if [ "$need_files" ]; then
1085 get_files $need_files
1088 # pass 2: proceed with md5 adding or updating
1090 local fp=$(nourl "$i")
1091 local srcno=$(src_no "$i")
1092 local md5=$(grep -iE '^#[ ]*(No)?'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
1093 if [ -z "$md5" ]; then
1094 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
1096 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
1097 local tag="# $srcno-md5:\t"
1098 if [[ "$md5" == *NoSource* ]]; then
1099 tag="# No$srcno-md5:\t"
1100 elif [ -n "$USEDIGEST" ]; then
1101 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
1103 md5=$(md5sum "$fp" | cut -f1 -d' ')
1104 echo "Updating $srcno ($md5: $fp)."
1106 print unless (/^\s*#\s*(No)?'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
1107 print "'"$tag$md5"'\n" if /^'$srcno'\s*:\s+/i;
1109 $PACKAGE_DIR/$SPECFILE
1116 [ "$NO5" = "yes" ] && return
1118 update_shell_title "check md5"
1122 if ! good_md5 "$i"; then
1123 echo -n "MD5 sum mismatch."
1126 if ! good_size "$i"; then
1127 echo -n "0 sized file."
1131 if [ $bad -eq 1 ]; then
1132 echo " Use -U to refetch sources,"
1133 echo "or -5 to update md5 sums, if you're sure files are correct."
1134 Exit_error err_no_source_in_repo $i
1140 update_shell_title "get_files"
1142 if [ -n "$DEBUG" ]; then
1147 if [ $# -gt 0 ]; then
1151 local get_files_cvs=""
1155 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1156 update_shell_title "$i"
1157 local fp=`nourl "$i"`
1158 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1163 local srcmd5=$(src_md5 "$i")
1165 # we know if source/patch is present in cvs/distfiles
1166 # - has md5 (in distfiles)
1167 # - in cvs... ideas?
1169 # CHECK: local file didn't exist or always cvs up (first) requested.
1170 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1171 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1172 echo "Warning: no URL given for $i"
1176 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1177 if good_md5 "$i" && good_size "$i"; then
1178 echo "$fp having proper md5sum already exists"
1182 # optionally prefer mirror over distfiles if there's mirror
1183 # TODO: build url list and then try each url from the list
1184 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1187 url=$(distfiles_url "$i")
1190 url_attic=$(distfiles_attic_url "$i")
1192 # is $url local file?
1193 if [[ "$url" = [./]* ]]; then
1194 update_shell_title "${GETLOCAL%% *}: $url"
1195 ${GETLOCAL} $url $target
1197 if [ -z "$NOMIRRORS" ]; then
1198 url=$(find_mirror "$url")
1202 # make shorter message for distfiles urls
1203 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1204 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1205 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1208 update_shell_title "${GETURI%% *}: $uri"
1209 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1210 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1211 update_shell_title "${GETURI2%% *}: $url"
1212 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1217 if [ ! -s "$target" ]; then
1219 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1220 update_shell_title "${GETLOCAL%% *}: $url_attic"
1221 ${GETLOCAL} $url_attic $target
1223 if [ -z "$NOMIRRORS" ]; then
1224 url_attic=$(find_mirror "$url_attic")
1226 update_shell_title "${GETURI%% *}: $url_attic"
1227 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1228 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1229 update_shell_title "${GETURI2%% *}: $url_attic"
1230 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1232 test -s "$target" || rm -f "$target"
1236 if [ -s "$target" ]; then
1237 cvsignore_df $target
1244 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1245 if [ -z "$NOMIRRORS" ]; then
1246 im=$(find_mirror "$i")
1250 update_shell_title "${GETURI%% *}: $im"
1251 ${GETURI} ${OUTFILEOPT} "$target" "$im" || \
1252 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1253 update_shell_title "${GETURI2%% *}: $im"
1254 ${GETURI2} ${OUTFILEOPT} "$target" "$im"
1256 test -s "$target" || rm -f "$target"
1259 if [ "$cvsup" = 1 ]; then
1265 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1266 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1267 Exit_error err_no_source_in_repo $i
1270 # we check md5 here just only to refetch immediately
1271 if good_md5 "$i" && good_size "$i"; then
1273 elif [ "$FROM_DISTFILES" = 1 ]; then
1274 # wrong md5 from distfiles: remove the file and try again
1276 echo "MD5 sum mismatch. Trying full fetch."
1279 update_shell_title "${GETURI%% *}: $url"
1280 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1281 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1282 update_shell_title "${GETURI2%% *}: $url"
1283 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1285 if [ ! -s "$target" ]; then
1287 update_shell_title "${GETURI%% *}: $url_attic"
1288 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1289 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1290 update_shell_title "${GETURI2%% *}: $url_attic"
1291 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1294 test -s "$target" || rm -f "$target"
1297 SHELL_TITLE_PREFIX=""
1300 if [ "$CHMOD" = "yes" ]; then
1301 CHMOD_FILES=$(nourl "$@")
1302 if [ -n "$CHMOD_FILES" ]; then
1303 chmod $CHMOD_MODE $CHMOD_FILES
1310 if [ -n "$DEBUG" ]; then
1315 # Check whether first character of PACKAGE_NAME is legal for tag name
1316 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1320 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1321 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1323 # Remove #kernel.version_release from TAGVER because tagging sources
1324 # could occur with different kernel-headers than kernel-headers used at build time.
1325 # besides, %{_kernel_ver_str} is not expanded.
1327 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1328 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1337 if [ -n "$DEBUG" ]; then
1342 echo "Version: $PACKAGE_VERSION"
1343 echo "Release: $PACKAGE_RELEASE"
1346 if [ "$TAG_VERSION" = "yes" ]; then
1347 TAGVER=`make_tagver`
1350 if [ -n "$TAG" ]; then
1354 local OPTIONS="tag $CVS_FORCE"
1357 if [ "$TAG_VERSION" = "yes" ]; then
1363 if [ "$TAG_VERSION" = "yes" ]; then
1364 update_shell_title "tag sources: $TAGVER"
1365 git $OPTIONS $TAGVER || exit
1366 git push $CVS_FORCE $REMOTE_PLD tag $TAGVER || Exit_error err_remote_problem $REMOTE_PLD
1368 if [ -n "$TAG" ]; then
1369 update_shell_title "tag sources: $TAG"
1370 git $OPTIONS $TAG $chunk || exit
1371 git push $CVS_FORCE $REMOTE_PLD tag $TAG || Exit_error err_remote_problem $REMOTE_PLD
1377 echo "Git branch: $TAG"
1380 if [ -n "$DEBUG" ]; then
1385 local OPTIONS="branch $CVS_FORCE"
1388 git $OPTIONS $TAG || exit
1392 # this function should exit early if package can't be built for this arch
1393 # this avoids unneccessary BR filling.
1396 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1398 if [ $ret -ne 0 ]; then
1410 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1411 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1417 local ver="$2" subver=$ver
1418 local newver="$3" newsubver=$newver
1420 # try handling subver, everything that's not numeric-dotted in version
1421 if grep -Eq '%define\s+subver' $specfile; then
1422 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1424 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1425 newver=${newver%$newsubver}
1428 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1429 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1430 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1435 if [ -n "$TRY_UPGRADE" ]; then
1436 local TNOTIFY TNEWVER TOLDVER
1437 update_shell_title "build_package: try_upgrade"
1441 if [ "$UPGRADE_VERSION" ]; then
1442 TNEWVER=$UPGRADE_VERSION
1444 if [ -n "$FLOAT_VERSION" ]; then
1445 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1447 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1450 # pldnotify.awk does not set exit codes, but it has match for ERROR
1451 # in output which means so.
1452 if [[ "$TNOTIFY" = *ERROR* ]]; then
1457 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1460 if [ -n "$TNEWVER" ]; then
1461 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1462 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1463 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1464 cp -f $SPECFILE $SPECFILE.bak
1467 set_release $SPECFILE $PACKAGE_RELEASE 1
1468 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1470 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1471 echo >&2 "Upgrading version failed, you need to update spec yourself"
1481 update_shell_title "build_package"
1482 if [ -n "$DEBUG" ]; then
1491 BUILD_SWITCH="-ba" ;;
1493 BUILD_SWITCH="-bb" ;;
1495 BUILD_SWITCH="-bs --nodeps" ;;
1497 BUILD_SWITCH="-bp --nodeps" ;;
1499 BUILD_SWITCH="-bc" ;;
1501 BUILD_SWITCH="-bi" ;;
1503 BUILD_SWITCH="-bl" ;;
1507 update_shell_title "build_package: $COMMAND"
1508 if [ -n "$LOGFILE" ]; then
1509 LOG=`eval echo $LOGFILE`
1510 if [ -d "$LOG" ]; then
1511 echo "Log file $LOG is a directory."
1512 echo "Parse error in the spec?"
1513 Exit_error err_build_fail
1515 if [ -n "$LASTLOG_FILE" ]; then
1516 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1518 RES_FILE=$(tempfile)
1519 local specfile=$(insert_gitlog $SPECFILE)
1521 (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
1522 RETVAL=`cat $RES_FILE`
1523 rm $RES_FILE $specfile
1524 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1525 if [ "$RETVAL" -eq "0" ]; then
1532 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1535 if [ "$RETVAL" -ne "0" ]; then
1536 if [ -n "$TRY_UPGRADE" ]; then
1537 echo "\nUpgrade package to new version failed."
1538 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1539 echo "Restoring old spec file."
1540 mv -f $SPECFILE.bak $SPECFILE
1544 Exit_error err_build_fail
1550 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1553 install_required_packages() {
1558 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1561 /^%changelog/ { exit }
1563 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1564 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1565 gsub(/[ \t]+/, "_", bcond);
1567 }' $SPEC | LC_ALL=C sort -u
1571 # expand bconds from ~/.bcondrc
1572 # The file structure is like gentoo's package.use:
1575 # samba -mysql -pgsql
1576 # w32codec-installer license_agreement
1579 if [ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ]); then
1585 SN=${SPECFILE%%\.spec}
1587 local bcondrc=$HOME/.bcondrc
1588 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1590 local bcond_avail=$(find_spec_bcond $SPECFILE)
1592 while read pkg flags; do
1594 [[ "$pkg" == \#* ]] && continue
1596 # any package or current package?
1597 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1598 for flag in $flags; do
1599 local opt=${flag#[+-]}
1601 # use only flags which are in this package.
1602 if [[ $bcond_avail = *${opt}* ]]; then
1603 if [[ $flag = -* ]]; then
1604 if [[ $BCOND != *--with?${opt}* ]]; then
1605 BCOND="$BCOND --without $opt"
1608 if [[ $BCOND != *--without?${opt}* ]]; then
1609 BCOND="$BCOND --with $opt"
1616 update_shell_title "parse ~/.bcondrc: DONE!"
1619 set_bconds_values() {
1620 update_shell_title "set bcond values"
1622 AVAIL_BCONDS_WITHOUT=""
1623 AVAIL_BCONDS_WITH=""
1625 if grep -Eq '^# *_with' ${SPECFILE}; then
1626 echo >&2 "ERROR: This spec has old style bconds."
1630 if ! grep -q '^%bcond' ${SPECFILE}; then
1634 local bcond_avail=$(find_spec_bcond $SPECFILE)
1635 process_bcondrc "$SPECFILE"
1637 update_shell_title "parse bconds"
1640 for opt in $bcond_avail; do
1643 bcond=${opt#without_}
1645 *--without?${bcond}*)
1646 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1649 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1657 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1660 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1665 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1674 update_shell_title "run_sub_builder $package_name"
1676 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1677 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1678 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1679 # jakby nie bylo tego kawalka kodu.
1681 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1682 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1686 # kurwa. translate that ^^^^
1690 # Istnieje taki spec? ${package}.spec
1691 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1692 parent_spec_name=${package}.spec
1693 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1694 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1696 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1701 if [ "${parent_spec_name}" != "" ]; then
1702 spawn_sub_builder $parent_spec_name
1704 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1707 spawn_sub_builder() {
1709 update_shell_title "spawn_sub_builder $package_name"
1712 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1713 sub_builder_opts="${sub_builder_opts} -R"
1715 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1716 sub_builder_opts="${sub_builder_opts} -RB"
1717 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1718 sub_builder_opts="${sub_builder_opts} -FRB"
1720 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1721 sub_builder_opts="${sub_builder_opts} -Upi"
1725 ./builder ${sub_builder_opts} "$@"
1728 remove_build_requires() {
1729 if [ "$INSTALLED_PACKAGES" != "" ]; then
1730 case "$REMOVE_BUILD_REQUIRES" in
1732 run_poldek --noask -ve $INSTALLED_PACKAGES
1735 run_poldek --ask -ve $INSTALLED_PACKAGES
1738 echo You may want to manually remove following BuildRequires fetched:
1739 echo $INSTALLED_PACKAGES
1740 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1747 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1748 if [ "$BCOND" ]; then
1750 echo "Building $SPECFILE with the following conditional flags:"
1754 echo "No conditional flags passed"
1757 echo "from available:"
1758 echo "--with :\t$AVAIL_BCONDS_WITH"
1759 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1764 display_branches() {
1765 echo -n "Available branches: "
1766 git branch -r | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs
1769 # checks a given list of packages/files/provides agains current rpmdb.
1770 # outputs all dependencies which current rpmdb doesn't satisfy.
1771 # input can be either STDIN or parameters
1775 if [ $# -gt 0 ]; then
1781 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1784 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1786 # other deps (files)
1787 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1790 # checks if given package/files/provides exists in rpmdb.
1791 # input can be either stdin or parameters
1792 # returns packages which are present in the rpmdb
1796 if [ $# -gt 0 ]; then
1802 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1805 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1806 install_build_requires_rpmdeps() {
1807 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1808 # TODO: Conflicts list doesn't check versions
1809 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1810 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1812 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1813 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1814 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1817 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1818 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1819 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1820 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1822 if [ -n "$CNFL" ]; then
1823 update_shell_title "uninstall conflicting packages: $CNFL"
1824 echo "Trying to uninstall conflicting packages ($CNFL):"
1825 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1828 while [ "$DEPS" ]; do
1829 update_shell_title "install deps: $DEPS"
1830 echo "Trying to install dependencies ($DEPS):"
1831 local log=.${SPECFILE}_poldek.log
1832 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1833 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1836 if [ -n "$failed" ]; then
1837 for package in $failed; do
1838 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1847 fetch_build_requires()
1849 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1853 update_shell_title "fetch build requires"
1854 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1855 install_build_requires_rpmdeps
1859 # XXX is this ugliest code written in human history still needed?
1860 echo "All packages installed by fetch_build_requires() are written to:"
1861 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1863 echo "If anything fails, you may get rid of them by executing:"
1864 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1866 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1867 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)
1869 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)
1871 package=$(basename "$package_item"|sed -e "s/}$//g")
1872 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1875 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1876 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1877 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
1882 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1885 if `echo $COND_TST|grep -q 'without_'`; then
1886 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1887 if `echo $COND_TST|grep -q !`; then
1892 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1893 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1894 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1900 elif `echo $COND_TST|grep -q 'with_'`; then
1901 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1902 if `echo $COND_TST|grep -q !`; then
1907 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1908 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1909 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1915 RESULT="${COND_STATE}-${COND_ARGV}"
1917 "with-wout" | "wout-with" )
1920 "wout-wout" | "with-with" )
1924 echo "Action '$RESULT' was not defined for package '$package_item'"
1930 if [ "$GO" = "yes" ]; then
1931 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1932 echo "Testing if $package has subrequirements..."
1933 run_poldek -t -i $package --dumpn=".$package-req.txt"
1934 if [ -f ".$package-req.txt" ]; then
1935 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1937 if [ "$package_name" = "$package" ]; then
1938 echo "Installing BuildRequired package:\t$package_name"
1939 update_shell_title "Installing BuildRequired package: ${package_name}"
1940 install_required_packages $package
1942 echo "Installing (sub)Required package:\t$package_name"
1943 update_shell_title "Installing (sub)Required package: ${package_name}"
1944 install_required_packages $package_name
1948 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1949 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1952 echo "Attempting to run spawn sub - builder..."
1953 echo "Package installation failed:\t$package_name"
1954 run_sub_builder $package_name
1955 if [ $? -eq 0 ]; then
1956 install_required_packages $package_name
1959 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1960 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1963 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1970 rm -f ".$package-req.txt"
1972 echo "Attempting to run spawn sub - builder..."
1973 echo "Package installation failed:\t$package"
1974 run_sub_builder $package
1975 if [ $? -eq 0 ]; then
1976 install_required_packages $package
1979 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1980 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1983 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1989 echo "Package $package is already installed. BuildRequirement satisfied."
1993 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1994 echo >&2 "Unable to install following packages and their dependencies:"
1995 for pkg in "$NOT_INSTALLED_PACKAGES"
1999 remove_build_requires
2005 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
2006 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
2007 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
2008 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
2011 echo "Initializing rpm directories to $TOP_DIR from $GIT_SERVER"
2012 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
2015 if [ ! -e ../rpm-build-tools ]; then
2016 git clone ${GIT_SERVER}:${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools
2018 for a in dropin md5 adapter builder mirrors {relup,compile,repackage,pearize}.sh pldnotify.awk; do
2019 ln -s ../rpm-build-tools/$a .
2027 DONT_PRINT_REVISION="yes"
2029 # remove spec and sources
2030 $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" --define "_builddir $builddir" $PACKAGE_DIR/$SPECFILE
2031 rm -rf $PACKAGE_DIR/{.git,.gitignore}
2032 rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
2035 #---------------------------------------------
2043 while [ $# -gt 0 ]; do
2046 # NOTE: we should be fetcher specific, like fille WGET_OPTS, but
2047 # unfortunately $GETURI is already formed
2052 COMMAND="update_md5"
2057 COMMAND="update_md5"
2066 DEBUG="yes"; shift ;;
2068 COMMAND="version"; shift ;;
2070 COMMAND="short-version"; shift ;;
2077 -b | -ba | --build )
2078 COMMAND="build"; shift ;;
2079 -bb | --build-binary )
2080 COMMAND="build-binary"; shift ;;
2082 COMMAND="build-build"; shift ;;
2084 COMMAND="build-install"; shift ;;
2086 COMMAND="build-list"; shift ;;
2087 -bp | --build-prep )
2088 COMMAND="build-prep"; shift ;;
2089 -bs | --build-source )
2090 COMMAND="build-source"; shift ;;
2092 COMMAND="branch"; shift; TAG="${1}"; shift;;
2094 CLEAN="--clean"; shift ;;
2096 CVS_FORCE="-f"; shift;;
2102 COMMAND="get"; shift ;;
2104 COMMAND="usage"; shift ;;
2106 PROTOCOL="ftp"; shift ;;
2108 PROTOCOL="http"; shift ;;
2110 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
2114 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
2118 shift; LOGFILE="${1}"; shift ;;
2120 shift; DEF_NICE_LEVEL=${1}; shift ;;
2121 -ske | --skip-existing-files)
2122 SKIP_EXISTING_FILES="yes"; shift ;;
2124 COMMAND="mr-proper"; shift ;;
2125 -ncs | --no-cvs-specs )
2126 NOCVSSPEC="yes"; shift ;;
2127 -nd | --no-distfiles )
2128 NODIST="yes"; shift ;;
2129 -nm | --no-mirrors )
2130 NOMIRRORS="yes"; shift ;;
2132 NOURLS="yes"; shift ;;
2134 NOSRCS="yes"; shift ;;
2135 -ns0 | --no-source0 )
2136 NOSOURCE0="yes"; shift ;;
2145 -pm | --prefer-mirrors )
2152 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2154 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2155 --skip-patch | -sp )
2156 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2158 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2161 --with | --without )
2162 case $GROUP_BCONDS in
2166 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2167 while ! `echo ${1}|grep -qE '(^-|spec)'`
2169 BCOND="$BCOND $COND $1"
2173 if [[ "$2" = *,* ]]; then
2174 for a in $(echo "$2" | tr , ' '); do
2175 BCOND="$BCOND $1 $a"
2178 BCOND="$BCOND $1 $2"
2184 shift; TARGET="${1}"; shift ;;
2186 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2188 QUIET="--quiet"; shift ;;
2190 CVSDATE="${2}"; shift 2
2191 date -d "$CVSDATE" > /dev/null 2>&1 || { echo >&2 "No valid date specified"; exit 3; }
2201 -R | --fetch-build-requires)
2202 FETCH_BUILD_REQUIRES="yes"
2203 NOT_INSTALLED_PACKAGES=
2205 -RB | --remove-build-requires)
2206 REMOVE_BUILD_REQUIRES="nice"
2208 -FRB | --force-remove-build-requires)
2209 REMOVE_BUILD_REQUIRES="force"
2211 -sc | --sources-cvs)
2212 COMMAND="list-sources-cvs"
2214 -sd | --source-distfiles)
2215 COMMAND="list-sources-distfiles"
2217 -sdp | --source-distfiles-paths)
2218 COMMAND="list-sources-distfiles-paths"
2220 -sf | --source-files)
2221 COMMAND="list-sources-files"
2223 -lsp | --source-paths)
2224 COMMAND="list-sources-local-paths"
2226 -su | --source-urls)
2227 COMMAND="list-sources-urls"
2229 -Tvs | --tag-version-stable )
2234 -Ts | --tag-stable )
2239 -Tv | --tag-version )
2244 -Tp | --tag-prefix )
2256 -ir | --integer-release-only )
2257 INTEGER_RELEASE="yes"
2260 COMMAND="update_md5"
2265 -Upi | --update-poldek-indexes )
2266 UPDATE_POLDEK_INDEXES="yes"
2269 COMMAND="init_rpm_dir"
2271 -u | --try-upgrade )
2272 TRY_UPGRADE="1"; shift ;;
2274 shift; UPGRADE_VERSION="$1"; shift;;
2275 -un | --try-upgrade-with-float-version )
2276 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2278 BE_VERBOSE="1"; shift ;;
2283 if echo "${MACRO}" | grep -q '\W'; then
2284 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2288 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2293 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2297 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2300 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2301 COMMAND="show_bconds"
2305 COMMAND="show_bcond_args"
2308 --show-avail-bconds)
2309 COMMAND="show_avail_bconds"
2314 RPMOPTS="${RPMOPTS} --nodeps"
2317 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2320 Exit_error err_invalid_cmdline "$1"
2323 SPECFILE=${1%/}; shift
2324 # check if specname was passed as specname:cvstag
2325 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2326 CVSTAG="${SPECFILE##*:}"
2327 SPECFILE="${SPECFILE%%:*}"
2329 # always have SPECFILE ending with .spec extension
2330 SPECFILE=${SPECFILE%%.spec}.spec
2331 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2335 if [ "$CVSTAG" ]; then
2336 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2337 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2340 if [ -n "$ALL_BRANCHES" -a -z "$DEPTH" ]; then
2341 echo >&2 "--all branches requires --depth <number>"
2342 Exit_error err_invalid_cmdline
2345 if [ -n "$DEBUG" ]; then
2350 if [ -n "$TARGET" ]; then
2353 TARGET_SWITCH="--target $TARGET" ;;
2355 TARGET_SWITCH="--target=$TARGET" ;;
2359 if [ "$SCHEDTOOL" != "no" ]; then
2360 NICE_COMMAND="$SCHEDTOOL"
2362 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2365 update_shell_title "$COMMAND"
2369 if [ -z "$SPECFILE" ]; then
2370 Exit_error err_no_spec_in_cmdl
2372 get_spec > /dev/null
2379 if [ -z "$SPECFILE" ]; then
2380 Exit_error err_no_spec_in_cmdl
2382 get_spec > /dev/null
2387 "show_avail_bconds")
2389 if [ -z "$SPECFILE" ]; then
2390 Exit_error err_no_spec_in_cmdl
2393 get_spec > /dev/null
2395 local bcond_avail=$(find_spec_bcond $SPECFILE)
2396 local opt bcond bconds
2397 for opt in $bcond_avail; do
2400 bcond=${opt#without_}
2401 bconds="$bconds $bcond"
2405 bconds="$bconds $bcond"
2408 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2416 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2418 if [ -z "$SPECFILE" ]; then
2419 Exit_error err_no_spec_in_cmdl
2422 # display SMP make flags if set
2423 smp_mflags=$(rpm -E %{?_smp_mflags})
2424 if [ "$smp_mflags" ]; then
2425 echo "builder: SMP make flags are set to $smp_mflags"
2433 if [ "$COMMAND" != "build-source" ]; then
2436 fetch_build_requires
2437 if [ "$INTEGER_RELEASE" = "yes" ]; then
2438 echo "Checking release $PACKAGE_RELEASE..."
2439 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2440 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2444 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2445 if [ -n "$TEST_TAG" ]; then
2446 local TAGVER=`make_tagver`
2447 # escape some regexp characters if part of TAGVER
2448 TAGVER=$(echo "$TAGVER" | sed -e 's#\([\+\*\.]\)#\\\1#g')
2449 echo "Searching for tag $TAGVER..."
2450 if [ -n "$DEPTH" ]; then
2451 local ref=`git ls-remote $REMOTE_PLD "refs/tags/$TAGVER"`
2452 [ -n "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$TAGVER"
2454 git show-ref "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER"
2456 # - do not allow to build from HEAD when XX-branch exists
2457 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2458 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2459 TAG_BRANCH="${TREE_PREFIX}-branch"
2460 if [ -n "$DEPTH" ]; then
2461 cmd_branches="git ls-remote --heads"
2462 ref_prefix=refs/heads
2464 cmd_branches="git show-ref"
2465 ref_prefix=refs/remotes/${REMOTE_PLD}
2467 TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$")
2468 if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != "$CVSTAG" ]; then
2469 Exit_error err_branch_exists "$TAG_STATUS"
2475 if [ -n "$NOSOURCE0" ] ; then
2476 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2481 get_files $SOURCES $PATCHES
2485 NODIST="yes" get_files $SOURCES $PATCHES
2486 update_md5 $SOURCES $PATCHES
2490 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2491 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2493 remove_build_requires
2497 if [ -z "$SPECFILE" ]; then
2498 Exit_error err_no_spec_in_cmdl
2507 if [ -z "$SPECFILE" ]; then
2508 Exit_error err_no_spec_in_cmdl
2512 if [ -n "$NEW_REPO" ]; then
2515 for file in $SOURCES $PATCHES; do
2516 if [ -z $(src_md5 "$file") ]; then
2517 git add $file || Exit_error err_no_source_in_repo $file
2519 cvsignore_df `nourl $file`
2523 git commit -m 'Initial commit'
2524 git push --dry-run $REMOTE_PLD master || Exit_error err_cvs_add_failed
2526 echo "You had already git repository. Push chosen branches to remote: ${REMOTE_PLD}"
2531 if [ -z "$SPECFILE" ]; then
2532 Exit_error err_no_spec_in_cmdl
2538 if [ -n "$NOSOURCE0" ] ; then
2539 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2541 get_files $SOURCES $PATCHES
2546 if [ -z "$SPECFILE" ]; then
2547 Exit_error err_no_spec_in_cmdl
2553 if [ -n "$NOSOURCE0" ] ; then
2554 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2556 update_md5 $SOURCES $PATCHES
2562 if [ -z "$SPECFILE" ]; then
2563 Exit_error err_no_spec_in_cmdl
2567 if [ ! -d .git ]; then
2568 echo "No git reposiotory" >&2
2576 "list-sources-files" )
2579 DONT_PRINT_REVISION="yes"
2582 for SAP in $SOURCES $PATCHES; do
2583 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2586 "list-sources-urls" )
2589 DONT_PRINT_REVISION="yes"
2592 SAPS="$SOURCES $PATCHES"
2593 for SAP in $SAPS ; do
2597 "list-sources-local-paths" )
2600 DONT_PRINT_REVISION="yes"
2603 for SAP in $SOURCES $PATCHES; do
2604 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2607 "list-sources-distfiles-paths" )
2610 DONT_PRINT_REVISION="yes"
2613 for SAP in $SOURCES $PATCHES; do
2614 if [ -n "$(src_md5 "$SAP")" ]; then
2615 distfiles_path "$SAP"
2619 "list-sources-distfiles" )
2622 DONT_PRINT_REVISION="yes"
2625 for SAP in $SOURCES $PATCHES; do
2626 if [ -n "$(src_md5 "$SAP")" ]; then
2627 distfiles_url "$SAP"
2631 "list-sources-cvs" )
2634 DONT_PRINT_REVISION="yes"
2637 for SAP in $SOURCES $PATCHES; do
2638 if [ -z "$(src_md5 "$SAP")" ]; then
2639 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2653 echo "$VERSIONSTRING"
2656 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2657 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2661 # vi:syntax=sh:ts=4:sw=4:noet