blob: 165d415cefef61b01f4936cbb59a4c5bf4e06c68 (
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
|
#!/bin/sh
set -e
if [ "$VCS" = git ]; then
rm -rf .git
file=.gitignore
elif [ "$VCS" = hg ]; then
rm -rf .hg
file=.hgignore
elif [ "$VCS" = bzr ]; then
rm -rf .bzr
file=.bzrignore
elif [ "$VCS" = darcs ]; then
rm -rf _darcs
file=.darcsignore
fi
managed_by_etckeeper="managed by etckeeper"
if ! grep -q "$managed_by_etckeeper" "$file"; then
echo "etckeeper: "$file" does not contain \"$managed_by_etckeeper\" comment; not removing"
exit 0
else
realfile="$file"
if [ -n "`type -p tempfile`" ]; then
tempfile="tempfile"
elif [ -n "`type -p mktemp`" ]; then
tempfile="mktemp"
else
echo "etckeeper warning: can't find tempfile or mktemp" >&2
exit 1
fi
file=$($tempfile)
otherentries=
skipping=
while read line; do
if echo "$line" | grep -q "$managed_by_etckeeper"; then
if [ ! "$skipping" ]; then
skipping=1
else
skipping=
fi
elif [ ! "$skipping" ]; then
echo "$line" >> "$file"
otherentries=1
fi
done <"$realfile"
if [ "$otherentries" ]; then
echo "etckeeper: "$realfile" nonempty after \"$managed_by_etckeeper\" section removal; preserving other entries"
mv -f "$file" "$realfile"
else
rm -f "$file"
rm -f "$realfile"
fi
fi
|