From bcf6059ec23ab4ff2d600c8669a5a81c24ee74b4 Mon Sep 17 00:00:00 2001 From: Henrik Riomar Date: Sun, 6 Aug 2017 11:26:38 +0200 Subject: community/etckeeper: move from testing --- ...-git-commit-s-lack-of-robustness-by-provi.patch | 102 +++++++++++++++++++++ community/etckeeper/APKBUILD | 52 +++++++++++ community/etckeeper/apk-commit_hook | 17 ++++ community/etckeeper/etckeeper.post-install | 10 ++ community/etckeeper/etckeeper.pre-deinstall | 6 ++ ...-git-commit-s-lack-of-robustness-by-provi.patch | 102 --------------------- testing/etckeeper/APKBUILD | 52 ----------- testing/etckeeper/apk-commit_hook | 17 ---- testing/etckeeper/etckeeper.post-install | 10 -- testing/etckeeper/etckeeper.pre-deinstall | 6 -- 10 files changed, 187 insertions(+), 187 deletions(-) create mode 100644 community/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch create mode 100644 community/etckeeper/APKBUILD create mode 100644 community/etckeeper/apk-commit_hook create mode 100644 community/etckeeper/etckeeper.post-install create mode 100644 community/etckeeper/etckeeper.pre-deinstall delete mode 100644 testing/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch delete mode 100644 testing/etckeeper/APKBUILD delete mode 100644 testing/etckeeper/apk-commit_hook delete mode 100644 testing/etckeeper/etckeeper.post-install delete mode 100644 testing/etckeeper/etckeeper.pre-deinstall diff --git a/community/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch b/community/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch new file mode 100644 index 0000000000..0726f43362 --- /dev/null +++ b/community/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch @@ -0,0 +1,102 @@ +From e19e9c51f63fdf6c836310bacf4a7d5caebdd55f Mon Sep 17 00:00:00 2001 +From: Joey Hess +Date: Thu, 8 Jun 2017 13:26:34 -0400 +Subject: [PATCH] Work around git commit's lack of robustness, by providing + reasonable default values for GIT_COMMITTER_EMAIL etc. + +This was already done as part of the su/sudo handling, and is now always +done. + +This commit was sponsored by Trenton Cronholm on Patreon. +--- + commit.d/50vcs-commit | 9 +++++++- + debian/changelog | 9 ++++++++ + ...___be_set_under_undocumented_circumstances.mdwn | 2 ++ + ...ent_1_f8399058ebbf3059000e6528296cc1e9._comment | 26 ++++++++++++++++++++++ + 4 files changed, 45 insertions(+), 1 deletion(-) + create mode 100644 doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment + +diff --git a/commit.d/50vcs-commit b/commit.d/50vcs-commit +index 55f0db2..f970d3d 100755 +--- a/commit.d/50vcs-commit ++++ b/commit.d/50vcs-commit +@@ -41,9 +41,16 @@ else + fi + + if [ "$VCS" = git ] && [ -d .git ]; then ++ # When not su'd to root, still set environment variables, ++ # since git's own code to determine the author and committer ++ # has several edge cases where it fails and would prevent the ++ # commit. ++ if [ -z "$USER" ]; then ++ USER="$(whoami)" ++ fi + if [ -n "$USER" ]; then + # Use user.name and user.email from the gitconfig belonging +- # to the user who became root. ++ # to USER. + USER_HOME="$(getent passwd "$USER" | cut -d: -f6)" + if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.gitconfig" ]; then + if [ -z "$GIT_AUTHOR_NAME" ]; then +diff --git a/debian/changelog b/debian/changelog +index 23783bd..46df223 100644 +--- a/debian/changelog ++++ b/debian/changelog +@@ -1,3 +1,12 @@ ++etckeeper (1.18.8) UNRELEASED; urgency=medium ++ ++ * Work around git commit's lack of robustness, by providing ++ reasonable default values for GIT_COMMITTER_EMAIL etc. ++ This was already done as part of the su/sudo handling, ++ and is now always done. ++ ++ -- Joey Hess Thu, 08 Jun 2017 13:22:01 -0400 ++ + etckeeper (1.18.7) unstable; urgency=medium + + * Added some unit tests. +diff --git a/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn +index 93177d8..5ddd8ad 100644 +--- a/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn ++++ b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn +@@ -34,3 +34,5 @@ This is not Ansible-specific: the last two conditions will also arise in the dai + + + IMO, considering how to document this behaviour shows it to be user-unfriendly. Therefore, it would be simplest if etckeeper could fall back to using `$(id -un)`, once `$(tty)` fails. ++ ++> Set `USER=$(whoami)`, for git only. [[done]] --[[Joey]] +diff --git a/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment +new file mode 100644 +index 0000000..16e907f +--- /dev/null ++++ b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment +@@ -0,0 +1,26 @@ ++[[!comment format=mdwn ++ username="joey" ++ subject="""comment 1""" ++ date="2017-06-08T17:00:19Z" ++ content=""" ++What actually requires user.email be set under ++undocumented circumstances? git does. Personally, I feel this is a total ++misfeature on git's part; git commit should succeed under all ++configuraations. Every single program that automates `git commit` ++is potentially buggy otherwise. ++ ++Anyway, yes, setting `USER=$(id -un)` (or whoami) would make ++the code that currently is used to handle sudo users be always ++run, and so git and any other VCSs that break in unusual circumstances ++would always work (at least as far as username and email goes, who knows ++what other requirements VCSs may have). ++ ++The downside is that this could change etckeeper's behavior, since ++it would now be guessing at the user name and email, and may make ++different choices than git does. ++ ++Setting USER would also impact the code for other VCSs than git. For ++example, the code for hg always sets HGUSER when USER is set. I don't know ++if the others VCSs are as picky as git; if this kind of breakage is not a ++problem for them it might be best to only set USER when using git. ++"""]] +-- +2.11.0 + diff --git a/community/etckeeper/APKBUILD b/community/etckeeper/APKBUILD new file mode 100644 index 0000000000..39d2efb368 --- /dev/null +++ b/community/etckeeper/APKBUILD @@ -0,0 +1,52 @@ +# Contributor: Henrik Riomar +# Maintainer: Henrik Riomar + +pkgname=etckeeper +pkgver=1.18.7 +pkgrel=1 +pkgdesc="Store /etc in git." +url="http://etckeeper.branchable.com" +arch="noarch" +license="GPL2" +checkdepends="bats fakeroot" +depends="findutils git" +subpackages="$pkgname-doc" +options="!checkroot" +install="$pkgname.post-install $pkgname.pre-deinstall" +source="$pkgname-$pkgver.tar.gz::https://git.joeyh.name/index.cgi/$pkgname.git/snapshot/$pkgname-$pkgver.tar.gz + apk-commit_hook + 0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch + " +builddir="$srcdir/$pkgname-$pkgver" + +prepare() { + default_prepare + + cd "$builddir" + sed -i 's|^PYTHON=python$|PYTHON=/bin/false|' Makefile + sed -i 's/_PACKAGE_MANAGER=.*/_PACKAGE_MANAGER=apk/' etckeeper.conf +} + +check() { + cd "$builddir" + make test +} + +package() { + cd "$builddir" + + make install DESTDIR="$pkgdir" + rm -rf "$pkgdir"/lib/systemd + rmdir "$pkgdir"/lib/ + rm -rf "$pkgdir"/etc/apt + + install -m755 -D "$builddir"/debian/cron.daily \ + "$pkgdir"/etc/periodic/daily/"$pkgname" + + install -m755 -D "$srcdir"/apk-commit_hook \ + "$pkgdir"/etc/apk/commit_hooks.d/"$pkgname" +} + +sha512sums="44b8f66b95663da1370943128bb5673e57bd7b9df7e727c93baea5dfc79852ebba9d0834827fed19722668849d3ed18b045db5cb42135e198576a2b839523d1a etckeeper-1.18.7.tar.gz +2b1a29d31b6e7cf4ddb05de9b5e088b5747c2abfb2d63f9bddd25f4b7dc8503d457df7fd644afe5bd6fea6a5285a111a47c0489d24378b483c1e026cc11c6bf7 apk-commit_hook +d4aa516f7b35c2eddd5c534391fd6363429633aea3b4b2e8e46b1fe192986c79f91bf9e3e808992ce524ffc3ac96cc3952d1a1e7c3b355b7f97ffa9badc8b8d0 0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch" diff --git a/community/etckeeper/apk-commit_hook b/community/etckeeper/apk-commit_hook new file mode 100644 index 0000000000..6f0a4c043c --- /dev/null +++ b/community/etckeeper/apk-commit_hook @@ -0,0 +1,17 @@ +#!/bin/sh + + +[ -x /usr/bin/etckeeper ] || exit + +case "$1" in + pre-commit) + etckeeper pre-install + ;; + post-commit) + etckeeper post-install + ;; + + *) + echo "$0: Un-handled action: $1" + ;; +esac diff --git a/community/etckeeper/etckeeper.post-install b/community/etckeeper/etckeeper.post-install new file mode 100644 index 0000000000..5bb094cb22 --- /dev/null +++ b/community/etckeeper/etckeeper.post-install @@ -0,0 +1,10 @@ +#!/bin/sh + +[ -e /etc/.git ] && exit 0 + +if etckeeper init; then + etckeeper commit "initial commit" + # we are in trigger context so the apk database + # contains info before the change takes effect + /etc/etckeeper/pre-install.d/10packagelist +fi diff --git a/community/etckeeper/etckeeper.pre-deinstall b/community/etckeeper/etckeeper.pre-deinstall new file mode 100644 index 0000000000..9170848b38 --- /dev/null +++ b/community/etckeeper/etckeeper.pre-deinstall @@ -0,0 +1,6 @@ +#!/bin/sh + +etckeeper uninit + +rm -f /var/cache/etckeeper/packagelist.fmt +rm -f /var/cache/etckeeper/packagelist.pre-install diff --git a/testing/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch b/testing/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch deleted file mode 100644 index 0726f43362..0000000000 --- a/testing/etckeeper/0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch +++ /dev/null @@ -1,102 +0,0 @@ -From e19e9c51f63fdf6c836310bacf4a7d5caebdd55f Mon Sep 17 00:00:00 2001 -From: Joey Hess -Date: Thu, 8 Jun 2017 13:26:34 -0400 -Subject: [PATCH] Work around git commit's lack of robustness, by providing - reasonable default values for GIT_COMMITTER_EMAIL etc. - -This was already done as part of the su/sudo handling, and is now always -done. - -This commit was sponsored by Trenton Cronholm on Patreon. ---- - commit.d/50vcs-commit | 9 +++++++- - debian/changelog | 9 ++++++++ - ...___be_set_under_undocumented_circumstances.mdwn | 2 ++ - ...ent_1_f8399058ebbf3059000e6528296cc1e9._comment | 26 ++++++++++++++++++++++ - 4 files changed, 45 insertions(+), 1 deletion(-) - create mode 100644 doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment - -diff --git a/commit.d/50vcs-commit b/commit.d/50vcs-commit -index 55f0db2..f970d3d 100755 ---- a/commit.d/50vcs-commit -+++ b/commit.d/50vcs-commit -@@ -41,9 +41,16 @@ else - fi - - if [ "$VCS" = git ] && [ -d .git ]; then -+ # When not su'd to root, still set environment variables, -+ # since git's own code to determine the author and committer -+ # has several edge cases where it fails and would prevent the -+ # commit. -+ if [ -z "$USER" ]; then -+ USER="$(whoami)" -+ fi - if [ -n "$USER" ]; then - # Use user.name and user.email from the gitconfig belonging -- # to the user who became root. -+ # to USER. - USER_HOME="$(getent passwd "$USER" | cut -d: -f6)" - if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.gitconfig" ]; then - if [ -z "$GIT_AUTHOR_NAME" ]; then -diff --git a/debian/changelog b/debian/changelog -index 23783bd..46df223 100644 ---- a/debian/changelog -+++ b/debian/changelog -@@ -1,3 +1,12 @@ -+etckeeper (1.18.8) UNRELEASED; urgency=medium -+ -+ * Work around git commit's lack of robustness, by providing -+ reasonable default values for GIT_COMMITTER_EMAIL etc. -+ This was already done as part of the su/sudo handling, -+ and is now always done. -+ -+ -- Joey Hess Thu, 08 Jun 2017 13:22:01 -0400 -+ - etckeeper (1.18.7) unstable; urgency=medium - - * Added some unit tests. -diff --git a/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn -index 93177d8..5ddd8ad 100644 ---- a/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn -+++ b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances.mdwn -@@ -34,3 +34,5 @@ This is not Ansible-specific: the last two conditions will also arise in the dai - - - IMO, considering how to document this behaviour shows it to be user-unfriendly. Therefore, it would be simplest if etckeeper could fall back to using `$(id -un)`, once `$(tty)` fails. -+ -+> Set `USER=$(whoami)`, for git only. [[done]] --[[Joey]] -diff --git a/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment -new file mode 100644 -index 0000000..16e907f ---- /dev/null -+++ b/doc/todo/requires___96__user.email__96___be_set_under_undocumented_circumstances/comment_1_f8399058ebbf3059000e6528296cc1e9._comment -@@ -0,0 +1,26 @@ -+[[!comment format=mdwn -+ username="joey" -+ subject="""comment 1""" -+ date="2017-06-08T17:00:19Z" -+ content=""" -+What actually requires user.email be set under -+undocumented circumstances? git does. Personally, I feel this is a total -+misfeature on git's part; git commit should succeed under all -+configuraations. Every single program that automates `git commit` -+is potentially buggy otherwise. -+ -+Anyway, yes, setting `USER=$(id -un)` (or whoami) would make -+the code that currently is used to handle sudo users be always -+run, and so git and any other VCSs that break in unusual circumstances -+would always work (at least as far as username and email goes, who knows -+what other requirements VCSs may have). -+ -+The downside is that this could change etckeeper's behavior, since -+it would now be guessing at the user name and email, and may make -+different choices than git does. -+ -+Setting USER would also impact the code for other VCSs than git. For -+example, the code for hg always sets HGUSER when USER is set. I don't know -+if the others VCSs are as picky as git; if this kind of breakage is not a -+problem for them it might be best to only set USER when using git. -+"""]] --- -2.11.0 - diff --git a/testing/etckeeper/APKBUILD b/testing/etckeeper/APKBUILD deleted file mode 100644 index 39d2efb368..0000000000 --- a/testing/etckeeper/APKBUILD +++ /dev/null @@ -1,52 +0,0 @@ -# Contributor: Henrik Riomar -# Maintainer: Henrik Riomar - -pkgname=etckeeper -pkgver=1.18.7 -pkgrel=1 -pkgdesc="Store /etc in git." -url="http://etckeeper.branchable.com" -arch="noarch" -license="GPL2" -checkdepends="bats fakeroot" -depends="findutils git" -subpackages="$pkgname-doc" -options="!checkroot" -install="$pkgname.post-install $pkgname.pre-deinstall" -source="$pkgname-$pkgver.tar.gz::https://git.joeyh.name/index.cgi/$pkgname.git/snapshot/$pkgname-$pkgver.tar.gz - apk-commit_hook - 0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch - " -builddir="$srcdir/$pkgname-$pkgver" - -prepare() { - default_prepare - - cd "$builddir" - sed -i 's|^PYTHON=python$|PYTHON=/bin/false|' Makefile - sed -i 's/_PACKAGE_MANAGER=.*/_PACKAGE_MANAGER=apk/' etckeeper.conf -} - -check() { - cd "$builddir" - make test -} - -package() { - cd "$builddir" - - make install DESTDIR="$pkgdir" - rm -rf "$pkgdir"/lib/systemd - rmdir "$pkgdir"/lib/ - rm -rf "$pkgdir"/etc/apt - - install -m755 -D "$builddir"/debian/cron.daily \ - "$pkgdir"/etc/periodic/daily/"$pkgname" - - install -m755 -D "$srcdir"/apk-commit_hook \ - "$pkgdir"/etc/apk/commit_hooks.d/"$pkgname" -} - -sha512sums="44b8f66b95663da1370943128bb5673e57bd7b9df7e727c93baea5dfc79852ebba9d0834827fed19722668849d3ed18b045db5cb42135e198576a2b839523d1a etckeeper-1.18.7.tar.gz -2b1a29d31b6e7cf4ddb05de9b5e088b5747c2abfb2d63f9bddd25f4b7dc8503d457df7fd644afe5bd6fea6a5285a111a47c0489d24378b483c1e026cc11c6bf7 apk-commit_hook -d4aa516f7b35c2eddd5c534391fd6363429633aea3b4b2e8e46b1fe192986c79f91bf9e3e808992ce524ffc3ac96cc3952d1a1e7c3b355b7f97ffa9badc8b8d0 0001-Work-around-git-commit-s-lack-of-robustness-by-provi.patch" diff --git a/testing/etckeeper/apk-commit_hook b/testing/etckeeper/apk-commit_hook deleted file mode 100644 index 6f0a4c043c..0000000000 --- a/testing/etckeeper/apk-commit_hook +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - - -[ -x /usr/bin/etckeeper ] || exit - -case "$1" in - pre-commit) - etckeeper pre-install - ;; - post-commit) - etckeeper post-install - ;; - - *) - echo "$0: Un-handled action: $1" - ;; -esac diff --git a/testing/etckeeper/etckeeper.post-install b/testing/etckeeper/etckeeper.post-install deleted file mode 100644 index 5bb094cb22..0000000000 --- a/testing/etckeeper/etckeeper.post-install +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -[ -e /etc/.git ] && exit 0 - -if etckeeper init; then - etckeeper commit "initial commit" - # we are in trigger context so the apk database - # contains info before the change takes effect - /etc/etckeeper/pre-install.d/10packagelist -fi diff --git a/testing/etckeeper/etckeeper.pre-deinstall b/testing/etckeeper/etckeeper.pre-deinstall deleted file mode 100644 index 9170848b38..0000000000 --- a/testing/etckeeper/etckeeper.pre-deinstall +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -etckeeper uninit - -rm -f /var/cache/etckeeper/packagelist.fmt -rm -f /var/cache/etckeeper/packagelist.pre-install -- cgit v1.2.3