Package: etckeeper
Version: 0.41
Severity: wishlist
Tags: patch
Every time etckeeper runs, it warns me about the same couple of files:
etckeeper warning: special files could cause problems with bzr:
./service/vbox-TinyXP/supervise/ok
./service/vbox-TinyXP/supervise/control
But I've already told bzr to ignore these files, so there is in fact
no problem. It would be nice if 20warn-hardlinks and
20warn-special-file in /etc/etckeeper/pre-commit.d removed ignored
files from the list before warning me.
The attached patches for 20warn-special-file and 20warn-hardlinks,
together with the file /usr/share/etckeeper/functions.sh, do this, but
only for bzr so far. To extend this to other VCSes, all that would be
needed is to add clauses for them to the 'if' statement in
filter_ignored(), with commands that output a newline-delimited list
of ignored files.
As things stand here, filter_ignored() is called twice, and it calls
the VCS to output the list of ignored files each time it's called. So
this solution could be slow. Obvious improvements would be to have
filter_ignored() exit immediately if it detects that there are no file
names on stdin, or else call out for the list of ignored files only
once, in /usr/sbin/etckeeper, and store the result in an environment
variable.
Thanks,
Andrew.
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (400, 'stable'), (1,
'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.26 (SMP w/3 CPU cores; PREEMPT)
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages etckeeper depends on:
ii bzr 1.17-1 easy to use distributed version co
ii debconf [debconf-2.0] 1.5.27 Debian configuration management sy
Versions of packages etckeeper recommends:
ii cron 3.0pl1-106 process scheduling daemon
etckeeper suggests no packages.
-- debconf information:
etckeeper/purge: true
* etckeeper/commit_failed:
=== modified file 'etckeeper/pre-commit.d/20warn-hardlinks'
--- etckeeper/pre-commit.d/20warn-hardlinks 2009-09-30 18:54:50 +0000
+++ etckeeper/pre-commit.d/20warn-hardlinks 2009-10-02 17:52:10 +0000
@@ -1,8 +1,10 @@
#!/bin/sh
set -e
+. /usr/share/etckeeper/functions.sh
+
if [ "$VCS" = git ] || [ "$VCS" = hg ] || [ "$VCS" = bzr ] || [ "$VCS" = darcs
]; then
- hardlinks=$(find -type f -not -links 1 | grep -v
'/\(.git\|.hg\|.bzr\|_darcs\)/' ) || true
+ hardlinks=$(find -type f -not -links 1 | grep -v
'/\(.git\|.hg\|.bzr\|_darcs\)/' | filter_ignored) || true
if [ -n "$hardlinks" ]; then
echo "etckeeper warning: hardlinked files could cause problems
with $VCS:" >&2
echo "$hardlinks" >&2
=== modified file 'etckeeper/pre-commit.d/20warn-special-file'
--- etckeeper/pre-commit.d/20warn-special-file 2009-09-30 18:54:50 +0000
+++ etckeeper/pre-commit.d/20warn-special-file 2009-10-02 16:44:15 +0000
@@ -1,8 +1,10 @@
#!/bin/sh
set -e
+. /usr/share/etckeeper/functions.sh
+
if [ "$VCS" = git ] || [ "$VCS" = hg ] || [ "$VCS" = bzr ] || [ "$VCS" = darcs
]; then
- special=$(find -not -type d -not -type f -not -type l | grep -v
'/\(.git\|.hg\|.bzr\|_darcs\)/') || true
+ special=$(find -not -type d -not -type f -not -type l | grep -v
'/\(.git\|.hg\|.bzr\|_darcs\)/' | filter_ignored) || true
if [ -n "$special" ]; then
echo "etckeeper warning: special files could cause problems
with $VCS:" >&2
echo "$special" >&2
# Utility functions for etckeeper scripts
# This is a shell fragment
filter_ignored () {
perl -e '
use File::Spec;
# create a hash of files ignored by the VCS
if ($ENV{VCS}=="bzr") {
$ignored = qx/bzr ls -R --ignored/;
# suppress ??? that "bzr ls" appends to the names of
pipes and sockets
$ignored =~ s/\?\?\?$//mg;
}
@ignored{ map {File::Spec->rel2abs($_)} split "\n", $ignored }
= ();
# filter out ignored files
while (<>) {
chomp;
print "$_\n" unless exists
$ignored{File::Spec->rel2abs($_)};
}
'
}