# Reference table for merging a regular file # # V1 Vuser V2 action # ------------------------------------------ 1 # none none none inconceivable! 2 # exists none none use V1 3 # none exists none use Vuser 4 # none none exists use V2 5 # exists none exists use V2 6 # exists exists none use Vuser 7 # none exists exists diff V2 Vuser applied to V2 8 # exists exists exists diff V1 Vuser applied to V2 1 No needed implementation 2 SCENARIO The old version has a file and the new hasn't GIVEN a version called foo AND a version called new-foo AND a basefile in the orignial version foo AND the version foo is the default THEN bscs merge the version new-foo AND version new-foo has the file basefile FINALLY set factory as default AND remove foo AND remove new-foo 3 SCENARIO The old version has a file created by the user GIVEN a version called foo AND a version called new-foo AND a userfile in the running version foo AND the version foo is the default THEN bscs merge the version new-foo AND version new-foo has the file userfile FINALLY set factory as default AND remove foo AND remove new-foo 4 SCENARIO The new version adds a file GIVEN a version called foo AND a version called new-foo AND a new-basefile in the running version new-foo AND the version foo is the default THEN bscs merge the version new-foo AND version new-foo has the file new-basefile FINALLY set factory as default AND remove foo AND remove new-foo 5 SCENARIO The new version changes a file which was removed by the user GIVEN a version called foo AND a version called new-foo AND a basefile in the original version foo AND a new-basefile in the running version new-foo AND the version foo is the default THEN bscs merge the version new-foo AND version new-foo has the file new-basefile FINALLY set factory as default AND remove foo AND remove new-foo 6 SCENARIO The old version has a file and the user has modified it GIVEN a version called foo AND a version called new-foo AND a basefile in the original version foo AND a userfile in the running version foo AND the version foo is the default THEN bscs merge the version new-foo AND version new-foo has the file userfile FINALLY set factory as default AND remove foo AND remove new-foo 7 patch applies 7 patch doesn't applies 8 patch applies 8 patch doesn't applies $ IMPLEMENTS GIVEN a version called (\S+) tmpdir=$(mktemp -d) mount_disk="$(findmnt / -n -l -o SOURCE | cut -f 1 | cut -d [ -f 1)" mount $mount_disk $tmpdir if [ -d $tmpdir/systems/$MATCH_1 ]; then rm -r $tmpdir/systems/$MATCH_1 fi mkdir $tmpdir/systems/$MATCH_1 mkdir -p $tmpdir/systems/$MATCH_1/orig/etc mkdir -p $tmpdir/systems/$MATCH_1/run/etc umount $tmpdir rm -r $tmpdir IMPLEMENTS GIVEN a (basefile|userfile|new-basefile) in the (original|running) version (\S+) tmpdir=$(mktemp -d) mount_disk="$(findmnt / -n -l -o SOURCE | cut -f 1 | cut -d [ -f 1)" mount $mount_disk $tmpdir case $MATCH_2 in 'original') version="orig" ;; 'running') version="run" ;; esac algo=`pwd` cp files/$MATCH_1 $tmpdir/systems/$MATCH_3/$version/etc/config.conf umount $tmpdir rm -r $tmpdir IMPLEMENTS GIVEN the version (\S+) is the default snapshot-mgr set-default $MATCH_1 IMPLEMENTS THEN bscs merge the version (\S+) baserock-system-config-sync merge $MATCH_1 IMPLEMENTS THEN version (\S+) has the file (\S+) set -e tmpdir=$(mktemp -d) mount_disk="$(findmnt / -n -l -o SOURCE | cut -f 1 | cut -d [ -f 1)" mount $mount_disk $tmpdir diff files/$MATCH_2 $tmpdir/systems/$MATCH_1/run/etc/config.conf permissions1=$(ls -l files/$MATCH_2 | cut -f 1 -d ' ') permissions2=$(ls -l $tmpdir/systems/$MATCH_1/run/etc/config.conf | cut -f 1 -d ' ') if [ $permissions1 != $permissions2 ]; then die "EH! persmissions problem" fi umount $tmpdir rm -r $tmpdir IMPLEMENTS FINALLY set (\S+) as default snapshot-mgr set-default $MATCH_1 IMPLEMENTS FINALLY remove (\S+) snapshot-mgr remove $MATCH_1