WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Script to show extension dependency tree  (Read 5681 times)

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Script to show extension dependency tree
« on: July 28, 2010, 10:33:56 PM »
Here is a script that shows a dependency tree for any given extension:

Code: [Select]
#!/bin/sh
# deptree.sh - Copyright 2010 Brian Smith
# Some edits by Curaga
# Licensed under GPLv2 License
#
# 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.

alias grep="busybox grep"
alias wget="busybox wget"
alias seq="busybox seq"
alias printf="busybox printf"
alias expr="busybox expr"

get_dependencies()
{
        app=${1//KERNEL/$kernel}

        if [ "$notree" == "TRUE" ]; then
                for x in $(seq  1 $(( ${#indent} / 2 )) ); do
                        printf " "
                done           
        else
                echo -n "${BLUE}"
                echo -n "$indent"
                echo -n "-----"
                echo -n "${NORMAL}"
        fi
       
        if [ -f "$localtce"/optional/"$app" ]; then
                echo -n "${GREEN}"
        fi
       
        echo "$app"
        echo -n "${NORMAL}"

        deplist=`wget -q -O - "$MIRROR"/"$app.dep" 2>/dev/null`
        for depapp in $deplist; do
                indent="${indent}     |"
                get_dependencies $depapp
        done
        indent=${indent%     |}
}

while getopts d opts
do
        case $opts in
                d) notree="TRUE" ;;
        esac
done

shift $(expr $OPTIND - 1)

app=$1

if [ -n "$app" ]; then
        app=${app%.tcz}
        app="$app.tcz"
       
        localtce=`cat /opt/.tce_dir`
        . /etc/init.d/tc-functions
        getMirror
       
        kernel=`uname -r`
        indent=""
        get_dependencies $app
else
        echo ""
        echo "Specify extension in command line:"
        echo "Example:   $0 [-d] firefox.tcz"
        echo ""
        echo "To disable '|' and '-' display, use -d parameter"
        echo ""
fi

Here is the output the script produces:

Code: [Select]
$ ./deptree.sh firefox.tcz
-----firefox.tcz
     |-----libasound.tcz
     |-----curl.tcz
     |     |-----openssl-0.9.8.tcz
     |-----libnotify.tcz
     |     |-----dbus-glib.tcz
     |     |     |-----dbus.tcz
     |     |     |     |-----expat2.tcz
     |     |     |-----glib2.tcz
     |     |-----gtk2.tcz
     |     |     |-----atk.tcz
     |     |     |     |-----glib2.tcz
     |     |     |-----cairo.tcz
     |     |     |     |-----pixman.tcz
     |     |     |     |-----fontconfig.tcz
     |     |     |     |     |-----expat2.tcz
     |     |     |     |-----graphics-libs-1.tcz
     |     |     |-----pango.tcz
     |     |     |     |-----glib2.tcz
     |     |     |-----libxml2.tcz
     |     |     |-----Xorg-7.5-lib.tcz


« Last Edit: July 30, 2010, 10:54:15 PM by ixbrian »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Script to show extension dependency tree
« Reply #1 on: July 29, 2010, 11:27:03 AM »
Excellent!
I admit having made use of the intermediate version of depinfo.sh which included dep tree for this purpose. Not that it really was of any harm to see the extension sizes, once one would be aware that the total comes out wrong.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: Script to show extension dependency tree
« Reply #2 on: July 29, 2010, 10:41:06 PM »
I updated the script in the original post with some of the improvements that Curaga added to the depinfo.sh script. 

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Script to show extension dependency tree
« Reply #3 on: July 29, 2010, 11:33:24 PM »
Would it be easy to show already installed extensions in green as in depinfo.sh ?
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: Script to show extension dependency tree
« Reply #4 on: July 30, 2010, 08:06:29 AM »
Would it be easy to show already installed extensions in green as in depinfo.sh ?

Good idea, I will add this in and post a new version tonight. 

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: Script to show extension dependency tree
« Reply #5 on: July 30, 2010, 10:57:01 PM »
Updated original message with new script with the following changes:

-Installed extensions are listed in green
-You can specify extensions on the command line with or without ".tcz" file extension
-It displays an actual tree layout using "|" and "-" characters.  If you don't like this, specify the "-d" parameter to the script and it will just use spaces instead.    I'm not sure which one should be the default, the new tree layout with "|" and "-", or just spaces?   

Brian

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Script to show extension dependency tree
« Reply #6 on: July 31, 2010, 01:45:04 AM »
Great tool, Brian. Thanks!

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Script to show extension dependency tree
« Reply #7 on: March 27, 2018, 01:53:47 AM »
Thanks for the script, ixbrian

I realize this is an old thread but thanking someone doesn't go out of date!