Makefile: de-duplicate dylibs and strings

to save space
This commit is contained in:
Michael Roitzsch
2025-05-13 11:50:25 +02:00
parent bcfee3495c
commit 50ba2072da

View File

@@ -126,19 +126,19 @@ db_binaries:: dyld
echo 'DROP TABLE IF EXISTS linkages;' echo 'DROP TABLE IF EXISTS linkages;'
echo 'DROP TABLE IF EXISTS entitlements;' echo 'DROP TABLE IF EXISTS entitlements;'
echo 'DROP TABLE IF EXISTS strings;' echo 'DROP TABLE IF EXISTS strings;'
echo 'CREATE TABLE linkages (id INTEGER REFERENCES files, dylib TEXT);' echo 'CREATE TABLE linkages (id INTEGER REFERENCES files, dylib TEXT, UNIQUE (id, dylib));'
echo 'CREATE TABLE entitlements (id INTEGER REFERENCES files, plist JSON);' echo 'CREATE TABLE entitlements (id INTEGER REFERENCES files, plist JSON);'
echo 'CREATE TABLE strings (id INTEGER REFERENCES files, string TEXT);' echo 'CREATE TABLE strings (id INTEGER REFERENCES files, string TEXT, UNIQUE (id, string));'
$(call find,-follow -type f -perm +111) | while read -r os path ; do \ $(call find,-follow -type f -perm +111) | while read -r os path ; do \
echo "UPDATE files SET executable = true WHERE os = '$$os' AND path = '$$(echo "$$path" | sed "s/'/''/g")';" ; \ echo "UPDATE files SET executable = true WHERE os = '$$os' AND path = '$$(echo "$$path" | sed "s/'/''/g")';" ; \
if test -r "$(call prefix,$$os)$$path" && file --no-dereference --brief --mime-type "$(call prefix,$$os)$$path" | grep -Fq application/x-mach-binary ; then \ if test -r "$(call prefix,$$os)$$path" && file --no-dereference --brief --mime-type "$(call prefix,$$os)$$path" | grep -Fq application/x-mach-binary ; then \
objdump --macho --dylibs-used "$(call prefix,$$os)$$path" | \ objdump --macho --dylibs-used "$(call prefix,$$os)$$path" | \
sed "1d;s/^.//;s/ ([^)]*)$$//;s/'/''/g;s|.*|INSERT INTO linkages $(call file,'&');|" ; \ sed "1d;s/^.//;s/ ([^)]*)$$//;s/'/''/g;s|.*|INSERT OR IGNORE INTO linkages $(call file,'&');|" ; \
codesign --display --xml --entitlements - "$(call prefix,$$os)$$path" 2> /dev/null | \ codesign --display --xml --entitlements - "$(call prefix,$$os)$$path" 2> /dev/null | \
plutil -convert json - -o - | \ plutil -convert json - -o - | \
sed "/^<stdin>: Property List error/d;/^{}/d;s/'/''/g;s|.*|INSERT INTO entitlements $(call file,json('&'));\n|" ; \ sed "/^<stdin>: Property List error/d;/^{}/d;s/'/''/g;s|.*|INSERT INTO entitlements $(call file,json('&'));\n|" ; \
strings -n 8 "$(call prefix,$$os)$$path" | \ strings -n 8 "$(call prefix,$$os)$$path" | \
LANG=C sed "s/'/''/g;s|.*|INSERT INTO strings $(call file,'&');|" ; \ LANG=C sed "s/'/''/g;s|.*|INSERT OR IGNORE INTO strings $(call file,'&');|" ; \
fi ; \ fi ; \
done done