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")
40 Build package utility from PLD Linux Packages repository
41 $VERSION (C) 1999-2016 Free Penguins".
43 CLEAN_PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
45 # required rpm-build-macros
64 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
66 # use rpm 4.4.6+ digest format instead of comments if non-zero
69 # user agent when fetching files
70 USER_AGENT="PLD/Builder($VERSION)"
72 # It can be used i.e. in log file naming.
73 # See LOGFILE example.
74 DATE=`date +%Y-%m-%d_%H-%M-%S`
76 # target arch, can also be used for log file naming
77 TARGET=$(rpm -E %{_target})
79 # Note the *single* quotes, this allows using shell variables expanded at build time
80 # Example: LOGFILE='../log.$PACKAGE_NAME'
81 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
82 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
83 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
84 # Example: LOGFILE='.log.$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE.$TARGET.$DATE'
87 # use teeboth Perl wrapper
88 # temporary option to disable if broken
103 # create symlinks for tools in PACKAGE_DIR, see get_spec()
116 # use lftp by default when available
118 lftp --version > /dev/null 2>&1 && USE_LFTP=yes
119 PARALLEL_DOWNLOADS=10
121 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
126 GIT_SERVER="git://git.pld-linux.org"
127 GIT_PUSH="git@git.pld-linux.org"
128 PACKAGES_DIR="packages"
137 DISTFILES_SERVER="://distfiles.pld-linux.org"
138 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
143 FAIL_IF_NO_SOURCES="yes"
145 # let get_files skip over files which are present to get those damn files fetched
146 SKIP_EXISTING_FILES="no"
149 # should the specfile be restored if upgrade failed?
150 REVERT_BROKEN_UPGRADE="yes"
152 if rpm --specsrpm 2>/dev/null; then
153 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
154 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
156 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
157 if [ -x /usr/bin/rpm-getdeps ]; then
158 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
160 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
164 UPDATE_POLDEK_INDEXES_OPTS=""
166 # Here we load saved user environment used to
167 # predefine options set above, or passed to builder
169 # This one reads global system environment settings:
170 if [ -f ~/etc/builderrc ]; then
173 # And this one cascades settings using user personal
175 # Example of ~/.builderrc:
177 #UPDATE_POLDEK_INDEXES="yes"
178 #UPDATE_POLDEK_INDEXES_OPTS="--mo=nodiff"
179 #FETCH_BUILD_REQUIRES="yes"
180 #REMOVE_BUILD_REQUIRES="force"
182 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
187 if [ -n "$HOME_ETC" ]; then
188 USER_CFG="$HOME_ETC/.builderrc"
189 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
191 USER_CFG=~/.builderrc
192 BUILDER_MACROS=~/.builder-rpmmacros
195 [ -f "$USER_CFG" ] && . "$USER_CFG"
197 if [ "$SCHEDTOOL" = "auto" ]; then
198 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
199 SCHEDTOOL="schedtool -B -e"
205 if [ -n "$USE_PROZILLA" ]; then
207 elif [ -n "$USE_AXEL" ]; then
209 elif [ -n "$USE_LFTP" ]; then
215 GETLOCAL=${GETLOCAL:-cp -a}
217 if rpm --version 2>&1 | grep -q '4.0.[0-2]'; then
228 if [ -d $HOME/rpm/SOURCES ]; then
229 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
230 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
234 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
235 POLDEK_CMD="$SU_SUDO /usr/bin/poldek"
238 # TODO: what this function does?
241 if [ -n "$LOGFILE" ]; then
242 LOG=`eval echo $LOGFILE`
243 if [ -n "$LASTLOG_FILE" ]; then
244 echo "LASTLOG=$LOG" > $LASTLOG_FILE
246 (${NICE_COMMAND} ${POLDEK_CMD} --noask `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
247 # FIXME $exit_pldk undefined
250 (${NICE_COMMAND} ${POLDEK_CMD} --noask `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
251 return `cat ${RES_FILE}`
256 #---------------------------------------------
259 download_prozilla() {
260 local outfile=$1 url=$2 retval
262 proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS -O "$outfile" "$url"
269 local outfile=$1 url=$2 retval
271 axel -a $AXEL_OPTS -o "$outfile" "$url"
278 local outfile=$1 url=$2 retval
279 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
280 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
281 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
282 wget --help 2>&1 | grep -q -- ' --no-iri ' && WGET_OPTS="$WGET_OPTS --no-iri"
283 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
285 GETURI="wget -c -nd -t$WGET_RETRIES $WGET_OPTS $IPOPT"
287 ${GETURI} --passive-ftp -O "$outfile" "$url"
289 if [ $retval -ne 0 ]; then
290 if [ "`echo $url | grep -E 'ftp://'`" ]; then
291 ${GETURI} -O "$outfile" "$url"
299 local outfile=$1 url=$2 retval tmpfile
300 tmpfile=$(tempfile) || exit 1
302 $([ "$DEBUG" = "yes" ] && echo "debug 5;")
303 $([ "$IPOPT" = "-4" ] && echo "set dns:order \"inet\";")
304 $([ "$IPOPT" = "-6" ] && echo "set dns:order \"inet6\";")
305 set ssl:verify-certificate no;
306 set net:max-retries $WGET_RETRIES;
307 set http:user-agent \"$USER_AGENT\";
308 pget -n $PARALLEL_DOWNLOADS -c \"$url\" -o \"$tmpfile\"
312 if [ $retval -eq 0 ]; then
313 mv -f "$tmpfile" "$outfile"
321 if [ -n "$DEBUG" ]; then set -xv; fi
323 # to make this output parseable by bash-completion _parse_help()
324 # if the line contains short and long option, it will take only the long option
325 # but if you want both being completed, put the short option to separate line
327 Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [-a|--add_cvs] [-b|-ba|--build]
328 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
329 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [--depth <number>]
330 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
331 [-q|--quiet] [--date <yyyy-mm-dd> [-r <tag>] [{-T|--tag <tag>]
332 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
333 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
334 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
335 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
336 <package>[.spec][:tag]
338 -4 - force IPv4 when transferring files
339 -6 - force IPv6 when transferring files
341 --update-md5 - update md5 comments in spec, implies -nd -ncs
343 --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
344 --all-branches - make shallow fetch of all branches; --depth required
345 -n5, --no-md5 - ignore md5 comments in spec
346 -D, --debug - enable builder script debugging mode,
347 -debug - produce rpm debug package (same as --opts -debug)
348 -V, --version - output builder version string
349 --short-version - output builder short version
350 -a - try add new package to PLD repo.
353 - get all files from PLD repo or HTTP/FTP and build package
355 -bb - get all files from PLD repo or HTTP/FTP and build binary
356 only package from <package>.spec,
357 -bp - execute the %prep phase of <package>.spec,
358 -bc - execute the %build phase of <package>.spec,
359 -bi - execute the %install phase of <package>.spec
360 -bl - execute the %files phase of <package>.spec
361 -bs - get all files from PLD repo or HTTP/FTP and only pack
363 --short-circuit - short-circuit build
364 -B, --branch - add branch
366 --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
367 may be used with building process.
368 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
369 SPECS and \$RPM_BUILD_ROOT). Doesn't run any rpm building.
370 -cf, --cvs-force - use -f when tagging
371 --define '<macro> <value>'
372 - define a macro <macro> with value <value>,
373 --depth <number> - make shallow fetch
374 --alt_kernel <kernel>
375 - same as --define 'alt_kernel <kernel>'
376 --nodeps - rpm won't check any dependences
378 --get - get <package>.spec and all related files from PLD repo
379 -h, --help - this message,
380 -j N - set %_smp_mflags to propagate concurrent jobs
381 --ftp - use FTP protocol to access distfiles server
382 --http - use HTTP protocol to access distfiles server
383 -l <logfile>, --logtofile=<logfile>
386 - don't pull from PLD repo
387 -nd, --no-distfiles - don't download from distfiles
388 -nm, --no-mirrors - don't download from mirror, if source URL is given,
389 -nu, --no-urls - don't try to download from FTP/HTTP location,
390 -ns, --no-srcs - don't download Sources/Patches
391 -ns0, --no-source0 - don't download Source0
392 -nn, --no-net - don't download anything from the net
393 -p N - set PARALLEL_DOWNLOADS to N (default $PARALLEL_DOWNLOADS)
394 -pm, --prefer-mirrors
395 - prefer mirrors (if any) over distfiles for SOURCES
396 --no-init - don't initialize builder paths (SPECS and SOURCES)
398 --skip-existing-files
399 - skip existing files in get_files
400 --opts <rpm opts> - additional options for rpm
401 -q, --quiet - be quiet,
402 --date yyyy-mm-dd - build package using resources from specified date,
403 -r <tag>, --cvstag <ref>
404 - build package using resources from specified branch/tag,
405 -A - build package using master branch as any sticky tags/branch/date being reset.
406 -R, --fetch-build-requires
407 - fetch what is BuildRequired,
408 -RB, --remove-build-requires
409 - remove all you fetched with -R or --fetch-build-requires
410 remember, this option requires confirmation,
411 -FRB, --force-remove-build-requires
412 - remove all you fetched with -R or --fetch-build-requires
413 remember, this option works without confirmation,
414 -sd, --source-distfiles
415 - list sources available from distfiles (intended for offline
416 operations; does not work when Icon field is present
417 but icon file is absent),
418 -sc, --source-cvs - list sources available from PLD repo
419 -sdp, --source-distfiles-paths
420 - list sources available from distfiles -
421 paths relative to distfiles directory (intended for offline
422 operations; does not work when Icon field is present
423 but icon file is absent),
424 -sf, --source-files - list sources - bare filenames (intended for offline
425 operations; does not work when Icon field is present
426 but icon file is absent),
428 - list sources - filenames with full local paths (intended for
429 offline operations; does not work when Icon field is present
430 but icon file is absent),
431 -su, --source-urls - list urls - urls to sources and patches
432 intended for copying urls with spec with lots of macros in urls
433 -T <tag> , --tag <tag>
434 - add git tag <tag> for files,
435 -Tvs, --tag-version-stable
436 - add git tags STABLE and NAME-VERSION-RELEASE for files,
438 - add git tag STABLE for files,
440 --tag-version - add git tag NAME-VERSION-RELEASE for files,
441 -Tp, --tag-prefix <prefix>
442 - add <prefix> to NAME-VERSION-RELEASE tags,
443 -tt, --test-tag <prefix>
444 - fail if tag is already present,
445 -ir, --integer-release-only
446 - allow only integer and snapshot releases
447 -v, --verbose - be verbose,
448 -u, --try-upgrade - check version, and try to upgrade package
449 -un, --try-upgrade-with-float-version
450 - as above, but allow float version
451 php-pear-Services_Digg/
452 --upgrade-version - upgrade to specified version in try-upgrade
453 -U, --update - refetch sources, don't use distfiles, and update md5 comments
454 -Upi, --update-poldek-indexes
455 - refresh or make poldek package index files.
457 --skip-patch <patchnumber>
458 - don't apply <patchnumber>. may be repeated.
460 --nopatch <patchnumber>
461 - abort instead of applying patch <patchnumber>
463 - do not initialize SPECS_DIR and SOURCES_DIR (set them to .)
464 --show-bconds - show available conditional builds, which can be used
465 - with --with and/or --without switches.
466 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by ./repackage.sh script.
467 In other words, the output is parseable by scripts.
468 --show-avail-bconds - show available bconds
471 - conditional build package depending on %_with_<feature>/
472 %_without_<feature> macro switch. You may now use
473 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
474 constructions. Set GROUP_BCONDS to yes to make use of it.
475 --target <platform>, --target=<platform>
476 - build for platform <platform>.
477 --init-rpm-dir, --init
478 - initialize ~/rpm directory structure
482 # create tempfile. as secure as possible
484 local prefix=builder.$PACKAGE_NAME${1:+.$1}
485 mktemp --tmpdir -t $prefix.XXXXXX || echo ${TMPDIR:-/tmp}/$prefix.$RANDOM.$$
489 local prefix=builder.$PACKAGE_NAME${1:+.$1}
490 mktemp --tmpdir -d $prefix.XXXXXX
493 # inserts git log instead of %changelog
494 # @output directory containing modified specfile
496 local SPECFILE=$1 specdir=$(tempdir) gitlog=$(tempfile) speclog=$(tempfile)
498 # allow this being customized
499 local log_entries=$(rpm -E '%{?_buildchangelogtruncate}')
501 # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997'
502 # otherwise i'd use --date=iso here
503 # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1
504 # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c;h=56ba69daa41d65ec9fd18c9f371b8ff14118cdca;hb=a113baa510a004476edc44b5ebaaf559238a18b6#l33
505 # NOTE: changelog date is always in UTC for rpmbuild
506 # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
507 git rev-list --date-order -${log_entries:-20} HEAD 2>/dev/null | while read sha1; do
509 git notes list $sha1 > /dev/null 2>&1 && logfmt='%N'
510 git log -n 1 $sha1 --format=format:"* %ad %an <%ae> %h%n- ${logfmt}%n" --date=raw | sed -re 's/^- +- */- /'| sed '/^$/q'
513 # add link to full git logs
514 local giturl="http://git.pld-linux.org/?p=packages/${SPECFILE%.spec}.git;a=log"
515 if [ -n "$CVSTAG" ]; then
516 giturl="$giturl;h=$CVSTAG"
518 local gitauthor="PLD Linux Team <feedback@pld-linux.org>"
519 LC_ALL=C gawk -vgiturl="$giturl" -vgitauthor="$gitauthor" -vpackage=$PACKAGE_NAME 'BEGIN{
520 printf("* %s %s\n- For complete changelog see: %s\n", strftime("%a %b %d %Y"), gitauthor, giturl);
525 LC_ALL=C gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog >> $speclog
526 sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
530 " > $specdir/$SPECFILE
531 rm -f $gitlog $speclog
535 # @param string logfile
536 # @param varargs... commands to execute
539 # use teeboth from toys/cleanbuild, if available and enabled
540 if [ "$USE_TEEBOTH" = "yes" ] && [ -x $APPDIR/teeboth ]; then
544 local efile rc logfile=$1; shift
545 if [ "$logfile" ]; then
547 { "$@" 2>&1; echo $? > $efile; } | tee -a $logfile
558 # change dependency to specname
560 # - perl(Package::Name) -> perl-Package-Name
564 if [ $# -gt 0 ]; then
570 echo "$DEPS" | tr ' ' '\n' | sed -re '
573 s/perl\((.*)\)/perl-\1/
577 s/apache\(EAPI\)-devel/apache-devel/
579 s/db-devel/db5.3-devel/
580 s/libjpeg-devel/libjpeg-turbo-devel/
584 update_shell_title() {
586 local len=${COLUMNS:-80}
587 local msg="$(echo "$*" | cut -c-$len)"
589 if [ -n "$BE_VERBOSE" ]; then
590 echo >&2 "$(date +%s.%N) $*"
593 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
595 if [ -n "$PACKAGE_NAME" ]; then
596 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
601 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
602 msg=$(echo $msg | tr -d '\n\r')
605 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
608 echo >&2 -ne "\033]0;$msg\007"
614 # set TARGET from BuildArch: from SPECFILE
616 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
617 local tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
619 local target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
623 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
625 TARGET_SWITCH="--target=$TARGET" ;;
631 # runs rpm with minimal macroset
633 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); print $0 } ')
635 # TODO: move these to /usr/lib/rpm/macros
636 cat > $BUILDER_MACROS <<'EOF'
637 %x8664 x86_64 amd64 ia32e
640 %bootstrap_release() %{1}
641 %requires_releq_kernel_up(s:n:) %{nil}
642 %requires_releq_kernel_smp(s:n:) %{nil}
643 %requires_releq_kernel(s:n:) %{nil}
644 %requires_releq() %{nil}
645 %pyrequires_eq() %{nil}
646 %requires_eq() %{nil}
647 %requires_eq_to() %{nil}
648 %requires_ge() %{nil}
649 %requires_ge_to() %{nil}
650 %requires_ge() %{nil}
651 %releq_kernel_up(n:) ERROR
652 %releq_kernel_smp(n:) ERROR
653 %releq_kernel(n:) ERROR
654 %py_postclean(x:) ERROR
658 %ruby_ver_requires_eq() %{nil}
659 %ruby_mod_ver_requires_eq() %{nil}
660 %__php_api_requires() %{nil}
661 %php_major_version ERROR
662 %php_api_version ERROR
663 %requires_xorg_xserver_extension %{nil}
664 %requires_xorg_xserver_xinput %{nil}
665 %requires_xorg_xserver_font %{nil}
666 %requires_xorg_xserver_videodrv %{nil}
668 %perl_vendorarch ERROR
669 %perl_vendorlib ERROR
670 # damn. need it here! - copied from /usr/lib/rpm/macros.build
671 %tmpdir %(echo "${TMPDIR:-/tmp}")
672 %patchset_source(f:b:) %(
673 base=%{-b*}%{!-b*:10000};
674 start=$(expr $base + %1);
675 end=$(expr $base + %{?2}%{!?2:%{1}});
676 # we need to call seq twice as it doesn't allow two formats
677 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
678 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
679 paste %{tmpdir}/__ps{1,2};
680 rm -f %{tmpdir}/__ps{1,2};
683 %add_etc_shells(p) %{p:<lua>}
684 %remove_etc_shells(p) %{p:<lua>}
685 %lua_add_etc_shells() %{nil}
686 %lua_remove_etc_shells() %{nil}
688 %buildrequires_jdk %{nil}
689 %pear_package_print_optionalpackages %{nil}
691 if [ "$NOINIT" = "yes" ] ; then
692 cat >> $BUILDER_MACROS <<'EOF'
697 eval PATH=$CLEAN_PATH $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
701 if [ -n "$DEBUG" ]; then
706 if [ -x /usr/bin/rpm-specdump ]; then
707 update_shell_title "cache_rpm_dump using rpm-specdump command"
708 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $PACKAGE_DIR/$SPECFILE)
710 update_shell_title "cache_rpm_dump using rpmbuild command"
713 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
714 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
720 ARGS='--nodigest --nosignature --nobuild'
723 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
725 if [ $? -gt 0 ]; then
726 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
728 Exit_error err_build_fail
731 # make small dump cache
732 rpm_dump_cache=`echo "$rpm_dump" | awk '
733 $2 ~ /^SOURCEURL/ {print}
734 $2 ~ /^PATCHURL/ {print}
735 $2 ~ /^nosource/ {print}
736 $2 ~ /^PACKAGE_/ {print}
740 update_shell_title "cache_rpm_dump: OK!"
744 if [ -z "$rpm_dump_cache" ] ; then
745 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
747 echo "$rpm_dump_cache"
751 update_shell_title "get icons"
752 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
753 if [ -z "$ICONS" ]; then
757 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
761 update_shell_title "parsing specfile"
762 if [ -n "$DEBUG" ]; then
767 # icons are needed for successful spec parse
773 if rpm_dump | grep -qEi ":.*nosource.*1"; then
774 FAIL_IF_NO_SOURCES="no"
777 if [ "$NOSRCS" != "yes" ]; then
778 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
779 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
780 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
783 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
784 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
785 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
787 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
788 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
791 if [ -n "$BE_VERBOSE" ]; then
792 echo "- Sources : `nourl $SOURCES`"
793 if [ -n "$PATCHES" ]; then
794 echo "- Patches : `nourl $PATCHES`"
796 echo "- Patches : *no patches needed*"
798 if [ -n "$ICONS" ]; then
799 echo "- Icon : `nourl $ICONS`"
801 echo "- Icon : *no package icon*"
803 echo "- Name : $PACKAGE_NAME"
804 echo "- Version : $PACKAGE_VERSION"
805 echo "- Release : $PACKAGE_RELEASE"
808 update_shell_title "parse_spec: OK!"
811 # aborts program abnormally
814 echo >&2 "$PROGRAM: ERROR: $*"
819 if [ -n "$DEBUG" ]; then
827 "err_no_spec_in_cmdl" )
828 remove_build_requires
829 echo >&2 "ERROR: spec file name not specified."
831 "err_invalid_cmdline" )
832 echo >&2 "ERROR: invalid command line arg ($2)."
834 "err_no_spec_in_repo" )
835 remove_build_requires
836 echo >&2 "Error: spec file not stored in repository."
842 "err_no_source_in_repo" )
843 remove_build_requires
844 echo >&2 "Error: some source, patch or icon files not stored in PLD repo. ($2)"
846 "err_cvs_add_failed" )
847 echo >&2 "Error: failed to add package to PLD repo."
850 remove_build_requires
851 echo >&2 "Error: package build failed. (${2:-no more info})"
853 "err_no_package_data" )
854 remove_build_requires
855 echo >&2 "Error: couldn't get out package name/version/release from spec file."
858 remove_build_requires
859 echo >&2 "Tag ${2} already exists"
862 remove_build_requires
863 echo >&2 "Release ${2} not integer and not a snapshot."
865 "err_branch_exists" )
866 remove_build_requires
867 echo >&2 "Tree branch already exists (${2})."
870 remove_build_requires
871 echo >&2 "Error: conditions reject building this spec (${2})."
873 "err_remote_problem" )
874 remove_build_requires
875 echo >&2 "Error: problem with remote (${2})"
878 echo >&2 "Error: cannot checkout $2"
880 "err_not_implemented" )
881 remove_build_requires
882 echo >&2 "Error: functionality not yet imlemented"
885 echo >&2 "Unknown error."
890 if [ -n "$DEBUG" ]; then
895 if [ "$NOINIT" != "yes" ] ; then
896 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
898 local macros_ver=$(rpm -E %?rpm_build_macros)
899 if [ -z "$macros_ver" ]; then
900 REPO_DIR=$TOP_DIR/packages
901 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
903 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
904 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
908 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
913 REPO_DIR=$PACKAGE_DIR
914 RPMBUILDOPTS="$RPMBUILDOPTS --define '_topdir $TOP_DIR' --define '_builddir %_topdir' --define '_rpmdir %_topdir' --define '_srcrpmdir %_topdir'"
916 export GIT_WORK_TREE=$PACKAGE_DIR
917 export GIT_DIR=$PACKAGE_DIR/.git
919 if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ] && git rev-parse --verify -q HEAD > /dev/null; then
920 if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then
921 CVSTAG=${CVSTAG#refs/heads/}
922 if [ "$CVSTAG" != "master" ]; then
923 echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override"
926 echo >&2 "On detached HEAD. Use -r BRANCHNAME to override"
929 elif [ "$CVSTAG" = "HEAD" ]; then
930 # assume -r HEAD is same as -A
938 update_shell_title "add_package"
940 if [ -n "$DEBUG" ]; then
946 SPECFILE=$(basename $SPECFILE)
947 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
948 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
951 [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes
952 ssh $GIT_PUSH create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed
956 git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git
957 git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME}
959 git config --local push.default current
960 git config --local branch.master.remote $REMOTE_PLD
961 git config --local branch.master.merge refs/heads/master
963 test $? = 0 || Exit_error err_remote_problem $REMOTE_PLD
968 update_shell_title "get_spec"
970 if [ -n "$DEBUG" ]; then
976 SPECFILE=$(basename $SPECFILE)
977 if [ "$NOCVSSPEC" != "yes" ]; then
978 if [ -z "$DEPTH" ]; then
979 if [ -d "$PACKAGE_DIR/.git" ]; then
980 git fetch $IPOPT $REMOTE_PLD || Exit_error err_no_spec_in_repo
981 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
982 if [ ! -r "$PACKAGE_DIR/$SPECFILE" ]; then
983 echo "ERROR: No package to add ($PACKAGE_DIR/$SPECFILE)" >&2
986 Exit_error err_not_implemented
990 git clone $IPOPT -o $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git || {
991 # softfail if new package, i.e not yet added to PLD rep
992 [ ! -f "$PACKAGE_DIR/$SPECFILE" ] && Exit_error err_no_spec_in_repo
993 echo "Warning: package not in Git - assuming new package"
996 git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*'
997 git config --local --add "remote.$REMOTE_PLD.push" 'refs/notes/*:refs/notes/*'
998 git config --local --add "remote.$REMOTE_PLD.push" HEAD
999 git config --local push.default current
1000 git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME}
1004 if [ ! -d "$PACKAGE_DIR/.git" ]; then
1005 if [ ! -d "$PACKAGE_DIR" ]; then
1006 install -d $PACKAGE_DIR
1009 git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git
1010 git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*'
1011 git config --local --add "remote.$REMOTE_PLD.push" 'refs/heads/*:refs/remotes/origin/*'
1012 git config --local --add "remote.$REMOTE_PLD.push" HEAD
1013 git config --local push.default current
1014 git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME}
1015 CVSTAG=${CVSTAG:-"master"}
1018 if [ -z "$ALL_BRANCHES" ]; then
1019 refs="${CVSTAG}:remotes/${REMOTE_PLD}/${CVSTAG}"
1021 git fetch $IPOPT $DEPTH $REMOTE_PLD $refs || {
1022 echo >&2 "Error: branch $CVSTAG does not exist"
1026 git fetch $IPOPT $REMOTE_PLD 'refs/notes/*:refs/notes/*'
1028 cvsignore_df .gitignore
1030 # add default log format to .gitignore if it is relative to package dir
1031 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
1032 # substitute known "macros" to glob
1033 local logfile=$(echo "$LOGFILE" | sed -r -e 's,\$(PACKAGE_(NAME|VERSION|RELEASE)|DATE|TARGET),*,g')
1034 if [ "$logfile" ]; then
1035 cvsignore_df "$logfile"
1039 # create symlinks for tools
1040 if [ "$SYMLINK_TOOLS" != "no" -a -d "$PACKAGE_DIR" ]; then
1041 for a in dropin md5 builder {relup,compile,repackage,rsync,pearize}.sh; do
1042 # skip tools that don't exist in top dir
1043 [ -f $a ] || continue
1044 # skip tools that already exist
1045 [ -f $PACKAGE_DIR/$a ] && continue
1046 ln -s ../$a $PACKAGE_DIR
1052 if [ -n "$CVSTAG" ]; then
1053 if git rev-parse --verify -q "$CVSTAG" >/dev/null; then
1054 git checkout "$CVSTAG" --
1055 elif git rev-parse --verify -q "refs/remotes/${REMOTE_PLD}/$CVSTAG"; then
1056 git checkout -t "refs/remotes/${REMOTE_PLD}/$CVSTAG" > /dev/null
1058 if [ $(git rev-parse "$CVSTAG") != $(git rev-parse HEAD) ]; then
1059 Exit_error "err_no_checkut" "$CVSTAG"
1062 git merge --ff-only '@{u}'
1063 git symbolic-ref -q HEAD > /dev/null && [ "$NOCVSSPEC" != "yes" ] &&
1064 if [ -n "$CVSDATE" ]; then
1065 git checkout $(git rev-list -n1 --before="'$CVSDATE'" $CVSTAG) || exit 1
1069 if [ ! -f "$PACKAGE_DIR/$SPECFILE" ]; then
1070 Exit_error err_no_spec_in_repo "$PACKAGE_DIR/$SPECFILE"
1073 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
1074 chmod $CHMOD_MODE $PACKAGE_DIR/$SPECFILE
1077 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $PACKAGE_DIR/$SPECFILE
1082 # find mirrors in this order. first match wins:
1083 # - package dir (~/rpm/packages/foo)
1084 # - repository dir (~/rpm/packages)
1085 # - tools dir dir (~/rpm/packages/rpm-build-tools)
1089 update_shell_title "find_mirror[$url][$REPO_DIR]"
1091 # NOTE: as while loop runs in subshell,
1092 # we use exit 2 to indicate that the match was found
1093 # otherwise we end up outputing mirror url and origin url.
1095 local origin mirror name rest ol prefix
1097 cat "$PACKAGE_DIR/mirrors" "$REPO_DIR/mirrors" "$REPO_DIR/../rpm-build-tools/mirrors" /dev/null 2>/dev/null | \
1098 while read origin mirror name rest; do
1099 # skip comments and empty lines
1100 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
1103 ol=$(echo -n "$origin" | wc -c)
1104 prefix=$(echo -n "$url" | head -c $ol)
1105 if [ "$prefix" = "$origin" ] ; then
1106 suffix=$(echo "$url" | cut -b $((ol+1))-)
1107 echo -n "$mirror$suffix"
1113 # Warning: unpredictable results if same URL used twice
1116 # escape some regexp characters if part of file name
1117 file=$(echo "$file" | sed -e 's#\([\+\*\.\&\#\?]\)#\\\1#g')
1120 grep -E "(SOURCE|PATCH)URL[0-9]*[ ]*${file}""[ ]*$" | \
1121 sed -e 's/.*\(SOURCE\|PATCH\)URL\([0-9][0-9]*\).*/\1\2/' | \
1122 head -n 1 | tr OURCEATH ourceath | xargs
1126 [ "$NO5" = "yes" ] && return
1128 [ -z "$no" ] && return
1132 # use "sources" file from package dir, like vim
1133 if [ -f sources ]; then
1134 md5=$(grep -s -v '^#' sources | \
1135 grep -E "[ *]$(basename "$1")([ ,]|\$)" | \
1136 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
1137 grep -E '^[0-9a-f]{32}$')
1140 if [ $(echo "$md5" | wc -l) != 1 ] ; then
1141 echo "$SPECFILE: more then one entry in sources for $1" 1>&2
1143 echo "$md5" | tail -n 1
1148 source_md5=$(grep -iE "^#[ ]*(No)?$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://')
1149 if [ -n "$source_md5" ]; then
1152 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
1153 if [ -n "$source_md5" ]; then
1156 # we have empty SourceX-md5, but it is still possible
1157 # that we have NoSourceX-md5 AND NoSource: X
1158 nosource_md5=`grep -i "^#[ ]*No$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
1159 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
1167 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
1171 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
1174 distfiles_attic_url() {
1175 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
1180 [ "$md5" = "" ] || \
1181 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
1185 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
1186 [ -n "$size" -a "$size" -gt 0 ]
1190 if [ "$CVSIGNORE_DF" != "yes" ]; then
1193 local cvsignore=${PACKAGE_DIR}/.git/info/exclude
1195 # add only if not yet there
1196 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
1197 echo "$1" >> $cvsignore
1201 # returns true if "$1" is ftp, http or https protocol url
1204 ftp://*|http://*|https://*)
1212 if [ $# -eq 0 ]; then
1216 update_shell_title "update md5"
1217 if [ -n "$DEBUG" ]; then
1224 # pass 1: check files to be fetched
1228 local fp=$(nourl "$i")
1229 local srcno=$(src_no "$i")
1230 if [ -n "$ADD5" ]; then
1231 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
1232 grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
1233 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
1235 grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
1237 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1238 need_files="$need_files $i"
1242 # pass 1a: get needed files
1243 if [ "$need_files" ]; then
1244 get_files $need_files
1247 # pass 2: proceed with md5 adding or updating
1249 local fp=$(nourl "$i")
1250 local srcno=$(src_no "$i")
1251 local md5=$(grep -iE '^#[ ]*(No)?'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
1252 if [ -z "$md5" ]; then
1253 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
1255 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
1256 local tag="# $srcno-md5:\t"
1257 if [[ "$md5" == *NoSource* ]]; then
1258 tag="# No$srcno-md5:\t"
1259 elif [ -n "$USEDIGEST" ]; then
1260 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
1262 md5=$(md5sum "$fp" | cut -f1 -d' ')
1263 echo "Updating $srcno ($md5: $fp)."
1265 print unless (/^\s*#\s*(No)?'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
1266 print "'"$tag$md5"'\n" if /^'$srcno'\s*:\s+/i;
1268 $PACKAGE_DIR/$SPECFILE
1275 [ "$NO5" = "yes" ] && return
1277 update_shell_title "check md5"
1281 if ! good_md5 "$i"; then
1282 echo -n "MD5 sum mismatch."
1285 if ! good_size "$i"; then
1286 echo -n "0 sized file."
1290 if [ $bad -eq 1 ]; then
1291 echo " Use -U to refetch sources,"
1292 echo "or -5 to update md5 sums, if you're sure files are correct."
1293 Exit_error err_no_source_in_repo $i
1299 update_shell_title "get_files"
1301 if [ -n "$DEBUG" ]; then
1306 if [ $# -gt 0 ]; then
1310 local get_files_cvs=""
1314 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1315 update_shell_title "$i"
1316 local fp=`nourl "$i"`
1317 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1322 local srcmd5=$(src_md5 "$i")
1324 # we know if source/patch is present in cvs/distfiles
1325 # - has md5 (in distfiles)
1326 # - in cvs... ideas?
1328 # CHECK: local file didn't exist or always cvs up (first) requested.
1329 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1330 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1331 echo "Warning: no URL given for $i"
1335 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1336 if good_md5 "$i" && good_size "$i"; then
1337 echo "$fp having proper md5sum already exists"
1341 # optionally prefer mirror over distfiles if there's mirror
1342 # TODO: build url list and then try each url from the list
1343 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1346 url=$(distfiles_url "$i")
1349 url_attic=$(distfiles_attic_url "$i")
1351 # is $url local file?
1352 if [[ "$url" = [./]* ]]; then
1353 update_shell_title "${GETLOCAL%% *}: $url"
1354 ${GETLOCAL} $url $target
1357 # make shorter message for distfiles urls
1358 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1359 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1360 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1363 update_shell_title "${GETURI%% *}: $uri"
1364 ${GETURI} "$target" "$url"
1368 if [ ! -s "$target" ]; then
1370 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1371 update_shell_title "${GETLOCAL%% *}: $url_attic"
1372 ${GETLOCAL} $url_attic $target
1374 update_shell_title "${GETURI%% *}: $url_attic"
1375 ${GETURI} "$target" "$url_attic"
1376 test -s "$target" || rm -f "$target"
1380 if [ -s "$target" ]; then
1381 cvsignore_df $target
1388 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1389 if [ -z "$NOMIRRORS" ]; then
1390 im=$(find_mirror "$i")
1394 update_shell_title "${GETURI%% *}: $im"
1395 ${GETURI} "$target" "$im"
1396 test -s "$target" || rm -f "$target"
1399 if [ "$cvsup" = 1 ]; then
1405 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1406 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1407 Exit_error err_no_source_in_repo $i
1410 # we check md5 here just only to refetch immediately
1411 if good_md5 "$i" && good_size "$i"; then
1413 elif [ "$FROM_DISTFILES" = 1 ]; then
1414 # wrong md5 from distfiles: remove the file and try again
1416 echo "MD5 sum mismatch. Trying full fetch."
1419 update_shell_title "${GETURI%% *}: $url"
1420 ${GETURI} "$target" "$url"
1421 if [ ! -s "$target" ]; then
1423 update_shell_title "${GETURI%% *}: $url_attic"
1424 ${GETURI} "$target" "$url_attic"
1426 test -s "$target" || rm -f "$target"
1429 SHELL_TITLE_PREFIX=""
1432 if [ "$CHMOD" = "yes" ]; then
1433 CHMOD_FILES=$(nourl "$@")
1434 if [ -n "$CHMOD_FILES" ]; then
1435 chmod $CHMOD_MODE $CHMOD_FILES
1442 # If tag exists and points to other commit exit with error
1443 # If it existsts and points to HEAD return 1
1444 # If it doesn't exist return 0
1446 local sha1=$(git rev-parse HEAD)
1447 echo "Searching for tag $_tag..."
1448 if [ -n "$DEPTH" ]; then
1449 local ref=$(git ls-remote $REMOTE_PLD "refs/tags/$_tag" | cut -c -40)
1451 local ref=$(git show-ref -s "refs/tags/$_tag")
1453 [ -z "$ref" ] && return 0
1454 [ "$ref" = "$sha1" ] || Exit_error err_tag_exists "$_tag"
1459 if [ -n "$DEBUG" ]; then
1464 # Check whether first character of PACKAGE_NAME is legal for tag name
1465 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1469 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1470 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE)
1472 # Remove @kernel.version_release from TAGVER because tagging sources
1473 # could occur with different kernel-headers than kernel-headers used at build time.
1474 # besides, %{_kernel_ver_str} is not expanded.
1476 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1@%{_kernel_ver_str}
1477 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1484 if [ -n "$DEBUG" ]; then
1489 echo "Version: $PACKAGE_VERSION"
1490 echo "Release: $PACKAGE_RELEASE"
1493 if [ "$TAG_VERSION" = "yes" ]; then
1496 if [ -n "$TAG" ]; then
1501 local OPTIONS="tag $CVS_FORCE"
1505 if tag_exist $_tag || [ -n "$CVS_FORCE" ]; then
1506 update_shell_title "tag sources: $_tag"
1507 git $OPTIONS $_tag || exit
1508 git push $IPOPT $CVS_FORCE $REMOTE_PLD tag $_tag || Exit_error err_remote_problem $REMOTE_PLD
1510 echo "Tag $_tag already exists and points to the same commit"
1516 echo "Git branch: $TAG"
1519 if [ -n "$DEBUG" ]; then
1524 local OPTIONS="branch $CVS_FORCE"
1527 git $OPTIONS $TAG || exit
1531 # this function should exit early if package can't be built for this arch
1532 # this avoids unneccessary BR filling.
1535 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1537 if [ $ret -ne 0 ]; then
1549 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1550 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1556 local ver="$2" subver=$ver
1557 local newver="$3" newsubver=$newver
1559 # try handling subver, everything that's not numeric-dotted in version
1560 if grep -Eq '%define\s+subver' $specfile; then
1561 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1563 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1564 newver=${newver%$newsubver}
1567 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1568 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1569 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1573 # try to upgrade .spec to new version
1574 # if --upgrade-version is specified, use that as new version, otherwise invoke pldnotify to find new version
1576 # return 1: if .spec was updated
1577 # return 0: no changes to .spec
1578 # exit 1 in case of error
1580 if [ -z "$TRY_UPGRADE" ]; then
1584 local TNOTIFY TNEWVER TOLDVER
1585 update_shell_title "build_package: try_upgrade"
1589 if [ "$UPGRADE_VERSION" ]; then
1590 TNEWVER=$UPGRADE_VERSION
1591 echo "Updating spec file to version $TNEWVER"
1593 if [ -n "$FLOAT_VERSION" ]; then
1594 TNOTIFY=$(pldnotify ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1596 TNOTIFY=$(pldnotify ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1599 # pldnotify does not set exit codes, but it has match for ERROR
1600 # in output which means so.
1601 if [[ "$TNOTIFY" = *ERROR* ]]; then
1606 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1607 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1609 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1612 if [ -z "$TNEWVER" ]; then
1616 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1617 cp -f $SPECFILE $SPECFILE.bak
1620 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1621 set_release $SPECFILE $PACKAGE_RELEASE 1
1623 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1624 echo >&2 "Upgrading version failed, you need to update spec yourself"
1631 update_shell_title "build_package"
1632 if [ -n "$DEBUG" ]; then
1641 BUILD_SWITCH="-ba" ;;
1643 BUILD_SWITCH="-bb" ;;
1645 BUILD_SWITCH="-bs --nodeps" ;;
1647 BUILD_SWITCH="-bp --nodeps" ;;
1649 BUILD_SWITCH="-bc" ;;
1651 BUILD_SWITCH="-bi" ;;
1653 BUILD_SWITCH="-bl" ;;
1657 update_shell_title "build_package: $COMMAND"
1658 local logfile retval
1659 if [ -n "$LOGFILE" ]; then
1660 logfile=`eval echo $LOGFILE`
1661 if [ -d "$logfile" ]; then
1662 echo "Log file $logfile is a directory."
1663 echo "Parse error in the spec?"
1664 Exit_error err_build_fail
1666 if [ -n "$LASTLOG_FILE" ]; then
1667 echo "LASTLOG=$logfile" > $LASTLOG_FILE
1671 # unset these, should not be exposed to builder shell!
1672 unset GIT_WORK_TREE GIT_DIR
1673 # these are set by jenkins
1674 unset GIT_PREVIOUS_COMMIT GIT_URL GIT_PREVIOUS_SUCCESSFUL_COMMIT GIT_BRANCH GIT_COMMIT
1675 # this may be set by user
1677 # may be set by user
1678 unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_TESTING_PORCELAIN_COMMAND_LIST
1679 # fail if something still set
1680 env | grep ^GIT_ && Exit_error err_build_fail
1682 local specdir=$(insert_gitlog $SPECFILE)
1683 # FIXME: eval here is exactly why?
1684 PATH=$CLEAN_PATH eval teeboth "'$logfile'" ${TIME_COMMAND} ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE
1688 if [ -n "$logfile" ] && [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1689 if [ "$retval" -eq "0" ]; then
1690 mv $logfile $LOGDIROK
1692 mv $logfile $LOGDIRFAIL
1696 if [ "$retval" -ne "0" ]; then
1697 if [ -n "$TRY_UPGRADE" ]; then
1698 echo "\nUpgrade package to new version failed."
1699 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1700 echo "Restoring old spec file."
1701 mv -f $SPECFILE.bak $SPECFILE
1705 Exit_error err_build_fail
1711 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1714 install_required_packages() {
1719 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1722 /^%changelog/ { exit }
1724 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1725 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1726 gsub(/[ \t]+/, "_", bcond);
1728 }' $SPEC | LC_ALL=C sort -u
1732 # expand bconds from ~/.bcondrc
1733 # The file structure is like gentoo's package.use:
1736 # samba -mysql -pgsql
1737 # w32codec-installer license_agreement
1740 if [ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ]); then
1746 SN=${SPECFILE%%\.spec}
1748 local bcondrc=$HOME/.bcondrc
1749 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1751 local bcond_avail=$(find_spec_bcond $SPECFILE)
1753 while read pkg flags; do
1755 [[ "$pkg" == \#* ]] && continue
1757 # any package or current package?
1758 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1759 for flag in $flags; do
1760 local opt=${flag#[+-]}
1762 # use only flags which are in this package.
1763 if [[ $bcond_avail = *${opt}* ]]; then
1764 if [[ $flag = -* ]]; then
1765 if [[ $BCOND != *--with?${opt}* ]]; then
1766 BCOND="$BCOND --without $opt"
1769 if [[ $BCOND != *--without?${opt}* ]]; then
1770 BCOND="$BCOND --with $opt"
1777 update_shell_title "parse ~/.bcondrc: DONE!"
1780 set_bconds_values() {
1781 update_shell_title "set bcond values"
1783 AVAIL_BCONDS_WITHOUT=""
1784 AVAIL_BCONDS_WITH=""
1786 if grep -Eq '^# *_with' ${SPECFILE}; then
1787 echo >&2 "ERROR: This spec has old style bconds."
1791 if ! grep -q '^%bcond' ${SPECFILE}; then
1795 local bcond_avail=$(find_spec_bcond $SPECFILE)
1796 process_bcondrc "$SPECFILE"
1798 update_shell_title "parse bconds"
1801 for opt in $bcond_avail; do
1804 bcond=${opt#without_}
1806 *--without?${bcond}*)
1807 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1810 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1818 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1821 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1826 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1835 update_shell_title "run_sub_builder $package_name"
1837 # No i tutaj bym chciał zrobić sztuczną inteligencję, która spróbuje tego
1838 # pakieta zbudować. Aktualnie niewiele dziala, bo generalnie nie widze do
1839 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1840 # jakby nie bylo tego kawalka kodu.
1842 # Update: Poprawiłem parę rzeczy i zaczęło generować pakiety spoza zadanej listy.
1843 # Jednym słowem budowanie niespoldkowanych zależności działa w paru przypadkach.
1847 # kurwa. translate that ^^^^
1851 # Istnieje taki spec? ${package}.spec
1852 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1853 parent_spec_name=${package}.spec
1854 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1855 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1857 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1862 if [ "${parent_spec_name}" != "" ]; then
1863 spawn_sub_builder $parent_spec_name
1865 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1868 # install package with poldek
1869 # @return exit code from poldek
1871 # this requires following sudo rules:
1872 # - poldek --noask --caplookup -uG
1874 LANG=C $POLDEK_CMD --noask --caplookup --uniq -uG "$@"
1879 # this requires following sudo rules:
1880 # - poldek -q --update --upa
1881 install_packages() {
1882 # sync poldek indexes once per invocation
1883 if [ -z "$package_indexes_updated" ]; then
1884 update_shell_title "poldek: update indexes"
1885 $POLDEK_CMD -q --update --upa --mo=nodesc
1886 package_indexes_updated=true
1889 update_shell_title "install packages: $*"
1890 poldek_install "$@" && return
1892 # retry install, install packages one by one
1893 # this is slower one
1895 for package in $*; do
1896 package=$(depspecname $package)
1897 update_shell_title "install package: $package"
1898 poldek_install "$package" || rc=$?
1903 uninstall_packages() {
1904 update_shell_title "uninstall packages: $*"
1905 $POLDEK_CMD --noask --nofollow -ev "$@"
1908 spawn_sub_builder() {
1910 update_shell_title "spawn_sub_builder $package_name"
1913 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1914 sub_builder_opts="${sub_builder_opts} -R"
1916 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1917 sub_builder_opts="${sub_builder_opts} -RB"
1918 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1919 sub_builder_opts="${sub_builder_opts} -FRB"
1921 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1922 sub_builder_opts="${sub_builder_opts} -Upi"
1926 ./builder ${sub_builder_opts} "$@"
1929 remove_build_requires() {
1930 if [ "$INSTALLED_PACKAGES" != "" ]; then
1931 case "$REMOVE_BUILD_REQUIRES" in
1933 run_poldek --noask -ve $INSTALLED_PACKAGES
1936 run_poldek --ask -ve $INSTALLED_PACKAGES
1939 echo You may want to manually remove following BuildRequires fetched:
1940 echo $INSTALLED_PACKAGES
1941 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1948 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1949 if [ "$BCOND" ]; then
1951 echo "Building $SPECFILE with the following conditional flags:"
1955 echo "No conditional flags passed"
1958 echo "from available:"
1959 echo "--with :\t$AVAIL_BCONDS_WITH"
1960 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1965 display_branches() {
1966 echo -n "Available branches: "
1967 git branch -r 2>/dev/null | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs
1970 # checks a given list of packages/files/provides against current rpmdb.
1971 # outputs all dependencies which current rpmdb doesn't satisfy.
1972 # input can be either STDIN or parameters
1976 if [ $# -gt 0 ]; then
1982 out=$(LC_ALL=C rpm -q --whatprovides $deps 2>&1)
1985 echo "$out" | awk '/^no package provides/ { print $NF }'
1987 # other deps (files)
1988 echo "$out" | sed -rne 's/file (.*): No such file or directory/\1/p'
1991 # checks if given package/files/provides exists in rpmdb.
1992 # input can be either stdin or parameters
1993 # returns packages which are present in the rpmdb
1997 if [ $# -gt 0 ]; then
2003 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
2006 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
2007 install_build_requires_rpmdeps() {
2009 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
2010 # TODO: Conflicts list doesn't check versions
2011 CNFL=$(eval rpm-getdeps $BCOND $RPMOPTS $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
2012 DEPS=$(eval rpm-getdeps $BCOND $RPMOPTS $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
2014 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
2015 CNFL=$(eval rpm -q --specsrpm --conflicts $BCOND $RPMOPTS $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
2016 DEPS=$(eval rpm -q --specsrpm --requires $BCOND $RPMOPTS $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
2019 if [ -n "$CNFL" ]; then
2020 echo "Uninstall conflicting packages: $CNFL"
2021 uninstall_packages $CNFL
2024 if [ -n "$DEPS" ]; then
2025 echo "Install dependencies: $DEPS"
2026 install_packages $DEPS
2030 fetch_build_requires()
2032 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
2036 update_shell_title "fetch build requires"
2037 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
2038 install_build_requires_rpmdeps
2042 die "need rpm-getdeps tool"
2049 if [ ! -e $localrepo ]; then
2050 git clone $IPOPT -o $REMOTE_PLD ${GIT_SERVER}/$remoterepo $localrepo
2051 git --git-dir=$localrepo/.git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/$remoterepo
2056 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
2057 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
2058 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
2059 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
2060 local TEMPLATES=template-specs
2063 echo "Initializing rpm directories to $TOP_DIR from $GIT_SERVER"
2064 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
2067 init_repository ${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools
2068 init_repository projects/$TEMPLATES ../$TEMPLATES
2069 for a in builder fetchsrc_request compile repackage; do
2070 ln -sf ../rpm-build-tools/${a}.sh $a
2073 ln -sf ../rpm-build-tools/${a} $a
2075 ln -sf ../rpm-build-tools/mirrors mirrors
2082 DONT_PRINT_REVISION="yes"
2084 # remove spec and sources
2085 PATH=$CLEAN_PATH $RPMBUILD --clean --rmsource --rmspec --nodeps --define "__urlgetfile() %nil" --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" --define "_builddir $builddir" $PACKAGE_DIR/$SPECFILE
2086 rm -rf $PACKAGE_DIR/{.git,.gitignore}
2087 rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
2090 #---------------------------------------------
2098 # stuff global $BUILDER_OPTS from env as args
2099 if [ "$BUILDER_OPTS" ]; then
2100 set -- "$BUILDER_OPTS" "$@"
2103 while [ $# -gt 0 ]; do
2110 COMMAND="update_md5"
2115 COMMAND="update_md5"
2124 DEBUG="yes"; shift ;;
2126 COMMAND="version"; shift ;;
2128 COMMAND="short-version"; shift ;;
2135 -b | -ba | --build )
2136 COMMAND="build"; shift ;;
2137 -bb | --build-binary )
2138 COMMAND="build-binary"; shift ;;
2140 COMMAND="build-build"; shift ;;
2142 COMMAND="build-install"; shift ;;
2144 COMMAND="build-list"; shift ;;
2145 -bp | --build-prep )
2146 COMMAND="build-prep"; shift ;;
2147 -bs | --build-source )
2148 COMMAND="build-source"; shift ;;
2150 COMMAND="branch"; shift; TAG="${1}"; shift;;
2152 CLEAN="--clean"; shift ;;
2154 CVS_FORCE="-f"; shift;;
2160 COMMAND="get"; shift ;;
2162 COMMAND="usage"; shift ;;
2164 PROTOCOL="ftp"; shift ;;
2166 PROTOCOL="http"; shift ;;
2168 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
2172 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
2176 PARALLEL_DOWNLOADS=$2
2180 PARALLEL_DOWNLOADS=${1#-p}
2184 shift; LOGFILE="${1}"; shift ;;
2186 shift; DEF_NICE_LEVEL=${1}; shift ;;
2187 -ske | --skip-existing-files)
2188 SKIP_EXISTING_FILES="yes"; shift ;;
2190 COMMAND="mr-proper"; shift ;;
2191 -ncs | --no-cvs-specs )
2192 NOCVSSPEC="yes"; shift ;;
2193 -nd | --no-distfiles )
2194 NODIST="yes"; shift ;;
2195 -nm | --no-mirrors )
2196 NOMIRRORS="yes"; shift ;;
2198 NOURLS="yes"; shift ;;
2200 NOSRCS="yes"; shift ;;
2201 -ns0 | --no-source0 )
2202 NOSOURCE0="yes"; shift ;;
2211 -pm | --prefer-mirrors )
2214 --noinit | --no-init )
2218 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2220 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2221 --skip-patch | -sp )
2222 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2224 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2227 --with | --without )
2228 case $GROUP_BCONDS in
2232 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2233 while ! `echo ${1}|grep -qE '(^-|spec)'`
2235 BCOND="$BCOND $COND $1"
2239 if [[ "$2" = *,* ]]; then
2240 for a in $(echo "$2" | tr , ' '); do
2241 BCOND="$BCOND $1 $a"
2244 BCOND="$BCOND $1 $2"
2250 shift; TARGET="${1}"; shift ;;
2252 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2254 QUIET="--quiet"; shift ;;
2256 CVSDATE="${2}"; shift 2
2257 date -d "$CVSDATE" > /dev/null 2>&1 || { echo >&2 "No valid date specified"; exit 3; }
2267 -R | --fetch-build-requires)
2268 FETCH_BUILD_REQUIRES="yes"
2269 NOT_INSTALLED_PACKAGES=
2271 -RB | --remove-build-requires)
2272 REMOVE_BUILD_REQUIRES="nice"
2274 -FRB | --force-remove-build-requires)
2275 REMOVE_BUILD_REQUIRES="force"
2278 COMMAND="list-sources-cvs"
2280 -sd | --source-distfiles)
2281 COMMAND="list-sources-distfiles"
2283 -sdp | --source-distfiles-paths)
2284 COMMAND="list-sources-distfiles-paths"
2286 -sf | --source-files)
2287 COMMAND="list-sources-files"
2289 -lsp | --source-paths)
2290 COMMAND="list-sources-local-paths"
2292 -su | --source-urls)
2293 COMMAND="list-sources-urls"
2295 -Tvs | --tag-version-stable )
2300 -Ts | --tag-stable )
2305 -Tv | --tag-version )
2310 -Tp | --tag-prefix )
2322 -ir | --integer-release-only )
2323 INTEGER_RELEASE="yes"
2326 COMMAND="update_md5"
2331 -Upi | --update-poldek-indexes )
2332 UPDATE_POLDEK_INDEXES="yes"
2334 --init-rpm-dir|--init)
2335 COMMAND="init_rpm_dir"
2337 -u | --try-upgrade )
2338 TRY_UPGRADE="1"; shift ;;
2340 shift; UPGRADE_VERSION="$1"; shift;;
2341 -un | --try-upgrade-with-float-version )
2342 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2344 BE_VERBOSE="1"; shift ;;
2349 if echo "${MACRO}" | grep -q '\W'; then
2350 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2354 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2359 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\" --define \"build_kernels $1\""
2363 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2366 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2367 COMMAND="show_bconds"
2371 COMMAND="show_bcond_args"
2374 --show-avail-bconds)
2375 COMMAND="show_avail_bconds"
2380 RPMOPTS="${RPMOPTS} --nodeps"
2383 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2386 Exit_error err_invalid_cmdline "$1"
2389 SPECFILE=${1%/}; shift
2390 # check if specname was passed as specname:cvstag
2391 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2392 CVSTAG="${SPECFILE##*:}"
2393 SPECFILE="${SPECFILE%%:*}"
2395 # always have SPECFILE ending with .spec extension
2396 SPECFILE=${SPECFILE%%.spec}.spec
2397 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2401 if [ "$CVSTAG" ]; then
2402 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2403 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2406 if [ -n "$ALL_BRANCHES" -a -z "$DEPTH" ]; then
2407 echo >&2 "--all branches requires --depth <number>"
2408 Exit_error err_invalid_cmdline
2411 if [ -n "$DEBUG" ]; then
2416 if [ -n "$TARGET" ]; then
2419 TARGET_SWITCH="--target $TARGET" ;;
2421 TARGET_SWITCH="--target=$TARGET" ;;
2425 if [ "$SCHEDTOOL" != "no" ]; then
2426 NICE_COMMAND="$SCHEDTOOL"
2428 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2431 # see time(1) for output format that could be used
2432 TIME_COMMAND="time -p"
2434 update_shell_title "$COMMAND"
2438 if [ -z "$SPECFILE" ]; then
2439 Exit_error err_no_spec_in_cmdl
2441 get_spec > /dev/null
2448 if [ -z "$SPECFILE" ]; then
2449 Exit_error err_no_spec_in_cmdl
2451 get_spec > /dev/null
2456 "show_avail_bconds")
2458 if [ -z "$SPECFILE" ]; then
2459 Exit_error err_no_spec_in_cmdl
2462 get_spec > /dev/null
2464 local bcond_avail=$(find_spec_bcond $SPECFILE)
2465 local opt bcond bconds
2466 for opt in $bcond_avail; do
2469 bcond=${opt#without_}
2470 bconds="$bconds $bcond"
2474 bconds="$bconds $bcond"
2477 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2485 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2487 if [ -z "$SPECFILE" ]; then
2488 Exit_error err_no_spec_in_cmdl
2491 # display SMP make flags if set
2492 smp_mflags=$(rpm -E %{?_smp_mflags})
2493 if [ "$smp_mflags" ]; then
2494 echo "builder: SMP make flags are set to $smp_mflags"
2502 if [ "$COMMAND" != "build-source" ]; then
2505 fetch_build_requires
2506 if [ "$INTEGER_RELEASE" = "yes" ]; then
2507 echo "Checking release $PACKAGE_RELEASE..."
2508 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2509 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2513 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2514 if [ -n "$TEST_TAG" ]; then
2515 local TAGVER=`make_tagver`
2516 tag_exist $TAGVER || [ $TAGVER = $CVSTAG ] || Exit_error err_tag_exists $TAGVER
2517 # check also tags created in CVS
2518 local TAGVER_CVS=$(echo $TAGVER | tr '[.@]' '[_#]')
2519 local CVSTAG_CVS=$(echo $CVSTAG | tr '[.@]' '[_#]')
2520 tag_exist $TAGVER_CVS || [ $TAGVER_CVS = $CVSTAG_CVS ] \
2521 || Exit_error err_tag_exists $TAGVER_CVS
2522 # - do not allow to build from HEAD when XX-branch exists
2523 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto/\([a-zA-Z]\+\)/.*#\1#g')
2524 if [ "$TAGVER" != "$CVSTAG" -a "$TAGVER_CVS" != "$CVSTAG" -a "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2525 TAG_BRANCH="${TREE_PREFIX}-branch"
2526 if [ -n "$DEPTH" ]; then
2527 cmd_branches="git ls-remote --heads"
2528 ref_prefix=refs/heads
2530 cmd_branches="git show-ref"
2531 ref_prefix=refs/remotes/${REMOTE_PLD}
2533 TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$" | cut -c'-40')
2534 if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != $(git rev-parse "$CVSTAG") ]; then
2535 Exit_error err_branch_exists "$TAG_STATUS"
2541 if [ -n "$NOSOURCE0" ] ; then
2542 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2547 get_files $SOURCES $PATCHES
2548 check_md5 $SOURCES $PATCHES
2551 NODIST="yes" get_files $SOURCES $PATCHES
2552 update_md5 $SOURCES $PATCHES
2556 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ] && [ "$COMMAND" = "build" -o "$COMMAND" = "build-binary" ]; then
2557 run_poldek --sdir="${POLDEK_INDEX_DIR}" ${UPDATE_POLDEK_INDEXES_OPTS} --mkidxz
2559 remove_build_requires
2563 if [ -z "$SPECFILE" ]; then
2564 Exit_error err_no_spec_in_cmdl
2573 if [ -z "$SPECFILE" ]; then
2574 Exit_error err_no_spec_in_cmdl
2578 if [ -n "$NEW_REPO" ]; then
2581 for file in $SOURCES $PATCHES; do
2582 if [ -z $(src_md5 "$file") ]; then
2583 git add $file || Exit_error err_no_source_in_repo $file
2585 cvsignore_df `nourl $file`
2589 echo "When you are ready commit your changes and run git push origin master"
2591 echo "You had already git repository. Push chosen branches to remote: ${REMOTE_PLD}"
2596 if [ -z "$SPECFILE" ]; then
2597 Exit_error err_no_spec_in_cmdl
2603 if [ -n "$NOSOURCE0" ] ; then
2604 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2606 get_files $SOURCES $PATCHES
2608 fetch_build_requires
2612 if [ -z "$SPECFILE" ]; then
2613 Exit_error err_no_spec_in_cmdl
2619 if [ -n "$NOSOURCE0" ] ; then
2620 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2622 update_md5 $SOURCES $PATCHES
2628 if [ -z "$SPECFILE" ]; then
2629 Exit_error err_no_spec_in_cmdl
2633 if [ ! -d .git ]; then
2634 echo "No git reposiotory" >&2
2642 "list-sources-files" )
2645 DONT_PRINT_REVISION="yes"
2648 for SAP in $SOURCES $PATCHES; do
2649 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2652 "list-sources-urls" )
2655 DONT_PRINT_REVISION="yes"
2658 SAPS="$SOURCES $PATCHES"
2659 for SAP in $SAPS; do
2663 "list-sources-local-paths" )
2666 DONT_PRINT_REVISION="yes"
2669 for SAP in $SOURCES $PATCHES; do
2670 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2673 "list-sources-distfiles-paths" )
2676 DONT_PRINT_REVISION="yes"
2679 for SAP in $SOURCES $PATCHES; do
2680 if [ -n "$(src_md5 "$SAP")" ]; then
2681 distfiles_path "$SAP"
2685 "list-sources-distfiles" )
2688 DONT_PRINT_REVISION="yes"
2691 for SAP in $SOURCES $PATCHES; do
2692 if [ -n "$(src_md5 "$SAP")" ]; then
2693 distfiles_url "$SAP"
2697 "list-sources-cvs" )
2700 DONT_PRINT_REVISION="yes"
2703 for SAP in $SOURCES $PATCHES; do
2704 if [ -z "$(src_md5 "$SAP")" ]; then
2705 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2719 echo "$VERSIONSTRING"
2722 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2723 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2727 # vi:syntax=sh:ts=4:sw=4:noet