db: collect contents of asset catalogs

This commit is contained in:
Michael Roitzsch
2020-11-24 10:09:01 +01:00
parent e03a6cd0ca
commit 5c7181b1f9

View File

@@ -1,6 +1,6 @@
MY_INTERNALS = $(HOME)/Library/Mobile\ Documents/com~apple~TextEdit/Documents/Apple\ Internals.rtf
DB := $(if $(DB),$(DB:.lz=),internals-$(shell sw_vers -productVersion).db)
DB_TARGETS = db_files db_binaries
DB_TARGETS = db_files db_binaries db_assets
CHECK_TARGETS = check_files check_binaries
.PHONY: all check $(DB_TARGETS) $(CHECK_TARGETS)
@@ -34,6 +34,9 @@ check: internals.txt
# MARK: - data extraction helpers
NIX = $(shell nix-build --no-out-link -A nixFlakes '<nixpkgs>')/bin/nix
ACEXTRACT = $(shell \
$(NIX) --experimental-features 'nix-command flakes' build --no-write-lock-file .\#acextract && \
readlink result && rm result)/bin/acextract
DSCU = $(shell \
$(NIX) --experimental-features 'nix-command flakes' build --no-write-lock-file .\#dyld-shared-cache && \
readlink result && rm result)/bin/dyld_shared_cache_util
@@ -102,6 +105,15 @@ db_binaries:: dyld
fi ; \
done
db_assets::
printf '\033[1mcollecting asset catalog information...\033[m\n' >&2
echo 'DROP TABLE IF EXISTS assets;'
echo 'CREATE TABLE assets (id INTEGER REFERENCES files, name TEXT);'
$(call find,-type f -name '*.car') | while read -r os path ; do \
test -r "$(call prefix,$$os)$$path" && $(ACEXTRACT) --list --input "$(call prefix,$$os)$$path" | \
sed "1d;s/'/''/g;s|.*|INSERT INTO assets $(call file,'&');|" ; \
done
$(DB_TARGETS)::
echo 'COMMIT TRANSACTION;'