summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-04 17:38:10 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-04 17:38:10 -0500
commit788ae5a34c0fad2e3c0788a745400a138d735195 (patch)
tree2517eb3ccf206f4ed7b6ef6a1d543c87caaf2e41 /init.d
parent69739dd0341ba72a645344ea14658f0ede006079 (diff)
parentfd4a85189390d6e6f022eb8f71fcecb5d5f82958 (diff)
Merge branch 'hg'
Significantly refactored
Diffstat (limited to 'init.d')
-rwxr-xr-xinit.d/40git-init6
-rwxr-xr-xinit.d/40vcs-init11
-rwxr-xr-xinit.d/50git-ignore34
-rwxr-xr-xinit.d/50git-perm3
-rwxr-xr-xinit.d/50git-pre-commit-hook15
-rwxr-xr-xinit.d/50vcs-ignore70
-rwxr-xr-xinit.d/50vcs-perm8
-rwxr-xr-xinit.d/50vcs-pre-commit-hook32
-rwxr-xr-xinit.d/70git-add5
-rwxr-xr-xinit.d/70vcs-add12
10 files changed, 133 insertions, 63 deletions
diff --git a/init.d/40git-init b/init.d/40git-init
deleted file mode 100755
index 1554166..0000000
--- a/init.d/40git-init
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-set -e
-if [ ! -e .git ]; then
- git init
- echo "$(hostname) /etc repository" > .git/description
-fi
diff --git a/init.d/40vcs-init b/init.d/40vcs-init
new file mode 100755
index 0000000..e2677bc
--- /dev/null
+++ b/init.d/40vcs-init
@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = git ] && [ ! -e .git ]; then
+ git init
+ echo "$(hostname) /etc repository" > .git/description
+elif [ "$VCS" = hg ] && [ ! -e .hg ]; then
+ hg init
+ echo "[web]" > .hg/hgrc
+ echo "description = $(hostname) /etc repository" >> .hg/hgrc
+fi
diff --git a/init.d/50git-ignore b/init.d/50git-ignore
deleted file mode 100755
index 71469ab..0000000
--- a/init.d/50git-ignore
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-set -e
-if [ ! -e .gitignore ]; then
- if [ "$LOWLEVEL_PACKAGE_MANAGER" = dpkg ]; then
- cat >.gitignore <<EOF
-# new and old versions of conffiles, stored by dpkg
-*.dpkg-*
-EOF
- fi
- if [ "$LOWLEVEL_PACKAGE_MANAGER" = "pacman-g2" ]; then
- cat >.gitignore <<EOF
-# new and old versions of conffiles, stored by pacman
-*.pacnew
-*.pacorig
-*.pacsave
-EOF
- fi
- cat >>.gitignore <<EOF
-
-*~
-
-# mount(8) records system state here, no need to keep these in git
-blkid.tab
-blkid.tab.old
-
-# some other files in /etc that typically do not need to be tracked
-ld.so.cache
-mtab
-.pwd.lock
-network/run
-adjtime
-
-EOF
-fi
diff --git a/init.d/50git-perm b/init.d/50git-perm
deleted file mode 100755
index 564e489..0000000
--- a/init.d/50git-perm
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-set -e
-chmod 700 .git
diff --git a/init.d/50git-pre-commit-hook b/init.d/50git-pre-commit-hook
deleted file mode 100755
index 0efd5e4..0000000
--- a/init.d/50git-pre-commit-hook
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-set -e
-if [ -x .git/hooks/pre-commit ]; then
- if ! grep -q "etckeeper pre-commit" .git/hooks/pre-commit; then
- echo "etckeeper warning: .git/hooks/pre-commit needs to be manually modifed to run: etckeeper pre-commit `pwd`" >&2
- fi
-else
- cat >.git/hooks/pre-commit <<EOF
-#!/bin/sh
-# pre-commit hook for etckeeper, to store metadata and do sanity checks
-set -e
-etckeeper pre-commit `pwd`
-EOF
- chmod +x .git/hooks/pre-commit
-fi
diff --git a/init.d/50vcs-ignore b/init.d/50vcs-ignore
new file mode 100755
index 0000000..18f368e
--- /dev/null
+++ b/init.d/50vcs-ignore
@@ -0,0 +1,70 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = git ] && [ ! -e .gitignore ]; then
+ file=.gitignore
+elif [ "$VCS" = hg ] && [ ! -e .hgignore ]; then
+ file=.hgignore
+fi
+
+if [ -z "$file" ] || [ -e "$file" ]; then
+ exit 0
+fi
+
+nl() {
+ echo >>$file
+}
+
+comment() {
+ comment="$1"
+ echo "# $comment" >>$file
+}
+
+ignore() {
+ glob="$1"
+
+ case "$VCS" in
+ git)
+ echo "$glob" >> $file
+ ;;
+ hg)
+ # rather than converting the glob to a regexp, just
+ # configure hg to use globs
+ if [ -z "$hg_syntax_printed" ]; then
+ comment "use glob syntax"
+ echo "syntax: glob" >> $file
+ nl
+ hg_syntax_printed=1
+ fi
+ echo "$glob" >> $file
+ ;;
+ esac
+}
+
+if [ "$LOWLEVEL_PACKAGE_MANAGER" = dpkg ]; then
+ comment "new and old versions of conffiles, stored by dpkg"
+ ignore "*.dpkg-*"
+ nl
+elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "pacman-g2" ]; then
+ comment "new and old versions of conffiles, stored by pacman"
+ ignore "*.pacnew"
+ ignore "*.pacorig"
+ ignore "*.pacsave"
+ nl
+fi
+
+ignore "*~"
+nl
+
+comment "mount(8) records system state here, no need to store these"
+ignore blkid.tab
+ignore blkid.tab.old
+nl
+
+comment "some other files in /etc that typically do not need to be tracked"
+ignore ld.so.cache
+ignore mtab
+ignore .pwd.lock
+ignore network/run
+ignore adjtime
+nl
diff --git a/init.d/50vcs-perm b/init.d/50vcs-perm
new file mode 100755
index 0000000..9ffad92
--- /dev/null
+++ b/init.d/50vcs-perm
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = git ]; then
+ chmod 700 .git
+elif [ "$VCS" = hg ]; then
+ chmod 700 .hg
+fi
diff --git a/init.d/50vcs-pre-commit-hook b/init.d/50vcs-pre-commit-hook
new file mode 100755
index 0000000..33d0ae7
--- /dev/null
+++ b/init.d/50vcs-pre-commit-hook
@@ -0,0 +1,32 @@
+#!/bin/sh
+set -e
+
+case "$VCS" in
+ git)
+ if [ -x .git/hooks/pre-commit ]; then
+ if ! grep -q "etckeeper pre-commit" .git/hooks/pre-commit; then
+ echo "etckeeper warning: .git/hooks/pre-commit needs to be manually modifed to run: etckeeper pre-commit `pwd`" >&2
+ fi
+ else
+ cat >.git/hooks/pre-commit <<EOF
+#!/bin/sh
+# pre-commit hook for etckeeper, to store metadata and do sanity checks
+set -e
+etckeeper pre-commit `pwd`
+EOF
+ chmod +x .git/hooks/pre-commit
+ fi
+ ;;
+ hg)
+ if [ -e .hg/hgrc ] && grep "^\[hooks\]" .hg/hgrc; then
+ echo "etckeeper warning: [hooks] section in .hg/hgrc needs to be manually modified to run: etckeeper pre-commit `pwd`" >&2
+ else
+ touch .hg/hgrc
+ cat >>.hg/hgrc <<EOF
+[hooks]
+# pre-commit hook for etckeeper, to store metadata and do sanity checks
+precommit = etckeeper pre-commit `pwd`
+EOF
+ fi
+ ;;
+esac
diff --git a/init.d/70git-add b/init.d/70git-add
deleted file mode 100755
index 1e2680c..0000000
--- a/init.d/70git-add
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-set -e
-if ! git add .; then
- echo "etckeeper warning: git add failed" >&2
-fi
diff --git a/init.d/70vcs-add b/init.d/70vcs-add
new file mode 100755
index 0000000..8cf60d0
--- /dev/null
+++ b/init.d/70vcs-add
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+
+if [ "$VCS" = git ]; then
+ if ! git add .; then
+ echo "etckeeper warning: git add failed" >&2
+ fi
+elif [ "$VCS" = hg ]; then
+ if ! hg add .; then
+ echo "etckeeper warning: hg add failed" >&2
+ fi
+fi