Tiny Core Linux
General TC => Programming & Scripting - Unofficial => Topic started by: ixbrian on July 28, 2010, 10:33:56 PM
-
Here is a script that shows a dependency tree for any given extension:
#!/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:
$ ./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
-
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.
-
I updated the script in the original post with some of the improvements that Curaga added to the depinfo.sh script.
-
Would it be easy to show already installed extensions in green as in depinfo.sh ?
-
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.
-
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
-
Great tool, Brian. Thanks!
-
Thanks for the script, ixbrian
I realize this is an old thread but thanking someone doesn't go out of date!