:!: This script is inspired by opkg-list-user-installed-packages.

:!: This script will list all packages instead of listing only user-installed packages.

Three conditions are applied in determining a package size (in order, if the first one is not applicable then the next one is used):

  • Calculate size of all files in package list file /usr/lib/opkg/info/packagename.list. du -k command is used. (fast and accurate)
  • Calculate package size using opkg itself. opkg info packagename command is used. (CPU-intensive and less-accurate as actual files residing on filesystem are probably consuming more space)
  • Mark package size as unknown using -.-.

:!: This script should work on base installation without requiring any additional packages to be installed.

packagelist=$(ls /usr/lib/opkg/info/*.list)
for packagelistpath in $packagelist
        packagefiles=$(cat $packagelistpath)
        packagename=$(echo $packagelistpath | sed 's/\/usr\/lib\/opkg\/info\///g' | sed 's/\.list//g')
        if [[ -z "$packagefiles" ]]
                packagesizeb=$(opkg info $packagename | grep Size\: | sed 's/Size\:\ //g')
                if [[ -z $packagesizeb ]]
                        echo -e "-.- KB \t\t$packagename"
                        packagesizekb=$(opkg info $packagename | grep Size\: | sed 's/Size\:\ //g' | awk 'END {printf "%.02f\n", $1/1024}')
                        printf '%-16s' "$packagesizekb KB"; printf '%s\n' "$packagename"
                packagesizekb=$(for file in $packagefiles; do if [[ -f $file ]]; then du -k $file | cut -f1; fi; done | awk '{s+=$1} END {printf "%.02f\n", s}')
                printf '%-16s' "$packagesizekb KB"; printf '%s\n' "$packagename"
done | sort -n
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/08/10 08:28
  • by tmomas