blob: 6f5227e9ee8acb46496f1335fbf3c7d579313021 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# 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
|