summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-02-04 21:57:13 -0500
committerJoey Hess <joey@gnu.kitenet.net>2009-02-04 21:57:13 -0500
commit40c6067eb67f28d207cf57f8ba2fc549315827b5 (patch)
tree51739f8915e3ddadc5fa0815c56672eae6ba064f /init.d
parentbc5d04189542e6da934f7c901b0765891cc5c1d1 (diff)
Support darcs. Thanks to Gian Piero Carrubba. Closes: #510032
Diffstat (limited to 'init.d')
-rwxr-xr-xinit.d/40vcs-init3
-rwxr-xr-xinit.d/50vcs-ignore22
-rwxr-xr-xinit.d/50vcs-perm2
-rwxr-xr-xinit.d/50vcs-pre-commit-hook15
-rw-r--r--init.d/60darcs-deleted-symlinks48
-rwxr-xr-xinit.d/70vcs-add11
6 files changed, 101 insertions, 0 deletions
diff --git a/init.d/40vcs-init b/init.d/40vcs-init
index bf2b03e..3c7a3bb 100755
--- a/init.d/40vcs-init
+++ b/init.d/40vcs-init
@@ -11,4 +11,7 @@ elif [ "$VCS" = hg ] && [ ! -e .hg ]; then
elif [ "$VCS" = bzr ] && [ ! -e .bzr ]; then
bzr init
bzr nick "$(hostname) /etc repository"
+elif [ "$VCS" = darcs ] && [ ! -e _darcs ]; then
+ darcs initialize
+ echo "$(hostname) /etc repository" > _darcs/prefs/motd
fi
diff --git a/init.d/50vcs-ignore b/init.d/50vcs-ignore
index 43c245d..5c7aa78 100755
--- a/init.d/50vcs-ignore
+++ b/init.d/50vcs-ignore
@@ -7,6 +7,8 @@ elif [ "$VCS" = hg ] && [ ! -e .hgignore ]; then
file=.hgignore
elif [ "$VCS" = bzr ] && [ ! -e .bzrignore ]; then
file=.bzrignore
+elif [ "$VCS" = darcs ] && [ ! -e .darcsignore ]; then
+ file=.darcsignore
fi
if [ -z "$file" ] || [ -e "$file" ]; then
@@ -40,9 +42,29 @@ ignore() {
fi
echo "$glob" >> $file
;;
+ darcs)
+ # darcs doesn't understand globs, so we need to translate
+ # them into regexs. Not a complete converter, but suitable
+ # for given globs.
+ if [ "${glob%\*}" != "$glob" ]; then
+ glob="${glob%\*}"
+ else
+ glob="$glob"'($|/)'
+ fi
+ if [ "${glob#\*}" != "$glob" ]; then
+ glob="${glob#\*}"
+ else
+ glob='(^|/)'"$glob"
+ fi
+ glob="$( printf %s $glob | sed -e 's/\./\\./g;s/\*/[^\/]*/g;' )"
+ echo "$glob" >> $file
esac
}
+if [ "$VCS" = darcs ]; then
+ darcs setpref boringfile .darcsignore
+fi
+
if [ "$LOWLEVEL_PACKAGE_MANAGER" = dpkg ]; then
comment "new and old versions of conffiles, stored by dpkg"
ignore "*.dpkg-*"
diff --git a/init.d/50vcs-perm b/init.d/50vcs-perm
index f9a6b8c..4dd080b 100755
--- a/init.d/50vcs-perm
+++ b/init.d/50vcs-perm
@@ -7,4 +7,6 @@ elif [ "$VCS" = hg ]; then
chmod 700 .hg
elif [ "$VCS" = bzr ]; then
chmod 700 .bzr
+elif [ "$VCS" = darcs ]; then
+ chmod 700 _darcs
fi
diff --git a/init.d/50vcs-pre-commit-hook b/init.d/50vcs-pre-commit-hook
index de496fe..06d433b 100755
--- a/init.d/50vcs-pre-commit-hook
+++ b/init.d/50vcs-pre-commit-hook
@@ -29,4 +29,19 @@ precommit = etckeeper pre-commit -d `pwd`
EOF
fi
;;
+ darcs)
+ if [ -e _darcs/prefs/defaults ]; then
+ if ! ( grep -q "record prehook etckeeper pre-commit" _darcs/prefs/defaults &&
+ grep -q "whatsnew prehook etckeeper pre-commit" _darcs/prefs/defaults ); then
+ echo "etckeeper warning: _darcs/prefs/defaults needs to be manually modified to run: etckeeper pre-commit -d `pwd`" >&2
+ fi
+ else
+ cat >_darcs/prefs/defaults <<EOF
+record prehook etckeeper pre-commit -d `pwd`
+record run-prehook
+whatsnew prehook etckeeper pre-commit -d `pwd`
+whatsnew run-prehook
+EOF
+ fi
+ ;;
esac
diff --git a/init.d/60darcs-deleted-symlinks b/init.d/60darcs-deleted-symlinks
new file mode 100644
index 0000000..8d10d56
--- /dev/null
+++ b/init.d/60darcs-deleted-symlinks
@@ -0,0 +1,48 @@
+#!/bin/sh
+set -e
+
+filter_ignore() {
+ if [ "$VCS" = darcs ]; then
+ ignorefile=.darcsignore
+ fi
+
+ if [ "$VCS" = darcs ] && [ -e "$ignorefile" ]; then
+ # Spaces embedded into patterns would break it.
+ # But really, why would anyone want to use ' ' instead of '\s' ?
+ #patterns=$( grep -v '^[[:space:]]*\(#\|$\)' "$ignorefile" | xargs -n 1 printf " -e %s" )
+ #grep -Ev $patterns
+ #unset patterns
+ # Alternative using a temp file
+ patternsfile="$( mktemp -t etckeeper-$VCS.XXXXXXXXXX )"
+ grep -v '^[[:space:]]*\(#\|$\)' "$ignorefile" > "$patternsfile" || true
+ grep -Evf "$patternsfile"
+ rm -f "$patternsfile"
+ unset patternsfile
+ else
+ cat -
+ fi
+}
+
+
+if [ "$VCS" = darcs ];then
+ NOVCS='. -wholename ./.git -prune -o -wholename ./.bzr -prune -o -wholename ./.hg -prune -o -wholename ./_darcs -prune -o'
+
+ # We assume that if .etckeeper is empty this is the first run
+ if [ -s .etckeeper ]; then
+ linksindex="$( mktemp -t etckeeper-$VCS.XXXXXXXXXX )"
+ grep '^ln -s' .etckeeper | while IFS="'" read n n n link n; do
+ printf "%s\n" "$link" >> "$linksindex"
+ done
+
+ # Warn about symbolic links that shouldn't exist
+ if links=$( find $NOVCS -type l -print | filter_ignore | grep -vFf "$linksindex" ); then
+ printf "%s\n%s\n" \
+ "The following symbolic links should not exist:" \
+ "$links" >&2
+ fi
+
+ rm -f "$linksindex"
+ unset links linksindex
+ fi
+
+fi
diff --git a/init.d/70vcs-add b/init.d/70vcs-add
index e6ab3d1..9a9ec45 100755
--- a/init.d/70vcs-add
+++ b/init.d/70vcs-add
@@ -13,4 +13,15 @@ elif [ "$VCS" = bzr ]; then
if ! bzr add .; then
echo "etckeeper warning: bzr add failed" >&2
fi
+elif [ "$VCS" = darcs ]; then
+ # Don't warn if all the files were already added.
+ rc=0
+ res=$( darcs add -qr . 2>&1 ) || rc=$?
+ if test $rc -ne 0; then
+ if ! test $rc -eq 2 -a "${res%No files were added}" != "$res"; then
+ printf "%s" "$res"
+ echo "etckeeper warning: darcs add failed" >&2
+ fi
+ fi
+ unset rc res
fi