* Added configuration options for highlevel and lowlevel package managers
authorJoey Hess <joey@kodama.kitenet.net>
Fri, 4 Jan 2008 02:12:05 +0000 (21:12 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Fri, 4 Jan 2008 02:12:05 +0000 (21:12 -0500)
    in etckeeper.conf.
  * Only install apt hooks if apt is used.
  * Only add backup conffile exclusion to gitignore if dpkg is used.
  * Rename pre/post-apt.d to pre/post-install.d to allow the same directories
    to be used for other package managers.
  * Use the name of the highlevel package manager in commit messages.

19 files changed:
INSTALL [new file with mode: 0644]
Makefile
README
TODO
apt.conf
debian/changelog
etckeeper
etckeeper.1
etckeeper.conf
init.d/50git-ignore
post-apt.d/README [deleted file]
post-install.d/10git-test [moved from post-apt.d/10git-test with 100% similarity]
post-install.d/30git-add [moved from post-apt.d/30git-add with 100% similarity]
post-install.d/40git-rm [moved from post-apt.d/40git-rm with 100% similarity]
post-install.d/50git-commit [moved from post-apt.d/50git-commit with 51% similarity]
post-install.d/README [new file with mode: 0644]
pre-apt.d/README [deleted file]
pre-install.d/50uncommitted-changes [moved from pre-apt.d/50uncommitted-changes with 91% similarity]
pre-install.d/README [new file with mode: 0644]

diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..56c26e7
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,5 @@
+Before running 'make install', you should edit etckeeper.conf and make sure
+it configured appropriately for your distribution.
+
+Distribution packagers may find it more convenient to set CONFFILE to point
+to a different etckeeper.conf that is preconfigured for your distribution.
index 17ac85485c0fa1a9d5af0da05ee5a42e53df5d3b..23cb3ea80e029dc8ca77c52c5e6ab02ad2d460bd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,15 @@
+# You should configure etckeeper.conf for your distribution before
+# installing etckeeper.
+CONFFILE=etckeeper.conf
+include $(CONFFILE)
+
 install:
        mkdir -p $(PREFIX)/etc/etckeeper/
        cp -a *.d $(PREFIX)/etc/etckeeper/
-       cp etckeeper.conf $(PREFIX)/etc/etckeeper/
+       cp $(CONFFILE) $(PREFIX)/etc/etckeeper/etckeeper.conf
        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
-       install -m 0644 -D bash_completion $(PREFIX)/etc/bash_completion.d/etckeeper
\ No newline at end of file
+       install -m 0644 -D bash_completion $(PREFIX)/etc/bash_completion.d/etckeeper
+ifeq ($(HIGHLEVEL_PACKAGE_MANAGER),apt))
+       install -m 0644 -D apt.conf $(PREFIX)/etc/apt/apt.conf.d/05etckeeper
+endif
diff --git a/README b/README
index 7ec20b274b438d68faf15f5638986edc52a381ed..c4887c55e4ca182ddae14264e59a0153e31101e6 100644 (file)
--- a/README
+++ b/README
@@ -33,8 +33,8 @@ So don't use it on git repositories from untrusted sources.
 
 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 contains no uncommitted changes.
-After apt installs packages, `etckeeper post-apt` will add any new
+`etckeeper pre-install` will check that /etc contains no uncommitted changes.
+After apt installs packages, `etckeeper post-install` 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
@@ -143,7 +143,7 @@ action.
 For example, here's how to configure it to run `git gc` after each apt run,
 which will save a lot of disk space:
 
-       cd /etc/etckeeper/post-apt.d
+       cd /etc/etckeeper/post-install.d
        (echo '#!/bin/sh' ; echo 'exec git-gc') > 99git-gc
        chmod +x 99git-gc
        git add .
@@ -152,7 +152,7 @@ which will save a lot of disk space:
 Here's how to disable the automatic commits after each apt run, while still
 letting it git-add new files and git-rm removed ones:
 
-       chmod -x /etc/etckeeper/post-apt.d/75git-commit
+       chmod -x /etc/etckeeper/post-install.d/75git-commit
 
 Note that the etckeeper commands are careful to not hardcode anything about
 git. If you want to use some other revision control system, that's
diff --git a/TODO b/TODO
index 4bcd9a9f8bdb9c694edd69af18258e78c4aef657..245f3a4621b2d98890b3c6e807095ba1cacc7217 100644 (file)
--- a/TODO
+++ b/TODO
   in one repo, and public in another. This would need either symlink
   farming or git "fake bare" repos, both of which are not pleasant, yet.
 
-  Another way would be to allow splitting out subdirs into their own
-  repos. This is already doable, would just need modifying the pre-apt and
-  post-apt stuff (ie, it needs to commit in the subdirs too). Using
-  mr would be a possibility..
+  Another way would be to allow splitting out subdirs into their own repos.
+  This is already doable, would just need modifying the pre-install and
+  post-instlal stuff (ie, it needs to commit in the subdirs too). Using mr
+  would be a possibility..
+
+* Figure out what packages were acted on, and include that info in the commit
+  message
index 4293637272b996220cd0daf12ee8ed71fe96f013..97d0f87e002049e697462d999fcdc90efd0cbbdc 100644 (file)
--- a/apt.conf
+++ b/apt.conf
@@ -1,2 +1,2 @@
-DPkg::Pre-Install-Pkgs { "if [ -x /usr/bin/etckeeper ]; then etckeeper pre-apt; fi"; };
-DPkg::Post-Invoke      { "if [ -x /usr/bin/etckeeper ]; then etckeeper post-apt; fi"; };
+DPkg::Pre-Install-Pkgs { "if [ -x /usr/bin/etckeeper ]; then etckeeper pre-install; fi"; };
+DPkg::Post-Invoke      { "if [ -x /usr/bin/etckeeper ]; then etckeeper post-install; fi"; };
index 999da6f7caeca49165875b0a1b0e3a705d59f4ab..f8184721427e8d7f99cd31304e1604fb0c5185d2 100644 (file)
@@ -1,3 +1,15 @@
+etckeeper (0.7) UNRELEASED; urgency=low
+
+  * Added configuration options for highlevel and lowlevel package managers
+    in etckeeper.conf.
+  * Only install apt hooks if apt is used.
+  * Only add backup conffile exclusion to gitignore if dpkg is used.
+  * Rename pre/post-apt.d to pre/post-install.d to allow the same directories
+    to be used for other package managers.
+  * Use the name of the highlevel package manager in commit messages.
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 03 Jan 2008 20:43:23 -0500
+
 etckeeper (0.6) unstable; urgency=low
 
   * Depend on a fairly recent git-core. Closes: #453063
index dfd44bb89de7307753e46cffab184ad19358c450..f78afdfff3feffcab5273eed3bdf37c1689a5c77 100755 (executable)
--- a/etckeeper
+++ b/etckeeper
@@ -8,6 +8,12 @@ fi
 if [ ! -z "$GIT_COMMIT_OPTIONS" ]; then
        export GIT_COMMIT_OPTIONS
 fi
+if [ ! -z "$HIGHLEVEL_PACKAGE_MANAGER" ]; then
+       export HIGHLEVEL_PACKAGE_MANAGER
+fi
+if [ ! -z "$LOWLEVEL_PACKAGE_MANAGER" ]; then
+       export LOWLEVEL_PACKAGE_MANAGER
+fi
 
 if [ -z "$1" ]; then
        echo "usage: etckeeper command [directory]" >&2
index 2d38bf87b449aa5fbbe4f7634cbe3cfd2ca40c12..6d00cdbd589e2b69fab71a1cba2b4eacb9ac56df 100644 (file)
@@ -21,13 +21,14 @@ a clone of the /etc repository located elsewhere.
 This is called as a git pre-commit hook. 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 before the apt run.
+.B pre-install
+This is called by apt's DPkg::Pre-Install-Pkgs hook, or by equivilant hooks
+of other package managers. It allows committing any uncommitted changes before
+packages are installed, upgraded, etc.
 .TP
-.B post-apt
-This is called by apt's DPkg::Post-Invoke hook. It commits changes made by
-packages into the repository. (You can also call this by hand after running
-dpkg by hand.)
+.B post-install
+This is called by apt's DPkg::Post-Invoke hook, or by equivilant hooks
+of other package managers. It commits changes made by packages into the
+repository. (You can also call this by hand after running dpkg by hand.)
 .SH AUTHOR 
 Joey Hess, <joey@kitenet.net>.
index 74bb34abac61c87ba0bdc96ecb939d1c6ad5d195..4a22a65e4a8af845106c0c578620431c9bc64e9a 100644 (file)
@@ -2,3 +2,9 @@
 # You could for exemple use "-e" if you want to edit all commit messages
 # before committing.
 #GIT_COMMIT_OPTIONS="-e"
+
+# The high level package manager that's being used.
+HIGHLEVEL_PACKAGE_MANAGER=apt
+
+# The low-level package manager that's being used.
+LOWLEVEL_PACKAGE_MANAGER=dpkg
index f931592ef417f970f9f946206fbeb943ff148fee..de58ed5b2ecd0f446cbc60902ae1bf7c51f40276 100755 (executable)
@@ -1,11 +1,14 @@
 #!/bin/sh
 set -e
 if [ ! -e .gitignore ]; then
-       cat >.gitignore <<EOF
-*~
-
+       if [ "$LOWLEVEL_PACKAGE_MANAGER" = dpkg ]; then
+               cat >.gitignore <<EOF
 # new and old versions of conffiles, stored by dpkg
 *.dpkg-*
+EOF
+       fi
+       cat >>.gitignore <<EOF
+*~
 
 # mount(8) records system state here, no need to keep these in git
 blkid.tab
diff --git a/post-apt.d/README b/post-apt.d/README
deleted file mode 100644 (file)
index befa5c0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Files in this directory are run after apt has run. They should commit
-changes and new files in /etc to repository.
similarity index 100%
rename from post-apt.d/40git-rm
rename to post-install.d/40git-rm
similarity index 51%
rename from post-apt.d/50git-commit
rename to post-install.d/50git-commit
index 1a5c55adbe781df6b40537c645f0855b711a4222..78247ca23640e93016ce10f405de7738b2a3dc1c 100755 (executable)
@@ -2,10 +2,7 @@
 set -e
 
 if [ -d .git ]; then
-
-       # TODO: figure out what packages were acted on by the apt run, and
-       # include that info in the commit message
-       message="committing changes after apt run"
+       message="committing changes after $HIGHLEVEL_PACKAGE_MANAGER run"
 
        # ignore exit code since it exits nonzero if there is nothing to do
        git commit $GIT_COMMIT_OPTIONS -m "$message" || true
diff --git a/post-install.d/README b/post-install.d/README
new file mode 100644 (file)
index 0000000..62f4f9c
--- /dev/null
@@ -0,0 +1,2 @@
+Files in this directory are run after packages are installed, upgraded, etc.
+They should commit changes and new files in /etc to repository.
diff --git a/pre-apt.d/README b/pre-apt.d/README
deleted file mode 100644 (file)
index 47001b4..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Files in this directory are run before apt is run. This is mostly used for
-sanity checks, ie, does /etc have any uncommitted changes?
similarity index 91%
rename from pre-apt.d/50uncommitted-changes
rename to pre-install.d/50uncommitted-changes
index d39401c14a216ce42c31a98cb6502c3d82f65aab..f8811ad09cb792b6df55941babca47bf0e4dc013 100755 (executable)
@@ -12,7 +12,7 @@ if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean";
        db_get etckeeper/unclean
        if [ "$RET" = true ]; then
                git add .
-               if ! git commit $GIT_COMMIT_OPTIONS -m "saving uncommitted changes in /etc prior to apt run"; then
+               if ! git commit $GIT_COMMIT_OPTIONS -m "saving uncommitted changes in /etc prior to $HIGHLEVEL_PACKAGE_MANAGER run"; then
                        db_input critical etckeeper/commit_failed || true
                        db_go || true
                        db_reset etckeeper/commit_failed || true
diff --git a/pre-install.d/README b/pre-install.d/README
new file mode 100644 (file)
index 0000000..a3b5a57
--- /dev/null
@@ -0,0 +1,3 @@
+Files in this directory are run before packages are installed, upgraded,
+etc. This is mostly used for sanity checks, ie, does /etc have any
+uncommitted changes?