From 7fab7722bdc67184bff18cc7e70d7f2043f5b057 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 4 Oct 2021 15:18:33 +0200 Subject: first add of cdemu (might not be useful) --- exp/Makefile | 55 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'exp/Makefile') diff --git a/exp/Makefile b/exp/Makefile index 16d4b65..0352f66 100644 --- a/exp/Makefile +++ b/exp/Makefile @@ -1,12 +1,17 @@ REPO_URL := https://club1.fr/~nicolas/git/dna-backup/ -REPO_PATH := repo +export MAX_VERSION ?= 3 +export LO_DEV ?= /dev/loop0 +export COMMITS ?= commits +export BACKUP ?= backup +export DIFFS ?= diffs +export UDF ?= udf + +export REPO_PATH ?= repo GIT_PATH := git GITC := git -C $(REPO_PATH) -MAX_VERSION ?= 3 - -DATADIRS := backup diffs +DATADIRS := $(BACKUP) $(DIFFS) $(UDF) SIZEFILES := $(DATADIRS:%=%-size) .PHONY: all exp @@ -27,10 +32,13 @@ backup-size: versions cut -f1 $$i | paste -sd+ | bc >> $@; \ done -diffs-size: diffs +diffs-size: diffs run find $< -type f -exec du -ba {} + | cut -f1 > $@ -versions: results backup +udf-size: udf run + du -b $< | cut -f1 > $@ + +versions: results rm -rf $@ mkdir -p $@ for i in backup/*; do \ @@ -38,16 +46,30 @@ versions: results backup grep $$i $< > $@/$$v ; \ done -results: backup +results: backup run find $< -type f -exec du -ba {} + \ | grep -v hashes \ | sort -k2 \ > $@ -$(DATADIRS): commits ../dna-backup - rm -rf $(DATADIRS) - ./exp.sh $< $(REPO_PATH) $(MAX_VERSION) $(DATADIRS) - touch $(DATADIRS) +run: commits ../dna-backup | $(DATADIRS) + rm -rf $(DATADIRS:%=%/*) + ./exp.sh + touch $@ + +backup diffs: + mkdir $@ + +udf: | udffile.img + mkdir $@ + sudo mount -t udf $(LO_DEV) $@ + sudo chown $$USER:$$USER $@ + +udffile.img: + dd if=/dev/zero of=$@ bs=100M count=10 + sudo losetup $(LO_DEV) $@ + sudo cdrwtool -d $(LO_DEV) -q + sudo mkfs -t udf --media-type=dvdrw $(LO_DEV) ../dna-backup: .FORCE @$(MAKE) -C .. --no-print-directory dna-backup @@ -57,7 +79,7 @@ commits: | repo git | sort --unique --key=2 \ > $@ -repo git: +repo git &: git clone --separate-git-dir=$(GIT_PATH) $(REPO_URL) $(REPO_PATH) # remove warning about detached head state $(GITC) config advice.detachedHead false @@ -65,10 +87,15 @@ repo git: .PHONY: clean clean: mostlyclean rm -rf $(REPO_PATH) $(GIT_PATH) - rm commits + rm -f commits -mostlyclean: +mostlyclean: resultsclean + -sudo umount -fqd udf + -sudo losetup -d $(LO_DEV) rm -rf $(DATADIRS) versions + rm -f udffile.img run + +resultsclean: rm -f results summary.csv $(SIZEFILES) .FORCE: ; -- cgit v1.2.3