35 lines
		
	
	
		
			900 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			900 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| CONFIGS = $(patsubst /%,%,$(shell cat configs))
 | |
| STORE = $(patsubst /%,%,$(shell cat store))
 | |
| CP = mkdir -p $(dir $@) && cp -a
 | |
| IGNORE_FILE = $(shell test -d .git/info && echo .git/info/exclude || echo .gitignore)
 | |
| GIT_COMMIT = git commit -m"add $@" --no-gpg-sign --no-signoff
 | |
| SELECTOR != command -v sk || command -v fzy || command -f fzf
 | |
| 
 | |
| .PHONY: all
 | |
| all: init backup.tgz $(IGNORE_FILE)
 | |
| 
 | |
| backup.tgz: $(CONFIGS) $(STORE)
 | |
| 	tar czf $@ $^
 | |
| 
 | |
| $(IGNORE_FILE): store
 | |
| 	echo $(STORE) backup.tgz | tr ' ' '\n' > $@
 | |
| 
 | |
| .PHONY: init
 | |
| init: configs store
 | |
| 
 | |
| configs store:
 | |
| 	while con="$$(find /var /etc/ /sys/ -maxdepth 2 -mindepth 1 -type f 2>/dev/null  | $(SELECTOR) -p "Select files for $@\nPress Ctrl+d once done")"; do \
 | |
| 	echo "$$con"; \
 | |
| 	done > $@
 | |
| 
 | |
| $(CONFIGS): %: /%
 | |
| 	$(CP) $< $@
 | |
| 	git add $@
 | |
| 	$(GIT_COMMIT)
 | |
| 	$(info made git commit for $@)
 | |
| $(STORE): %: /%
 | |
| 	$(CP) $< $@
 | |
| 
 | |
| clean:
 | |
| 	$(RM) -r $(CONFIGS) $(STORE) backup.tgz
 |