Bug 1219721 - rpm lua checker throws error on "!"
Summary: rpm lua checker throws error on "!"
Status: RESOLVED INVALID
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: All openSUSE Tumbleweed
: P3 - Medium : Major (vote)
Target Milestone: ---
Assignee: Michael Schröder
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-08 08:55 UTC by Dr. Werner Fink
Modified: 2024-02-23 11:50 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dr. Werner Fink 2024-02-08 08:55:54 UTC
This simple lua scriplet

 %transfiletriggerin -p <lua> -- %{_mandir}
 if posix.getcwd() != '/' then
     print("Hello")
 endif

cause:

[    4s] + exec rpmbuild -ba --define '_srcdefattr (-,root,root)' --noclean --nosignature --define '_build_create_debug 1' /home/abuild/rpmbuild/SOURCES/man.spec
[    4s] error: invalid syntax in lua scriptlet: [string "%transfiletriggerin"]:1: 'then' expected near '!'


... accordingly to /usr/share/doc/packages/rpm/manual/lua.md the syntax is correct ...

I'd like to use the return value of

  stat = posix.stat("/var/cache/man")

to test is /var/cache/man exists and is also a directory but the string compare

  stat.type != "directory"

crashes with a similar error
Comment 1 Dr. Werner Fink 2024-02-08 10:42:54 UTC
I use the workaround

    stat = posix.stat("/var/cache/man")
    if not stat then
        domkdir = true
    elseif not (stat.type == "directory") then
        domkdir = true
        os.remove("/var/cache/man")
    end

seems to work
Comment 2 Michael Schröder 2024-02-23 11:46:42 UTC
Lua uses ~= instead of != for inequality. So the rpm documentation is not correct. I'll open an issue.
Comment 3 Michael Schröder 2024-02-23 11:50:37 UTC
https://github.com/rpm-software-management/rpm/issues/2929