Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-13 Thread Jeff Johnson


> On Sep 13, 2018, at 7:21 AM, Panu Matilainen  wrote:
> 
>> On 9/13/18 12:38 PM, Thierry Vignaud wrote:
>> Le mer. 12 sept. 2018 à 19:15, Neal Gompa  a écrit :
>> In Mageia, we eg had:
>> 1) manual "requires(post)" or "requires(posttrans): info-install"
>> (info-install being the package containing /sbin/ /sbin/install-info
>> 2) plus manual %post or %posttrans calling install-info
>> 
>> This was a manual process, so it was sometimes missed in some pkgs.
> 
> 
> That's why Fedora switched to transfiletrigger. It is much better ;)
 
 But we still need the pkgs container the info files to require the
 needed /sbin/info-install
 
>> We've replaced those manual requires+scriptlets by a filetrigger.
>> But we still want info-install to be installed, so in order to replace
>> the manual requires, we want to automatically emit the requires on
>> info-install
>> But we don't want to emit "requires: info-install",
>> what we want really is "requires(posttrans): info-install"
>> 
>> The patch enables to emit requires for scriptlets or filetriggers.
> 
> 
> This is too specific use case I think..
 
 That's an example but there could be more
>>> 
>>> I think the idea usually is that the file trigger would not fire if
>>> the package isn't installed, so forcing a dependency here means that
>>> there was no benefit to separating it out to be run only when it was
>>> needed. It basically makes it impossible to avoid running the trigger.
>> Which is exactly the point here:
>> Again, here the policy was for all those pkgs to require info-install
>> & run it in %post or %posttrans
>> In order to ease packager work, we replaced this manual work by using
>> a filetrigger.
>> But we stil want info-isntall to be installed, hence this patch
>>> In the case of info, there's no point in running the info commands if
>>> info itself is not installed. You can't use them anyway. :)
>> Again, info-install was manually required before, we just want to automate 
>> that.
> 
> But you don't need scriptlet context dependecies for that.
> 
> There's actually a more generic issue behind this: content viewer 
> applications. You'll want an info-viewer for texinfo pages, a man page viewer 
> for man pages, a browser for html content etc.
> 
> I've occasionally played with the idea of generating viewer(mimetype) style 
> dependencies. Traditionally no such dependencies have been generated because 
> it is a bit dubious - "every system will have man installed", right, and same 
> for "info"? And if not then maybe it's for a reason, such as wanting a 
> minimal disk usage and install was done with --nodocs, in which case dragging 
> the viewer in would be highly counter-productive. It should be a soft 
> dependency if anything at all.
> 
> Info only differs from man in that there's a central registry that needs 
> updating, but that does bring up an interesting question: there are multiple 
> alternative viewer applications but only install-info from info itself can 
> maintain the registry. So where does the dependency on the package containing 
> the trigger script (and install-info) belong?
> 
> After a bit of thought over lunch, I think it actually belongs in the 
> viewers: as long as nobody wants to view those info files, there's no need to 
> maintain the registry. Once you install a viewer, that changes. But as long 
> as the viewers drag in the package with the trigger (so in this case "info"), 
> the trigger will run on the viewer installation and register all the files 
> already on disk.
> 

Here's a minority, contrarian POV:

Running cache/index rebuilds -- ldconfig, fonts, XML, etc -- should be 
implemented in rpm, implemented through a different mechanism than triggers.

Too much time and effort has been spent arranging dependencies and mechanisms 
in packaging for what is ultimately simple and obvious tasks.

With multiple (3 if you include rpm5) file trigger implementations, designing a 
common representation and mechanism is almost impossible.

*shrug*

73 de Jeff
>- Panu -
> ___
> Rpm-maint mailing list
> Rpm-maint@lists.rpm.org
> http://lists.rpm.org/mailman/listinfo/rpm-maint
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-13 Thread Panu Matilainen

On 9/13/18 12:38 PM, Thierry Vignaud wrote:

Le mer. 12 sept. 2018 à 19:15, Neal Gompa  a écrit :

In Mageia, we eg had:
1) manual "requires(post)" or "requires(posttrans): info-install"
 (info-install being the package containing /sbin/ /sbin/install-info
2) plus manual %post or %posttrans calling install-info

This was a manual process, so it was sometimes missed in some pkgs.



That's why Fedora switched to transfiletrigger. It is much better ;)


But we still need the pkgs container the info files to require the
needed /sbin/info-install


We've replaced those manual requires+scriptlets by a filetrigger.
But we still want info-install to be installed, so in order to replace
the manual requires, we want to automatically emit the requires on
info-install
But we don't want to emit "requires: info-install",
what we want really is "requires(posttrans): info-install"

The patch enables to emit requires for scriptlets or filetriggers.



This is too specific use case I think..


That's an example but there could be more


I think the idea usually is that the file trigger would not fire if
the package isn't installed, so forcing a dependency here means that
there was no benefit to separating it out to be run only when it was
needed. It basically makes it impossible to avoid running the trigger.


Which is exactly the point here:
Again, here the policy was for all those pkgs to require info-install
& run it in %post or %posttrans
In order to ease packager work, we replaced this manual work by using
a filetrigger.
But we stil want info-isntall to be installed, hence this patch


In the case of info, there's no point in running the info commands if
info itself is not installed. You can't use them anyway. :)


Again, info-install was manually required before, we just want to automate that.


But you don't need scriptlet context dependecies for that.

There's actually a more generic issue behind this: content viewer 
applications. You'll want an info-viewer for texinfo pages, a man page 
viewer for man pages, a browser for html content etc.


I've occasionally played with the idea of generating viewer(mimetype) 
style dependencies. Traditionally no such dependencies have been 
generated because it is a bit dubious - "every system will have man 
installed", right, and same for "info"? And if not then maybe it's for a 
reason, such as wanting a minimal disk usage and install was done with 
--nodocs, in which case dragging the viewer in would be highly 
counter-productive. It should be a soft dependency if anything at all.


Info only differs from man in that there's a central registry that needs 
updating, but that does bring up an interesting question: there are 
multiple alternative viewer applications but only install-info from info 
itself can maintain the registry. So where does the dependency on the 
package containing the trigger script (and install-info) belong?


After a bit of thought over lunch, I think it actually belongs in the 
viewers: as long as nobody wants to view those info files, there's no 
need to maintain the registry. Once you install a viewer, that changes. 
But as long as the viewers drag in the package with the trigger (so in 
this case "info"), the trigger will run on the viewer installation and 
register all the files already on disk.


- Panu -
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-13 Thread Panu Matilainen

On 9/12/18 3:25 PM, Thierry Vignaud wrote:

In Mageia, we eg had:
1) manual "requires(post)" or "requires(posttrans): info-install"
 (info-install being the package containing /sbin/ /sbin/install-info
2) plus manual %post or %posttrans calling install-info

This was a manual process, so it was sometimes missed in some pkgs.

We've replaced those manual requires+scriptlets by a filetrigger.
But we still want info-install to be installed, so in order to replace
the manual requires, we want to automatically emit the requires on
info-install
But we don't want to emit "requires: info-install",
what we want really is "requires(posttrans): info-install"


No no no. Packages do not (and should not!) know what triggers might get 
run on them and what those triggers might need to do their job. 
Dependencies of trigger scripts need to be in the package containing 
those triggers.


I wouldn't be surprised if we have issues with ordering related to 
(file) triggers, but this is not the way to fix it. If you have a 
reproducer for a (file) trigger dependency related ordering issue, I'd 
certainly be interested.



The patch enables to emit requires for scriptlets or filetriggers.


Scriptlet dependencies cannot be discovered by looking at the package 
content, they'd need to be discovered by looking at the script. So 
there's no valid use-case for generating scriptlet dependencies with the 
current dependency generator, and if we some day start generating 
autodependencies for the scriptlets themselves, the scriptlet type 
(pre/post etc) info is not going to come from file attributes anyway, it 
comes from the scriptlet itself. NAK.


- Panu -
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-13 Thread Thierry Vignaud
Le mer. 12 sept. 2018 à 19:15, Neal Gompa  a écrit :
> > >> In Mageia, we eg had:
> > >> 1) manual "requires(post)" or "requires(posttrans): info-install"
> > >> (info-install being the package containing /sbin/ /sbin/install-info
> > >> 2) plus manual %post or %posttrans calling install-info
> > >>
> > >> This was a manual process, so it was sometimes missed in some pkgs.
> > >
> > >
> > > That's why Fedora switched to transfiletrigger. It is much better ;)
> >
> > But we still need the pkgs container the info files to require the
> > needed /sbin/info-install
> >
> > >> We've replaced those manual requires+scriptlets by a filetrigger.
> > >> But we still want info-install to be installed, so in order to replace
> > >> the manual requires, we want to automatically emit the requires on
> > >> info-install
> > >> But we don't want to emit "requires: info-install",
> > >> what we want really is "requires(posttrans): info-install"
> > >>
> > >> The patch enables to emit requires for scriptlets or filetriggers.
> > >
> > >
> > > This is too specific use case I think..
> >
> > That's an example but there could be more
>
> I think the idea usually is that the file trigger would not fire if
> the package isn't installed, so forcing a dependency here means that
> there was no benefit to separating it out to be run only when it was
> needed. It basically makes it impossible to avoid running the trigger.

Which is exactly the point here:
Again, here the policy was for all those pkgs to require info-install
& run it in %post or %posttrans
In order to ease packager work, we replaced this manual work by using
a filetrigger.
But we stil want info-isntall to be installed, hence this patch

> In the case of info, there's no point in running the info commands if
> info itself is not installed. You can't use them anyway. :)

Again, info-install was manually required before, we just want to automate that.

> That said, there may be a case where we might want this, so I'm not
> completely ruling out its relevance.
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-12 Thread Neal Gompa
On Wed, Sep 12, 2018 at 9:41 AM Thierry Vignaud
 wrote:
>
> Le mer. 12 sept. 2018 à 14:30, Igor Gnatenko
>  a écrit :
> >> In Mageia, we eg had:
> >> 1) manual "requires(post)" or "requires(posttrans): info-install"
> >> (info-install being the package containing /sbin/ /sbin/install-info
> >> 2) plus manual %post or %posttrans calling install-info
> >>
> >> This was a manual process, so it was sometimes missed in some pkgs.
> >
> >
> > That's why Fedora switched to transfiletrigger. It is much better ;)
>
> But we still need the pkgs container the info files to require the
> needed /sbin/info-install
>
> >> We've replaced those manual requires+scriptlets by a filetrigger.
> >> But we still want info-install to be installed, so in order to replace
> >> the manual requires, we want to automatically emit the requires on
> >> info-install
> >> But we don't want to emit "requires: info-install",
> >> what we want really is "requires(posttrans): info-install"
> >>
> >> The patch enables to emit requires for scriptlets or filetriggers.
> >
> >
> > This is too specific use case I think..
>
> That's an example but there could be more

I think the idea usually is that the file trigger would not fire if
the package isn't installed, so forcing a dependency here means that
there was no benefit to separating it out to be run only when it was
needed. It basically makes it impossible to avoid running the trigger.

In the case of info, there's no point in running the info commands if
info itself is not installed. You can't use them anyway. :)

That said, there may be a case where we might want this, so I'm not
completely ruling out its relevance.


-- 
真実はいつも一つ!/ Always, there's only one truth!
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-12 Thread Thierry Vignaud
Le mer. 12 sept. 2018 à 14:30, Igor Gnatenko
 a écrit :
>> In Mageia, we eg had:
>> 1) manual "requires(post)" or "requires(posttrans): info-install"
>> (info-install being the package containing /sbin/ /sbin/install-info
>> 2) plus manual %post or %posttrans calling install-info
>>
>> This was a manual process, so it was sometimes missed in some pkgs.
>
>
> That's why Fedora switched to transfiletrigger. It is much better ;)

But we still need the pkgs container the info files to require the
needed /sbin/info-install

>> We've replaced those manual requires+scriptlets by a filetrigger.
>> But we still want info-install to be installed, so in order to replace
>> the manual requires, we want to automatically emit the requires on
>> info-install
>> But we don't want to emit "requires: info-install",
>> what we want really is "requires(posttrans): info-install"
>>
>> The patch enables to emit requires for scriptlets or filetriggers.
>
>
> This is too specific use case I think..

That's an example but there could be more
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-12 Thread Thierry Vignaud
In Mageia, we eg had:
1) manual "requires(post)" or "requires(posttrans): info-install"
(info-install being the package containing /sbin/ /sbin/install-info
2) plus manual %post or %posttrans calling install-info

This was a manual process, so it was sometimes missed in some pkgs.

We've replaced those manual requires+scriptlets by a filetrigger.
But we still want info-install to be installed, so in order to replace
the manual requires, we want to automatically emit the requires on
info-install
But we don't want to emit "requires: info-install",
what we want really is "requires(posttrans): info-install"

The patch enables to emit requires for scriptlets or filetriggers.
See you

Le mer. 12 sept. 2018 à 10:34, Igor Gnatenko
 a écrit :
>
> What is the point of this? I just don't get the use-case..
>
> On Wed, Sep 12, 2018 at 10:32 AM Thierry Vignaud  
> wrote:
>>
>> Le sam. 8 sept. 2018 à 09:10, Thierry Vignaud
>>  a écrit :
>> >
>> > Hi
>> >
>> > The attached patch adds support for scriptlet deps in generated deps.
>> > Eg on Mageia, there's a file trigger for automatically
>> > installing/removing info pages from /usr/share/info index
>> >
>> > Having manual or auto generated "Requires: ..." mean some strong
>> > deploops in base packages which rpmlib can break at random places,
>> > sometimes borking scriptlets.
>> >
>> > What we want in such a case is "Requires(posttrans): ..;" as
>> > filetriggers will be run late anyway.
>> >
>> > This patch enables to do that (but only in internal deps generators)
>> >
>> > Example:
>> > %__info_requires%{_rpmconfigdir}/mageia/info-file.req
>> > %__info_scriptlet   posttrans
>> > %__info_path^%{_datadir}/info/.*\\.info.*$
>> >
>> > See you
>>
>> Can you consider this one for inclusion?
>> ___
>> Rpm-maint mailing list
>> Rpm-maint@lists.rpm.org
>> http://lists.rpm.org/mailman/listinfo/rpm-maint
>
> --
>
> -Igor Gnatenko
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-12 Thread Igor Gnatenko
What is the point of this? I just don't get the use-case..

On Wed, Sep 12, 2018 at 10:32 AM Thierry Vignaud 
wrote:

> Le sam. 8 sept. 2018 à 09:10, Thierry Vignaud
>  a écrit :
> >
> > Hi
> >
> > The attached patch adds support for scriptlet deps in generated deps.
> > Eg on Mageia, there's a file trigger for automatically
> > installing/removing info pages from /usr/share/info index
> >
> > Having manual or auto generated "Requires: ..." mean some strong
> > deploops in base packages which rpmlib can break at random places,
> > sometimes borking scriptlets.
> >
> > What we want in such a case is "Requires(posttrans): ..;" as
> > filetriggers will be run late anyway.
> >
> > This patch enables to do that (but only in internal deps generators)
> >
> > Example:
> > %__info_requires%{_rpmconfigdir}/mageia/info-file.req
> > %__info_scriptlet   posttrans
> > %__info_path^%{_datadir}/info/.*\\.info.*$
> >
> > See you
>
> Can you consider this one for inclusion?
> ___
> Rpm-maint mailing list
> Rpm-maint@lists.rpm.org
> http://lists.rpm.org/mailman/listinfo/rpm-maint
>
-- 

-Igor Gnatenko
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-12 Thread Thierry Vignaud
Le sam. 8 sept. 2018 à 09:10, Thierry Vignaud
 a écrit :
>
> Hi
>
> The attached patch adds support for scriptlet deps in generated deps.
> Eg on Mageia, there's a file trigger for automatically
> installing/removing info pages from /usr/share/info index
>
> Having manual or auto generated "Requires: ..." mean some strong
> deploops in base packages which rpmlib can break at random places,
> sometimes borking scriptlets.
>
> What we want in such a case is "Requires(posttrans): ..;" as
> filetriggers will be run late anyway.
>
> This patch enables to do that (but only in internal deps generators)
>
> Example:
> %__info_requires%{_rpmconfigdir}/mageia/info-file.req
> %__info_scriptlet   posttrans
> %__info_path^%{_datadir}/info/.*\\.info.*$
>
> See you

Can you consider this one for inclusion?
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH] add support for scriptlet deps in generated deps

2018-09-08 Thread Thierry Vignaud
Hi

The attached patch adds support for scriptlet deps in generated deps.
Eg on Mageia, there's a file trigger for automatically
installing/removing info pages from /usr/share/info index

Having manual or auto generated "Requires: ..." mean some strong
deploops in base packages which rpmlib can break at random places,
sometimes borking scriptlets.

What we want in such a case is "Requires(posttrans): ..;" as
filetriggers will be run late anyway.

This patch enables to do that (but only in internal deps generators)

Example:
%__info_requires%{_rpmconfigdir}/mageia/info-file.req
%__info_scriptlet   posttrans
%__info_path^%{_datadir}/info/.*\\.info.*$

See you
From c70b34df68cedc93c2a77fd92ceed3e78cc06651 Mon Sep 17 00:00:00 2001
From: Thierry Vignaud 
Date: Sat, 8 Sep 2018 08:30:45 +0200
Subject: [PATCH] add support for scriptlet deps in generated deps

only in internal deps generators
---
 build/rpmfc.c | 67 +++
 1 file changed, 67 insertions(+)

diff --git a/build/rpmfc.c b/build/rpmfc.c
index 2fbfc69ab..9fb7945e5 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -504,6 +505,7 @@ static ARGV_t runCmd(const char *nsdep, const char *depname,
 struct addReqProvDataFc {
 rpmfc fc;
 const char *namespace;
+const char *scriptlet;
 regex_t *exclude;
 };
 
@@ -524,6 +526,61 @@ static rpmRC addReqProvFc(void *cbdata, rpmTagVal tagN,
 return RPMRC_OK;
 }
 
+// Stolen from build/parsePreamble.c
+typedef const struct tokenBits_s {
+const char * name;
+rpmsenseFlags bits;
+} * tokenBits;
+
+static struct tokenBits_s const installScriptBits[] = {
+{ "interp", RPMSENSE_INTERP },
+{ "preun",  RPMSENSE_SCRIPT_PREUN },
+{ "pre",RPMSENSE_SCRIPT_PRE },
+{ "postun", RPMSENSE_SCRIPT_POSTUN },
+{ "post",   RPMSENSE_SCRIPT_POST },
+//{ "rpmlib", RPMSENSE_RPMLIB },
+{ "verify", RPMSENSE_SCRIPT_VERIFY },
+{ "pretrans",   RPMSENSE_PRETRANS },
+{ "posttrans",  RPMSENSE_POSTTRANS },
+{ NULL, 0 }
+};
+
+static int parseBits(const char * s, const tokenBits tokbits,
+rpmsenseFlags * bp)
+{
+tokenBits tb;
+const char * se;
+rpmsenseFlags bits = RPMSENSE_ANY;
+int c = 0;
+int rc = RPMRC_OK;
+
+if (s) {
+while (*s != '\0') {
+while ((c = *s) && risspace(c)) s++;
+se = s;
+while ((c = *se) && risalpha(c)) se++;
+if (s == se)
+break;
+for (tb = tokbits; tb->name; tb++) {
+if (tb->name != NULL &&
+strlen(tb->name) == (se-s) && rstreqn(tb->name, s, (se-s)))
+break;
+}
+if (tb->name == NULL) {
+rc = RPMRC_FAIL;
+break;
+}
+bits |= tb->bits;
+while ((c = *se) && risspace(c)) se++;
+if (c != ',')
+break;
+s = ++se;
+}
+}
+*bp |= bits;
+return rc;
+}
+
 /**
  * Run per-interpreter dependency helper.
  * @param fc		file classifier
@@ -541,6 +598,7 @@ static int rpmfcHelper(rpmfc fc, int ix,
 ARGV_t pav = NULL;
 const char * fn = fc->fn[ix];
 char *namespace = NULL;
+char *scriptlet = NULL;
 int pac;
 int rc = 0;
 regex_t *exclude = NULL;
@@ -563,11 +621,19 @@ static int rpmfcHelper(rpmfc fc, int ix,
 pac = argvCount(pav);
 namespace = rpmfcAttrMacro(nsdep, "namespace", NULL);
 exclude = rpmfcAttrReg(depname, "exclude", NULL);
+scriptlet = rpmfcAttrMacro(nsdep, "scriptlet", NULL);
+rpmsenseFlags tagflags = RPMSENSE_ANY;
+if (scriptlet && parseBits(scriptlet, installScriptBits, )) {
+rpmlog(RPMLOG_ERR, _("Bad scriptlet: %s\n"), scriptlet);
+goto exit;
+}
+dsContext |= tagflags;
 
 struct addReqProvDataFc data;
 data.fc = fc;
 data.namespace = namespace;
 data.exclude = exclude;
+data.scriptlet = scriptlet;
 
 for (int i = 0; i < pac; i++) {
 	if (parseRCPOT(NULL, fc->pkg, pav[i], tagN, ix, dsContext, addReqProvFc, ))
@@ -577,6 +643,7 @@ static int rpmfcHelper(rpmfc fc, int ix,
 argvFree(pav);
 regFree(exclude);
 free(namespace);
+free(scriptlet);
 
 exit:
 regFree(exclude_from);
-- 
2.18.0

___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint