Skip to content

Instantly share code, notes, and snippets.

@blueforesticarus
Created August 26, 2020 22:15
Show Gist options
  • Save blueforesticarus/2563f483417458796c400bca4d429ce4 to your computer and use it in GitHub Desktop.
Save blueforesticarus/2563f483417458796c400bca4d429ce4 to your computer and use it in GitHub Desktop.
determine upper bound increase in size if every exe on the system was statically linked.
#this will figure out how much additional space would be taken up if all executables were static.
( cat asdf || ( \
sudo fd . '/' --type x -E *.sh -E *.py -E *.so -E *.so.* -E *.la -E *.js \
| xargs -I {} ldd {} 2>/dev/null \
| tee asdf \
)) \
| grep -v "no version information" \
| grep -v "/home/" \
| sort \
| sed 's/(.*)//g' \
| sed 's/.*=>//g' \
| sort \
| uniq -c \
| sort -h \
| python -c '
import sys, os
total = 0
tuples = []
for l in sys.stdin:
try:
fn = l.split()[1]
n = int(l.split()[0])
bs = os.path.getsize(fn)
total += n * bs
tuples.append((bs*n,n,fn))
except:
print("ERR " + l.strip())
tuples.sort(key = lambda x: x[0])
def sigfigs(i,n):
return "{:g}".format(float("{:.{p}g}".format(i, p=n)))
displayGB=False
for t,n,fn in tuples:
if t > 10000000000 and displayGB:
N = t // 1000000000
S = "GB"
elif t > 10000000:
N = t // 1000000
S = "MB"
else:
N = t // 1000
S = "KB"
P = sigfigs(t*100 /total,2)
print("{:15} ({}%) {} ({})".format("%d %s" % (N,S),P,fn,n))
print("%s MB TOTAL" % (total//1000000))
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment