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

2021-04-16 Thread Miro Hrončok
Thanks. 

-- 
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-821376174___
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)

2021-04-16 Thread Panu Matilainen
Closed #1215 via 180afaf3b1a7c5a3b8f31815fde1e398594e22fb.

-- 
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#event-4604476436___
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-06-13 Thread Miro Hrončok
This gets the job done:

```python
librpm = cdll.LoadLibrary("librpm.so.9")

# Load general configuration (such as macros defined in standard places)
# Second argument is target platform, NULL is the default
librpm.rpmReadConfigFiles(librpm.rpmcliRcfile, 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-643676287___
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-06-04 Thread Miro Hrončok
My script doesn't seem to see system defined macros. Do I need to call 
something explicitly to load them?

```
$ rpmlua 

RPM Interactive Lua 5.3 Interpreter
> print(rpm.expand("%python3"))
%python3
> rpm.define("test b")
> print(rpm.expand("%test"))
b
> 


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

RPM Interactive Lua 5.3 Interpreter
> print(rpm.expand("%python3"))
> 
/usr/bin/python3
```

-- 
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-638770015___
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] 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] 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] 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] rpm --eval "%{lua:rpm.interactive()}" does not immediately print the output (#1215)

2020-05-13 Thread Miro Hrončok
This gets the job done:

```python
from ctypes import cdll, c_char_p
librpmio = cdll.LoadLibrary("librpmio.so.9")
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-628278283___
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-13 Thread Miro Hrončok
Can I do anything to have the interneter not in the macro expansion mode?

Dne st 13. 5. 2020 11:03 uživatel Michael Schroeder <
notificati...@github.com> napsal:

> This happens because you're in a macro expansion, so all the output is
> collected and returned to the macro engine.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> ,
> or unsubscribe
> 
> .
>


-- 
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-627859734___
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-13 Thread Michael Schroeder
This happens because you're in a macro expansion, so all the output is 
collected and returned to 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-627852393___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


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

2020-05-12 Thread Miro Hrončok
I'd liek to use the interactive Lua console, however, it doesn't seem to be 
very... interactive.

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

RPM Interactive Lua 5.3 Interpreter
>
```

So far so good...

```
> print"a"
> 
```

Nothing...

```
> print"a"
> print"a"
> print"a"
> print"a"
>
```

Nothing...

```
> ^D
a
```

Is there a way to receive the output as I put the input?

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