[pacman-dev] Hooks for pacman, more ideas

Mårten Olsson marten.olsson at purplescout.se
Mon Feb 2 17:53:28 EST 2009


----- "Mårten Olsson" <marten.olsson at purplescout.se> wrote:

> ----- "Allan McRae" <allan at archlinux.org> skrev:

<snip>
> > >> I'm sure it would be possible to have a package set off a hook
> such
> > as
> > >> you are suggesting, although I think most packages would have a
> > file
> > >> that would be the obvious choice to use (e.g. /boot/vmlinuz26 for
> > >> kernel26).   Please add a comment to the wiki page about this.
> > >>
> > >>
> > > Yep, I don't see that as a major problem.
> > > From what I have seen of the code it might however be easier to
> > start
> > > with Package matching (I might be wrong about this but it is my
> > personal
> > > opinion). In the end both options would be good, we have
> > > at least seen that between us that both variants are desirable.
> > >
> > >
> >
> >  From my understanding, there should be a list of files involved in
> a
> > transaction created during conflict checking.  So we can hopefully
> use
> > that to test which hooks need to be run.  However, I am not very
> > familiar with that part of the pacman code...
> >
> 
> Ah that seems resonable.
> 

I have done some looking around and the as far as I understand it it would 
be possible to use "alpm_pkg_get_files" whenever a package is installed/
upgraded/removed to find files to match.

Do you know if that is possible?

Also it seems like good places to check the hooks would be around the same
places where it is currently checked if a package has a scriptlet 
(where "alpm_pkg_has_scriptlet" is called in the "commit_single_pkg" and 
"_alpm_remove_commit" functions).

The hooks should probably be run after the package scriptlets, rigth?

Your ideas?

I also have tried to find good places for the "Transaction" hooks but
have really found a really good place, maybe in "_alpm_trans_free" but
I don't understand enought about the transation part of the code to 
determine if that is a good place...

I also have one question about the config syntax:
Currently the syntax is something like:
[<script to run>]
Files = <file to match>
(or 
Package = <packagename>
if that idea is added)
Run = <time to run the script>

[<script to run2>]
Files = <file to match2>
(or 
Package = <packagename2>
if that idea is added)
Run = <time to run the script>

What about lay it out like this instead:
[time to run the script]
File = <file to match> (or package)
Run = <script>
File = <file to match2> (or package2)
Run = <script2>

[time to run the script2]
File = <file to match3> (or package)
Run = <script3>

My personal opinion is that it gives a cleaner seperation as the "section
header" determines at which point "in time" to run the hook and it would be
more static thing to search/compare with when parsing the config.

What do you think?

> > Allan
> >
//Mårten



More information about the pacman-dev mailing list