From 9ea07a1d87689df106d4fe1b0e76237aeea32630 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Makefile cleaning + use of DESTDIR --- Makefile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 17ac854..488b5cc 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,19 @@ +DESTDIR ?= +prefix = /usr +bindir = ${prefix}/bin +etcdir = /etc +mandir = ${prefix}/man1 + +INSTALL = install +INSTALL_EXE = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 0644 -D + install: - mkdir -p $(PREFIX)/etc/etckeeper/ - cp -a *.d $(PREFIX)/etc/etckeeper/ - cp etckeeper.conf $(PREFIX)/etc/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 - install -m 0644 -D bash_completion $(PREFIX)/etc/bash_completion.d/etckeeper \ No newline at end of file + mkdir -p $(DESTDIR)$(etcdir)/etckeeper/ + $(INSTALL_DATA) etckeeper.conf $(DESTDIR)$(etcdir)/etckeeper/etckeeper.conf + cp -a *.d $(DESTDIR)$(etcdir)/etckeeper/ + chown root.root -R $(DESTDIR)$(etcdir)/etckeeper/ + $(INSTALL_EXE) etckeeper $(DESTDIR)$(bindir)/etckeeper + $(INSTALL_DATA) apt.conf $(DESTDIR)$(etcdir)/apt/apt.conf.d/05etckeeper + $(INSTALL_DATA) etckeeper.1 $(DESTDIR)$(mandir)/man1/etckeeper.1 + $(INSTALL_DATA) bash_completion $(DESTDIR)$(etcdir)/bash_completion.d/etckeeper -- cgit v1.2.3 From 631af60701ca747861d67a19d431005c7d45d6be Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Debut intégration HG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etckeeper | 3 +++ etckeeper.conf | 2 ++ 2 files changed, 5 insertions(+) diff --git a/etckeeper b/etckeeper index dfd44bb..9baa7b6 100755 --- a/etckeeper +++ b/etckeeper @@ -8,6 +8,9 @@ fi if [ ! -z "$GIT_COMMIT_OPTIONS" ]; then export GIT_COMMIT_OPTIONS fi +if [ ! -z "$HG_COMMIT_OPTIONS" ]; then + export HG_COMMIT_OPTIONS +fi if [ -z "$1" ]; then echo "usage: etckeeper command [directory]" >&2 diff --git a/etckeeper.conf b/etckeeper.conf index 74bb34a..753952d 100644 --- a/etckeeper.conf +++ b/etckeeper.conf @@ -1,4 +1,6 @@ # Options passed to git commit when run by etckeeper. # You could for exemple use "-e" if you want to edit all commit messages # before committing. +# VCS="HG" #GIT_COMMIT_OPTIONS="-e" +#HG_COMMIT_OPTIONS="-e" -- cgit v1.2.3 From f82235032f162aae0bb08828d45c6306e60dcd29 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: hg and git subrepo creation (hg is for now a copy of git) --- etckeeper | 11 ++++++++--- etckeeper.conf | 3 ++- git/init.d/10restore-etckeeper | 8 ++++++++ git/init.d/20restore-metadata | 10 ++++++++++ git/init.d/40git-init | 6 ++++++ git/init.d/50git-ignore | 22 ++++++++++++++++++++++ git/init.d/50git-perm | 3 +++ git/init.d/50git-pre-commit-hook | 15 +++++++++++++++ git/init.d/70git-add | 5 +++++ git/init.d/README | 13 +++++++++++++ git/post-apt.d/10git-test | 6 ++++++ git/post-apt.d/30git-add | 7 +++++++ git/post-apt.d/40git-rm | 12 ++++++++++++ git/post-apt.d/50git-commit | 12 ++++++++++++ git/post-apt.d/README | 2 ++ git/pre-apt.d/50uncommitted-changes | 22 ++++++++++++++++++++++ git/pre-apt.d/README | 2 ++ git/pre-commit.d/20store-empty-directory | 19 +++++++++++++++++++ git/pre-commit.d/20warn-hardlinks | 7 +++++++ git/pre-commit.d/20warn-special-file | 9 +++++++++ git/pre-commit.d/30store-metadata | 18 ++++++++++++++++++ git/pre-commit.d/README | 2 ++ hg/init.d/10restore-etckeeper | 8 ++++++++ hg/init.d/20restore-metadata | 10 ++++++++++ hg/init.d/40git-init | 6 ++++++ hg/init.d/50git-ignore | 22 ++++++++++++++++++++++ hg/init.d/50git-perm | 3 +++ hg/init.d/50git-pre-commit-hook | 15 +++++++++++++++ hg/init.d/70git-add | 5 +++++ hg/init.d/README | 13 +++++++++++++ hg/post-apt.d/10git-test | 6 ++++++ hg/post-apt.d/30git-add | 7 +++++++ hg/post-apt.d/40git-rm | 12 ++++++++++++ hg/post-apt.d/50git-commit | 12 ++++++++++++ hg/post-apt.d/README | 2 ++ hg/pre-apt.d/50uncommitted-changes | 22 ++++++++++++++++++++++ hg/pre-apt.d/README | 2 ++ hg/pre-commit.d/20store-empty-directory | 19 +++++++++++++++++++ hg/pre-commit.d/20warn-hardlinks | 7 +++++++ hg/pre-commit.d/20warn-special-file | 9 +++++++++ hg/pre-commit.d/30store-metadata | 18 ++++++++++++++++++ hg/pre-commit.d/README | 2 ++ init.d/10restore-etckeeper | 8 -------- init.d/20restore-metadata | 10 ---------- init.d/40git-init | 6 ------ init.d/50git-ignore | 22 ---------------------- init.d/50git-perm | 3 --- init.d/50git-pre-commit-hook | 15 --------------- init.d/70git-add | 5 ----- init.d/README | 13 ------------- post-apt.d/10git-test | 6 ------ post-apt.d/30git-add | 7 ------- post-apt.d/40git-rm | 12 ------------ post-apt.d/50git-commit | 12 ------------ post-apt.d/README | 2 -- pre-apt.d/50uncommitted-changes | 22 ---------------------- pre-apt.d/README | 2 -- pre-commit.d/20store-empty-directory | 19 ------------------- pre-commit.d/20warn-hardlinks | 7 ------- pre-commit.d/20warn-special-file | 9 --------- pre-commit.d/30store-metadata | 18 ------------------ pre-commit.d/README | 2 -- 62 files changed, 410 insertions(+), 204 deletions(-) create mode 100644 git/init.d/10restore-etckeeper create mode 100644 git/init.d/20restore-metadata create mode 100644 git/init.d/40git-init create mode 100644 git/init.d/50git-ignore create mode 100644 git/init.d/50git-perm create mode 100644 git/init.d/50git-pre-commit-hook create mode 100644 git/init.d/70git-add create mode 100644 git/init.d/README create mode 100644 git/post-apt.d/10git-test create mode 100644 git/post-apt.d/30git-add create mode 100644 git/post-apt.d/40git-rm create mode 100644 git/post-apt.d/50git-commit create mode 100644 git/post-apt.d/README create mode 100644 git/pre-apt.d/50uncommitted-changes create mode 100644 git/pre-apt.d/README create mode 100644 git/pre-commit.d/20store-empty-directory create mode 100644 git/pre-commit.d/20warn-hardlinks create mode 100644 git/pre-commit.d/20warn-special-file create mode 100644 git/pre-commit.d/30store-metadata create mode 100644 git/pre-commit.d/README create mode 100644 hg/init.d/10restore-etckeeper create mode 100644 hg/init.d/20restore-metadata create mode 100644 hg/init.d/40git-init create mode 100644 hg/init.d/50git-ignore create mode 100644 hg/init.d/50git-perm create mode 100644 hg/init.d/50git-pre-commit-hook create mode 100644 hg/init.d/70git-add create mode 100644 hg/init.d/README create mode 100644 hg/post-apt.d/10git-test create mode 100644 hg/post-apt.d/30git-add create mode 100644 hg/post-apt.d/40git-rm create mode 100644 hg/post-apt.d/50git-commit create mode 100644 hg/post-apt.d/README create mode 100644 hg/pre-apt.d/50uncommitted-changes create mode 100644 hg/pre-apt.d/README create mode 100644 hg/pre-commit.d/20store-empty-directory create mode 100644 hg/pre-commit.d/20warn-hardlinks create mode 100644 hg/pre-commit.d/20warn-special-file create mode 100644 hg/pre-commit.d/30store-metadata create mode 100644 hg/pre-commit.d/README delete mode 100755 init.d/10restore-etckeeper delete mode 100755 init.d/20restore-metadata delete mode 100755 init.d/40git-init delete mode 100755 init.d/50git-ignore delete mode 100755 init.d/50git-perm delete mode 100755 init.d/50git-pre-commit-hook delete mode 100755 init.d/70git-add delete mode 100644 init.d/README delete mode 100755 post-apt.d/10git-test delete mode 100755 post-apt.d/30git-add delete mode 100755 post-apt.d/40git-rm delete mode 100755 post-apt.d/50git-commit delete mode 100644 post-apt.d/README delete mode 100755 pre-apt.d/50uncommitted-changes delete mode 100644 pre-apt.d/README delete mode 100755 pre-commit.d/20store-empty-directory delete mode 100755 pre-commit.d/20warn-hardlinks delete mode 100755 pre-commit.d/20warn-special-file delete mode 100755 pre-commit.d/30store-metadata delete mode 100644 pre-commit.d/README diff --git a/etckeeper b/etckeeper index 9baa7b6..aace0f5 100755 --- a/etckeeper +++ b/etckeeper @@ -5,6 +5,11 @@ if [ -e /etc/etckeeper/etckeeper.conf ]; then . /etc/etckeeper/etckeeper.conf fi +if [ -z "$VCS" ]; then + echo "Please configure a VCS in /etc/etckeeper/etckeeper.conf" >&2 + exit 1 +fi + if [ ! -z "$GIT_COMMIT_OPTIONS" ]; then export GIT_COMMIT_OPTIONS fi @@ -19,8 +24,8 @@ fi command="$1" shift 1 -if [ ! -d "/etc/etckeeper/$command.d" ]; then - echo "etckeeper: /etc/etckeeper/$command.d does not exist" >&2 +if [ ! -d "/etc/etckeeper/$VCS/$command.d" ]; then + echo "etckeeper: /etc/etckeeper/$VCS/$command.d does not exist" >&2 exit 1 fi @@ -30,4 +35,4 @@ else cd /etc fi -run-parts --exit-on-error "/etc/etckeeper/$command.d" +run-parts --exit-on-error "/etc/etckeeper/$VCS/$command.d" diff --git a/etckeeper.conf b/etckeeper.conf index 753952d..114dd39 100644 --- a/etckeeper.conf +++ b/etckeeper.conf @@ -1,6 +1,7 @@ # Options passed to git commit when run by etckeeper. # You could for exemple use "-e" if you want to edit all commit messages # before committing. -# VCS="HG" +# VCS="hg" + VCS="git" #GIT_COMMIT_OPTIONS="-e" #HG_COMMIT_OPTIONS="-e" diff --git a/git/init.d/10restore-etckeeper b/git/init.d/10restore-etckeeper new file mode 100644 index 0000000..376524c --- /dev/null +++ b/git/init.d/10restore-etckeeper @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Yes, this runs code from the repository. As documented, etckeeper-init +# should only be run on repositories you trust. +if [ -e .etckeeper ]; then + . ./.etckeeper +fi diff --git a/git/init.d/20restore-metadata b/git/init.d/20restore-metadata new file mode 100644 index 0000000..01c45e4 --- /dev/null +++ b/git/init.d/20restore-metadata @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +# Note that metastore doesn't check that the .metastore file only changes +# perms of files in the current directory. It's ok to trust the .metastore +# file won't do anything shady, because, as documented, etckeeper-init +# should only be run on repositories you trust. +if [ -e .metadata ]; then + metastore --apply --mtime +fi diff --git a/git/init.d/40git-init b/git/init.d/40git-init new file mode 100644 index 0000000..69867c4 --- /dev/null +++ b/git/init.d/40git-init @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +if [ ! -e .git ]; then + git-init + echo "$(hostname) /etc repository" > .git/description +fi diff --git a/git/init.d/50git-ignore b/git/init.d/50git-ignore new file mode 100644 index 0000000..f931592 --- /dev/null +++ b/git/init.d/50git-ignore @@ -0,0 +1,22 @@ +#!/bin/sh +set -e +if [ ! -e .gitignore ]; then + cat >.gitignore <&2 + fi +else + cat >.git/hooks/pre-commit <&2 +fi diff --git a/git/init.d/README b/git/init.d/README new file mode 100644 index 0000000..90aec67 --- /dev/null +++ b/git/init.d/README @@ -0,0 +1,13 @@ +Executable files in this directory are run to initialise the working directory +for use by etckeeper. If the working directory is not already in version +control, that includes setting up the version control, but not actually +committing anything. If the working directory is in version control, +it includes applying stored metadata to the checked out files in the +working directory. + +Please be careful to *never* overwrite existing files/directories +in the working directory (or use absolute care when doing so). If a file +you need to write already exists, check if its contents are sane, and +if not, emit a warning on stderr. + +If initialisation fails, exit nonzero and no later files will be run. diff --git a/git/post-apt.d/10git-test b/git/post-apt.d/10git-test new file mode 100644 index 0000000..e72f195 --- /dev/null +++ b/git/post-apt.d/10git-test @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +if [ ! -d .git ]; then + echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2 + echo "etckeeper warning: run etckeeper init to enable it" >&2 +fi diff --git a/git/post-apt.d/30git-add b/git/post-apt.d/30git-add new file mode 100644 index 0000000..79aa406 --- /dev/null +++ b/git/post-apt.d/30git-add @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +if [ -d .git ]; then + if ! git-add .; then + echo "etckeeper warning: git-add failed" >&2 + fi +fi diff --git a/git/post-apt.d/40git-rm b/git/post-apt.d/40git-rm new file mode 100644 index 0000000..680dac0 --- /dev/null +++ b/git/post-apt.d/40git-rm @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +TAB=" " + +if [ -d .git ]; then + for file in $(git ls-files --deleted); do + if [ ! -d "$file" ]; then + git rm --quiet "$file" + fi + done +fi diff --git a/git/post-apt.d/50git-commit b/git/post-apt.d/50git-commit new file mode 100644 index 0000000..1a5c55a --- /dev/null +++ b/git/post-apt.d/50git-commit @@ -0,0 +1,12 @@ +#!/bin/sh +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" + + # ignore exit code since it exits nonzero if there is nothing to do + git commit $GIT_COMMIT_OPTIONS -m "$message" || true +fi diff --git a/git/post-apt.d/README b/git/post-apt.d/README new file mode 100644 index 0000000..befa5c0 --- /dev/null +++ b/git/post-apt.d/README @@ -0,0 +1,2 @@ +Files in this directory are run after apt has run. They should commit +changes and new files in /etc to repository. diff --git a/git/pre-apt.d/50uncommitted-changes b/git/pre-apt.d/50uncommitted-changes new file mode 100644 index 0000000..d39401c --- /dev/null +++ b/git/pre-apt.d/50uncommitted-changes @@ -0,0 +1,22 @@ +#!/bin/sh +set -e +if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean"; then + . /usr/share/debconf/confmodule + db_capb escape + db_title etckeeper + + db_reset etckeeper/unclean || true + db_subst etckeeper/unclean STATUS $(git-status | debconf-escape -e) || true + db_input critical etckeeper/unclean || true + db_go || true + 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 + db_input critical etckeeper/commit_failed || true + db_go || true + db_reset etckeeper/commit_failed || true + fi + fi + db_reset etckeeper/unclean || true +fi diff --git a/git/pre-apt.d/README b/git/pre-apt.d/README new file mode 100644 index 0000000..47001b4 --- /dev/null +++ b/git/pre-apt.d/README @@ -0,0 +1,2 @@ +Files in this directory are run before apt is run. This is mostly used for +sanity checks, ie, does /etc have any uncommitted changes? diff --git a/git/pre-commit.d/20store-empty-directory b/git/pre-commit.d/20store-empty-directory new file mode 100644 index 0000000..e0f9538 --- /dev/null +++ b/git/pre-commit.d/20store-empty-directory @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +# Make sure the file is not readable by others, since it can leak +# information about contents of non-readable directories in /etc. +umask 077 + +if [ -e .etckeeper ]; then + egrep -v '^mkdir ' .etckeeper > .etckeeper.new || true +fi +find -type d -empty | grep -v /.git/ | sort | + sed -e "s/^/mkdir -p '/" -e "s/\$/'/" >> .etckeeper.new + +if [ ! -e .etckeeper ] || ! cmp -s .etckeeper .etckeeper.new ; then + mv -f .etckeeper.new .etckeeper + git add .etckeeper +else + rm -f .etckeeper.new +fi diff --git a/git/pre-commit.d/20warn-hardlinks b/git/pre-commit.d/20warn-hardlinks new file mode 100644 index 0000000..3dd7a96 --- /dev/null +++ b/git/pre-commit.d/20warn-hardlinks @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +hardlinks=$(find -type f -not -links 1 | grep -v /.git/) || true +if [ -n "$hardlinks" ]; then + echo "etckeeper warning: hardlinked files could cause problems with git:" >&2 + echo "$hardlinks" >&2 +fi diff --git a/git/pre-commit.d/20warn-special-file b/git/pre-commit.d/20warn-special-file new file mode 100644 index 0000000..cb4d019 --- /dev/null +++ b/git/pre-commit.d/20warn-special-file @@ -0,0 +1,9 @@ +#!/bin/sh +set -e +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 git:" >&2 + echo "$special" >&2 +fi + +true diff --git a/git/pre-commit.d/30store-metadata b/git/pre-commit.d/30store-metadata new file mode 100644 index 0000000..b878abd --- /dev/null +++ b/git/pre-commit.d/30store-metadata @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +# Make sure the file is not readable by others, since it can leak +# information about contents of non-readable directories in /etc. +umask 077 + +# ensure the file exists so that it will list its own metadata +if [ ! -e .metadata ]; then + metastore --save +fi + +# metastore doesn't produce the same output file for the same metadata +# everytime, so avoid changing the file if nothing really changed. +if [ ! -z "$(metastore --compare)" ]; then + metastore --save + git add .metadata +fi diff --git a/git/pre-commit.d/README b/git/pre-commit.d/README new file mode 100644 index 0000000..051d094 --- /dev/null +++ b/git/pre-commit.d/README @@ -0,0 +1,2 @@ +This is run by a git pre-commit hook before committing changes to the +repository. This can be used for storing metadata, and for sanity checks. diff --git a/hg/init.d/10restore-etckeeper b/hg/init.d/10restore-etckeeper new file mode 100644 index 0000000..376524c --- /dev/null +++ b/hg/init.d/10restore-etckeeper @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Yes, this runs code from the repository. As documented, etckeeper-init +# should only be run on repositories you trust. +if [ -e .etckeeper ]; then + . ./.etckeeper +fi diff --git a/hg/init.d/20restore-metadata b/hg/init.d/20restore-metadata new file mode 100644 index 0000000..01c45e4 --- /dev/null +++ b/hg/init.d/20restore-metadata @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +# Note that metastore doesn't check that the .metastore file only changes +# perms of files in the current directory. It's ok to trust the .metastore +# file won't do anything shady, because, as documented, etckeeper-init +# should only be run on repositories you trust. +if [ -e .metadata ]; then + metastore --apply --mtime +fi diff --git a/hg/init.d/40git-init b/hg/init.d/40git-init new file mode 100644 index 0000000..69867c4 --- /dev/null +++ b/hg/init.d/40git-init @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +if [ ! -e .git ]; then + git-init + echo "$(hostname) /etc repository" > .git/description +fi diff --git a/hg/init.d/50git-ignore b/hg/init.d/50git-ignore new file mode 100644 index 0000000..f931592 --- /dev/null +++ b/hg/init.d/50git-ignore @@ -0,0 +1,22 @@ +#!/bin/sh +set -e +if [ ! -e .gitignore ]; then + cat >.gitignore <&2 + fi +else + cat >.git/hooks/pre-commit <&2 +fi diff --git a/hg/init.d/README b/hg/init.d/README new file mode 100644 index 0000000..90aec67 --- /dev/null +++ b/hg/init.d/README @@ -0,0 +1,13 @@ +Executable files in this directory are run to initialise the working directory +for use by etckeeper. If the working directory is not already in version +control, that includes setting up the version control, but not actually +committing anything. If the working directory is in version control, +it includes applying stored metadata to the checked out files in the +working directory. + +Please be careful to *never* overwrite existing files/directories +in the working directory (or use absolute care when doing so). If a file +you need to write already exists, check if its contents are sane, and +if not, emit a warning on stderr. + +If initialisation fails, exit nonzero and no later files will be run. diff --git a/hg/post-apt.d/10git-test b/hg/post-apt.d/10git-test new file mode 100644 index 0000000..e72f195 --- /dev/null +++ b/hg/post-apt.d/10git-test @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +if [ ! -d .git ]; then + echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2 + echo "etckeeper warning: run etckeeper init to enable it" >&2 +fi diff --git a/hg/post-apt.d/30git-add b/hg/post-apt.d/30git-add new file mode 100644 index 0000000..79aa406 --- /dev/null +++ b/hg/post-apt.d/30git-add @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +if [ -d .git ]; then + if ! git-add .; then + echo "etckeeper warning: git-add failed" >&2 + fi +fi diff --git a/hg/post-apt.d/40git-rm b/hg/post-apt.d/40git-rm new file mode 100644 index 0000000..680dac0 --- /dev/null +++ b/hg/post-apt.d/40git-rm @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +TAB=" " + +if [ -d .git ]; then + for file in $(git ls-files --deleted); do + if [ ! -d "$file" ]; then + git rm --quiet "$file" + fi + done +fi diff --git a/hg/post-apt.d/50git-commit b/hg/post-apt.d/50git-commit new file mode 100644 index 0000000..1a5c55a --- /dev/null +++ b/hg/post-apt.d/50git-commit @@ -0,0 +1,12 @@ +#!/bin/sh +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" + + # ignore exit code since it exits nonzero if there is nothing to do + git commit $GIT_COMMIT_OPTIONS -m "$message" || true +fi diff --git a/hg/post-apt.d/README b/hg/post-apt.d/README new file mode 100644 index 0000000..befa5c0 --- /dev/null +++ b/hg/post-apt.d/README @@ -0,0 +1,2 @@ +Files in this directory are run after apt has run. They should commit +changes and new files in /etc to repository. diff --git a/hg/pre-apt.d/50uncommitted-changes b/hg/pre-apt.d/50uncommitted-changes new file mode 100644 index 0000000..d39401c --- /dev/null +++ b/hg/pre-apt.d/50uncommitted-changes @@ -0,0 +1,22 @@ +#!/bin/sh +set -e +if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean"; then + . /usr/share/debconf/confmodule + db_capb escape + db_title etckeeper + + db_reset etckeeper/unclean || true + db_subst etckeeper/unclean STATUS $(git-status | debconf-escape -e) || true + db_input critical etckeeper/unclean || true + db_go || true + 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 + db_input critical etckeeper/commit_failed || true + db_go || true + db_reset etckeeper/commit_failed || true + fi + fi + db_reset etckeeper/unclean || true +fi diff --git a/hg/pre-apt.d/README b/hg/pre-apt.d/README new file mode 100644 index 0000000..47001b4 --- /dev/null +++ b/hg/pre-apt.d/README @@ -0,0 +1,2 @@ +Files in this directory are run before apt is run. This is mostly used for +sanity checks, ie, does /etc have any uncommitted changes? diff --git a/hg/pre-commit.d/20store-empty-directory b/hg/pre-commit.d/20store-empty-directory new file mode 100644 index 0000000..e0f9538 --- /dev/null +++ b/hg/pre-commit.d/20store-empty-directory @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +# Make sure the file is not readable by others, since it can leak +# information about contents of non-readable directories in /etc. +umask 077 + +if [ -e .etckeeper ]; then + egrep -v '^mkdir ' .etckeeper > .etckeeper.new || true +fi +find -type d -empty | grep -v /.git/ | sort | + sed -e "s/^/mkdir -p '/" -e "s/\$/'/" >> .etckeeper.new + +if [ ! -e .etckeeper ] || ! cmp -s .etckeeper .etckeeper.new ; then + mv -f .etckeeper.new .etckeeper + git add .etckeeper +else + rm -f .etckeeper.new +fi diff --git a/hg/pre-commit.d/20warn-hardlinks b/hg/pre-commit.d/20warn-hardlinks new file mode 100644 index 0000000..3dd7a96 --- /dev/null +++ b/hg/pre-commit.d/20warn-hardlinks @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +hardlinks=$(find -type f -not -links 1 | grep -v /.git/) || true +if [ -n "$hardlinks" ]; then + echo "etckeeper warning: hardlinked files could cause problems with git:" >&2 + echo "$hardlinks" >&2 +fi diff --git a/hg/pre-commit.d/20warn-special-file b/hg/pre-commit.d/20warn-special-file new file mode 100644 index 0000000..cb4d019 --- /dev/null +++ b/hg/pre-commit.d/20warn-special-file @@ -0,0 +1,9 @@ +#!/bin/sh +set -e +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 git:" >&2 + echo "$special" >&2 +fi + +true diff --git a/hg/pre-commit.d/30store-metadata b/hg/pre-commit.d/30store-metadata new file mode 100644 index 0000000..b878abd --- /dev/null +++ b/hg/pre-commit.d/30store-metadata @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +# Make sure the file is not readable by others, since it can leak +# information about contents of non-readable directories in /etc. +umask 077 + +# ensure the file exists so that it will list its own metadata +if [ ! -e .metadata ]; then + metastore --save +fi + +# metastore doesn't produce the same output file for the same metadata +# everytime, so avoid changing the file if nothing really changed. +if [ ! -z "$(metastore --compare)" ]; then + metastore --save + git add .metadata +fi diff --git a/hg/pre-commit.d/README b/hg/pre-commit.d/README new file mode 100644 index 0000000..051d094 --- /dev/null +++ b/hg/pre-commit.d/README @@ -0,0 +1,2 @@ +This is run by a git pre-commit hook before committing changes to the +repository. This can be used for storing metadata, and for sanity checks. diff --git a/init.d/10restore-etckeeper b/init.d/10restore-etckeeper deleted file mode 100755 index 376524c..0000000 --- a/init.d/10restore-etckeeper +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -# Yes, this runs code from the repository. As documented, etckeeper-init -# should only be run on repositories you trust. -if [ -e .etckeeper ]; then - . ./.etckeeper -fi diff --git a/init.d/20restore-metadata b/init.d/20restore-metadata deleted file mode 100755 index 01c45e4..0000000 --- a/init.d/20restore-metadata +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -e - -# Note that metastore doesn't check that the .metastore file only changes -# perms of files in the current directory. It's ok to trust the .metastore -# file won't do anything shady, because, as documented, etckeeper-init -# should only be run on repositories you trust. -if [ -e .metadata ]; then - metastore --apply --mtime -fi diff --git a/init.d/40git-init b/init.d/40git-init deleted file mode 100755 index 69867c4..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/50git-ignore b/init.d/50git-ignore deleted file mode 100755 index f931592..0000000 --- a/init.d/50git-ignore +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -set -e -if [ ! -e .gitignore ]; then - cat >.gitignore <&2 - fi -else - cat >.git/hooks/pre-commit <&2 -fi diff --git a/init.d/README b/init.d/README deleted file mode 100644 index 90aec67..0000000 --- a/init.d/README +++ /dev/null @@ -1,13 +0,0 @@ -Executable files in this directory are run to initialise the working directory -for use by etckeeper. If the working directory is not already in version -control, that includes setting up the version control, but not actually -committing anything. If the working directory is in version control, -it includes applying stored metadata to the checked out files in the -working directory. - -Please be careful to *never* overwrite existing files/directories -in the working directory (or use absolute care when doing so). If a file -you need to write already exists, check if its contents are sane, and -if not, emit a warning on stderr. - -If initialisation fails, exit nonzero and no later files will be run. diff --git a/post-apt.d/10git-test b/post-apt.d/10git-test deleted file mode 100755 index e72f195..0000000 --- a/post-apt.d/10git-test +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -e -if [ ! -d .git ]; then - echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2 - echo "etckeeper warning: run etckeeper init to enable it" >&2 -fi diff --git a/post-apt.d/30git-add b/post-apt.d/30git-add deleted file mode 100755 index 79aa406..0000000 --- a/post-apt.d/30git-add +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -e -if [ -d .git ]; then - if ! git-add .; then - echo "etckeeper warning: git-add failed" >&2 - fi -fi diff --git a/post-apt.d/40git-rm b/post-apt.d/40git-rm deleted file mode 100755 index 680dac0..0000000 --- a/post-apt.d/40git-rm +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -e - -TAB=" " - -if [ -d .git ]; then - for file in $(git ls-files --deleted); do - if [ ! -d "$file" ]; then - git rm --quiet "$file" - fi - done -fi diff --git a/post-apt.d/50git-commit b/post-apt.d/50git-commit deleted file mode 100755 index 1a5c55a..0000000 --- a/post-apt.d/50git-commit +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -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" - - # ignore exit code since it exits nonzero if there is nothing to do - git commit $GIT_COMMIT_OPTIONS -m "$message" || true -fi diff --git a/post-apt.d/README b/post-apt.d/README deleted file mode 100644 index befa5c0..0000000 --- a/post-apt.d/README +++ /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. diff --git a/pre-apt.d/50uncommitted-changes b/pre-apt.d/50uncommitted-changes deleted file mode 100755 index d39401c..0000000 --- a/pre-apt.d/50uncommitted-changes +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -set -e -if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean"; then - . /usr/share/debconf/confmodule - db_capb escape - db_title etckeeper - - db_reset etckeeper/unclean || true - db_subst etckeeper/unclean STATUS $(git-status | debconf-escape -e) || true - db_input critical etckeeper/unclean || true - db_go || true - 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 - db_input critical etckeeper/commit_failed || true - db_go || true - db_reset etckeeper/commit_failed || true - fi - fi - db_reset etckeeper/unclean || true -fi diff --git a/pre-apt.d/README b/pre-apt.d/README deleted file mode 100644 index 47001b4..0000000 --- a/pre-apt.d/README +++ /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? diff --git a/pre-commit.d/20store-empty-directory b/pre-commit.d/20store-empty-directory deleted file mode 100755 index e0f9538..0000000 --- a/pre-commit.d/20store-empty-directory +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -set -e - -# Make sure the file is not readable by others, since it can leak -# information about contents of non-readable directories in /etc. -umask 077 - -if [ -e .etckeeper ]; then - egrep -v '^mkdir ' .etckeeper > .etckeeper.new || true -fi -find -type d -empty | grep -v /.git/ | sort | - sed -e "s/^/mkdir -p '/" -e "s/\$/'/" >> .etckeeper.new - -if [ ! -e .etckeeper ] || ! cmp -s .etckeeper .etckeeper.new ; then - mv -f .etckeeper.new .etckeeper - git add .etckeeper -else - rm -f .etckeeper.new -fi diff --git a/pre-commit.d/20warn-hardlinks b/pre-commit.d/20warn-hardlinks deleted file mode 100755 index 3dd7a96..0000000 --- a/pre-commit.d/20warn-hardlinks +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -e -hardlinks=$(find -type f -not -links 1 | grep -v /.git/) || true -if [ -n "$hardlinks" ]; then - echo "etckeeper warning: hardlinked files could cause problems with git:" >&2 - echo "$hardlinks" >&2 -fi diff --git a/pre-commit.d/20warn-special-file b/pre-commit.d/20warn-special-file deleted file mode 100755 index cb4d019..0000000 --- a/pre-commit.d/20warn-special-file +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e -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 git:" >&2 - echo "$special" >&2 -fi - -true diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata deleted file mode 100755 index b878abd..0000000 --- a/pre-commit.d/30store-metadata +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -set -e - -# Make sure the file is not readable by others, since it can leak -# information about contents of non-readable directories in /etc. -umask 077 - -# ensure the file exists so that it will list its own metadata -if [ ! -e .metadata ]; then - metastore --save -fi - -# metastore doesn't produce the same output file for the same metadata -# everytime, so avoid changing the file if nothing really changed. -if [ ! -z "$(metastore --compare)" ]; then - metastore --save - git add .metadata -fi diff --git a/pre-commit.d/README b/pre-commit.d/README deleted file mode 100644 index 051d094..0000000 --- a/pre-commit.d/README +++ /dev/null @@ -1,2 +0,0 @@ -This is run by a git pre-commit hook before committing changes to the -repository. This can be used for storing metadata, and for sanity checks. -- cgit v1.2.3 From b7ea2156e88479a2fe829894a606707df5555b6f Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Rename git files to hg --- hg/init.d/40git-init | 6 ------ hg/init.d/40hg-init | 6 ++++++ hg/init.d/50git-ignore | 22 ---------------------- hg/init.d/50git-perm | 3 --- hg/init.d/50git-pre-commit-hook | 15 --------------- hg/init.d/50hg-ignore | 22 ++++++++++++++++++++++ hg/init.d/50hg-perm | 3 +++ hg/init.d/50hg-pre-commit-hook | 15 +++++++++++++++ hg/init.d/70git-add | 5 ----- hg/init.d/70hg-add | 5 +++++ 10 files changed, 51 insertions(+), 51 deletions(-) delete mode 100644 hg/init.d/40git-init create mode 100644 hg/init.d/40hg-init delete mode 100644 hg/init.d/50git-ignore delete mode 100644 hg/init.d/50git-perm delete mode 100644 hg/init.d/50git-pre-commit-hook create mode 100644 hg/init.d/50hg-ignore create mode 100644 hg/init.d/50hg-perm create mode 100644 hg/init.d/50hg-pre-commit-hook delete mode 100644 hg/init.d/70git-add create mode 100644 hg/init.d/70hg-add diff --git a/hg/init.d/40git-init b/hg/init.d/40git-init deleted file mode 100644 index 69867c4..0000000 --- a/hg/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/hg/init.d/40hg-init b/hg/init.d/40hg-init new file mode 100644 index 0000000..69867c4 --- /dev/null +++ b/hg/init.d/40hg-init @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +if [ ! -e .git ]; then + git-init + echo "$(hostname) /etc repository" > .git/description +fi diff --git a/hg/init.d/50git-ignore b/hg/init.d/50git-ignore deleted file mode 100644 index f931592..0000000 --- a/hg/init.d/50git-ignore +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -set -e -if [ ! -e .gitignore ]; then - cat >.gitignore <&2 - fi -else - cat >.git/hooks/pre-commit <.gitignore <&2 + fi +else + cat >.git/hooks/pre-commit <&2 -fi diff --git a/hg/init.d/70hg-add b/hg/init.d/70hg-add new file mode 100644 index 0000000..06504b4 --- /dev/null +++ b/hg/init.d/70hg-add @@ -0,0 +1,5 @@ +#!/bin/sh +set -e +if ! git-add .; then + echo "etckeeper warning: git-add failed" >&2 +fi -- cgit v1.2.3 From c65ad8cba4ebf8eb7625b4e0801a6c68125384ac Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Tranlsation of init.d in mercurial idiom --- hg/init.d/40hg-init | 7 +++--- hg/init.d/50hg-ignore | 51 +++++++++++++++++++++++++++++++++++------- hg/init.d/50hg-perm | 2 +- hg/init.d/50hg-pre-commit-hook | 15 +++++-------- hg/init.d/70hg-add | 4 ++-- 5 files changed, 56 insertions(+), 23 deletions(-) diff --git a/hg/init.d/40hg-init b/hg/init.d/40hg-init index 69867c4..cf9733b 100644 --- a/hg/init.d/40hg-init +++ b/hg/init.d/40hg-init @@ -1,6 +1,7 @@ #!/bin/sh set -e -if [ ! -e .git ]; then - git-init - echo "$(hostname) /etc repository" > .git/description +if [ ! -e .hg ]; then + hg init + echo "[web]\n" > .hg/hgrc + echo "$(hostname) /etc repository" > .hg/hgrc fi diff --git a/hg/init.d/50hg-ignore b/hg/init.d/50hg-ignore index f931592..b02107e 100644 --- a/hg/init.d/50hg-ignore +++ b/hg/init.d/50hg-ignore @@ -1,22 +1,57 @@ #!/bin/sh set -e -if [ ! -e .gitignore ]; then - cat >.gitignore <.hgignore <&2 - fi +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 - cat >.git/hooks/pre-commit <>.hg/hgrc <&2 +if ! hg addremove .; then + echo "etckeeper warning: hg addremove failed" >&2 fi -- cgit v1.2.3 From 83d1b75cabbd594019ea6fb0395c4d27e38d8aa3 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: pre-commit.d : Translation into mercurial idiom --- hg/pre-commit.d/20store-empty-directory | 2 +- hg/pre-commit.d/20warn-hardlinks | 7 +++++-- hg/pre-commit.d/20warn-special-file | 4 ++-- hg/pre-commit.d/30store-metadata | 2 +- hg/pre-commit.d/README | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hg/pre-commit.d/20store-empty-directory b/hg/pre-commit.d/20store-empty-directory index e0f9538..2f127dd 100644 --- a/hg/pre-commit.d/20store-empty-directory +++ b/hg/pre-commit.d/20store-empty-directory @@ -13,7 +13,7 @@ find -type d -empty | grep -v /.git/ | sort | if [ ! -e .etckeeper ] || ! cmp -s .etckeeper .etckeeper.new ; then mv -f .etckeeper.new .etckeeper - git add .etckeeper + hg add .etckeeper else rm -f .etckeeper.new fi diff --git a/hg/pre-commit.d/20warn-hardlinks b/hg/pre-commit.d/20warn-hardlinks index 3dd7a96..aa4b705 100644 --- a/hg/pre-commit.d/20warn-hardlinks +++ b/hg/pre-commit.d/20warn-hardlinks @@ -1,7 +1,10 @@ #!/bin/sh + +# TODO +# Not sure if it is the case with Mercurial ? set -e -hardlinks=$(find -type f -not -links 1 | grep -v /.git/) || true +hardlinks=$(find -type f -not -links 1 | grep -v /.hg/) || true if [ -n "$hardlinks" ]; then - echo "etckeeper warning: hardlinked files could cause problems with git:" >&2 + echo "etckeeper warning: hardlinked files could cause problems with mercurial:" >&2 echo "$hardlinks" >&2 fi diff --git a/hg/pre-commit.d/20warn-special-file b/hg/pre-commit.d/20warn-special-file index cb4d019..d5d1d7f 100644 --- a/hg/pre-commit.d/20warn-special-file +++ b/hg/pre-commit.d/20warn-special-file @@ -1,8 +1,8 @@ #!/bin/sh set -e -special=$(find -not -type d -not -type f -not -type l | grep -v /.git/) || true +special=$(find -not -type d -not -type f -not -type l | grep -v /.hg/) || true if [ -n "$special" ]; then - echo "etckeeper warning: special files could cause problems with git:" >&2 + echo "etckeeper warning: special files could cause problems with mercurial:" >&2 echo "$special" >&2 fi diff --git a/hg/pre-commit.d/30store-metadata b/hg/pre-commit.d/30store-metadata index b878abd..3f119f5 100644 --- a/hg/pre-commit.d/30store-metadata +++ b/hg/pre-commit.d/30store-metadata @@ -14,5 +14,5 @@ fi # everytime, so avoid changing the file if nothing really changed. if [ ! -z "$(metastore --compare)" ]; then metastore --save - git add .metadata + hg add .metadata fi diff --git a/hg/pre-commit.d/README b/hg/pre-commit.d/README index 051d094..08b8cc9 100644 --- a/hg/pre-commit.d/README +++ b/hg/pre-commit.d/README @@ -1,2 +1,2 @@ -This is run by a git pre-commit hook before committing changes to the +This is run by a mercurial pre-commit hook before committing changes to the repository. This can be used for storing metadata, and for sanity checks. -- cgit v1.2.3 From ee9cbb397107f216db196b2a7717f278a51b578d Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Move git files to hg one --- hg/post-apt.d/10git-test | 6 ------ hg/post-apt.d/10hg-test | 6 ++++++ hg/post-apt.d/30git-add | 7 ------- hg/post-apt.d/30hg-add | 7 +++++++ hg/post-apt.d/40git-rm | 12 ------------ hg/post-apt.d/40hg-rm | 12 ++++++++++++ hg/post-apt.d/50git-commit | 12 ------------ hg/post-apt.d/50hg-commit | 12 ++++++++++++ 8 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 hg/post-apt.d/10git-test create mode 100644 hg/post-apt.d/10hg-test delete mode 100644 hg/post-apt.d/30git-add create mode 100644 hg/post-apt.d/30hg-add delete mode 100644 hg/post-apt.d/40git-rm create mode 100644 hg/post-apt.d/40hg-rm delete mode 100644 hg/post-apt.d/50git-commit create mode 100644 hg/post-apt.d/50hg-commit diff --git a/hg/post-apt.d/10git-test b/hg/post-apt.d/10git-test deleted file mode 100644 index e72f195..0000000 --- a/hg/post-apt.d/10git-test +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -e -if [ ! -d .git ]; then - echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2 - echo "etckeeper warning: run etckeeper init to enable it" >&2 -fi diff --git a/hg/post-apt.d/10hg-test b/hg/post-apt.d/10hg-test new file mode 100644 index 0000000..e72f195 --- /dev/null +++ b/hg/post-apt.d/10hg-test @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +if [ ! -d .git ]; then + echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2 + echo "etckeeper warning: run etckeeper init to enable it" >&2 +fi diff --git a/hg/post-apt.d/30git-add b/hg/post-apt.d/30git-add deleted file mode 100644 index 79aa406..0000000 --- a/hg/post-apt.d/30git-add +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -e -if [ -d .git ]; then - if ! git-add .; then - echo "etckeeper warning: git-add failed" >&2 - fi -fi diff --git a/hg/post-apt.d/30hg-add b/hg/post-apt.d/30hg-add new file mode 100644 index 0000000..79aa406 --- /dev/null +++ b/hg/post-apt.d/30hg-add @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +if [ -d .git ]; then + if ! git-add .; then + echo "etckeeper warning: git-add failed" >&2 + fi +fi diff --git a/hg/post-apt.d/40git-rm b/hg/post-apt.d/40git-rm deleted file mode 100644 index 680dac0..0000000 --- a/hg/post-apt.d/40git-rm +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -e - -TAB=" " - -if [ -d .git ]; then - for file in $(git ls-files --deleted); do - if [ ! -d "$file" ]; then - git rm --quiet "$file" - fi - done -fi diff --git a/hg/post-apt.d/40hg-rm b/hg/post-apt.d/40hg-rm new file mode 100644 index 0000000..680dac0 --- /dev/null +++ b/hg/post-apt.d/40hg-rm @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +TAB=" " + +if [ -d .git ]; then + for file in $(git ls-files --deleted); do + if [ ! -d "$file" ]; then + git rm --quiet "$file" + fi + done +fi diff --git a/hg/post-apt.d/50git-commit b/hg/post-apt.d/50git-commit deleted file mode 100644 index 1a5c55a..0000000 --- a/hg/post-apt.d/50git-commit +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -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" - - # ignore exit code since it exits nonzero if there is nothing to do - git commit $GIT_COMMIT_OPTIONS -m "$message" || true -fi diff --git a/hg/post-apt.d/50hg-commit b/hg/post-apt.d/50hg-commit new file mode 100644 index 0000000..1a5c55a --- /dev/null +++ b/hg/post-apt.d/50hg-commit @@ -0,0 +1,12 @@ +#!/bin/sh +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" + + # ignore exit code since it exits nonzero if there is nothing to do + git commit $GIT_COMMIT_OPTIONS -m "$message" || true +fi -- cgit v1.2.3 From 73188e18a0967551f5d502793717a981fb27a688 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: pre-apt.d : Translation into mercurial idiom --- hg/pre-apt.d/50uncommitted-changes | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hg/pre-apt.d/50uncommitted-changes b/hg/pre-apt.d/50uncommitted-changes index d39401c..62d62c3 100644 --- a/hg/pre-apt.d/50uncommitted-changes +++ b/hg/pre-apt.d/50uncommitted-changes @@ -1,18 +1,18 @@ #!/bin/sh set -e -if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean"; then +if [ -d .hg ] && ! hg status 2>&1 | wc -l | grep -q "^0$"; then . /usr/share/debconf/confmodule db_capb escape db_title etckeeper db_reset etckeeper/unclean || true - db_subst etckeeper/unclean STATUS $(git-status | debconf-escape -e) || true + db_subst etckeeper/unclean STATUS $(hg status | debconf-escape -e) || true db_input critical etckeeper/unclean || true db_go || true 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 + hg addremove . + if ! hg commit $GIT_COMMIT_OPTIONS -m "saving uncommitted changes in /etc prior to apt run"; then db_input critical etckeeper/commit_failed || true db_go || true db_reset etckeeper/commit_failed || true -- cgit v1.2.3 From 2a2227a3a79e0c246c1d3e4a9af967724196c3b5 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: post-apt.d : Translation into mercurial idiom --- hg/post-apt.d/10hg-test | 2 +- hg/post-apt.d/30hg-add | 7 ------- hg/post-apt.d/30hg-addremove | 7 +++++++ hg/post-apt.d/40hg-rm | 12 ------------ hg/post-apt.d/50hg-commit | 4 ++-- 5 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 hg/post-apt.d/30hg-add create mode 100644 hg/post-apt.d/30hg-addremove delete mode 100644 hg/post-apt.d/40hg-rm diff --git a/hg/post-apt.d/10hg-test b/hg/post-apt.d/10hg-test index e72f195..9149585 100644 --- a/hg/post-apt.d/10hg-test +++ b/hg/post-apt.d/10hg-test @@ -1,6 +1,6 @@ #!/bin/sh set -e -if [ ! -d .git ]; then +if [ ! -d .hg ]; then echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2 echo "etckeeper warning: run etckeeper init to enable it" >&2 fi diff --git a/hg/post-apt.d/30hg-add b/hg/post-apt.d/30hg-add deleted file mode 100644 index 79aa406..0000000 --- a/hg/post-apt.d/30hg-add +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -e -if [ -d .git ]; then - if ! git-add .; then - echo "etckeeper warning: git-add failed" >&2 - fi -fi diff --git a/hg/post-apt.d/30hg-addremove b/hg/post-apt.d/30hg-addremove new file mode 100644 index 0000000..43356a7 --- /dev/null +++ b/hg/post-apt.d/30hg-addremove @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +if [ -d .hg ]; then + if ! hg addremove .; then + echo "etckeeper warning: hg addremove failed" >&2 + fi +fi diff --git a/hg/post-apt.d/40hg-rm b/hg/post-apt.d/40hg-rm deleted file mode 100644 index 680dac0..0000000 --- a/hg/post-apt.d/40hg-rm +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -e - -TAB=" " - -if [ -d .git ]; then - for file in $(git ls-files --deleted); do - if [ ! -d "$file" ]; then - git rm --quiet "$file" - fi - done -fi diff --git a/hg/post-apt.d/50hg-commit b/hg/post-apt.d/50hg-commit index 1a5c55a..81f9e9f 100644 --- a/hg/post-apt.d/50hg-commit +++ b/hg/post-apt.d/50hg-commit @@ -1,12 +1,12 @@ #!/bin/sh set -e -if [ -d .git ]; then +if [ -d .hg ]; 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" # ignore exit code since it exits nonzero if there is nothing to do - git commit $GIT_COMMIT_OPTIONS -m "$message" || true + hg commit $GIT_COMMIT_OPTIONS -m "$message" || true fi -- cgit v1.2.3 From 5036bb6911a3a6f7d0b0350b2d80b6e236bd737f Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Makefile : hg subdirs installation --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 488b5cc..16f942f 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ INSTALL_DATA = ${INSTALL} -m 0644 -D install: mkdir -p $(DESTDIR)$(etcdir)/etckeeper/ $(INSTALL_DATA) etckeeper.conf $(DESTDIR)$(etcdir)/etckeeper/etckeeper.conf - cp -a *.d $(DESTDIR)$(etcdir)/etckeeper/ + cp -a hg $(DESTDIR)$(etcdir)/etckeeper/ + cp -a git $(DESTDIR)$(etcdir)/etckeeper/ chown root.root -R $(DESTDIR)$(etcdir)/etckeeper/ $(INSTALL_EXE) etckeeper $(DESTDIR)$(bindir)/etckeeper $(INSTALL_DATA) apt.conf $(DESTDIR)$(etcdir)/apt/apt.conf.d/05etckeeper -- cgit v1.2.3 From f8a08579d9ff274a17da0bbb29f8575d10425585 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Makefile correction - dir creation, and man dest --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 16f942f..daf2a60 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,10 @@ DESTDIR ?= prefix = /usr bindir = ${prefix}/bin etcdir = /etc -mandir = ${prefix}/man1 +mandir = ${prefix}/man INSTALL = install -INSTALL_EXE = ${INSTALL} +INSTALL_EXE = ${INSTALL} -D INSTALL_DATA = ${INSTALL} -m 0644 -D install: -- cgit v1.2.3 From 3fec1173b92e548968d6647b65ff5ec82d205518 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Adapt bash_completio to the new subdir structure --- bash_completion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash_completion b/bash_completion index 372b76b..8d5632e 100644 --- a/bash_completion +++ b/bash_completion @@ -2,7 +2,7 @@ _etckeeper() { local cur; COMPREPLY=(); cur=${COMP_WORDS[COMP_CWORD]}; - COMPREPLY=( $( compgen -W '$(cd /etc/etckeeper/; for i in *.d/; do echo ${i%.d/}; done)' -- $cur ) ); + COMPREPLY=( $( compgen -W '$(cd /etc/etckeeper/git/; for i in *.d/; do echo ${i%.d/}; done)' -- $cur ) ); } -complete -F _etckeeper etckeeper \ No newline at end of file +complete -F _etckeeper etckeeper -- cgit v1.2.3 From 8ad9330c37b5e11eefecc243cb8890fcab4e076a Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: hg-pre-commit-hook: typo when touching file --- hg/init.d/50hg-pre-commit-hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hg/init.d/50hg-pre-commit-hook b/hg/init.d/50hg-pre-commit-hook index 0603d30..bccd79b 100644 --- a/hg/init.d/50hg-pre-commit-hook +++ b/hg/init.d/50hg-pre-commit-hook @@ -3,7 +3,7 @@ set -e 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 + touch .hg/hgrc cat >>.hg/hgrc < Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: Ignore .pacsave files --- hg/init.d/50hg-ignore | 1 + 1 file changed, 1 insertion(+) diff --git a/hg/init.d/50hg-ignore b/hg/init.d/50hg-ignore index b02107e..5d3a6a6 100644 --- a/hg/init.d/50hg-ignore +++ b/hg/init.d/50hg-ignore @@ -42,6 +42,7 @@ squid/errors .orig$ .swp$ ^.java/.* +.pacsave$ # new and old versions of conffiles, stored by dpkg *.dpkg-* -- cgit v1.2.3 From 31ea1c1103b358f1dcbe2de40fefaf539e8bcbc3 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: .hgrc section was overwriten --- hg/init.d/40hg-init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hg/init.d/40hg-init b/hg/init.d/40hg-init index cf9733b..7d8404a 100644 --- a/hg/init.d/40hg-init +++ b/hg/init.d/40hg-init @@ -2,6 +2,6 @@ set -e if [ ! -e .hg ]; then hg init - echo "[web]\n" > .hg/hgrc - echo "$(hostname) /etc repository" > .hg/hgrc + echo "[web]" > .hg/hgrc + echo "description = $(hostname) /etc repository" >> .hg/hgrc fi -- cgit v1.2.3 From fd4a85189390d6e6f022eb8f71fcecb5d5f82958 Mon Sep 17 00:00:00 2001 From: Mathieu Clabaut Date: Fri, 21 Dec 2007 15:47:30 -0600 Subject: .hgignore syntax correction --- hg/init.d/50hg-ignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hg/init.d/50hg-ignore b/hg/init.d/50hg-ignore index 5d3a6a6..eee5462 100644 --- a/hg/init.d/50hg-ignore +++ b/hg/init.d/50hg-ignore @@ -2,7 +2,7 @@ set -e if [ ! -e .hgignore ]; then cat >.hgignore <