diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-10-04 15:51:55 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-10-04 15:51:55 +0200 |
commit | b5842cb956aeac90bdf26a5ad26c86c594fe30ee (patch) | |
tree | 7f35a5434b1b838bfd8affeda32f3ce9836fe810 /exp | |
parent | a8d4b5b440ed9ac29a0eae7fc47c144d46745078 (diff) | |
download | dna-backup-b5842cb956aeac90bdf26a5ad26c86c594fe30ee.tar.gz dna-backup-b5842cb956aeac90bdf26a5ad26c86c594fe30ee.zip |
export env vars instead of passing params to exp.sh
Diffstat (limited to 'exp')
-rw-r--r-- | exp/Makefile | 38 | ||||
-rwxr-xr-x | exp/exp.sh | 30 |
2 files changed, 39 insertions, 29 deletions
diff --git a/exp/Makefile b/exp/Makefile index 16d4b65..a5b4864 100644 --- a/exp/Makefile +++ b/exp/Makefile @@ -1,12 +1,15 @@ REPO_URL := https://club1.fr/~nicolas/git/dna-backup/ -REPO_PATH := repo +export MAX_VERSION ?= 3 +export COMMITS ?= commits +export BACKUP ?= backup +export DIFFS ?= diffs + +export REPO_PATH ?= repo GIT_PATH := git GITC := git -C $(REPO_PATH) -MAX_VERSION ?= 3 - -DATADIRS := backup diffs +DATADIRS := $(BACKUP) $(DIFFS) SIZEFILES := $(DATADIRS:%=%-size) .PHONY: all exp @@ -27,10 +30,10 @@ 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 +versions: results rm -rf $@ mkdir -p $@ for i in backup/*; do \ @@ -38,26 +41,29 @@ 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 $@ ../dna-backup: .FORCE @$(MAKE) -C .. --no-print-directory dna-backup -commits: | repo git +$(COMMITS): | repo git $(GITC) log --reverse --no-merges --pretty=tformat:"%H %as" \ | 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 +71,12 @@ repo git: .PHONY: clean clean: mostlyclean rm -rf $(REPO_PATH) $(GIT_PATH) - rm commits + rm -f $(COMMITS) -mostlyclean: +mostlyclean: resultsclean rm -rf $(DATADIRS) versions + +resultsclean: rm -f results summary.csv $(SIZEFILES) .FORCE: ; @@ -1,35 +1,37 @@ #!/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 +# - 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 -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) 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 - 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 |