Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 517782 - etckeeper AVOID_COMMIT_BEFORE_INSTALL does not work
Summary: etckeeper AVOID_COMMIT_BEFORE_INSTALL does not work
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Manuel Rüger (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-22 12:13 UTC by gerion
Modified: 2015-03-25 23:06 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gerion 2014-07-22 12:13:38 UTC
etckeeper has in /etc/etckeeper/etckeeper.conf an option AVOID_COMMIT_BEFORE_INSTALL
Set this feature does not work.

Reproducible: Always

Steps to Reproduce:
1. Set this option
2. unclean your /etc
3. emerge something
Actual Results:  
etckeeper commits unclean stuff.

Expected Results:  
etckeeper does not commit unclean stuff.

This behaviour can be fixed by changing the portage hook. If etckeeper detects uncommited stuff it outputs some lines and exit with 1 in "etckeeper pre-install". With the provided portage bashrc this results in nothing. This works:
case "${EBUILD_PHASE}" in
        setup|prerm) etckeeper pre-install || exit 1 ;;
        postinst|postrm) etckeeper post-install ;;
esac
Note, that I changed the preinst phase in setup additionally, so it prevents you from compiling 2 hours and then recognize, that the installation fails.
Comment 1 Manuel Rüger (RETIRED) gentoo-dev 2014-07-24 23:01:31 UTC
Is there any reason you choosed pkg_setup and not pkg_pretend? 

https://devmanual.gentoo.org/ebuild-writing/functions/index.html
Comment 2 gerion 2014-07-25 00:25:47 UTC
I found no documentation about the EBUILD_PHASE variable (which is used in the provided script, found only docus about EBUILD_PHASE_FUNC), so I tried it out with writing echo "ebuildphase is $EBUILD_PHASE" in bashrc.
This is the output:
# emerge -1 htop
Calculating dependencies ------------------------ebuildphase is depend------------------------------------
 ------------------------ebuildphase is depend------------------------------------
 |-----------------------ebuildphase is depend------------------------------------
...
... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-process/htop-1.0.2
-----------------------ebuildphase is clean------------------------------------
 * htop-1.0.2.tar.gz SHA256 SHA512 WHIRLPOOL size ;-) ...                                                                                                                                                                                                            [ ok ]
-----------------------ebuildphase is setup------------------------------------
-----------------------ebuildphase is unpack------------------------------------
...

So you see, there is no pretend (and clean is called twice, at the beginning and end).
Comment 3 Manuel Rüger (RETIRED) gentoo-dev 2014-10-24 15:12:58 UTC
*etckeeper-1.15 (24 Oct 2014)

  24 Oct 2014; Manuel Rüger <mrueg@gentoo.org> +etckeeper-1.15.ebuild,
  +files/bashrc-r1, +files/etckeeper-1.15-gentoo.patch:
  Version bump. Update bashrc example to fix bug #517782.
Comment 4 Michael Gn. Gajda 2015-03-25 23:06:12 UTC
Two things:

1) I was wondering why etckeeper did not do anything with portage on gentoo. The 'You may want to adjust your …bashrc' message did not make it clear for me that this is needed for portage to use etckeeper. I suggest changing this message to:

        elog
        elog "To use the pre-/post-commit hooks of etckeeper with portage"
        elog "you need to edit /etc/portage/bashrc"
        elog "see the example file in /usr/share/doc/${PF}/examples"
        elog


2) The way I figured it out was by the changelog and this bug. I also want to use the 'do not emerge when there are uncommited changes' feature, so I installed the keyworded 1.15 version.

But the example file provided with this version still reads:
case "${EBUILD_PHASE}" in
        # run etckeeper
        setup|prerm) etckeeper pre-install ;;
        postinst|postrm) etckeeper post-install ;;
esac
which results in portage emerging the package even with uncommited changes. Adding || exit 1 to the setup check does cuase portage to quit as requested (tho with a rather ugly error message, but that I can live with)

Is there any reason why this file was not update? Am I missing something?

Plus, I tried using 'pretend' instead of 'setup' which seems to be not part of a normal emerge - the check is never called.

I suggest just adding || exit 1 as the OP suggested. And appart from this, etckeeper-1.15 has been doing a good job for me so far. Maybe time to get rid of keywording?

Sincerely
Michael