WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Recursive Dependency size.  (Read 13212 times)

Offline richardh

  • Newbie
  • *
  • Posts: 17
Recursive Dependency size.
« on: July 27, 2010, 08:06:20 AM »
Is there anything in AppBrowser/AppAudit which will tell me the size of an extention and all of its depedencies? If not does anyone have a script which will do this? I have searched the forums but I couldn't find anything relevant.

Many thanks,

Richard.

« Last Edit: July 28, 2010, 07:13:28 AM by richardh »

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: Recursive Dependency size.
« Reply #1 on: July 27, 2010, 01:04:31 PM »
Here is a script that will calculate the total size including dependencies.  

Code: [Select]
#!/bin/sh
# depinfo.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 awk="busybox awk"
alias wget="busybox wget"
alias dc="busybox dc"
alias nc="busybox nc"

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

   case "$tempfile" in
   *":${app}:"*)
   ;;
   *)
      tempfile="${tempfile}${app}:"
      size=`echo -e "HEAD /$server_path/$app HTTP/1.0\n" | nc $server 80 | grep "^Content-Length" | awk '{print $2'}`

      case $size in
      [0-9]*)
         sizemb=`dc $size 1024 / 1024 / p`
         if [ -f "$localtce"/optional/"$app" ]; then
                 totalsize_installed=$(($totalsize_installed + $size))
                 echo -n "${GREEN}"
                 printf "%-40s" $app
                 echo -n "${NORMAL}"
                 printf " size(bytes): %10d, %6.2f MB\n" $size $sizemb
         else
                 totalsize_needed=$(($totalsize_needed + $size))
                 printf "%-40s size(bytes): %10d, %6.2f MB\n" $app $size $sizemb
         fi
         deplist=`wget -q -O - "$MIRROR"/"$app.dep" 2>/dev/null`
         for depapp in $deplist; do
            get_dependencies $depapp
         done
      ;;
      *)
         printf "%-40s Error, not found \n" $app
      ;;
      esac
   ;;
   esac
}

app=$1

if [ -n "$app" ]; then
   app=${app%.tcz}
   app="$app.tcz"

   localtce=`cat /opt/.tce_dir`
   . /etc/init.d/tc-functions
   getMirror
   server=${MIRROR#http://}
   server_path=${server#*/}
   server=${server%%/*}

   kernel=`uname -r`
   totalsize_needed=0
   totalsize_installed=0
   tempfile=":"
   get_dependencies $app

   totalsize=$(($totalsize_needed + $totalsize_installed))
   totalsizemb=`dc $totalsize 1024 / 1024 / p`
   totalsize_neededmb=`dc $totalsize_needed 1024 / 1024 / p`
   totalsize_installedmb=`dc $totalsize_installed 1024 / 1024 / p`

   printf "\n           Total size (bytes)     %10d, %6.2f MB\n" $totalsize $totalsizemb
   printf "    (Not currently installed)     %10d, %6.2f MB\n" $totalsize_needed $totalsize_neededmb
   printf "          (Already installed)     %10d, %6.2f MB\n\n" $totalsize_installed $totalsize_installedmb
else
   echo "Specify extension in command line:"
   echo "Example:   $0 firefox.tcz"
fi

When you run it, it produces the following output:

Code: [Select]
$ ./depinfo.sh firefox.tcz
firefox.tcz                              size(bytes):   13664256,  13.03 MB
libasound.tcz                            size(bytes):     372736,   0.36 MB
curl.tcz                                 size(bytes):     380928,   0.36 MB
openssl-0.9.8.tcz                        size(bytes):    1118208,   1.07 MB
libnotify.tcz                            size(bytes):      94208,   0.09 MB
dbus-glib.tcz                            size(bytes):     167936,   0.16 MB
dbus.tcz                                 size(bytes):     520192,   0.50 MB
expat2.tcz                               size(bytes):      77824,   0.07 MB
glib2.tcz                                size(bytes):    1040384,   0.99 MB
gtk2.tcz                                 size(bytes):    3182592,   3.04 MB
atk.tcz                                  size(bytes):      53248,   0.05 MB
cairo.tcz                                size(bytes):     274432,   0.26 MB
pixman.tcz                               size(bytes):     200704,   0.19 MB
fontconfig.tcz                           size(bytes):     135168,   0.13 MB
graphics-libs-1.tcz                      size(bytes):     790528,   0.75 MB
pango.tcz                                size(bytes):     405504,   0.39 MB
libxml2.tcz                              size(bytes):     696320,   0.66 MB
Xorg-7.5-lib.tcz                         size(bytes):     204800,   0.20 MB

Total size (bytes):   23379968,  22.30 MB

« Last Edit: August 08, 2010, 10:43:45 AM by ixbrian »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Recursive Dependency size.
« Reply #2 on: July 27, 2010, 04:14:06 PM »
Code: [Select]
tc@box:~$ depsize.sh firefox.tcz
/home/tc/.local/bin/depsize.sh: line 38: getMirror: not found
expr: syntax error
firefox.tcz          size(bytes): sh: : invalid number
         0

Total size:  bytes
:'(
Using 2.10, in case that would matter
"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: Recursive Dependency size.
« Reply #3 on: July 27, 2010, 05:54:31 PM »
Updated script, it will now display an indented tree listing of the dependencies
                                                                               
As is, the script will only work on Tiny Core 3.x.   If you want to run it on 2.x, try replacing the 2 lines:
. /etc/init.d/tc-functions
getMirror
                 
With this single line:
MIRROR="http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/tcz"

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Recursive Dependency size.
« Reply #4 on: July 27, 2010, 06:42:11 PM »
Updated script, it will now display an indented tree listing of the dependencies
Umm, and where is the update?  ???
Quote
As is, the script will only work on Tiny Core 3.x.   If you want to run it on 2.x, try replacing the 2 lines:
. /etc/init.d/tc-functions
getMirror
                 
With this single line:
MIRROR="http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/tcz"
Heh, i was halfway there having tried just "http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux" instead :P

Seems to work fine now with this modification.  :)

Thank you so much for this invaluable tool, this is brilliant!  ;D

I think this will help a lot in taking decisions of installing apps and also might even be of use for discussions in the forum, when now instead of estimating/speculating one could just quickly check total size including all deps. I take it all deps are proceeded recursively.
"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: Recursive Dependency size.
« Reply #5 on: July 27, 2010, 07:56:16 PM »
Quote
Umm, and where is the update?  ???

See my original post in this thread, I just updated it with the updated script. 

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Recursive Dependency size.
« Reply #6 on: July 27, 2010, 08:48:20 PM »
Ohhh... thank you, gotcha now! ::)

However, i made following observation:
An extension may be listed multiply in proceeding of recursive deps.
A rather random example: When doing "./depsize.sh epiphany.tcz", e.g. gtk2.tcz (and in consequence all its deps) is listed in multiple instances. Haven't made any calculations, but suspecting all instances will be added to total.
"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: Recursive Dependency size.
« Reply #7 on: July 27, 2010, 10:14:09 PM »
Ohhh... thank you, gotcha now! ::)

However, i made following observation:
An extension may be listed multiply in proceeding of recursive deps.
A rather random example: When doing "./depsize.sh epiphany.tcz", e.g. gtk2.tcz (and in consequence all its deps) is listed in multiple instances. Haven't made any calculations, but suspecting all instances will be added to total.

Good catch.   I posted a new version that fixes this (and I also dropped the dependency tabbed tree display)

Offline Arslan S.

  • Hero Member
  • *****
  • Posts: 825
Re: Recursive Dependency size.
« Reply #8 on: July 28, 2010, 03:19:56 AM »
thanks great tool, i have a bug to report :)

your script does not handle KERNEL entries in dep files, you should replace KERNEL with `uname -r`
Code: [Select]
tc@box:~$ ./depinfo lm_sensors.tcz
lm_sensors.tcz                                     size(bytes):     131072
expr: syntax error
hwmon-KERNEL.tcz                                   size(bytes): sh: : invalid number
         0

Total size:  bytes

Offline richardh

  • Newbie
  • *
  • Posts: 17
Re: Recursive Dependency size.
« Reply #9 on: July 28, 2010, 04:03:28 AM »
Thanks for that - this will be very useful in comparing packages.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Recursive Dependency size.
« Reply #10 on: July 28, 2010, 05:52:15 AM »
thanks great tool, i have a bug to report :)

your script does not handle KERNEL entries in dep files, you should replace KERNEL with `uname -r`
Code: [Select]
tc@box:~$ ./depinfo lm_sensors.tcz
lm_sensors.tcz                                     size(bytes):     131072
expr: syntax error
hwmon-KERNEL.tcz                                   size(bytes): sh: : invalid number
         0

Total size:  bytes
Works fine here in 2.10, but i note the difference in syntax of deps between extensions of 2.x and 3.x
Code: [Select]
tc@box:~$ depinfo.sh lmsensors.tcz
lmsensors.tcz                                      size(bytes):     135168
perl5.tcz                                          size(bytes):   12529664
hwmon-2.6.29.1-tinycore.tcz                        size(bytes):     507904

Total size: 13172736 bytes
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Recursive Dependency size.
« Reply #11 on: July 28, 2010, 06:02:12 AM »
Would be more readable to display size in kbyte or Mbyte and using thousands separator.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Recursive Dependency size.
« Reply #12 on: July 28, 2010, 06:56:20 AM »
I just use
Code: [Select]
dc $bytes 1024 / p
(where $bytes is number printed on last line of output) to get size in kilobytes.
Quite sure someone with better knowledge than me could manage to grep that number and pipe it to dc.
"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: Recursive Dependency size.
« Reply #13 on: July 28, 2010, 07:54:07 AM »
Thanks for the suggestions.

tinypoodle/bmarkus:  It now shows the size in bytes and megabytes.   Thanks tinypoodle for the "dc" command idea, I used this in the script. 

Arslan S.:   I have fixed the issue with Kernel dependencies. 

I also added in some additional error checking so it will display an error if an extension is not found.

I modified my original posting in this thread with the updated code. 

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11037
Re: Recursive Dependency size.
« Reply #14 on: July 28, 2010, 09:16:45 AM »
You should be able to work with just the base, use nc (netcat) in place of curl:

Quote
echo -e "HEAD $FILE HTTP/1.0\n" | nc $MIRROR 80

MIRROR being the host name (distro.ibiblio.org), and FILE the full path (/pub/linux/distributions/tinycorelinux/2.x/tcz/firefox.tcz)
The only barriers that can stop you are the ones you create yourself.