diff options
author | Scott Bronson <b.git@u32.net> | 2008-03-20 02:28:32 -0700 |
---|---|---|
committer | Scott Bronson <b.git@u32.net> | 2008-03-20 02:28:32 -0700 |
commit | 20d7d55942b53bca4def251ce037fc84ff0f5e0d (patch) | |
tree | b56d0e91bd5fbbbc5173aad00e820a771848c173 /pre-commit.d/30store-metadata | |
parent | 4f14253f34de8bc04da2072364b19f8135ec4730 (diff) |
Store metadata in .etckeeper, not .fix-metadata.
Diffstat (limited to 'pre-commit.d/30store-metadata')
-rwxr-xr-x | pre-commit.d/30store-metadata | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata index fbd9096..65040bf 100755 --- a/pre-commit.d/30store-metadata +++ b/pre-commit.d/30store-metadata @@ -15,6 +15,7 @@ filter_unknown() { done } + generate_metadata() { # This function generates the script commands to fix any files # that aren't owner=root, group=root, or mode=0644 or 0755. @@ -24,6 +25,13 @@ generate_metadata() { # but we want find to ignore the VCS files themselves. NOVCS='. -wholename ./.git -prune -o -wholename ./.bzr -prune -o -wholename ./.hg -prune -o' + if [ "$VCS" = git ] || [ "$VCS" = hg ]; then + # These version control systems do not track directories, + # so empty directories must be stored specially. + find $NOVCS -type d -empty | sort | \ + sed -e "s/^/mkdir -p '/" -e "s/\$/'/" + fi + # Find all files and directories that don't have root as the owner find $NOVCS \! -user root -exec stat --format="chown %U {}" {} \; \ | sort | filter_unknown chown owner @@ -47,22 +55,27 @@ generate_metadata() { if [ "$VCS" = git ] || [ "$VCS" = hg ] || [ "$VCS" = bzr ]; then # ensure the file exists so that it will list its own metadata - if [ ! -e .fix-metadata ]; then - touch .fix-metadata + if [ ! -e .etckeeper ]; then + touch .etckeeper # Make sure the file is not readable by others, since it can leak # information about contents of non-readable directories in /etc. - chmod 700 .fix-metadata + chmod 700 .etckeeper fi - echo "# Generated by etckeeper." > .fix-metadata - echo >> .fix-metadata - generate_metadata >> .fix-metadata + echo "# Generated by etckeeper." > .etckeeper + echo >> .etckeeper + generate_metadata >> .etckeeper # stage the file as part of the current commit if [ "$VCS" = git ]; then # this will do nothing if the metadata file is unchanged. - git add .fix-metadata + git add .etckeeper fi # hg and bzr add not done, they will automatically # include the file in the current commit + + # Finally, VCS remove obsolete .metadata (as long as VCS is set) + if [ -f .metadata ] && [ "x$VCS" != "x" ]; then + $VCS rm .metadata + fi fi |