From 40c6067eb67f28d207cf57f8ba2fc549315827b5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 4 Feb 2009 21:57:13 -0500 Subject: Support darcs. Thanks to Gian Piero Carrubba. Closes: #510032 --- init.d/40vcs-init | 3 +++ init.d/50vcs-ignore | 22 +++++++++++++++++++ init.d/50vcs-perm | 2 ++ init.d/50vcs-pre-commit-hook | 15 +++++++++++++ init.d/60darcs-deleted-symlinks | 48 +++++++++++++++++++++++++++++++++++++++++ init.d/70vcs-add | 11 ++++++++++ 6 files changed, 101 insertions(+) create mode 100644 init.d/60darcs-deleted-symlinks (limited to 'init.d') 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 @@ -26,6 +26,21 @@ EOF [hooks] # pre-commit hook for etckeeper, to store metadata and do sanity checks 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 < "$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 -- cgit v1.2.3