implemented pre-apt checks
authorJoey Hess <joey@kodama.kitenet.net>
Mon, 5 Nov 2007 21:25:21 +0000 (16:25 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Mon, 5 Nov 2007 21:25:21 +0000 (16:25 -0500)
other development too..

README
init.d/40git-pre-commit-hook
post-apt.d/README
pre-apt.d/50uncommitted-changes [new file with mode: 0755]
pre-apt.d/README
pre-commit.d/10warn-empty-directory [moved from pre-commit.d/10warn-empty with 61% similarity]
pre-commit.d/10warn-hardlinks
pre-commit.d/10warn-special-file [moved from pre-commit.d/10warn-special with 64% similarity]

diff --git a/README b/README
index f9a6115c3f6d64210c88d9af806448ac20f2e767..2751eb75cc585ebdf4ba6db1de8dacde3d095963 100644 (file)
--- a/README
+++ b/README
@@ -28,10 +28,9 @@ repository.
 
 etckeeper has special support to handle changes to /etc caused by
 installing and upgrading packages. Before apt installs packages,
-`etckeeper-pre-apt` will check that /etc is clean, and if it's not, prompt
-you about whether or not to continue. (This check can be disabled.) After
-apt installs packages, `etckeeper-post-apt` will add any new interesting
-files to the repository, and commit the changes.
+`etckeeper-pre-apt` will check that /etc contains no uncommitted changes.
+After apt installs packages, `etckeeper-post-apt` will add any new
+interesting files to the repository, and commit the changes.
 
 git is designed as a way to manage source code, not as a way to manage
 arbitrary directories like /etc. This means it has a few limitations that
@@ -54,7 +53,7 @@ empty directory, if it's not significant, or put a file (such as
 
 git doesn't support several special files that you _probably_ won't have in
 /etc, such as unix sockets, named pipes, hardlinked files (but softlinks
-are fine), and device files. Again git hooks are used to warn if your /etc
+are fine), and device files. Again git hooks are used to warn if your /etc
 contains such untrackable special files.
 
 
index a5b45d34ee7431b85f1a1c9227d2c88f306039de..f1609ebd70ed5587ad1a9c21319acf6b178e3dee 100755 (executable)
@@ -2,7 +2,7 @@
 set -e
 if [ -x .git/hooks/pre-commit ]; then
        if ! grep -q etckeeper-pre-commit .git/hooks/pre-commit; then
-               echo "warning: .git/hooks/pre-commit needs to be manually modifed to run etckeeper-pre-commit" >&2
+               echo "etckeeper warning: .git/hooks/pre-commit needs to be manually modifed to run etckeeper-pre-commit" >&2
        fi
 else
        echo <<EOF >>.git/hooks/pre-commit
index 34b65ac3d7ff69a6cc937155d582ff3e7b185c86..befa5c057701f237581e89210525ca54b01d811c 100644 (file)
@@ -1,2 +1,2 @@
 Files in this directory are run after apt has run. They should commit
-changed and new files in the working directory to to repository.
+changes and new files in /etc to repository.
diff --git a/pre-apt.d/50uncommitted-changes b/pre-apt.d/50uncommitted-changes
new file mode 100755 (executable)
index 0000000..4c0c5ee
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+cd /etc
+while git-status || ! LANG=C git-status 2>&1 | grep -q "working directory clean"
+do
+       echo "etckeeper warning: /etc has uncommitted changes" >&2
+       printf "Press Enter to commit these changes and continue. "
+       read line
+       git add .
+       if ! git commit -m "saving uncommitted changes in /etc prior to apt run"; then
+               echo "etckeeper warning: git commit failed" >&2
+               echo "Please resolve the uncommitted changes by hand."
+               printf "Press Enter when ready to continue. "
+               read line
+       fi
+done
index aadbd4f1f52d73a9bc6608abfc60b9d7ab7133ba..47001b491f7c12b81dd245a8f8222a8dab31c294 100644 (file)
@@ -1,2 +1,2 @@
 Files in this directory are run before apt is run. This is mostly used for
-sanity checks, ie, does the working directory have any uncommitted changes?
+sanity checks, ie, does /etc have any uncommitted changes?
similarity index 61%
rename from pre-commit.d/10warn-empty
rename to pre-commit.d/10warn-empty-directory
index 8dcb3575b96d63fa6996bc07c5496b31a50ace2d..eed41aeaff039bd6dd70fc27c92f18e2136fea79 100755 (executable)
@@ -2,6 +2,6 @@
 set -e
 empty=$(find -type f -empty | grep -v /.git/)
 if [ -n "$empty" ]; then
-       echo "warning: empty directories, not tracked by git:" >&2
+       echo "etckeeper warning: empty directories, not tracked by git:" >&2
        echo "$empty" >&2
 fi
index f449fedda01797553ec00b3ff72244be5d6fd8ea..29f007b9a9141e5eb7561e87518cab73ed4b33a3 100755 (executable)
@@ -2,6 +2,6 @@
 set -e
 hardlinks=$(find -type f -not -links 1 | grep -v /.git/)
 if [ -n "$hardlinks" ]; then
-       echo "warning: hardlinked files could cause problems with git:" >&2
+       echo "etckeeper warning: hardlinked files could cause problems with git:" >&2
        echo "$hardlinks" >&2
 fi
similarity index 64%
rename from pre-commit.d/10warn-special
rename to pre-commit.d/10warn-special-file
index 92d1d3dabfd959d8c5335ba4bb4cd360a1cd4606..aa5c683561215331cfc4059089c486cfbf46ad5b 100755 (executable)
@@ -2,6 +2,6 @@
 set -e
 special=$(find -not -type d -not -type f -not -type l | grep -v /.git/)
 if [ -n "$special" ]; then
-       echo "warning: special files could cause problems with git:" >&2
+       echo "etckeeper warning: special files could cause problems with git:" >&2
        echo "$special" >&2
 fi