Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
> Ok, documentation can go into > https://rpm.org/user_doc/dependency_generators.html as soon as this is > upstream/released. Added: https://rpm.org/user_doc/dependency_generators#parametric-macro-generators-rpm--416 -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-593852175___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Merged #1053 into master. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#event-3025934733___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -514,6 +514,22 @@ static ARGV_t runCmd(const char *cmd, return output; } +static ARGV_t runCall(const char *cmd, +const char *buildRoot, const char *fn) +{ + +ARGV_t output = NULL; +char *fullcmd = rstrscat(NULL, "%{", cmd, " ", "%{?buildroot:buildroot/}", fn, "}", NULL); The latest version using literal resolves even the % case. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r377526881___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Updated to use rpmMacroIsParametric() as the API name, tweaks to commit message(s). -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-584549360___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
@pmatilai pushed 2 commits. c2177646458ef20c6d3cfeeddc0fa7ca34c0d50b Add APIs for testing whether a macro is defined and whether its parametric fc98504d59603014edffa53439b96c793ac11f29 Add support for macro-only dependency generators -- You are receiving this because you are subscribed to this thread. View it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053/files/d301eb41d0ac6cada357f281ff465f2f0b25b63a..fc98504d59603014edffa53439b96c793ac11f29 ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -1784,6 +1784,29 @@ rpmDefineMacro(rpmMacroContext mc, const char * macro, > int level) return rc; } +int rpmMacroIsDefined(rpmMacroContext mc, const char *n) +{ +int defined = 0; +if ((mc = rpmmctxAcquire(mc)) != NULL) { + if (findEntry(mc, n, 0, NULL)) + defined = 1; + rpmmctxRelease(mc); +} +return defined; +} + +int rpmMacroIsCallable(rpmMacroContext mc, const char *n) +{ But okay, I'll update it to use rpmMacroIsParametric(), it's at least more in line with our internal terminology than "callable". -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r377518331___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
mlschroe approved this pull request. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#pullrequestreview-356505622___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -1784,6 +1784,29 @@ rpmDefineMacro(rpmMacroContext mc, const char * macro, > int level) return rc; } +int rpmMacroIsDefined(rpmMacroContext mc, const char *n) +{ +int defined = 0; +if ((mc = rpmmctxAcquire(mc)) != NULL) { + if (findEntry(mc, n, 0, NULL)) + defined = 1; + rpmmctxRelease(mc); +} +return defined; +} + +int rpmMacroIsCallable(rpmMacroContext mc, const char *n) +{ That seems to answer a different question (ie whether the macro was called with parameters or not). -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r377516660___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
mlschroe commented on this pull request. > @@ -1784,6 +1784,29 @@ rpmDefineMacro(rpmMacroContext mc, const char * macro, > int level) return rc; } +int rpmMacroIsDefined(rpmMacroContext mc, const char *n) +{ +int defined = 0; +if ((mc = rpmmctxAcquire(mc)) != NULL) { + if (findEntry(mc, n, 0, NULL)) + defined = 1; + rpmmctxRelease(mc); +} +return defined; +} + +int rpmMacroIsCallable(rpmMacroContext mc, const char *n) +{ Maybe `rpmMacroHasParameters()`? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r377514959___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Okay, together with the new RPMMACRO_LITERAL and a whole pile of other escaping-related changes, a path with percent signs can actually be passed unharmed through this. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-584134028___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
@pmatilai pushed 13 commits. 8b1ea52de31a428952a470225b153393489743fe Double the '%' chars when splitting macro args c886b359ba5f05eec6a8da34b55437834b7d80ee Fix pointer dereference before testing for NULL in rpmtdGetNumber() 94623389ba61a3a93decc726ed63e52cca7b3d39 Fix buffer overflow in %{S:...} and %{P:...} macro primitives 227cddca88fe99b0e2454a45b941adc3d09bd2ce Fix %{uncompress:...} double-expanding arguments + other miscellania b551b256eaf03a1e4bfa7174e08f505dde8a5d2d Refactor %{expand:...} handling to its own function 47dbb3e070efe8ef5583f22d4903a89bcda90d3c Don't double-expand arguments to built-in macros (#311) abcb0af241ea9ad0ef8f5a4467885245c0101d15 Refactor %{verbose:...} handling out of doFoo() 7d3a87ca1838d9a0983ab8532fc697cbca75a1d5 Remove duplicated code in macro expansion 07cc75f4d4173e5224faa1cb3715c5c7bc8856a2 Add a ME_LITERAL macro flag that turns off body expansion cc66df4fa10470356639c47cec0761baccbc4aee Add rpmPushMacroFlags function to allow the definition of literal macros 490c70d43cb16a794ac6a73c014ddb119cc9cd12 Use RPMMACRO_LITERAL/ME_LITERAL when defining some macros 18ddc291c30b2527deb974eb7d9a6e5b7f19d5ec Add APIs for testing whether a macro is defined and whether its callable d301eb41d0ac6cada357f281ff465f2f0b25b63a Add support for macro-only dependency generators -- You are receiving this because you are subscribed to this thread. View it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053/files/53fa6af7a59e307eee0468ad5a94e45906ea2b2f..d301eb41d0ac6cada357f281ff465f2f0b25b63a ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Blocked until #1060 is merged and this PR updated to pass the argument as a literal. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-584105708___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -514,6 +514,22 @@ static ARGV_t runCmd(const char *cmd, return output; } +static ARGV_t runCall(const char *cmd, +const char *buildRoot, const char *fn) +{ + +ARGV_t output = NULL; +char *fullcmd = rstrscat(NULL, "%{", cmd, " ", "%{?buildroot:buildroot/}", fn, "}", NULL); Possibly. I don't know if I can bring myself to care enough about that fringe case though... -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r375797492___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
mlschroe commented on this pull request. > @@ -514,6 +514,22 @@ static ARGV_t runCmd(const char *cmd, return output; } +static ARGV_t runCall(const char *cmd, +const char *buildRoot, const char *fn) +{ + +ARGV_t output = NULL; +char *fullcmd = rstrscat(NULL, "%{", cmd, " ", "%{?buildroot:buildroot/}", fn, "}", NULL); I'm not sure but I think you still need to double the '%' chars... -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r375793422___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -514,6 +514,22 @@ static ARGV_t runCmd(const char *cmd, return output; } +static ARGV_t runCall(const char *cmd, +const char *buildRoot, const char *fn) +{ + +ARGV_t output = NULL; +char *fullcmd = rstrscat(NULL, "%{", cmd, " ", "%{?buildroot:buildroot/}", fn, "}", NULL); Fixed in the latest push by faking the %1 argument. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r375782453___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
@pmatilai pushed 1 commit. 53fa6af7a59e307eee0468ad5a94e45906ea2b2f Add support for macro-only dependency generators -- You are receiving this because you are subscribed to this thread. View it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053/files/4bca4dc8908e34c7d12b8378bda436210def4f0b..53fa6af7a59e307eee0468ad5a94e45906ea2b2f ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -514,6 +514,22 @@ static ARGV_t runCmd(const char *cmd, return output; } +static ARGV_t runCall(const char *cmd, +const char *buildRoot, const char *fn) +{ + +ARGV_t output = NULL; +char *fullcmd = rstrscat(NULL, "%{", cmd, " ", "%{?buildroot:buildroot/}", fn, "}", NULL); Hmm, actually just pushing/popping a macro named "1" gets around that. It's a bit of a cheat of course but it'll probably do for now. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r375776400___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -514,6 +514,22 @@ static ARGV_t runCmd(const char *cmd, return output; } +static ARGV_t runCall(const char *cmd, +const char *buildRoot, const char *fn) +{ + +ARGV_t output = NULL; +char *fullcmd = rstrscat(NULL, "%{", cmd, " ", "%{?buildroot:buildroot/}", fn, "}", NULL); Hmm, annoying but true. One simple way around this would be passing the argument via a separately defined macro, eg ``` char *path = rstrscat(NULL, buildRoot ? buildRoot : "", "/", fn, NULL); rpmPushMacro(NULL, "filename", NULL, path, 0); char *exp = rpmExpand("%{", cmd, "}", NULL); rpmPopMacro(NULL, "filename"); ... ``` ...and then use %{filename} instead of %{1} in the macro, but that's not very elegant. Maybe there should be a rpmPushMacroArg() or such to get around this in a generic way. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r375771770___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
pmatilai commented on this pull request. > @@ -1784,6 +1784,29 @@ rpmDefineMacro(rpmMacroContext mc, const char * macro, > int level) return rc; } +int rpmMacroIsDefined(rpmMacroContext mc, const char *n) +{ +int defined = 0; +if ((mc = rpmmctxAcquire(mc)) != NULL) { + if (findEntry(mc, n, 0, NULL)) + defined = 1; + rpmmctxRelease(mc); +} +return defined; +} + +int rpmMacroIsCallable(rpmMacroContext mc, const char *n) +{ That depends on whether one considers "parametric" to be a descriptive name. I find the term pretty horrible, especially as it's called "parameterized" in the docs and comments. I just cannot bring myself to add call a function rpmMacroIsParameterized()... -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#discussion_r375752797___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
mlschroe commented on this pull request. > @@ -514,6 +514,22 @@ static ARGV_t runCmd(const char *cmd, return output; } +static ARGV_t runCall(const char *cmd, +const char *buildRoot, const char *fn) +{ + +ARGV_t output = NULL; +char *fullcmd = rstrscat(NULL, "%{", cmd, " ", "%{?buildroot:buildroot/}", fn, "}", NULL); This doesn't work for file names like `foo}bar` or `foo%%bar`. To make that bulletproof, you'd need a `rpmMacroExpandParametric(rpmMacroContext mc, const char *n, ARGV_t argv)` function. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#pullrequestreview-354340714___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
mlschroe commented on this pull request. > @@ -1784,6 +1784,29 @@ rpmDefineMacro(rpmMacroContext mc, const char * macro, > int level) return rc; } +int rpmMacroIsDefined(rpmMacroContext mc, const char *n) +{ +int defined = 0; +if ((mc = rpmmctxAcquire(mc)) != NULL) { + if (findEntry(mc, n, 0, NULL)) + defined = 1; + rpmmctxRelease(mc); +} +return defined; +} + +int rpmMacroIsCallable(rpmMacroContext mc, const char *n) +{ Wouldn't `rpmMacroIsParametric()` be a better name for this? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#pullrequestreview-354336470___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Testcase added. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-582828428___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
@pmatilai pushed 1 commit. 4bca4dc8908e34c7d12b8378bda436210def4f0b Add support for macro-only dependency generators -- You are receiving this because you are subscribed to this thread. View it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053/files/a3614643b55eaeabe28c1f23822602994d9d9582..4bca4dc8908e34c7d12b8378bda436210def4f0b ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Fixed rpmdeps case where buildroot is not defined. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-582815254___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
@pmatilai pushed 1 commit. a3614643b55eaeabe28c1f23822602994d9d9582 Add support for macro-only dependency generators -- You are receiving this because you are subscribed to this thread. View it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053/files/39326b3685e6ad979401271c572e17d88d2e8ec6..a3614643b55eaeabe28c1f23822602994d9d9582 ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
For an example, take a look at kmod.prov (which is actually what inspired this whole thing): the core of it boils down to echoing the basename of the filename back, stripped of suffix. For each, it spawns a shell and runs external utilities. When you consider that the kernel has (tens of) thousands of modules, it adds up. With the existing kmod.prov script, `find /lib/modules/`uname -r`| ./rpmdeps --provides` (consisting of ~3500 kernel modules) takes around 30s when hot in cache. The macro function version runs under two seconds, which is dominated by the file classifying. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-582814304___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Just noticed this isn't working when called from rpmdeps, need to sort that out. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-582807559___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
This deserves both some documentation and a test case. Ok, documentation can go into https://rpm.org/user_doc/dependency_generators.html as soon as this is upstream/released. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-582804200___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Add support for macro-only dependency generators (#1053)
Do you have some example how this could be used? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/1053#issuecomment-582803014___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint