check: existence of mentioned files

first check also sets up checks infrastructure
This commit is contained in:
Michael Roitzsch
2020-11-24 14:28:33 +01:00
parent 76c9417244
commit d85af9cea8

View File

@@ -1,11 +1,12 @@
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
CHECK_TARGETS = check_files
.PHONY: all $(DB_TARGETS)
.PHONY: all check $(DB_TARGETS) $(CHECK_TARGETS)
.INTERMEDIATE: $(DB)
all: internals.txt $(DB).lz
all: $(DB).lz check
ifneq ($(wildcard $(MY_INTERNALS)),)
internals.txt: $(MY_INTERNALS)
@@ -24,6 +25,10 @@ $(DB).lz: $(DB)
tmutil addexclusion $@
endif
check: internals.txt
@LANG=en sort --ignore-case $< | diff -uw $< -
@$(MAKE) --silent --jobs=1 $(CHECK_TARGETS)
# MARK: - data extraction helpers
@@ -63,3 +68,12 @@ db_files::
$(DB_TARGETS)::
echo 'COMMIT TRANSACTION;'
# MARK: - check targets for internals.txt
check_files: internals.txt $(DB)
printf '\033[1mchecking files...\033[m\n' >&2
grep -ow '~\?/[^,;]*' $< | sed -E 's/ \(.*\)$$//;s/^\/(etc|var)\//\/private&/' | \
sed "s/'/''/g;s|.*|SELECT count(*), '&' FROM files WHERE path GLOB '&';|" | \
sqlite3 $(DB) | sed -n "/^0|/{s/^0|//;p;}"