#!/bin/bash # tsrpmv - wrapper around tsrpm VERBOSE=1 RPM_DIR=~/rpm RPM_CACHE=$RPM_DIR/cache RPM_SOURCES=$RPM_DIR/rpm-sources CMD_LINE=( --verbose ) TIME=time BOOL_COPY_PACKAGES= BOOL_DO_DIFF= BOOL_LIST_CROSS_INSTALLED_PACKAGES= BOOL_RECURSE_FOR_COMPILE_DEPS=1 BOOL_RESOLVE_INSTALL_DEPS= TSRPM_LAST=.tsrpm_last # file where tsrpm keeps last command invoked TSRPMV_ARCH=~/.tsrpmv_arch # file where we want to keep last arch used TSRPMV_TEMP=~/.tsrpmv_temp # dir for persistent storage (cache) TARGET_ARCH= PACKAGE_TRANSFORMS="libpng12=libpng:xrender=libXrender:xproto=xorg-x11-proto :x11=libX11:xau=libXau:xdmcp=libXdmcp:gtk+-2.0=gtk2:gobject-2.0=glib2 :freetype2=freetype:glib-2.0=glib2:libxml-2.0=libxml2:mimedir-1.0=libmimedir :dbus-glib-1=dbus-glib:dbus-1=dbus:gmodule-2.0=glib2 :ORBit-CosNaming-2.0=ORBit2:ORBit-2.0=ORBit2:pangoft2=pango :gdk-pixbuf-2.0=gtk2:xext=libXext:xft=libXft:librsvg-2.0=librsvg2 :fontutil=xorg-x11-font-utils:xtrans=xorg-x11-xtrans:ice=libICE:sm=libSM :xt=libXt-:xmu=libXmu:xpm=libXpm:xtst=libXtst:xres=libXres:xxf86vm=libXxf86vm :xi=libXi-:xmuu=libXmu:xrandr=libXrandr:xtrap=libXTrap :xbitmaps=xorg-x11-xbitmaps:fontenc=libfontenc:xextproto=xorg-x11-proto :xaw7=libXaw:xvmc=libXvMC:xv=libXv:gstreamer-plugins-base-0.10=gst-plugins-base" [ -r /etc/tsrpmvrc ] && . /etc/tsrpmvrc [ -r ~/.tsrpmvrc ] && . ~/.tsrpmvrc function _is_in_cmd_line { # returns 0 if $@ is in the command line or 1 if it is not # global CMD_LINE local a=0; while [ $a -le ${#CMD_LINE[@]} ]; do [ "${CMD_LINE[$a]}" = "$@" ] && return 0 ((a++)) done return 1 } function _replace_cmd_line { # replace any args that match ${1}* with ${[2..n]} # returns 0 if args were replaced or 1 if none were replaced # global CMD_LINE local a=0 local b="$1" shift local c=1 while [ $a -le ${#CMD_LINE[@]} ]; do if [ "${CMD_LINE[$a]:0:${#b}}" = "$b" ]; then einfo 4 `basename $0`: replacing ${CMD_LINE[$a]} on command line with "\033[01;32m$@\033[00m" CMD_LINE[$a]="$@" c=0 fi ((a++)) done return $c } function _delete_from_cmd_line { # delete any args that match ${1}* # returns 0 if args were deleted or 1 if none were deleted # global CMD_LINE local a=0 local b="$1" shift local c=1 while [ $a -le ${#CMD_LINE[@]} ]; do if [ "${CMD_LINE[$a]:0:${#b}}" = "$b" ]; then einfo 4 `basename $0`: deleting "\033[01;32m$b\033[00m" on command line unset CMD_LINE[$a] c=0 fi ((a++)) done return $c } function _add_to_cmd_line { # global CMD_LINE local num_args=${#CMD_LINE[@]} CMD_LINE[$num_args]="$@" einfo 4 `basename $0`: adding "\033[01;32m$@\033[00m" to command line } function _process_args { # arg processing # global CMD_LINE ARGV="$@" # preserve original command line local a # find target automatically, if we can [ -e $TSRPM_LAST ] && a=`tr ' ' '\n' < $TSRPM_LAST | grep -e --target` if [ "$a" != "" ]; then # no target specified TARGET_ARCH=`echo $a | cut -d = -f 2` einfo 2 `basename $0`: "assuming TARGET_ARCH of \033[01;32m$TARGET_ARCH\033[00m per $TSRPM_LAST" _add_to_cmd_line "$a" elif [ -e $TSRPMV_ARCH -a "$TARGET_ARCH" = "" ]; then TARGET_ARCH=`cat $TSRPMV_ARCH` einfo 2 `basename $0`: "assuming TARGET_ARCH of \033[01;32m$TARGET_ARCH\033[00m per $TSRPMV_ARCH" _add_to_cmd_line "--target=$TARGET_ARCH" fi while [ "$#" -ge 1 ]; do case "$1" in -b?|--build|-b|-diff|--diff) if [ "$1" = --diff -o "$1" = -diff ]; then _add_to_cmd_line -bp BOOL_DO_DIFF=1 elif [ "$1" = "-b" ]; then _add_to_cmd_line -ba else _add_to_cmd_line "$1" fi perl -pi -e 's,-\%\(\%\{__id_u\} -n\),,g' *.spec # filter out f7 stuff tsrpm doesn't like perl -pi -e 's,-\%\(\%\{__id_u\}\),,g' *.spec # filter out f7 stuff tsrpm doesn't like perl -pi -e 's,-\%\(id -un\),,g' *.spec # filter out f7 stuff tsrpm doesn't like shift if [ "${1%%.spec}" = "$1" ]; then # NOT a spec file if [ `ls *.spec | wc -l` = 1 ]; then # only one spec file, add it _add_to_cmd_line *.spec fi fi ;; -ee|--enchanced-extract) _add_to_cmd_line --dir=$RPM_SOURCES _add_to_cmd_line --extract shift if [ "$#" -ge 1 ]; then # no RPMs on cmd line? get all SRPMs from home dir a="$@" shift "$#" # empty out arg list else a=~/*.src.rpm fi einfo 4 after checking for args on command line, arg list is now "$a" c= for b in $a; do # add .src.rpm if args dont end in src.rpm if [ "${b%%.src.rpm}" = "$b" ]; then # args DO NOT end in .src.rpm dummy=$(echo ${b}*.src.rpm) einfo 2 `basename $0`: changing --install-cross args from $b to "\033[01;32m${dummy}\033[00m" c="$c $dummy" else c="$c $b" fi done einfo 4 after checking for .src.rpm suffixes, arg list is now"$c" a= for b in $c; do # look in ~ and RPM_CACHE if they do not exist and no path specified if [ ! -e "$b" -a "$b" = "${b##*/}" ]; then # file doesnt exist and no path specified if [ -e `echo ~/$b | tr ' ' '\n' | head -n 1` ]; then # as long as there is at least one match einfo 2 `basename $0`: changing --install-cross args from $b to "\033[01;32m~/$b\033[00m" a="$a ~/$b" elif [ -e `echo $RPM_CACHE/$b | tr ' ' '\n' | head -n 1` ]; then einfo 2 `basename $0`: changing --install-cross args from $b to "\033[01;32m$RPM_CACHE/$b\033[00m" a="$a $RPM_CACHE/$b" else ewarn 2 `basename $0`: $b not found\! skipping ... fi else a="$a $b" fi done einfo 4 after checking whether the files exist, arg list is now "$a" \($a\) for d in $a; do echo $d | grep -q -s '*' && continue # dont process it if it still has wildcards in it mv $d $RPM_CACHE 2> /dev/null && \ einfo 2 `basename $0`: moving "\033[01;32m`basename $d`\033[00m" from `dirname $d` to $RPM_CACHE _add_to_cmd_line $RPM_CACHE/`basename $d` done ;; -ic|-ci|--install-cross|-i|--install) [ "$1" = -i -o "$1" = --install ] && _add_to_cmd_line --install || \ _add_to_cmd_line --install-cross shift NUM_PACKAGES=0 while [ "${1:0:1}" != - -a "$1" != "" ]; do # for each non-option arg if [ "${1%%.rpm}" = "$1" ]; then # args DO NOT end in .rpm a=$(echo ${1}*.$TARGET_ARCH.rpm) # add .rpm einfo 2 `basename $0`: no rpm extension, changing $1 to "\033[01;32m${a}\033[00m" else a="$1" fi # look in RPM_CACHE if they arent found for b in ${a}; do if [ ! -e "$b" ]; then einfo 3 `basename $0`: file "$b" does not exist, changing to "\033[01;32m$RPM_CACHE/$b\033[00m" b="$RPM_CACHE/$b" else b="./$b" # we need a dirname for var g, below fi # expand wildcards so that only the latest [== most recently added] version of a package is included f= g="${b%/*}" # dirname of b # save output in var h h=$( ls -t $b | xargs -n 1 rpm -qp --queryformat '%{NAME} %{VERSION} %{RELEASE}\n' \ | while read c d e; do # while loops cause a subshell, cant add it if ! echo "$f" | grep -q -s ":$c:"; then # not already seen einfo 4 `basename $0`: adding "$g/$c-$d-$e" echo $g/$c-$d-$e.$TARGET_ARCH.rpm # cant add it here cuz we are in a subshell f="$f:$c:" else ewarn 4 `basename $0`: not adding "$g/$c-$d-$e" as a newer one has already been added fi done # while read c d e ) for c in $h; do # for loops dont cause a subshell - add it now if ! _is_in_cmd_line $c; then _add_to_cmd_line $c ((NUM_PACKAGES++)) # recurse to find 1/10th of the number of packages we have, but not less than 3 NUM_DEPS_TO_RECURSE=$[ $NUM_PACKAGES / 10 ] [ "$NUM_DEPS_TO_RECURSE" -lt 3 ] && NUM_DEPS_TO_RECURSE=3 einfo 4 `basename $0`: number of packages to add now $NUM_PACKAGES, \ will recurse for $NUM_DEPS_TO_RECURSE packages fi done done # for b in $a shift done # for each non-option args [ 0"$NUM_PACKAGES" -gt 0 ] && \ einfo 3 `basename $0`: number of packages to add now "\033[01;32m$NUM_PACKAGES\033[00m", \ will recurse for "\033[01;32m$NUM_DEPS_TO_RECURSE\033[00m" packages ;; --target=*) _replace_cmd_line --target "$1" || _add_to_cmd_line "$1" TARGET_ARCH=`echo $1 | cut -d = -f 2` einfo 2 `basename $0`: "found explicit TARGET_ARCH of \033[01;32m$TARGET_ARCH\033[00m on command line" shift ;; -t) _replace_cmd_line --target "--target=$2" || _add_to_cmd_line "--target=$2" TARGET_ARCH="$2" einfo 2 `basename $0`: "found explicit TARGET_ARCH of \033[01;32m$TARGET_ARCH\033[00m on command line" shift 2 ;; --list-cross-installed-packages|-l[cip][cip][cip]|--list-cross-install|-lci|--list-cross-packages|-lcp) BOOL_LIST_CROSS_INSTALLED_PACKAGES=1 shift ;; --copy|-cp) BOOL_COPY_PACKAGES=1 shift ;; -ncd|--nocompiledeps|--no-compile-deps) BOOL_RECURSE_FOR_COMPILE_DEPS= shift ;; -whichrpm|-which-rpm|--whichrpm|--which-rpm|-w) shift TSRPMV_TEMP_PROVIDES=$TSRPMV_TEMP/rpm_provides mkdir -p $TSRPMV_TEMP_PROVIDES || _die Cannot make $TSRPMV_TEMP_PROVIDES! Egads! dying. cd $RPM_CACHE RESULTS= SEARCH_REGEX=$(echo $1 | tr '()' . | sed -e 's, >=.*,,g') einfo 4 SEARCH_REGEX is now "\033[01;32m$SEARCH_REGEX\033[00m" # tsrpmv smarts: if LC_MESSAGES is needed, pick glibc-common # if echo $SEARCH_REGEX | grep -q -s LC_MESSAGES$; then # einfo 2 `basename $0`: choosing glibc-common over all others # echo glibc-common # exit 0 # fi for a in *.$TARGET_ARCH.rpm ; do # *.src.rpm einfo 3 checking $a ... b="$TSRPMV_TEMP_PROVIDES/${a/.rpm/.txt}" if [ "$a" -nt "$b" ]; then ebegin 4 regenerating rpm_provides cache for "\033[01;32m$a\033[00m" rpm -qpl --nosignature --provides "$a" | sed -e 's, *,,g' | \ sed -e 's,=.*,,g' > "$b" eend 4 $? fi if grep -q -s ^"$SEARCH_REGEX"$ "$b"; then RESULTS="$RESULTS $a" fi done if [ "$RESULTS" = "" ]; then eerror 2 Egads! no results found! exit 1 fi einfo 2 all results: "\033[01;32m$RESULTS\033[00m" # tsrpmv smarts: if filesystem is one of the results, just pick that one if ls -1t $RESULTS | grep -q -s filesystem; then einfo 2 `basename $0`: choosing filesystem over all others ls -1t $RESULTS | grep filesystem | head -n 1 exit 0 fi # tsrpmv smarts: if glibc is one of the results, just pick that one if ls -1t $RESULTS | grep -q -s ^glibc; then einfo 2 `basename $0`: choosing glibc over all others ls -1t $RESULTS | grep glibc | head -n 1 exit 0 fi # tsrpmv smarts: if *-devel-* is one of the results, don't pick that one if echo $RESULTS | grep -q -s -e -devel- && \ [ `ls -1t $RESULTS | grep -v -e -devel- | wc -w` -ge 1 ]; then einfo 2 `basename $0`: removing devel package from results ls -1t $RESULTS | grep -v -e -devel- | head -n 1 exit 0 fi # tsrpmv smarts: if timesys-init is one of the results, don't pick that one if echo $RESULTS | grep -q -s timesys-init && \ [ `ls -1t $RESULTS | grep -v timesys-init | wc -w` -ge 1 ]; then einfo 2 `basename $0`: removing timesys-init from results ls -1t $RESULTS | grep -v timesys-init | head -n 1 exit 0 fi # tsrpmv smarts: if busybox is one of the results, don't pick that one if echo $RESULTS | grep -q -s busybox && \ [ `ls -1t $RESULTS | grep -v busybox | wc -w` -ge 1 ]; then einfo 2 `basename $0`: removing busybox from results ls -1t $RESULTS | grep -v busybox | head -n 1 exit 0 fi ls -1t $RESULTS | head -n 1 # show only the newest entry if more than one exit 0 ;; -q|-quiet|--quiet) VERBOSE=-1 _is_in_cmd_line --verbose && _delete_from_cmd_line --verbose shift ;; -v|--verbose) ((VERBOSE++)) einfo 0 `basename $0`: VERBOSITY now "\033[01;32m$VERBOSE\033[00m" _is_in_cmd_line --verbose || _add_to_cmd_line --verbose shift ;; -vv) ((VERBOSE++)) ((VERBOSE++)) einfo 0 `basename $0`: VERBOSITY now "\033[01;32m$VERBOSE\033[00m" _is_in_cmd_line --verbose || _add_to_cmd_line --verbose shift ;; -vvv) ((VERBOSE++)) ((VERBOSE++)) ((VERBOSE++)) einfo 0 `basename $0`: VERBOSITY now "\033[01;32m$VERBOSE\033[00m" _is_in_cmd_line --verbose || _add_to_cmd_line --verbose shift ;; -vvvv) ((VERBOSE++)) ((VERBOSE++)) ((VERBOSE++)) ((VERBOSE++)) einfo 0 `basename $0`: VERBOSITY now "\033[01;32m$VERBOSE\033[00m" _is_in_cmd_line --verbose || _add_to_cmd_line --verbose shift ;; -h|--help) einfo 0 $0 einfo 0 attempts to guess target from .tsrpm_last einfo 0 opts are: einfo 0 ' --build or -b or -b?' einfo 0 ' --copy or -cp' einfo 0 ' --diff' einfo 0 ' --enhanced-extract or -ee' einfo 0 ' --install or -i' einfo 0 ' --install-cross or -ic' einfo 0 ' --list-cross-installed-packages or -lcip' einfo 0 ' --no-compile-deps or -ncd' einfo 0 ' --target or -t' einfo 0 ' --verbose or -v' einfo 0 ' --whichrpm or -w' einfo 0 ' ' and --help of course\! einfo 0 tsrpm --help: tsrpm --help exit 1 ;; *) _add_to_cmd_line "$1" shift ;; esac done } function _list_cross_installed_packages { local a ls install-cross/*/manifest | grep -v -e -[0-9] | while read a; do echo -e \\t\\t\'$a\', done exit 0 } function _copy_packages { local a einfo 1 "copying packages into \033[01;32m$RPM_CACHE\033[00m" for a in */RPMS/*.rpm */SRPMS/*.src.rpm; do ebegin 2 "`basename $a`" cp "$a" $RPM_CACHE eend 2 $? done exit 0 } function _dep_transform { # transform the pkg-config name to rpm name # global PACKAGE_TRANSFORMS local b c d b=$(echo $1 | sed s,^No.,,g | cut -d ' ' -f 2 | tr -d \\\',) c=$(echo $PACKAGE_TRANSFORMS | tr : '\n' | grep ^$b=) einfo 5 transforming $b einfo 5 found this in transform table: $c if [ "$c" != "" ]; then d=$(echo $c | cut -d = -f 2) einfo 4 changing $b to "\033[01;32m$d\033[00m" b=$d fi echo $b return } function _recurse_for_deps { # attempt to find them and install # global $0 $ARGV einfo 0 `basename $0`: attempting to find package\(s\) $@ einfo 0 -- spawning new `basename $0` instance ------------------------------------------ if ! eval $0 -ic "$@"; then einfo 0 -- returning from new `basename $0` instance ------------------------------------ eerror 0 failed\! return fi einfo 0 -- returning from new `basename $0` instance ------------------------------------ einfo 0 succeeded, restarting with $0 $ARGV einfo 0 -- chaining to new `basename $0` instance --------------------------------------- exec $0 $ARGV } function die { eerror 0 "$*" # read exit 1 } function eerror { # debug_level statement ... if [ $VERBOSE -ge $1 ]; then shift echo -e " \033[01;31m*\033[00m $*" >&2 fi } function ewarn { # debug_level statement ... if [ $VERBOSE -ge $1 ]; then shift echo -e " \033[01;33m*\033[00m $*" >&2 fi } function einfo { # debug_level statement ... if [ $VERBOSE -ge $1 ]; then shift echo -e " \033[01;32m*\033[00m $*" >&2 fi } function ebegin { # verbosity text local a if [ $VERBOSE -ge $1 ]; then shift a=" \033[01;32m*\033[00m $* " echo -ne "${a:0:91} " >&2 fi } function eend { # verbosity exit_code if [ $VERBOSE -ge $1 ]; then shift if [ "$1" = 0 -o "$1" = "" ]; then echo -e "[\033[01;32m ok \033[00m]" >&2 else echo -e "[\033[01;31mfail\033[00m]" >&2 fi fi } function eendyesno { # verbosity exit_code if [ $VERBOSE -ge $1 ]; then shift if [ "$1" = 0 -o "$1" = "" ]; then echo -e "[\033[01;32m yes\033[00m]" >&2 else echo -e "[\033[01;33m no \033[00m]" >&2 fi fi } # main() LOGFILE=`mktemp /tmp/tsrpmv.XXXXXX` VERSION=`tsrpm --version | head -n 1` [ "$1" = -q ] || einfo 0 $VERSION, latest is 1.37, logging to $LOGFILE _process_args "$@" || die echo $TARGET_ARCH > $TSRPMV_ARCH einfo 1 tsrpm ${CMD_LINE[@]} DISPLAY_COMPILATION=1 [ "$BOOL_LIST_CROSS_INSTALLED_PACKAGES" ] && _list_cross_installed_packages [ "$BOOL_COPY_PACKAGES" ] && _copy_packages shopt -s extglob $TIME tsrpm ${CMD_LINE[@]} 2>&1 | while read a; do echo "$a" >> $LOGFILE while [ "${a:0:2}" = "++" ]; do # strip multiple +s a="${a:1}" done if [ "$PREPEND" != "" ]; then a="${PREPEND}${a}" einfo 4 `basename $0`: Prepending $PREPEND PREPEND= fi if echo "$a" | grep -q -s -i '^checking.*\.\.\. + /'; then PREPEND=`echo "$a" | sed 's,\.\.\. .*,... ,'` einfo 4 `basename $0`: setting PREPEND to $PREPEND continue fi case "$a" in 'tsrpm: *** configuring in '*) echo -e "\033[01;32m$a\033[00m" CONFIGURE_DIR="${a:26}" einfo 4 `basename $0`: setting CONFIGURE_DIR to $CONFIGURE_DIR echo $CONFIGURE_DIR > $LOGFILE.in_configure # dirty hack ;; tsrpm*) echo -e "\033[01;32m$a\033[00m" ;; '+ export '*|'+ cd '*|'+ unset '*|'+ echo '*|'+ set '*|'+ return '*|'+ local '*|'+ shift'|'+ shift '*|'+ eval '*) : dont echo ;; '+ umask '*|'+ [[ '*|'+ :'|'+ : '*|'+ declare '*|'+ setopt '*|'+ pwd'|'+ case '*|'+ TSRPM_'*|'+ RPM_'*) : dont echo ;; '+ push '*|'+ '*(let )+([A-Za-z_])*(=|++)*|'+ ispgm '*|*tshint|'+ for '[af]' in '??'$@'??|'+ for f in '??'${'*|'+ echo') : dont echo ;; '+ '?\[?*|'+ exit'|'+ exit 0'|'+ tsrpm_'*|'*** done'|'+ (( i'@(++|<=1|=0)' ))'*|'+ eval') : dont echo ;; '+ continue'|'+ '?=?|'+ test_verbosity'*|'+ env_to_array '*|'+ sed '*|'+ arr=hints'|'+ dostdhints '*|'+ set_rpm_'*) : dont echo ;; '+ STATUS='*|'+ rm -rf '*|'+ tar -xf -'*) : dont echo ;; '+ autoconf'*|'+ automake'*|'+ aclocal'*|'+ libtoolize'*|'+ configure'*|'+ make'*) ebegin 0 Running "${a:2}" eend 0 ;; '+ ./configure'*) DISPLAY_COMPILATION= einfo 3 `basename $0`: turning off compilation display einfo 0 "${a:2}" ;; '+ /usr/bin/ccache'*|'+ /opt/timesys/toolchains/'*) [ "$DISPLAY_COMPILATION" = 1 ] && einfo 0 "${a:2}" ;; 'configure: creating'*config.status) rm $LOGFILE.in_configure # dirty hack DISPLAY_COMPILATION=1 einfo 3 `basename $0`: turning on compilation display echo $a ;; '+ '*) einfo 0 "${a:2}" ;; '*** '*) einfo 0 "${a:4}" ;; 'Making all in '*|'Patch #'*) einfo 0 "$a" ;; *'(cached) yes') b=$[ ${#a} - 4 ] ebegin 0 ${a:0:$b} eendyesno 0 ;; *'(cached) no') b=$[ ${#a} - 3 ] ebegin 0 ${a:0:$b} eendyesno 0 1 ;; *'... yes') b=$[ ${#a} - 7 ] ebegin 0 ${a:0:$b} eendyesno 0 ;; *'... ok') b=$[ ${#a} - 6 ] ebegin 0 ${a:0:$b} eend 0 ;; *'... no') b=$[ ${#a} - 6 ] ebegin 0 ${a:0:$b} eendyesno 0 1 ;; [cC]hecking*) einfo 0 "$a" ;; *[Ww][Aa][Rr][Nn]?[Nn][Gg]*|/*.rpm) echo -e "\033[01;33m$a\033[00m" ;; Package*not?found*|No?package*found) echo -e "\033[01;33m$a\033[00m" b=`_dep_transform "$a"` if [ "$BOOL_RECURSE_FOR_COMPILE_DEPS" = 1 ]; then einfo 0 `basename $0`: attempting to find package $b einfo 0 -- spawning new `basename $0` instance ------------------------------------------ if ! eval $0 -ic $b; then einfo 0 -- returning from new `basename $0` instance ------------------------------------ eerror 0 failed\! continue fi einfo 0 -- returning from new `basename $0` instance ------------------------------------ einfo 0 succeeded, restarting with $0 $ARGV einfo 0 -- chaining to new `basename $0` instance --------------------------------------- exec $0 $ARGV fi ;; Executing*|Building?target?platform*|Building?for?target*|*:?starting?at*|*': *** '*) echo -e "\033[01;36m$a\033[00m" ;; error*|*ld:?cannot?find*|*No?such?file?or?directory*|*fg:?no?job?control*) echo -e "\033[01;31m$a\033[00m" if [ "$a" = "error: Failed dependencies:" ]; then einfo 3 `basename $0`: turning on dependency resolution BOOL_RESOLVE_INSTALL_DEPS=1 RESOLVED_DEPS= UNRESOLVED_DEPS= DEP_LIST= fi ;; *is?needed?by*) b=$(echo $a | sed -e 's,.is.needed.by.*,,g') # dep c=$(echo $a | sed -e 's,.*is.needed.by.,,g') # package echo -e "\033[01;32m$b\033[00m" is needed by $c if [ "$BOOL_RESOLVE_INSTALL_DEPS" = 1 ]; then d=$($0 -q -t $TARGET_ARCH --whichrpm "$b") if [ "$d" != "" ]; then echo -e " ..." and is provided by "\033[01;32m$d\033[00m" ((RESOLVED_DEPS++)) DEP_LIST="$DEP_LIST $d" # chain to new instance after resolving only $NUM_DEPS_TO_RECURSE deps # this makes the entire process go faster - jwc 06Nov2008 if [ "$RESOLVED_DEPS" -ge "$NUM_DEPS_TO_RECURSE" ]; then einfo 0 calling `basename $0` $ARGV $DEP_LIST einfo 0 -- chaining to new `basename $0` instance ------------------------------------------ # ewarn 0 "(ENTER to continue)" # read <&2 exec $0 $ARGV $DEP_LIST fi # enough deps to resolve? go for it! else ewarn 2 but could not be resolved! ((UNRESOLVED_DEPS++)) fi fi ;; "Command exited with non-zero status "*) EXIT_CODE="${a:36}" echo -e "\033[01;31m$a\033[00m" eerror 4 EXIT_CODE=$EXIT_CODE if [ "$BOOL_RESOLVE_INSTALL_DEPS" = 1 ]; then # install deps found? if [ 0"$RESOLVED_DEPS" -ge 1 ]; then # as long as some were resolved, try again if [ 0"$UNRESOLVED_DEPS" -ge 1 ]; then ewarn 1 `basename $0`: warning: some dependencies were unresolved. your install may not complete. fi DEP_LIST=$(echo $DEP_LIST | tr ' ' '\n' | sort -u) einfo 0 calling `basename $0` $ARGV $DEP_LIST einfo 0 -- chaining to new `basename $0` instance ------------------------------------------ # ewarn 0 "(ENTER to continue)" # read <&2 exec $0 $ARGV $DEP_LIST else # none were resolved. error out. eerror 0 `basename $0`: no dependencies could be resolved. Please resolve manually eerror 0 or use --nodeps on the command line. # die unresolvable dependencies fi # some resolved? fi # install deps found? ;; *) echo "$a" ;; esac done # dirty hack cuz we can't keep any variables from inside the while loop EXIT_CODE=`tail -n 19 $LOGFILE | grep ^Command.exited.with.non-zero.status | cut -b 36-` [ "$EXIT_CODE" = "" ] && EXIT_CODE=0 if [ "$EXIT_CODE" -gt 0 ]; then if [ -r $LOGFILE.in_configure ]; then einfo 0 tsrpm exited with $EXIT_CODE in configure, trying to find relevant config.log section CONFIGURE_DIR=`cat $LOGFILE.in_configure` rm $LOGFILE.in_configure einfo 0 $CONFIGURE_DIR/config.log if [ -r $CONFIGURE_DIR/config.log ]; then echo >&2 einfo 0 -------- begin config.log snippet -------- b=`grep -B 999 '## Cache variables.' $CONFIGURE_DIR/config.log | \ grep '^configure:.*: result: yes' | tail -n 1 | cut -d : -f 1-2` # configure:2519 grep -B 999 '## Cache variables.' $CONFIGURE_DIR/config.log | \ grep -A 999 ^$b: | tail -n +2 | grep -v ^'## ' | while read a; do case $a in Package*not?found*|No?package*found) echo -e "\033[01;33m$a\033[00m" b=`_dep_transform "$a"` [ "$BOOL_RECURSE_FOR_COMPILE_DEPS" = 1 ] && \ _recurse_for_deps $b ;; *) echo "$a" ;; esac done einfo 0 -------- end config.log snippet -------- fi else eerror 0 tsrpm exited with $EXIT_CODE fi fi if [ "$BOOL_DO_DIFF" = 1 ]; then einfo 0 `basename $0`: generating diff diff -Naur *.spec $TARGET_ARCH/SPECS | more fi einfo 0 complete tsrpm logfile is in "\033[01;32m$LOGFILE\033[00m" exit $EXIT_CODE