Re: [Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Michael Schroeder
Yeah, I should read the comments instead of just looking at the "Files Changed" 
tab...

-- 
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/1220#issuecomment-628682647___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Panu Matilainen
I'll try to submit a more complete version tomorrowish, there's some bulldozing 
in order...

-- 
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/1220#issuecomment-628681865___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
> v"%{php_version}" < v"5.6"

I initially failed to register the Python connection. I kinda like this as it's 
a far stronger hint at what it is than the other variants, and has precedent in 
at least one major language.

-- 
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/issues/1217#issuecomment-628661165___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Panu Matilainen
@mlschroe , as noted in the description and commit messages: "this isn't right 
as it uses rpmvercmp() whereas this would need to compare entire EVR labels, 
but suffices for PoC purposes."

-- 
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/1220#issuecomment-628651978___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Miro Hrončok
While `@1.2@ < @1.0@` looks quite OK, when combined with macros, it's not very 
readable either:

```spec
%if @%{php_version}@ < @5.6@
```

-- 
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/issues/1217#issuecomment-628651033___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Miro Hrončok
Listed in 
https://github.com/rpm-software-management/rpm/issues/1217#issuecomment-628526414

-- 
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/1220#issuecomment-628650303___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Michael Schroeder
How about supporting EVR syntax instead of that rpmvercmp() call?

-- 
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/1220#issuecomment-628650459___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Michael Schroeder
Another possibility would be the pythonish/perlish `v"1.2.3"`.

-- 
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/1220#issuecomment-628647876___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Panu Matilainen
Just a word of caution: rpmluaRunScript() and rpmluaRunScriptFile() are not 
considered public API and are not available in the public headers on C side, 
although the symbols are accessible in the ABI. So they are subject to change 
without further notice, although the likelihood of that happening doesn't seem 
that great, they've been exactly the way are since their inception 16 years 
ago...

-- 
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/issues/1215#issuecomment-628594473___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Panu Matilainen
Wonderfully weird stuff :smile: 

-- 
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/issues/1215#issuecomment-628588855___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Miro Hrončok
Here is my draft blog post about how to get a nicer console 
https://hackmd.io/@hroncok/SyNjuxcqL

-- 
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/issues/1215#issuecomment-628586104___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Panu Matilainen
Adding a native way to flush the output shouldn't be hard. This is code that 
for all practical purposes nobody has touched in 16 years so it's not 
surprising if its a bit rusty and squeaky...

-- 
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/issues/1215#issuecomment-628583853___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
Yup, the way the expression parser works there are basically two possibilities: 
either tag the version strings or the comparison operator, somehow. I think the 
former is the far less weird option.

@ does ensure the reader attention more than any of the quoting variants:
`@1.2 < @1.0` 
`@1.2@ < @1.0@`

Another "easy" special marker would be # but that seems entirely wrong for the 
purpose.
`#1.2 < #1.0`


-- 
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/issues/1217#issuecomment-628579751___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Vít Ondruch
Or if there was a way to flush to the output the content collected by the macro 
engine 

-- 
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/issues/1215#issuecomment-628566016___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Vít Ondruch
I think it could be enough if the documentation give more reasonable example 
such as:

~~~
rpm.expand("%{echo:some message}")
~~~

Which provides expected output:

~~~
$ rpm --eval "%{lua:rpm.interactive()}"

RPM Interactive Lua 5.3 Interpreter
> rpm.expand("%{echo:some message}")
some message
> rpm.expand("%{echo:%{_bindir}}")
/usr/bin
>
~~~

Or IDK what else one could be interested.

-- 
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/issues/1215#issuecomment-628564806___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Miro Hrončok
Thank you!

-- 
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/1220#issuecomment-628557926___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [rpm-software-management/rpm] RFC: support rpm version comparison in expression parser (#1220)

2020-05-14 Thread Panu Matilainen
Inspired by #1217, this is a proof-of-concept patch series to add support for 
version comparison in the expression parser, allowing things like this to do 
the right thing:

```
%if `%{python_version}` < `3.9`
...
%endif
```

...and also macros, eg
```
$ ./rpm --eval '%["5.3.0" == "5.3.0+"]'
0
$ ./rpm --eval '%[`5.3.0` == `5.3.0+`]'
1
```

Backticks are used to denote versions as opposed to regular strings not because 
I particularly like them but just because I had to use something and single 
quotes get painful when testing with shell. 
As noted in the commit messages, this isn't right as it uses rpmvercmp() 
whereas this would need to compare entire EVR labels, but suffices for PoC 
purposes.
You can view, comment on, or merge this pull request online at:

  https://github.com/rpm-software-management/rpm/pull/1220

-- Commit Summary --

  * Move rpmVersionCompare() to headerutil.c for better layer match
  * Move rpmvercmp() to librpmio
  * Support rpm version comparison in expressions

-- File Changes --

M Makefile.am (1)
M lib/Makefile.am (2)
M lib/headerutil.c (21)
M lib/rpmlib.h (10)
M preinstall.am (4)
M rpmio/Makefile.am (2)
M rpmio/expression.c (55)
R rpmio/rpmvercmp.c (20)

-- Patch Links --

https://github.com/rpm-software-management/rpm/pull/1220.patch
https://github.com/rpm-software-management/rpm/pull/1220.diff

-- 
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/1220
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] scripts/pythondistdeps: New test suite and various updates and fixes (#1195)

2020-05-14 Thread Miro Hrončok
Since the high level discussion of whether this shall be split or not, can we 
please merge this for now to avoid the base diverging?

-- 
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/1195#issuecomment-628550526___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Florian Festi
Another option would be having special operators. But this is also confusion as 
we use the normal `<`,  `>`, ... in dependencies. I also don't have a good 
suggestion. `%if %{php_version} ver>= "1.2.3"` looks weird, too. But may be 
someone has an better idea.


-- 
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/issues/1217#issuecomment-628530128___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Miro Hrončok
Reopened #1217.

-- 
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/issues/1217#event-3335805799___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Miro Hrončok
Closed #1217.

-- 
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/issues/1217#event-3335805261___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Miro Hrončok
So, here are couple examples. I haven't checked if they don't collide with 
existing syntax.

```spec
# int comparison, fallbacks to version comparison if at least one operand has 
nondigits?
%if %{php_version} < 5.6

# string comparison, produces incorrect results some time
%if "%{php_version}" < "5.6"

# single quotes (easy, but it doesn't actually scream *this is version 
comparison*)
%if '%{php_version}' < '5.6'

# backticks (easy, as above, but at least screams "I am special")
%if `%{php_version}` < `5.6`

# string prefixes (see Python f-strings, b-strings and r-strings; confusing to 
non-Python people)
%if v"%{php_version}" < v"5.6"

# square brackets (special enough, but screams "I am an array with 1 element" 
to me)
%if [%{php_version}] < [5.6]

# square brackets  around the whole thing (why? screams "wtf")
%if [%{php_version} < 5.6]

# special %if like %ifarch (maybe too much?)
%ifver %{php_version} < 5.6

# a prefix without quotes (both confusing)
%if @%{php_version} < @5.6
%if $%{php_version} < $5.6

# a special macro (easy to understand a bit more complicated to write) 
%if %{vercmp %{php_version} < 5.6}

# a special macro to mark the values as versions (a bit more complicated to 
write as well)
%if %{ver:%{php_version}} < %{ver:5.6}

# golging the above (a bit more complicated to read)
%if %{V:%{php_version}} < %{V:5.6}
```

-- 
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/issues/1217#issuecomment-628526414___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
Yeah... might get too weird really. Another, saner option might be using single 
quotes (or similar) to denote rpm version strings over regular strings.

-- 
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/issues/1217#issuecomment-628508988___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient %version without tilde macro (#1219)

2020-05-14 Thread Miro Hrončok
technically, since we are at RPM level, I wouldn't mind having this syntax:

%{version//~}

To remove whatever symbols I like.

-- 
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/issues/1219#issuecomment-628496489___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Miro Hrončok
also "01" == "1"

-- 
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/issues/1217#issuecomment-628493078___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
Hmm. The other hmm is that rpmvercmp() can actually return 0 for strings that 
are very obviously different (#925), which can get decidedly weird.

-- 
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/issues/1217#issuecomment-628490659___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
Yeah - right now would actually be the optimal time to implement this as there 
are some other incompatibilities in the 4.16 expression parser as well, and the 
macro side of this is all new now, so there's not that much that is 
incompatible. 

There are some technical obstacles though, for example rpmvercmp() and a higher 
level version parsing/comparison (which isn't really exported at all) needing 
moving to librpmio from librpm. Hmm.

-- 
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/issues/1217#issuecomment-628484872___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient %version without tilde macro (#1219)

2020-05-14 Thread Panu Matilainen
As I noted above, the problem with "upstream version" is that the pre/post 
suffixes *are* upstream. So upstream version and the bare version are two 
different things.

-- 
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/issues/1219#issuecomment-628482024___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Miro Hrončok
right. ok then, comparing `""` as stings works for me \o/ Obviously, that'll be 
4.16+ only, so in Fedora terms, rawhide+.

-- 
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/issues/1217#issuecomment-628481897___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient %version without tilde macro (#1219)

2020-05-14 Thread Igor Raits
I think `%{upstream_version}` would be better. However, probably in this case, 
we should just define %{pypi_version}, %{semver_version} because those have 
different rules.

-- 
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/issues/1219#issuecomment-628480076___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
We can't really hijack integers because we support simple mathematical 
operations on them besides just comparison, and might be some other technical 
restrictions. In any case, string comparisons in specs typically are either == 
or !=, in which case treating them as versions wouldn't affect the outcome. And 
looking at Fedora specs, there are numerous examples where people actually use 
just that (apparently oblivious to it not doing what they expect):

```
%if "%{php_version}" < "5.6"
%if "%(pkg-config --version 2>/dev/null)" < "0.20.0"
%if "%{version}" > "2.12"
%if "%{_qt5_version}" < "5.12.0"
%if "%version" < "0.20"
%if 0%{?rhel} && "%rhel" < "5"
```

-- 
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/issues/1217#issuecomment-628480292___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient %version without tilde macro (#1219)

2020-05-14 Thread Miro Hrončok
> As for passing passing empty strings (or strings with spaces etc) as a macro 
> argument, use %{quote:}

Thanks. Ugly, but works.

-- 
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/issues/1219#issuecomment-628475121___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient %version without tilde macro (#1219)

2020-05-14 Thread Miro Hrončok
I get your point. But before we come ou with a concept of native "pre/post 
tag", I think we should have a way to address this in a common way. I like 
`%{bare_version}` (not "ursine" please).

-- 
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/issues/1219#issuecomment-628475009___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: pass parametric macro options and arguments to Lua natively (#1092)

2020-05-14 Thread Miro Hrončok
I was about to explore this as well, thanks for filing 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/issues/1092#issuecomment-628473072___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Miro Hrončok
OTOH this is backwards incompatible and a bit weird.

What if `""` would still compare strings, but without `""` would compare 
versions? That is backwards compatible with comparing integers.

-- 
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/issues/1217#issuecomment-628472204___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Miro Hrončok
I meant something a bit more sophisticated. I have so far:

```python
#!/usr/bin/python3
import sys
from ctypes import cdll, c_char_p


librpmio = cdll.LoadLibrary("librpmio.so.9")

adjust_path = b"""
if os.getenv("LUA_PATH") then
package.path =  os.getenv("LUA_PATH") .. ";" .. package.path
end
"""

# first argument is an "rpmlua" pointer, but uses global one when NULL
# second argument is code
# third argument is "name", used in errors, reasonable default when NULL
librpmio.rpmluaRunScript(None, c_char_p(adjust_path), None)

if len(sys.argv) > 1:
sys.argv[-1] = '/dev/stdin' if sys.argv[-1] == '-' else sys.argv[-1]
# first argument as above, second argument is path
librpmio.rpmluaRunScriptFile(None, c_char_p(sys.argv[-1].encode("utf-8")))
else:
librpmio.rpmluaRunScript(None, c_char_p(b"rpm.interactive()"), None)
```

-- 
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/issues/1215#issuecomment-628471186___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
...except that versions are not integers, they're strings, and the expression 
parser now explicitly separates the two. So we could make the string comparison 
*be* version comparison, at which point you could do this in a spec

```
%if "%{python3_version}" >= "3.9"
...
%endif
```

...and it'd do the actually right thing without any extra macros, but also 
available in the macro side through %[] and %{expr:...}.



-- 
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/issues/1217#issuecomment-628471158___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Panu Matilainen
If by "something like the above" you mean something that allows actual 
interactive experience, sure :sweat_smile: 

-- 
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/issues/1215#issuecomment-628460983___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Miro Hrončok
I have it all figured out. Blog post coming. Would you consider adding 
something like the above to rpm itself? 

-- 
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/issues/1215#issuecomment-628455808___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-14 Thread Panu Matilainen
Ouch :rofl: 

The interactive interpreter was added years before my time, but as far as I can 
recall, you're the first person *ever* to try actually using it. There may be 
some resident fauna there... :beetle: :bug:

-- 
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/issues/1215#issuecomment-628453859___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)

2020-05-14 Thread Panu Matilainen
This is closely related to, but perhaps not a duplicate of #897.

Having an actually usable version comparison macro is one of the rare things 
that truly are generic enough to belong to rpm, it's actually rather hysterical 
how little we have in that space.

This being rpm, versions are the primary numerical entities we deal with, and 
as such could easily warrant something a bit special. I'm myself wondering if 
we could somehow expose the version comparison in our expression parser - as we 
now can do things like
```
$ rpm --eval "%[0<1]"
1
```
...it'd seem fitting to be able to do this with same ease with EVRs too. I 
don't have any concrete suggestions offhand though. @mlschroe ?

-- 
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/issues/1217#issuecomment-628447670___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Lua rpm.error() function (#1218)

2020-05-14 Thread Panu Matilainen
No disagreement there, `rpm.expand("%{error:...}")` is just absurd. And so are 
many other things hidden behind rpm.expand().

This falls into the same general category of better Lua integration (or in 
other words, "make using Lua in rpm sane") as #1092.

-- 
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/issues/1218#issuecomment-628435164___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: Convenient %version without tilde macro (#1219)

2020-05-14 Thread Panu Matilainen
This was actually suggested here first (see #722) and rejected in this form 
with the notion that there might be something there however. So of the problem 
is figuring what that "something like" is.

Singling out tilde seems odd. I could imagine there being cases where you want 
these "rpm embellishments" stripped out, but that should then also cover caret 
(and any other such thing that might get added in the future), which calls for 
a more generic name. "Upstream version" was mentioned in the PR, but that 
doesn't sound right either because the tilde/caret parts typically *are* from 
upstream. Something like "bare version" (any phonetic resemblance to large four 
feet mammals is purely coincidental), *but* this makes me think we're going 
backwards here, and that we should start by disassembling Version to its 
components at the "source" already.

There's this "main" or "bare" version which is typically something like 
[major[.minor[.micro[.nano and these can have pre- and post-modifiers that 
affect the sorting. Should spec have separate tags to declare these as 
individual components that rpm arranges into a Version as we know it? Or 
something...

As for passing passing empty strings (or strings with spaces etc) as a macro 
argument, use %{quote:} 

-- 
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/issues/1219#issuecomment-628431525___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint