summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--README16
-rwxr-xr-xetckeeper2
-rw-r--r--etckeeper.131
-rwxr-xr-xinit.d/40git-ignore3
-rwxr-xr-xpost-apt.d/75git-commit5
-rwxr-xr-xpre-apt.d/50uncommitted-changes14
-rwxr-xr-xpre-commit.d/10warn-empty-directory3
8 files changed, 53 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index 96f7fb8..4497b0d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,13 @@ install:
cp -a *.d $(PREFIX)/usr/lib/etckeeper/
install -D etckeeper $(PREFIX)/usr/bin/etckeeper
+ install -m 0644 -D apt.conf $(PREFIX)/etc/apt/apt.conf.d/05etckeeper
+ install -m 0644 -D etckeeper.1 $(PREFIX)/usr/share/man/man1/etckeeper.1
+
for dir in *.d; do \
command=$$(echo "$$dir" | sed -e 's/\.d$$//'); \
- ln -s etckeeper $(PREFIX)/usr/bin/etckeeper-$$command; \
+ ln -sf etckeeper $(PREFIX)/usr/bin/etckeeper-$$command; \
+ ln -sf etckeeper.1 $(PREFIX)/usr/share/man/man1/etckeeper-$$command.1; \
done
for dir in *.d; do \
@@ -14,5 +18,3 @@ install:
ln -sf /usr/lib/etckeeper/$$file $(PREFIX)/etc/etckeeper/$$file; \
done; \
done
-
- install -m 0644 -D apt.conf $(PREFIX)/etc/apt/apt.conf.d/05etckeeper
diff --git a/README b/README
index 6fb04d9..690b669 100644
--- a/README
+++ b/README
@@ -85,17 +85,11 @@ further changes:
Rinse, lather, repeat.
-etckeeper hooks into apt so changed or new files caused by installing or
-upgrading packages will automatically be added and committed.
-(`etckeeper-post-apt` uses `git-add .`, so any new files in /etc that arn't
-gitignored will be added.)
-
-If a package *removes* a file from /etc, etckeeper does not automatically
-commit this removal, though it will let you know that the file was removed.
-You can manually remove it with commands like these;
-
- git rm init.d/somedaemon rc*.d/*somedaemon
- git commit -a "removed somedaemon"
+etckeeper hooks into apt so changes to files in /etc caused by installing or
+upgrading packages will automatically be committed. (`etckeeper-post-apt`
+uses `git-add .`, so any new files in /etc that arn't gitignored will be
+added. If it auto-adds files you don't want added, put them in
+`.gitignore`.)
You can use any git commands you like, but do keep in mind that, if you
check out a different branch or an old version, git is operating directly
diff --git a/etckeeper b/etckeeper
index c05845d..0840e85 100755
--- a/etckeeper
+++ b/etckeeper
@@ -19,7 +19,7 @@ fi
if [ "$command" = post-apt ] || [ "$command" = pre-apt ]; then
cd /etc
-elif [ "$command" = pre-commit ]; then
+elif [ "$command" = pre-commit ] && [ -n "$1" ]; then
chdir "$1"
fi
diff --git a/etckeeper.1 b/etckeeper.1
new file mode 100644
index 0000000..bcecf59
--- /dev/null
+++ b/etckeeper.1
@@ -0,0 +1,31 @@
+.\" -*- nroff -*-
+.TH ETCKEEPER 1 "" "" ""
+.SH NAME
+etckeeper \- keep /etc in git
+.SH SYNOPSIS
+.B etckeeper command [args]
+.SH DESCRIPTION
+etckeeper is a collection of tools to let /etc be stored in a git
+repository. Please see its README for more detailed information.
+.SH COMMANDS
+.TP
+.B init
+This is the only command you typically need to run by hand. It initialises
+a git repository for the current directory. Typically this is run in /etc
+once when starting to use etckeeper on a machine. It can also be used to
+initialise a clone of the /etc repository.
+.TP
+.B pre-commit
+This is called as a git pre-commit hook. It should be passed the name
+of the toplevel directory of the repository (typically /etc). It stores
+metadata and does sanity checks.
+.TP
+.B pre-apt
+This is called by apt's DPkg::Pre-Install-Pkgs hook. It allows committing
+any uncommitted changes in /etc before the apt run.
+.TP
+.B post-apt
+This is called by apt's DPkg::Post-Invoke hook. It commits changes made by
+packages to the repository.
+.SH AUTHOR
+Joey Hess, <joey@kitenet.net>.
diff --git a/init.d/40git-ignore b/init.d/40git-ignore
index f99f396..88866cf 100755
--- a/init.d/40git-ignore
+++ b/init.d/40git-ignore
@@ -5,8 +5,7 @@ if [ ! -e .gitignore ]; then
*~
# new and old versions of conffiles, stored by dpkg
-*.dpkg-new
-*.dpkg-old
+*.dpkg-*
# mount(8) records system state here, no need to keep these in git
blkid.tab(|.old)
diff --git a/post-apt.d/75git-commit b/post-apt.d/75git-commit
index 0a84fbd..30ef0f2 100755
--- a/post-apt.d/75git-commit
+++ b/post-apt.d/75git-commit
@@ -5,6 +5,5 @@ set -e
# that info in the commit message
message="committing changes after apt run"
-if ! git commit -m "$message"; then
- echo "etckeeper warning: git-commit failed"
-fi
+# ignore exit code since it exits nonzero if there is nothing to do
+git commit -m "$message" || true
diff --git a/pre-apt.d/50uncommitted-changes b/pre-apt.d/50uncommitted-changes
index 5a198ef..c8e4736 100755
--- a/pre-apt.d/50uncommitted-changes
+++ b/pre-apt.d/50uncommitted-changes
@@ -1,15 +1,15 @@
#!/bin/sh
set -e
-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
+if ! LANG=C git-status 2>&1 | grep -q "working directory clean"; then
+ git-status || true
+ echo "etckeeper warning: /etc is not clean" >&2
+ printf "Press Enter to commit changes and continue. "
+ read line </dev/tty
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
+ read line </dev/tty
fi
-done
+fi
diff --git a/pre-commit.d/10warn-empty-directory b/pre-commit.d/10warn-empty-directory
index ef70b72..b850c86 100755
--- a/pre-commit.d/10warn-empty-directory
+++ b/pre-commit.d/10warn-empty-directory
@@ -2,6 +2,5 @@
set -e
empty=$(find -type d -empty | grep -v /.git/) || true
if [ -n "$empty" ]; then
- echo "etckeeper warning: empty directories, not tracked by git:" >&2
- echo "$empty" >&2
+ echo "etckeeper warning: there are some empty directories, which git will ignore" >&2
fi