summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-03-11 15:03:24 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-03-11 15:03:24 -0400
commit6398f205b74c158eecdf2ed6a057f77f64db0340 (patch)
treee0ad2676db44d647972ea7a3fbbccb46aaa3a798
parent93b0abfb666273774e3c418f31396b5b5ad1c043 (diff)
* Add support for bzr, thanks to Mark A. Hershberger. Closes: #470515
(Note that bzr does not support etckeeper's pre-commit hook.)
-rw-r--r--README48
-rwxr-xr-xcommit.d/10vcs-test2
-rwxr-xr-xcommit.d/40bzr-rm12
-rwxr-xr-xcommit.d/45bzr-precommit6
-rwxr-xr-xcommit.d/50vcs-commit6
-rw-r--r--debian/changelog2
-rw-r--r--debian/control8
-rwxr-xr-xetckeeper3
-rw-r--r--etckeeper.119
-rw-r--r--etckeeper.conf4
-rwxr-xr-xinit.d/40vcs-init2
-rwxr-xr-xinit.d/50vcs-ignore4
-rwxr-xr-xinit.d/50vcs-perm2
-rwxr-xr-xinit.d/70vcs-add4
-rwxr-xr-xpre-commit.d/20warn-hardlinks2
-rwxr-xr-xpre-commit.d/20warn-special-file2
-rwxr-xr-xpre-commit.d/30store-metadata6
-rwxr-xr-xunclean.d/50test2
-rwxr-xr-xunclean.d/50test.orig8
19 files changed, 102 insertions, 40 deletions
diff --git a/README b/README
index 2422151..296b46f 100644
--- a/README
+++ b/README
@@ -1,10 +1,11 @@
-etckeeper is a collection of tools to let /etc be stored in a git or
-mercurial repository. It hooks into apt to automatically commit changes
-made to /etc during package upgrades. It uses [metastore][1] to track file
-metadata that git does not normally support, but that is important for
-/etc, such as the permissions of `/etc/shadow`. It's quite modular and
-configurable, while also being simple to use if you understand the basics
-of working with version control.
+etckeeper is a collection of tools to let /etc be stored in a git,
+mercurial, or bazaar repository. It hooks into apt to automatically
+commit changes made to /etc during package upgrades. It uses
+[metastore][1] to track file metadata that git does not normally
+support, but that is important for /etc, such as the permissions of
+`/etc/shadow`. It's quite modular and configurable, while also being
+simple to use if you understand the basics of working with version
+control.
[1]: http://david.hardeman.nu/software.php
@@ -20,7 +21,7 @@ or copying these repositories, not to allow anyone else to see the data.
Since git mushes all the files into packs under the .git directory, the
whole .git directory content needs to be kept secret. (Ditto for mercurial
-and .hg)
+and .hg as well as bazaar and .bzr)
Also, since revision control systems don't keep track of the mode of files
like the shadow file, it will check out world readable, before etckeeper
@@ -44,24 +45,29 @@ a way to manage arbitrary directories like /etc. This means there are a few
limitations that etckeeper has to work around. These include file metadata
storage, empty directories, and special files.
-git and mercurial have only limited tracking of file metadata, being able
-to track the executable bit, but not other permissions or owner info. So
-file metadata storage is handled by `metastore`. Among other chores,
-`etckeeper init` sets up a `pre-commit` hook that uses `metastore` to store
-metadata about file owners, permissions, and even extended attributes into
-a `/etc/.metadata` file. This metadata is stored in git along with
-everything else, and can be applied if the repo should need to be checked
-back out.
+Most VCS, including git, mercurial and bazaar have only limited tracking of
+file metadata, being able to track the executable bit, but not other
+permissions or owner info. So file metadata storage is handled by
+`metastore`. Among other chores, `etckeeper init` sets up a `pre-commit`
+hook that uses `metastore` to store metadata about file owners,
+permissions, and even extended attributes into a `/etc/.metadata` file.
+This metadata is stored in version control along with everything else, and
+can be applied if the repo should need to be checked back out.
+
+Warning: bazaar cannot support running etckeeper's pre-commit hook. To
+ensure that all file metadata is stored in bzr, you have to manually
+run "etckeeper pre-commit" before committing to bazaar.
git and mercurial cannot track empty directories, but they can be
significant sometimes in /etc. So the `pre-commit` hook also stores
information that can be used to recreate the empty directories in a
`/etc/.etckeeper` file.
-git and mercurial don'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. The `pre-commit` hook will warn
-if your /etc contains such special files.
+Most VCS, including git, mercurial, and bazaar don'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. The `pre-commit` hook will warn if your /etc contains
+such special files.
## tutorial
@@ -70,7 +76,7 @@ A quick walkthrough of using etckeeper.
First, edit `/etc/etckeeper/etckeeper.conf` to select which version control
system to use. The default is git, and this tutorial assumes you're using
-it. Mercurial is similar.
+it. Mercurial and bazaar are similar.
The `etckeeper init` command initialises an /etc/.git/ repository. This
command is careful to never overwrite existing files or directories in
diff --git a/commit.d/10vcs-test b/commit.d/10vcs-test
index ddd4448..1fd4226 100755
--- a/commit.d/10vcs-test
+++ b/commit.d/10vcs-test
@@ -10,4 +10,6 @@ if [ "$VCS" = git ] && [ ! -d .git ]; then
not_enabled_warning
elif [ "$VCS" = hg ] && [ ! -d .hg ]; then
not_enabled_warning
+elif [ "$VCS" = bzr ] && [ ! -d .bzr ]; then
+ not_enabled_warning
fi
diff --git a/commit.d/40bzr-rm b/commit.d/40bzr-rm
new file mode 100755
index 0000000..a13bfd7
--- /dev/null
+++ b/commit.d/40bzr-rm
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+
+TAB=" "
+
+if [ "$VCS" = bzr ] && [ -d .bzr ]; then
+ for file in $(bzr deleted); do
+ if [ ! -d "$file" ]; then
+ bzr rm --keep --quiet "$file"
+ fi
+ done
+fi
diff --git a/commit.d/45bzr-precommit b/commit.d/45bzr-precommit
new file mode 100755
index 0000000..3128c7a
--- /dev/null
+++ b/commit.d/45bzr-precommit
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = bzr ] && [ -d .bzr ]; then
+ etckeeper precommit .
+fi
diff --git a/commit.d/50vcs-commit b/commit.d/50vcs-commit
index 48fa177..86fe8fb 100755
--- a/commit.d/50vcs-commit
+++ b/commit.d/50vcs-commit
@@ -15,4 +15,10 @@ elif [ "$VCS" = hg ] && [ -d .hg ]; then
else
hg commit $HG_COMMIT_OPTIONS
fi
+elif [ "$VCS" = bzr ] && [ -d .bzr ]; then
+ if [ -n "$message" ]; then
+ bzr commit $BZR_COMMIT_OPTIONS -m "$message"
+ else
+ bzr commit $BZR_COMMIT_OPTIONS
+ fi
fi
diff --git a/debian/changelog b/debian/changelog
index 19a2e5b..f9fbbcb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
etckeeper (0.12) UNRELEASED; urgency=low
* Use git ls-files instead of git status. Depend on new enough git for this.
+ * Add support for bzr, thanks to Mark A. Hershberger. Closes: #470515
+ (Note that bzr does not support etckeeper's pre-commit hook.)
-- Joey Hess <joeyh@debian.org> Fri, 29 Feb 2008 15:12:51 -0500
diff --git a/debian/control b/debian/control
index dd33cef..87cb67c 100644
--- a/debian/control
+++ b/debian/control
@@ -10,11 +10,11 @@ Homepage: http://kitenet.net/~joey/code/etckeeper/
Package: etckeeper
Architecture: all
Section: admin
-Depends: metastore, git-core (>= 1:1.5.4) | mercurial, ${misc:Depends}
+Depends: metastore, git-core (>= 1:1.5.4) | mercurial | bzr (>= 1.0), ${misc:Depends}
Description: store /etc in git or mercurial
- The etckeeper program is a tool to let /etc be stored in a git or mercurial
- repository. It hooks into APT to automatically commit changes made to /etc
- during package upgrades. It uses 'metastore' to track file metadata that
+ The etckeeper program is a tool to let /etc be stored in a git, mercurial,
+ or bzr repository. It hooks into APT to automatically commit changes made to
+ /etc during package upgrades. It uses 'metastore' to track file metadata that
version control systems do not normally support, but that is important for
/etc, such as the permissions of /etc/shadow. It's quite modular and
configurable, while also being simple to use if you understand the basics of
diff --git a/etckeeper b/etckeeper
index f237315..49d1063 100755
--- a/etckeeper
+++ b/etckeeper
@@ -23,6 +23,9 @@ fi
if [ ! -z "$HG_COMMIT_OPTIONS" ]; then
export HG_COMMIT_OPTIONS
fi
+if [ ! -z "$BZR_COMMIT_OPTIONS" ]; then
+ export BZR_COMMIT_OPTIONS
+fi
if [ ! -z "$HIGHLEVEL_PACKAGE_MANAGER" ]; then
export HIGHLEVEL_PACKAGE_MANAGER
diff --git a/etckeeper.1 b/etckeeper.1
index e05cd5f..c313a0c 100644
--- a/etckeeper.1
+++ b/etckeeper.1
@@ -1,22 +1,23 @@
.\" -*- nroff -*-
.TH ETCKEEPER 1 "" "" ""
.SH NAME
-etckeeper \- store /etc in git or mercurial
+etckeeper \- store /etc in git, mercurial, or bazaar
.SH SYNOPSIS
.B etckeeper command [-d directory]
.SH DESCRIPTION
-etckeeper manages /etc be stored in a git or mercurial repository. By
-default each of the commands operates on /etc, but a different directory
-can be specified to operate on a clone of the /etc repository located
-elsewhere.
+etckeeper manages /etc be stored in a git, mercurial, or bazaar
+repository. By default each of the commands operates on /etc, but a
+different directory can be specified to operate on a clone of the /etc
+repository located elsewhere.
.SH COMMANDS
.TP
.B init
-This is the only command you typically need to run by hand. It initialises
-and sets up a git or mercurial repository (depending on the VCS setting in
+This is the only command you typically need to run by hand. It
+initialises and sets up a git, mercurial, or bazaar repository
+(depending on the VCS setting in
/etc/etckeeper/etckeeper.conf). 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 located elsewhere.
+when starting to use etckeeper on a machine. It can also be used to
+initialise a clone of the /etc repository located elsewhere.
.TP
.B commit [message]
Commits changes in /etc to the repository. A commit message can be
diff --git a/etckeeper.conf b/etckeeper.conf
index bd07ea7..f7a7ddf 100644
--- a/etckeeper.conf
+++ b/etckeeper.conf
@@ -1,6 +1,7 @@
# The VCS to use.
# VCS="hg"
VCS="git"
+# VCS="bzr"
# Options passed to git commit when run by etckeeper.
#GIT_COMMIT_OPTIONS=""
@@ -8,6 +9,9 @@ VCS="git"
# Options passed to hg commit when run by etckeeper.
#HG_COMMIT_OPTIONS=""
+# Options passed to bzr commit when run by etckeeper.
+#BZR_COMMIT_OPTIONS=""
+
# The high-level package manager that's being used.
HIGHLEVEL_PACKAGE_MANAGER=apt
diff --git a/init.d/40vcs-init b/init.d/40vcs-init
index e2677bc..dec33a4 100755
--- a/init.d/40vcs-init
+++ b/init.d/40vcs-init
@@ -8,4 +8,6 @@ elif [ "$VCS" = hg ] && [ ! -e .hg ]; then
hg init
echo "[web]" > .hg/hgrc
echo "description = $(hostname) /etc repository" >> .hg/hgrc
+elif [ "$VCS" = bzr ] && [ ! -e .bzr ]; then
+ bzr init
fi
diff --git a/init.d/50vcs-ignore b/init.d/50vcs-ignore
index c11a12e..43c245d 100755
--- a/init.d/50vcs-ignore
+++ b/init.d/50vcs-ignore
@@ -5,6 +5,8 @@ if [ "$VCS" = git ] && [ ! -e .gitignore ]; then
file=.gitignore
elif [ "$VCS" = hg ] && [ ! -e .hgignore ]; then
file=.hgignore
+elif [ "$VCS" = bzr ] && [ ! -e .bzrignore ]; then
+ file=.bzrignore
fi
if [ -z "$file" ] || [ -e "$file" ]; then
@@ -24,7 +26,7 @@ ignore() {
glob="$1"
case "$VCS" in
- git)
+ git|bzr)
echo "$glob" >> $file
;;
hg)
diff --git a/init.d/50vcs-perm b/init.d/50vcs-perm
index 9ffad92..f9a6b8c 100755
--- a/init.d/50vcs-perm
+++ b/init.d/50vcs-perm
@@ -5,4 +5,6 @@ if [ "$VCS" = git ]; then
chmod 700 .git
elif [ "$VCS" = hg ]; then
chmod 700 .hg
+elif [ "$VCS" = bzr ]; then
+ chmod 700 .bzr
fi
diff --git a/init.d/70vcs-add b/init.d/70vcs-add
index 8cf60d0..e6ab3d1 100755
--- a/init.d/70vcs-add
+++ b/init.d/70vcs-add
@@ -9,4 +9,8 @@ elif [ "$VCS" = hg ]; then
if ! hg add .; then
echo "etckeeper warning: hg add failed" >&2
fi
+elif [ "$VCS" = bzr ]; then
+ if ! bzr add .; then
+ echo "etckeeper warning: bzr add failed" >&2
+ fi
fi
diff --git a/pre-commit.d/20warn-hardlinks b/pre-commit.d/20warn-hardlinks
index 8716dbd..e82740a 100755
--- a/pre-commit.d/20warn-hardlinks
+++ b/pre-commit.d/20warn-hardlinks
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-if [ "$VCS" = git ] || [ "$VCS" = hg ]; then
+if [ "$VCS" = git ] || [ "$VCS" = hg ] || [ "$VCS" = bzr ]; then
hardlinks=$(find -type f -not -links 1 | grep -v /.git/) || true
if [ -n "$hardlinks" ]; then
echo "etckeeper warning: hardlinked files could cause problems with $VCS:" >&2
diff --git a/pre-commit.d/20warn-special-file b/pre-commit.d/20warn-special-file
index 42e812b..0835687 100755
--- a/pre-commit.d/20warn-special-file
+++ b/pre-commit.d/20warn-special-file
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-if [ "$VCS" = git ] || [ "$VCS" = hg ]; then
+if [ "$VCS" = git ] || [ "$VCS" = hg ] || [ "$VCS" = bzr ]; then
special=$(find -not -type d -not -type f -not -type l | grep -v /.git/) || true
if [ -n "$special" ]; then
echo "etckeeper warning: special files could cause problems with $VCS:" >&2
diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata
index 19b4673..7a75344 100755
--- a/pre-commit.d/30store-metadata
+++ b/pre-commit.d/30store-metadata
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-if [ "$VCS" = git ] || [ "$VCS" = hg ]; then
+if [ "$VCS" = git ] || [ "$VCS" = hg ] || [ "$VCS" = bzr ]; then; then
# Make sure the file is not readable by others, since it can leak
# information about contents of non-readable directories in /etc.
umask 077
@@ -20,7 +20,7 @@ if [ "$VCS" = git ] || [ "$VCS" = hg ]; then
if [ "$VCS" = git ]; then
git add .metadata
fi
- # hg add not done, hg will automatically include the file
- # in the current commit
+ # hg and bzr add not done, they will automatically
+ # include the file in the current commit
fi
fi
diff --git a/unclean.d/50test b/unclean.d/50test
index ef8ea93..6829bec 100755
--- a/unclean.d/50test
+++ b/unclean.d/50test
@@ -5,4 +5,6 @@ if [ "$VCS" = git ]; then
[ -d .git ] && [ -n "`git-ls-files --modified --deleted --others --exclude-standard`" ]
elif [ "$VCS" = hg ]; then
[ -d .hg ] && ! hg status 2>&1 | wc -l | grep -q "^0$"
+elif [ "$VCS" = bzr ]; then
+ [ -d .bzr ] && ! bzr status 2>&1 | wc -l | grep -q "^0$"
fi
diff --git a/unclean.d/50test.orig b/unclean.d/50test.orig
new file mode 100755
index 0000000..ef8ea93
--- /dev/null
+++ b/unclean.d/50test.orig
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = git ]; then
+ [ -d .git ] && [ -n "`git-ls-files --modified --deleted --others --exclude-standard`" ]
+elif [ "$VCS" = hg ]; then
+ [ -d .hg ] && ! hg status 2>&1 | wc -l | grep -q "^0$"
+fi