etckeeper – keeping /etc in a git repository

When having a look at git yesterday, I stumbled upon etckeeper, a tool to keep /etc in a git (or mercurial) repository and also keeps the metadata (file permissions, …) in the repo making use of metastore.

It hooks into apt but I used /etc/portage/basrc to call it before and after installing a package:

case “$EBUILD_PHASE” in
preinst)
elog “Running etckeeper pre-install…”
/usr/bin/etckeeper pre-install
;;
postinst)
elog “Running etckeeper post-install…”
/usr/bin/etckeeper post-install
;;
esac

One could also modify /etc/etckeeper/post-install.d/50vcs-commit to include the package name etc. in the commit message while emerging:

— a/post-install.d/50vcs-commit
+++ b/post-install.d/50vcs-commit
@@ -2,5 +2,12 @@
set -e

if etckeeper unclean; then
- etckeeper commit “committing changes after $HIGHLEVEL_PACKAGE_MANAGER run”
+ case $LOWLEVEL_PACKAGE_MANAGER in
+ portage)
+ etckeeper commit “committing changes after $HIGHLEVEL_PACKAGE_MANAGER run ($CATEGORY/$P)”
+ ;;
+ *)
+ etckeeper commit “committing changes after $HIGHLEVEL_PACKAGE_MANAGER run”
+ ;;
+ esac
fi

There are probably other/better ways to accomplish this and more…

Anyways… etckeeper looks like a nice and very flexible tool to keep /etc in a repository if one wants to.

This entry was posted in Computer stuff, English, Gentoo and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. vti
    Posted 5 Mar 2008 at 17:43 | Permalink

    That’s is very cool! :-)

    Time to write an ebuild? ;-)

  2. derfian
    Posted 5 Mar 2008 at 20:54 | Permalink

    Also, dispatch-conf can be configured to use RCS. RCS may not have the coolness factor of git, but it works very well for keeping a history of config files.

  3. jeremy
    Posted 7 Mar 2008 at 20:33 | Permalink

    Neat. Hope to see an ebuild soon ;)

  4. Posted 7 Mar 2008 at 21:38 | Permalink

    Well… I’m just a security dev ;-) and actually I don’t have much time for Gentoo at the moment thanks to my thesis.

    derfian: I use dispatch-conf with RCS on my machines too. I just found etckeeper interesting since I had a look at git anyways and of course it comes with the extra features of git, like remote repos and such. Though the question is if one really needs it…

  5. Posted 2 Feb 2009 at 21:29 | Permalink

    Ho provato a farlo io l’ebuil per etckeeper e metastore(dipendenza di etckeeper). Lo trovate su http://www.salug.it/~sydro/progetti

Post a Comment

Your email is never published nor shared.