diff options
Diffstat (limited to 'init.d')
-rwxr-xr-x | init.d/40vcs-init | 3 | ||||
-rwxr-xr-x | init.d/50vcs-ignore | 22 | ||||
-rwxr-xr-x | init.d/50vcs-perm | 2 | ||||
-rwxr-xr-x | init.d/50vcs-pre-commit-hook | 15 | ||||
-rw-r--r-- | init.d/60darcs-deleted-symlinks | 48 | ||||
-rwxr-xr-x | init.d/70vcs-add | 11 |
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 |