From d85af9cea803509a41f4eaf2f831ff8edc0f3dcb Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Tue, 24 Nov 2020 14:28:33 +0100 Subject: [PATCH] check: existence of mentioned files first check also sets up checks infrastructure --- Makefile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 86fb2de..d0f9d24 100644 --- a/Makefile +++ b/Makefile @@ -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;}"