diff options
-rw-r--r-- | exp/.gitignore | 1 | ||||
-rw-r--r-- | exp/Makefile | 55 | ||||
-rw-r--r-- | exp/cdemu/.gitignore | 3 | ||||
-rw-r--r-- | exp/cdemu/Makefile | 63 | ||||
-rwxr-xr-x | exp/exp.sh | 39 |
5 files changed, 133 insertions, 28 deletions
diff --git a/exp/.gitignore b/exp/.gitignore index 8267a55..04ca262 100644 --- a/exp/.gitignore +++ b/exp/.gitignore @@ -1,4 +1,5 @@ * +!cdemu !.gitignore !exp.sh !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: ; diff --git a/exp/cdemu/.gitignore b/exp/cdemu/.gitignore new file mode 100644 index 0000000..a0991ff --- /dev/null +++ b/exp/cdemu/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!Makefile diff --git a/exp/cdemu/Makefile b/exp/cdemu/Makefile new file mode 100644 index 0000000..273a99e --- /dev/null +++ b/exp/cdemu/Makefile @@ -0,0 +1,63 @@ +PKGS := vhba-module-20210418 libmirage-3.2.5 cdemu-daemon-3.2.5 +TARS := $(PKGS:%=%.tar.xz) + + +.PHONY: install +install: install-cdemu-daemon-3.2.5 install-vhba-module + +.PHONY: install-cdemu-daemon-3.2.5 +install-cdemu-daemon-3.2.5: cdemu-daemon-3.2.5/install_manifest.txt + +.PHONY: install-libmirage-3.2.5 +install-libmirage-3.2.5: libmirage-3.2.5/install_manifest.txt + +.PHONY: install-vhba-module +install-vhba-module: vhba-module-20210418/vhba.ko + -sudo insmod vhba-module-20210418/vhba.ko + +.PHONY: uninstall +uninstall: uninstall-cdemu-daemon-3.2.5 uninstall-libmirage-3.2.5 + -sudo rmmod vhba + +.PHONY: uninstall-% +uninstall-%: %/install_manifest.txt + sort $< | while read line; do \ + sudo rm -f $$line; \ + sudo rm -d `dirname $$line` 2>&1 && echo success; \ + done | uniq | tac | sed '/success/I,+1 d' + rm -f $< + +.PHONY: clean +clean: + rm -f $(TARS) + rm -rf $(PKGS) + +cdemu-daemon-3.2.5/install_manifest.txt: | cdemu-daemon-3.2.5/Makefile cdemu-daemon-3.2.5/cdemu-daemon + @echo "Don't worry there is an uninstall target" + sudo $(MAKE) -C $(@D) install + +cdemu-daemon-3.2.5/cdemu-daemon: cdemu-daemon-3.2.5/Makefile + $(MAKE) -C $(@D) + +cdemu-daemon-3.2.5/Makefile: | install-libmirage-3.2.5 cdemu-daemon-3.2.5 + cd $(@D) && cmake . + +libmirage-3.2.5/install_manifest.txt: libmirage-3.2.5/libmirage.so + @echo "Please enter your password. Don't worry there is an uninstall target" + sudo $(MAKE) -C $(@D) install + +libmirage-3.2.5/libmirage.so: libmirage-3.2.5/Makefile + $(MAKE) -C $(@D) + +libmirage-3.2.5/Makefile: | libmirage-3.2.5 + cd $(@D) && cmake . + +vhba-module-20210418/vhba.ko: | vhba-module-20210418 + cd $(@D) && $(MAKE) + +$(PKGS): %: %.tar.xz + tar -xvf $< + +%.tar.xz: + wget -q http://downloads.sourceforge.net/cdemu/$@ + @@ -1,35 +1,46 @@ #!/bin/bash -commits="$1" -repo="$2" -max_count="$3" -backup="$4" -diffs="$5" +# This script expects the following variables to be exported: +# - REPO_PATH: the path of the repo the experiment is based on +# - MAX_VERSION: the max number for versions for the experiment +# - LO_DEV: the loopbak device used to mount the UDF dir +# - COMMITS: the name of the file that contains the lists of versions +# - BACKUP: the path fo the dna-backup dir +# - DIFFS: the path of the git diff dir +# - UDF: the path of the UDF dir -mkdir -p $backup $diffs +GITC="git -C $REPO_PATH" # "empty tree" commit prev="4b825dc642cb6eb9a060e54bf8d69288fbee4904" -last=$(tail --lines=1 "$commits" | cut -f1) +last=$(tail --lines=1 $COMMITS | cut -f1) + +sudo mount -t udf -o loop $LO_DEV $UDF +sudo chown $USER:$USER $UDF i=0 -cat "$commits" | while read line +cat $COMMITS | while read line do hash=$(echo "$line" | cut -f1) - git -C "$repo" checkout "$hash" + $GITC checkout $hash # create diff for this version - git -C "$repo" diff --minimal --binary --unified=0 "$prev" | gzip > "$diffs/$i.diff.gz" + $GITC diff --minimal --binary --unified=0 $prev | gzip > $DIFFS/$i.diff.gz # create backup for this version - ../dna-backup commit -v 2 "$repo" "$backup" + ../dna-backup commit -v 2 $REPO_PATH $BACKUP + + # write to udf + $GITC diff | git -C $UDF apply - + sudo umount $UDF - prev="$hash" + prev=$hash let i++ - if [[ $i == $max_count ]] + if [[ $i == $MAX_VERSION ]] then break fi done -git -C "$repo" checkout "$last" +# cleanup +$GITC checkout $last |