X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=builder.sh;h=2d577eb7847b0fccbcf693c5a563d8fc60606478;hb=71e53097c12fee8ddf036696e2d48e6c6eca9b8b;hp=72c5f66ec9517c8ef3d3cb0772ec595d109fd56f;hpb=52a2ef00e8fec0d74192471b727d8f67c8338131;p=packages%2Frpm-build-tools.git diff --git a/builder.sh b/builder.sh index 72c5f66..2d577eb 100755 --- a/builder.sh +++ b/builder.sh @@ -35,11 +35,10 @@ PROGRAM=${0##*/} APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d") -RCSID='$Id: builder,v 1.645 2011/02/13 17:54:10 glen Exp $' r=${RCSID#* * } rev=${r%% *} -VERSION="v0.35/$rev" +VERSION="v0.35" VERSIONSTRING="\ Build package utility from PLD Linux Packages repository -$VERSION (C) 1999-2013 Free Penguins". +$VERSION (C) 1999-2016 Free Penguins". CLEAN_PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" @@ -77,11 +76,12 @@ DATE=`date +%Y-%m-%d_%H-%M-%S` # target arch, can also be used for log file naming TARGET=$(rpm -E %{_target}) +# Note the *single* quotes, this allows using shell variables expanded at build time # Example: LOGFILE='../log.$PACKAGE_NAME' # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE' # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log' # Example: LOGFILE='$PACKAGE_NAME.$DATE.log' -# Yes, you can use variable name! Note _single_ quotes! +# Example: LOGFILE='.log.$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE.$TARGET.$DATE' LOGFILE='' # use teeboth Perl wrapper @@ -180,8 +180,9 @@ fi #GROUP_BCONDS="yes" #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE' #TITLECHANGE=no -# -SU_SUDO="" + +SU_SUDO="sudo" + if [ -n "$HOME_ETC" ]; then USER_CFG="$HOME_ETC/.builderrc" BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros" @@ -216,6 +217,7 @@ else wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate" wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet" wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused" + wget --help 2>&1 | grep -q -- ' --no-iri ' && WGET_OPTS="$WGET_OPTS --no-iri" WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT" GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS" @@ -243,9 +245,10 @@ if [ -d $HOME/rpm/SOURCES ]; then fi POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/" -POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask" +POLDEK_CMD="$SU_SUDO /usr/bin/poldek" # TODO: add teeboth +# TODO: what this function does? run_poldek() { RES_FILE=$(tempfile) if [ -n "$LOGFILE" ]; then @@ -253,11 +256,11 @@ run_poldek() { if [ -n "$LASTLOG_FILE" ]; then echo "LASTLOG=$LOG" > $LASTLOG_FILE fi - (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG + (${NICE_COMMAND} ${POLDEK_CMD} --noask `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG # FIXME $exit_pldk undefined return $exit_pldk else - (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null + (${NICE_COMMAND} ${POLDEK_CMD} --noask `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null return `cat ${RES_FILE}` rm -rf ${RES_FILE} fi @@ -444,21 +447,24 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ constructions. Set GROUP_BCONDS to yes to make use of it. --target , --target= - build for platform . ---init-rpm-dir - initialize ~/rpm directory structure +--init-rpm-dir, --init + - initialize ~/rpm directory structure " } # create tempfile. as secure as possible tempfile() { - mktemp --tmpdir -t builder.$PACKAGE_NAME.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$ + local prefix=builder.$PACKAGE_NAME${1:+.$1} + mktemp --tmpdir -t $prefix.XXXXXX || echo ${TMPDIR:-/tmp}/$prefix.$RANDOM.$$ } tempdir() { - mktemp --tmpdir -d builder.$PACKAGE_NAME.XXXXXX + local prefix=builder.$PACKAGE_NAME${1:+.$1} + mktemp --tmpdir -d $prefix.XXXXXX } # inserts git log instead of %changelog -# outputs name of modified file created by tempfile +# @output directory containing modified specfile insert_gitlog() { local SPECFILE=$1 specdir=$(tempdir) gitlog=$(tempfile) speclog=$(tempfile) @@ -478,7 +484,7 @@ insert_gitlog() { done > $gitlog # add link to full git logs - local giturl="http://git.pld-linux.org/?p=packages/$PACKAGE_NAME.git;a=log" + local giturl="http://git.pld-linux.org/?p=packages/${SPECFILE%.spec}.git;a=log" if [ -n "$CVSTAG" ]; then giturl="$giturl;h=$CVSTAG" fi @@ -526,14 +532,30 @@ teeboth() { # common changes: # - perl(Package::Name) -> perl-Package-Name depspecname() { - local package="$1" + local DEPS + + if [ $# -gt 0 ]; then + DEPS="$@" + else + DEPS=$(cat) + fi - package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' ) - echo "$package" + echo "$DEPS" | tr ' ' '\n' | sed -re ' + # perl virtual deps + /perl\(.*\)/{ + s/perl\((.*)\)/perl-\1/ + s/::/-/g + } + + s/apache\(EAPI\)-devel/apache-devel/ + + s/db-devel/db5.3-devel/ + s/libjpeg-devel/libjpeg-turbo-devel/ + ' } update_shell_title() { - [ -t 1 ] || return + [ -t 2 ] || return local len=${COLUMNS:-80} local msg="$(echo "$*" | cut -c-$len)" @@ -635,7 +657,7 @@ minirpm() { %remove_etc_shells(p) %{p:} %lua_add_etc_shells() %{nil} %lua_remove_etc_shells() %{nil} -%required_jdk %{nil} +%required_jdk jdk %buildrequires_jdk %{nil} %pear_package_print_optionalpackages %{nil} EOF @@ -759,6 +781,13 @@ parse_spec() { update_shell_title "parse_spec: OK!" } +# aborts program abnormally +die() { + local rc=${2:-1} + echo >&2 "$PROGRAM: ERROR: $*" + exit $rc +} + Exit_error() { if [ -n "$DEBUG" ]; then set -x @@ -777,7 +806,11 @@ Exit_error() { exit 2 ;; "err_no_spec_in_repo" ) remove_build_requires - echo >&2 "Error: spec file not stored in PLD repo." + echo >&2 "Error: spec file not stored in repository." + if [ -n "$2" ]; then + echo >&2 "Tried: $2" + fi + exit 3 ;; "err_no_source_in_repo" ) remove_build_requires @@ -890,10 +923,17 @@ create_git_repo() { fi [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes ssh $GIT_PUSH create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed + ( + set -e git init - git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git && \ - git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} \ - || Exit_error err_remote_problem $REMOTE_PLD + git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git + git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} + + git config --local push.default current + git config --local branch.master.remote $REMOTE_PLD + git config --local branch.master.merge refs/heads/master + ) + test $? = 0 || Exit_error err_remote_problem $REMOTE_PLD } get_spec() { @@ -926,7 +966,10 @@ get_spec() { echo "Warning: package not in CVS - assuming new package" NOCVSSPEC="yes" } - git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*' + git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*' + git config --local --add "remote.$REMOTE_PLD.push" 'refs/notes/*:refs/notes/*' + git config --local --add "remote.$REMOTE_PLD.push" HEAD + git config --local push.default current git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} ) fi @@ -937,7 +980,10 @@ get_spec() { fi git init git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git - git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*' + git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*' + git config --local --add "remote.$REMOTE_PLD.push" 'refs/heads/*:refs/remotes/origin/*' + git config --local --add "remote.$REMOTE_PLD.push" HEAD + git config --local push.default current git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} CVSTAG=${CVSTAG:-"master"} fi @@ -957,7 +1003,7 @@ get_spec() { # add default log format to .gitignore if it is relative to package dir if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then # substitute known "macros" to glob - local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\|TARGET\),*,g') + local logfile=$(echo "$LOGFILE" | sed -r -e 's,\$(PACKAGE_(NAME|VERSION|RELEASE)|DATE|TARGET),*,g') if [ "$logfile" ]; then cvsignore_df "$logfile" fi @@ -965,7 +1011,7 @@ get_spec() { # create symlinks for tools if [ "$SYMLINK_TOOLS" != "no" -a -d "$PACKAGE_DIR" ]; then - for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do + for a in dropin md5 builder {relup,compile,repackage,rsync,pearize}.sh; do # skip tools that don't exist in top dir [ -f $a ] || continue # skip tools that already exist @@ -993,7 +1039,7 @@ get_spec() { fi if [ ! -f "$PACKAGE_DIR/$SPECFILE" ]; then - Exit_error err_no_spec_in_repo + Exit_error err_no_spec_in_repo "$PACKAGE_DIR/$SPECFILE" fi if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then @@ -1005,15 +1051,22 @@ get_spec() { set_spec_target } +# find mirrors in this order. first match wins: +# - package dir (~/rpm/packages/foo) +# - repository dir (~/rpm/packages) +# - tools dir dir (~/rpm/packages/rpm-build-tools) find_mirror() { - cd "$REPO_DIR" local url="$1" - if [ ! -f "mirrors" ] ; then - ln -s ../rpm-build-tools/mirrors . - fi - IFS="|" + update_shell_title "find_mirror[$url][$REPO_DIR]" + + # NOTE: as while loop runs in subshell, + # we use exit 2 to indicate that the match was found + # otherwise we end up outputing mirror url and origin url. + local origin mirror name rest ol prefix + IFS="|" + cat "$PACKAGE_DIR/mirrors" "$REPO_DIR/mirrors" "$REPO_DIR/../rpm-build-tools/mirrors" /dev/null 2>/dev/null | \ while read origin mirror name rest; do # skip comments and empty lines if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then @@ -1024,10 +1077,9 @@ find_mirror() { if [ "$prefix" = "$origin" ] ; then suffix=$(echo "$url" | cut -b $((ol+1))-) echo -n "$mirror$suffix" - return 0 + exit 2 fi - done < mirrors - echo "$url" + done && echo "$url" } # Warning: unpredictable results if same URL used twice @@ -1110,7 +1162,7 @@ cvsignore_df() { if [ "$CVSIGNORE_DF" != "yes" ]; then return fi - cvsignore=${PACKAGE_DIR}/.gitignore + local cvsignore=${PACKAGE_DIR}/.git/info/exclude # add only if not yet there if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then @@ -1531,12 +1583,12 @@ try_upgrade() { echo "Updating spec file to version $TNEWVER" else if [ -n "$FLOAT_VERSION" ]; then - TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1 + TNOTIFY=$(pldnotify ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1 else - TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1 + TNOTIFY=$(pldnotify ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1 fi - # pldnotify.awk does not set exit codes, but it has match for ERROR + # pldnotify does not set exit codes, but it has match for ERROR # in output which means so. if [[ "$TNOTIFY" = *ERROR* ]]; then echo >&2 "$TNOTIFY" @@ -1608,6 +1660,17 @@ build_package() { fi fi + # unset these, should not be exposed to builder shell! + unset GIT_WORK_TREE GIT_DIR + # these are set by jenkins + unset GIT_PREVIOUS_COMMIT GIT_URL GIT_PREVIOUS_SUCCESSFUL_COMMIT GIT_BRANCH GIT_COMMIT + # this may be set by user + unset GIT_SSH + # may be set by user + unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL + # fail if something still set + env | grep ^GIT_ && Exit_error err_build_fail + local specdir=$(insert_gitlog $SPECFILE) # FIXME: eval here is exactly why? 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 @@ -1763,13 +1826,13 @@ run_sub_builder() { package_name="${1}" update_shell_title "run_sub_builder $package_name" # - # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego - # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do + # No i tutaj bym chciał zrobić sztuczną inteligencję, która spróbuje tego + # pakieta zbudować. Aktualnie niewiele dziala, bo generalnie nie widze do # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo # jakby nie bylo tego kawalka kodu. # - # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy. - # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach. + # Update: Poprawiłem parę rzeczy i zaczęło generować pakiety spoza zadanej listy. + # Jednym słowem budowanie niespoldkowanych zależności działa w paru przypadkach. # # # y0shi. @@ -1794,6 +1857,46 @@ run_sub_builder() { NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name" } +# install package with poldek +# @return exit code from poldek +# +# this requires following sudo rules: +# - poldek --noask --caplookup -uG +poldek_install() { + LANG=C $POLDEK_CMD --noask --caplookup --uniq -uG "$@" +} + +# install packages +# +# this requires following sudo rules: +# - poldek -q --update --upa +install_packages() { + # sync poldek indexes once per invocation + if [ -z "$package_indexes_updated" ]; then + update_shell_title "poldek: update indexes" + $POLDEK_CMD -q --update --upa + package_indexes_updated=true + fi + + update_shell_title "install packages: $*" + poldek_install "$@" && return + + # retry install, install packages one by one + # this is slower one + local rc=0 package + for package in $*; do + package=$(depspecname $package) + update_shell_title "install package: $package" + poldek_install "$package" || rc=$? + done + return $rc +} + +uninstall_packages() { + update_shell_title "uninstall packages: $*" + $POLDEK_CMD --noask --nofollow -ev "$@" +} + spawn_sub_builder() { package_name="${1}" update_shell_title "spawn_sub_builder $package_name" @@ -1856,25 +1959,25 @@ display_branches() { git branch -r 2>/dev/null | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs } -# checks a given list of packages/files/provides agains current rpmdb. +# checks a given list of packages/files/provides against current rpmdb. # outputs all dependencies which current rpmdb doesn't satisfy. # input can be either STDIN or parameters _rpm_prov_check() { - local DEPS + local deps out if [ $# -gt 0 ]; then - DEPS="$@" + deps="$@" else - DEPS=$(cat) + deps=$(cat) fi - DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }') + out=$(LC_ALL=C rpm -q --whatprovides $deps 2>&1) # packages - echo "$DEPS" | awk '/^no package provides/ { print $NF }' + echo "$out" | awk '/^no package provides/ { print $NF }' # other deps (files) - echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}' + echo "$out" | sed -rne 's/file (.*): No such file or directory/\1/p' } # checks if given package/files/provides exists in rpmdb. @@ -1894,44 +1997,26 @@ _rpm_cnfl_check() { # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm' install_build_requires_rpmdeps() { + local DEPS CNFL if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then # TODO: Conflicts list doesn't check versions - local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs) - local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs) + CNFL=$(eval rpm-getdeps $BCOND $RPMOPTS $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs) + DEPS=$(eval rpm-getdeps $BCOND $RPMOPTS $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs) fi if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then - local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs) - local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs) + CNFL=$(eval rpm -q --specsrpm --conflicts $BCOND $RPMOPTS $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs) + DEPS=$(eval rpm -q --specsrpm --requires $BCOND $RPMOPTS $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs) fi - if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then - echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]" - update_shell_title "poldek: install [$DEPS]; remove [$CNFL]" - $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa - fi if [ -n "$CNFL" ]; then - update_shell_title "uninstall conflicting packages: $CNFL" - echo "Trying to uninstall conflicting packages ($CNFL):" - $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL - fi - - while [ "$DEPS" ]; do - update_shell_title "install deps: $DEPS" - echo "Trying to install dependencies ($DEPS):" - local log=.${SPECFILE}_poldek.log - LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log - failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log) - rm -f $log - local ok - if [ -n "$failed" ]; then - for package in $failed; do - spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package" - done - DEPS="$ok" - else - DEPS="" - fi - done + echo "Uninstall conflicting packages: $CNFL" + uninstall_packages $CNFL + fi + + if [ -n "$DEPS" ]; then + echo "Install dependencies: $DEPS" + install_packages $DEPS + fi } fetch_build_requires() @@ -1946,149 +2031,7 @@ fetch_build_requires() return fi - # XXX is this ugliest code written in human history still needed? - echo "All packages installed by fetch_build_requires() are written to:" - echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" - echo "" - echo "If anything fails, you may get rid of them by executing:" - echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`" - echo "" - echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES - 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) - do - 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) - GO="yes" - package=$(basename "$package_item"|sed -e "s/}$//g") - COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g") - mach=$(uname -m) - - COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"` - if `echo $COND_TST|grep -q '^BuildRequires:'`; then - 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 - GO="yes" - fi - # bcond: - else - COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g` - GO="" - # %{without} - if `echo $COND_TST|grep -q 'without_'`; then - COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g` - if `echo $COND_TST|grep -q !`; then - COND_STATE="with" - else - COND_STATE="wout" - fi - COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"` - COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"` - if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then - COND_ARGV="wout" - else - COND_ARGV="with" - fi - # %{with} - elif `echo $COND_TST|grep -q 'with_'`; then - COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g` - if `echo $COND_TST|grep -q !`; then - COND_STATE="wout" - else - COND_STATE="with" - fi - COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"` - COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"` - if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then - COND_ARGV="with" - else - COND_ARGV="wout" - fi - fi - RESULT="${COND_STATE}-${COND_ARGV}" - case "$RESULT" in - "with-wout" | "wout-with" ) - GO="" - ;; - "wout-wout" | "with-with" ) - GO="yes" - ;; - * ) - echo "Action '$RESULT' was not defined for package '$package_item'" - GO="yes" - ;; - esac - fi - - if [ "$GO" = "yes" ]; then - if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then - echo "Testing if $package has subrequirements..." - run_poldek -t -i $package --dumpn=".$package-req.txt" - if [ -f ".$package-req.txt" ]; then - for package_name in `cat ".$package-req.txt"|grep -v ^#` - do - if [ "$package_name" = "$package" ]; then - echo "Installing BuildRequired package:\t$package_name" - update_shell_title "Installing BuildRequired package: ${package_name}" - install_required_packages $package - else - echo "Installing (sub)Required package:\t$package_name" - update_shell_title "Installing (sub)Required package: ${package_name}" - install_required_packages $package_name - fi - case $? in - 0) - INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES" - echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES - ;; - *) - echo "Attempting to run spawn sub - builder..." - echo "Package installation failed:\t$package_name" - run_sub_builder $package_name - if [ $? -eq 0 ]; then - install_required_packages $package_name - case $? in - 0) - INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES" - echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES - ;; - *) - NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES" - ;; - esac - fi - ;; - esac - done - rm -f ".$package-req.txt" - else - echo "Attempting to run spawn sub - builder..." - echo "Package installation failed:\t$package" - run_sub_builder $package - if [ $? -eq 0 ]; then - install_required_packages $package - case $? in - 0) - INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES" - echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES - ;; - *) - NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES" - ;; - esac - fi - fi - else - echo "Package $package is already installed. BuildRequirement satisfied." - fi - fi - done - if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then - echo >&2 "Unable to install following packages and their dependencies:" - for pkg in "$NOT_INSTALLED_PACKAGES" - do - echo $pkg - done - remove_build_requires - exit 8 - fi + die "need rpm-getdeps tool" } init_repository() { @@ -2115,7 +2058,7 @@ init_rpm_dir() { cd "$TOP_DIR" init_repository ${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools init_repository projects/$TEMPLATES ../$TEMPLATES - for a in adapter builder fetchsrc_request compile repackage; do + for a in builder fetchsrc_request compile repackage; do ln -sf ../rpm-build-tools/${a}.sh $a done for a in md5; do @@ -2144,6 +2087,11 @@ if [ $# = 0 ]; then exit 1 fi +# stuff global $BUILDER_OPTS from env as args +if [ "$BUILDER_OPTS" ]; then + set -- "$BUILDER_OPTS" "$@" +fi + while [ $# -gt 0 ]; do case "${1}" in -4|-6) @@ -2377,7 +2325,7 @@ while [ $# -gt 0 ]; do -Upi | --update-poldek-indexes ) UPDATE_POLDEK_INDEXES="yes" shift ;; - --init-rpm-dir) + --init-rpm-dir|--init) COMMAND="init_rpm_dir" shift ;; -u | --try-upgrade ) @@ -2402,7 +2350,7 @@ while [ $# -gt 0 ]; do ;; --alt_kernel) shift - RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\"" + RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\" --define \"build_kernels $1\"" shift ;; --short-circuit) @@ -2651,6 +2599,7 @@ case "$COMMAND" in fi get_files $SOURCES $PATCHES check_md5 $SOURCES + fetch_build_requires ;; "update_md5" ) init_builder