User Tools

Site Tools


user:yeti:opkg-list-user-installed-packages

FIXME unfinished stuff.

Opkg List User Installed Packages

2018-01-14

opkg-list-user-installed-packages-sorted-by-size-20180114
#!/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
			t+=$1
		}
		close(J)
		print s"\t"P|S
	}
	close(S)
	print t"\t---TOTAL---"
}

:!: This originally was created as 1-liner and now just has been unfolded.

2018-01-15

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---"
}

:!: 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)

$ du logs
8       logs/refs/heads
8       logs/refs/remotes/origin
12      logs/refs/remotes
24      logs/refs
32      logs

The script only needs the summary of directories:

$ du -s logs
32      logs

If called with files and directories, files are shown like without -s and directories are totalled:

$ 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

As long as this script shall show no intermediate results, letting du sum the directories' sizes fits.

user/yeti/opkg-list-user-installed-packages.txt · Last modified: 2018/02/03 01:06 by yeti