--- src/tovid-init.in 2007-02-02 18:42:19.000000000 +0100 +++ src/tovid-init.in.new 2007-05-04 17:12:27.000000000 +0200 @@ -4,24 +4,24 @@ # Part of the tovid suite # ======================= # Define global (suite-wide) functions and variables -# for the tovid suite. +# for the tovid suite. # # Project homepage: http://www.tovid.org # # # Copyright (C) 2005 tovid.org -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later # version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Or see: @@ -128,7 +128,7 @@ echo ":" else echo "false" - fi + fi ;; "set" ) @@ -145,7 +145,7 @@ # ****************************************************************************** # Print a pretty (wrapped) notice message. -# Args: $@ == text string containing the message +# Args: $@ == text string containing the message # ****************************************************************************** function precho() { @@ -154,7 +154,7 @@ # ****************************************************************************** # Print error message, then exit. -# Args: $@ == text string containing error message +# Args: $@ == text string containing error message # ****************************************************************************** function exit_with_error() { @@ -261,11 +261,11 @@ if test ! -e "$FOP_OUTFILE"; then runtime_error "Couldn't create file: \"$FOP_OUTFILE\"" fi - + # File size in bytes FOP_LAST_SIZE=0 FOP_CUR_SIZE=$(du -b "$FOP_OUTFILE" | awk '{print $1}') - + # Keep looping until outfile stops getting bigger while test "$FOP_CUR_SIZE" -gt "$FOP_LAST_SIZE"; do # Display a changing line @@ -286,7 +286,7 @@ # (SLEEP_TIME defaults to 1s if unset) sleep ${SLEEP_TIME-"1s"} - FOP_LAST_SIZE=$FOP_CUR_SIZE + FOP_LAST_SIZE=$FOP_CUR_SIZE FOP_CUR_SIZE=$(du -b "$FOP_OUTFILE" | awk '{print $1}') done printf "\n\n" @@ -294,7 +294,7 @@ # ****************************************************************************** # Check to see if a dependency group exists, quit if missing -# Input args: +# Input args: # $1 = dependency group to check for; note that this can be a globally # defined group (below), or a space-separated list of executables # $2 = Descriptive message about why the user needs the dependencies @@ -330,7 +330,7 @@ # See what filesystem a directory is in # Input args: # $1 = directory to find filesystem type -# +# # Usage: # FS_TYPE=$(get_filesystem "$WORK_DIR") # ****************************************************************************** @@ -342,6 +342,19 @@ echo "$FILESYSTEM" } +# ****************************************************************************** +# Do floating point math with bc +# Input args: +# $1 = The math operation to perfrom, in a quoted string +# +# Usage: +# ANSWER=$(bc_math "$NUM1 + $NUM2") +# ****************************************************************************** +function bc_math() +{ + echo "scale=2; $1" | bc -l +} + # ****************************************************************************** # Countdown 5 seconds, then return @@ -390,21 +403,30 @@ # ****************************************************************************** INSTALLED_TOVIDS=$(type -a tovid 2>>/dev/null | awk '{print $NF}' | tr '\n' ' ') NUM_INSTALLED=0 +INSTALLED_VERS="" +INSTALLED_PREFS="" -# Only count non-links +# Only count tovids that are different versions for tovid in $INSTALLED_TOVIDS; do - if ! test -L $tovid; then - let "NUM_INSTALLED=NUM_INSTALLED+1" - fi + tovid_PREFIX=$(dirname $tovid) + tovid_VERSION=$(grep TOVID_VERSION $tovid_PREFIX/tovid-init | \ + awk -F '"' '{print $2}') + INSTALLED_VERS="$INSTALLED_VERS $tovid_VERSION" done +UNIQ_TOVIDS="$(echo $INSTALLED_VERS | tr ' ' '\n' | uniq)" +NUM_INSTALLED="$(echo $INSTALLED_VERS | tr ' ' '\n' | uniq | wc -l)" # Exit when there is more than one tovid installed if test $NUM_INSTALLED -ne 1; then - echo "Found $NUM_INSTALLED installations of tovid on your system!" + echo "Found $NUM_INSTALLED versions of tovid on your system!" echo "I won't run until there is only one of me :)" echo "Installed versions:" - for version in $INSTALLED_TOVIDS; do - echo " $version" + i=1 + while test $i -le $(echo "$INSTALLED_TOVIDS" | awk '{print NF}'); do + tovid_ver=$(echo $INSTALLED_VERS | awk '{print $'$i'}') + tovid_path=$(echo $INSTALLED_TOVIDS | awk '{print $'$i'}') + printf " %s (%s)\n" $tovid_ver $tovid_path + let "i=i+1" done echo "Exiting..." exit 1 @@ -442,7 +464,7 @@ #-kvcd #-ksvcd #-kdvd - + # TV system standard #-pal #-ntsc @@ -493,15 +515,15 @@ # No: add another group and fill it with members. # ************************************************************************* - # Required Dependencies + # Required Dependencies # ************************************************************************* core="grep sed md5sum mplayer mencoder mplex mpeg2enc yuvfps yuvdenoise ppmtoy4m mp2enc jpeg2yuv ffmpeg" # ************************************************************************* # Optional Dependencies # ************************************************************************* - # Optional dependencies are grouped according to the functionality they - # bring to tovid: menu creation, DVD creation, (S)VCD creation, and + # Optional dependencies are grouped according to the functionality they + # bring to tovid: menu creation, DVD creation, (S)VCD creation, and # post-processing. # -------------------------------------------------------------------------