Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear how to reach post_pkg_postinst() equality via BashrcdPhase postinst? #21

Open
lkraav opened this issue Feb 22, 2020 · 2 comments

Comments

@lkraav
Copy link

lkraav commented Feb 22, 2020

Hi. I'm looking to automatically git commit all /etc changes, meaning I need to execute as late as possible, probably after pkg_postinst().

Many packages, like https://github.com/gentoo-mirror/gentoo/blob/stable/app-text/docbook-xml-dtd/docbook-xml-dtd-4.5-r2.ebuild#L52 use pkg_postinst phase to run various configuration file change actions.

BashrcdPhase postinst seems to execute its callback before package. Is this intentional?

I seem to have 2 options:

A) BashrcdPhase postinst set a "reached postinst" flag variable, BashrcdPhase clean to execute git operations

B) Just use Portage native post_pkg_postinst() function

Is option A possible even?

lkraav added a commit to lkraav/portage-git-etc that referenced this issue Feb 23, 2020
@vaeth
Copy link
Owner

vaeth commented Feb 25, 2020

It is portage which decides when /etc/portage/bashrc is sourced. Only when it is sourced, the code set up with BashrcdPhase will be executed. So there is nothing which this script can do to change any order.

I do not know whether A can work: variable and function states can be saved on disk between phases, and I doubt that pms gives a guarantee that something is restored for the clean phase. It might work currently, but fail with future portage versions.

@lkraav
Copy link
Author

lkraav commented Feb 25, 2020

I think a clearer version of my question is: does or should portage-bashrc-mv support pre/post-phase hooks as well?

Option A works (see lkraav/portage-git-etc@b786eb1), in theory, but ran into the issue of "register_die_hook() not allowed in global scope"

I couldn't figure out a way to pass variables between phases, so I went with following .setuped etc PMS lockfiles convention, for first attempt. But generates a lot of extra lockfile cleanup concern work, due to clean phase being executed multiple times, and without custom lockfiles, you don't really know which clean phase of the emerge process you're at inside any given execution fo it.

It is strongly looking like implementing PMS native post_pkg_postinst() hook is the way to go here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants