Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
user:yeti:opkg-list-user-installed-packages [2018/01/14 12:26] – created yetiuser:yeti:opkg-list-user-installed-packages [2018/02/03 01:06] – [2018-01-16] yeti
Line 1: Line 1:
-===== List User Installed Packages =====+FIXME unfinished stuff. 
 + 
 +===== Opkg List User Installed Packages =====
  
 See [[https://unix.stackexchange.com/questions/157097/how-to-know-disk-space-occupied-by-packages-in-openwrt]]. See [[https://unix.stackexchange.com/questions/157097/how-to-know-disk-space-occupied-by-packages-in-openwrt]].
  
-<file awk opkg-list-user-installed-packages-sorted-by-size>+==== 2018-01-14 ==== 
 + 
 +<file awk opkg-list-user-installed-packages-sorted-by-size-20180114>
 #!/usr/bin/awk -f #!/usr/bin/awk -f
 BEGIN { BEGIN {
-        D="cd /overlay/upper/usr/lib/opkg/info&&" + D="cd /overlay/upper/usr/lib/opkg/info&&" 
-        C=D"ls *.list" + C=D"ls *.list" 
-        S="sort -n" + S="sort -n" 
-        while(C|getline>0) { + while(C|getline>0) { 
-                P=substr(F=$1,1,length($1)-5) + P=substr(F=$1,1,length($1)-5) 
-                J=D"du -sk $(cat "F")" + J=D"du -sk $(cat "F")" 
-                s=0 + s=0 
-                while(J|getline>0) { + while(J|getline>0) { 
-                        s+=$1 + s+=$1 
-                        t+=$1 + t+=$1 
-                +
-                close(J) + close(J) 
-                print s"\t"P|S + print s"\t"P|S 
-        +
-        close(S) + close(S) 
-        print t"\t---TOTAL---"+ print t"\t---TOTAL---"
 } }
 </file> </file>
 +
 +:!: This originally was created as 1-liner and now just has been unfolded.
 +
 +==== 2018-01-15 ====
 +
 +<file awk opkg-list-user-installed-packages-sorted-by-size-20180115>
 +#!/usr/bin/awk -f
 +BEGIN {
 + D="cd /overlay/upper/usr/lib/opkg/info&&"
 + C=D"ls *.list"
 + S="sort -n"
 + while(C|getline>0) {
 + P=substr(F=$1,1,length($1)-5)
 + J=D"du -sk $(cat "F")"
 + s=0
 + while(J|getline>0) s+=$1
 + close(J)
 + t+=s
 + print s"\t"P|S
 + }
 + close(S)
 + print t"\t---TOTAL---"
 +}
 +</file>
 +
 +:!: Moved summing ''t'' (total) to outside the loop.
 +
 +:?: Should the size of the files in ''/overlay/upper/usr/lib/opkg/info/packagename.*'' which describe the package be counted too? Can-o-worms?
 +
 +==== 2018-01-16 ====
 +
 +:?: Why ''du -k''? What was the mysterious reason why it makes sense despite being ''du'''s default?
 +
 +:?: Why ''du -s''?
 +
 +:!: Have a look: //(the example was run on Debian)//
 +<code>
 +$ du logs
 +8       logs/refs/heads
 +8       logs/refs/remotes/origin
 +12      logs/refs/remotes
 +24      logs/refs
 +32      logs
 +</code>
 +The script only needs the summary of directories:
 +<code>
 +$ du -s logs
 +32      logs
 +</code>
 +If called with files and directories, files are shown like without ''-s'' and directories are totalled:
 +<code>
 +$ ls -ld description logs
 +-rw-r--r-- 1 yeti yeti   73 Mai 15  2017 description
 +drwxr-xr-x 3 yeti yeti 4096 Mai 15  2017 logs
 +$ du -s description logs
 +4       description
 +32      logs
 +</code>
 +As long as this script shall show no intermediate results, letting ''du'' sum the directories' sizes fits.
  • Last modified: 2019/09/07 19:18
  • by yeti