.\" Generated by scdoc 1.11.4 .\" Complete documentation for this program is not available as a GNU info page .ie \n(.g .ds Aq \(aq .el .ds Aq ' .nh .ad l .\" Begin generated content: .TH "RPM-LUA" "7" "2026-01-08" "RPM 6.0.1" .PP .SH NAME .PP rpm-lua - RPM embedded Lua interpreter .PP .SH SYNOPSIS .PP %scriptlet -p .PP %{lua:.\&.\&.\&} .PP .SH DESCRIPTION Lua is a general purpose programming language specifically designed for embedding in other programs, and RPM includes an embedded Lua interpreter for use in advanced \fBrpm-macros\fR(7) and transaction scriptlets.\& .PP The embedded Lua interpreter makes possible various things that are hard or impossible with plain macros or external shell scripts, such as help eliminate dependency loops from package scriptlets.\& .PP .SH MACROS .SS Accessing macros The \fBrpm\fR extension has various functions for dealing with macros, but the most convenient way to access \fBrpm-macroproc\fR(7) from the RPM Lua environment is via the global \fBmacros\fR table.\& .PP Lua makes no difference between table index and field name syntaxes so \fBmacros.\&foo\fR and \fBmacros['\&foo'\&]\fR are equivalent, use what better suits the purpose.\& .PP Like any real Lua table, non-existent items are returned as \fBnil\fR, and assignment can be used to define or undefine macros.\& .PP Example: .nf .RS 4 if not macros\&.yours then macros\&.my = \&'my macro\&' end local v = { \&'_libdir\&', \&'_bindir\&', \&'_xbindir\&' } for _, v in ipairs(v) do if not macros[v] then macros[v] = \&'default\&' end end .fi .RE .PP All macros share the same global Lua execution environment.\& .PP .SS Calling parametric macros Parametric macros (including all built-in macros) can be called in a Lua native manner via the \fBmacros\fR table, with either \fBmacros.\&\fR\fIname\fR\fB()\fR or \fBmacros[\fR\fIname\fR\fB]()\fR syntax.\& .PP Arguments are passed through a single argument, which is either .PD 0 .IP \(bu 4 a single string, in which case it'\&s expanded and split with the macro-native rules .IP \(bu 4 a table, in which case the table contents are used as literal arguments that are not expanded in any way .PD .PP Example 1: .nf .RS 4 macros\&.with(\&'foo\&') .fi .RE .PP Example 2: .nf .RS 4 macros\&.dostuff({\&'one\&', \&'two\&', \&'three\&'}) .fi .RE .PP .SS Returning data By definition, anything \fBprint()\fR'\&ed in Lua will end up in the macro expansion.\& Lua macros can also \fBreturn\fR their output, which makes programming helper macros look more natural.\& .PP Example: .nf .RS 4 %sum() %{lua: local v = 0 for _, a in ipairs(arg) do v = v + tonumber(a) end return v } .fi .RE .PP .SS Options and arguments Parametric Lua macros receive their options and arguments as two local tables \fBopt\fR and \fBarg\fR, where \fBopt\fR holds processed option values keyed by the option character, and \fBarg\fR contains arguments numerically indexed.\& .PP These tables are always present regardless of whether options or arguments were actually passed to simplify use.\& .PP Example: .nf .RS 4 %foo(a:b) %{lua: if opt\&.b then print(\&'do b\&') else print(\&'or not\&') end if opt\&.a == \&'s\&' then print(\&'do s\&') end if #arg == 0 then print(\&'no arguments :(\&') else for i = 1, #arg do print(arg[i]) end end } .fi .RE .PP .SH SCRIPTLETS The internal Lua can be used as the interpreter of RPM any transaction scriptlets, including triggers and file triggers: .PP Example: .nf .RS 4 %pre -p print(\&'Hello from Lua\&') .fi .RE .PP While the venerable \fI/bin/sh\fR is usually more convenient for packaging related scripting activities, the embedded Lua interpreter has some unique advantages for transaction scriptlets: they add no extra dependencies to the packages and so can help eliminate dependency loops.\& This can be a crucial difference in the early "bootstrap" package set in an initial install.\& .PP In particular, an embedded Lua script is the only generally usable option in \fB%pretrans\fR scriplets during the initial installation of a system.\& .PP Embedded Lua is also much faster than executing a potentially heavyweight interpreter just to run a couple of lines of shell script.\& .PP Note: scriptlets using the internal Lua should not make assumptions about sharing the execution environment with other scriptlets.\& .PP .SS Arguments Scriptlet arguments are accessible from a global \fBarg\fR table.\& .PP Note: in Lua, indexes customarily start at 1 (one) instead of 0 (zero), and for the better or worse, the RPM implementation follows this practise.\& Thus the scriptlet arg indexes are off by one from general expectation based on traditional scriptlet arguments.\& The argument containing number of installed package instances is \fBarg[2]\fR and the similar argument for trigger targets is \fBarg[3]\fR, vs the traditional \fB$1\fR and \fB$2\fR in shell scripts.\& .PP Example: .nf .RS 4 %postun -p if arg[2] == 0 then print("erasing") end .fi .RE .PP .SS Relocatable packages Scriptlets of relocatable packages additionally carry a global \fBRPM_INSTALL_PREFIX\fR table containing all the possible prefixes of the package.\& .PP Added: 4.\&18.\&0 .PP .SS Exit status While scriptlets shouldn'\&t be allowed to fail normally, you can signal scriptlet failure status by using Lua'\&s \fBerror(\fR\fImsg\fR, [\fIlevel\fR]\fB)\fR function if you need to.\& .PP .SH SPEC FILES In the context of a \fBrpm-spec\fR(5) file parse with \fBrpmbuild\fR(1) or \fBrpmspec\fR(1), the RPM Lua environment contains the following spec specific global tables: .PP \fBpatches\fR .RS 4 The filenames of the patches in the spec, in the order they appeared in the spec.\& .PP .RE \fBpatch_nums\fR .RS 4 The numbers of the patches in the spec, in the order they appeared in the spec.\& .PP .RE \fBsources\fR .RS 4 The filenames of the sources in the spec, in the order they appeared in the spec.\& .PP .RE \fBsource_nums\fR .RS 4 The numbers of the sources in the spec, in the order they appeared in the spec.\& .PP .RE Example: .nf .RS 4 for i, p in ipairs(patches) do print(string\&.format("echo %d: %sn", patch_nums[i], patches[i])) end .fi .RE .PP .SH EXTENSIONS In addition to Lua standard libraries (subject to the Lua version RPM is linked to), the following extensions are available in the RPM internal Lua interpreter.\& These can be used in all contexts where the internal Lua can be used.\& .PP .SS rpm extension .PP The following RPM specific functions are available: .PP \fBb64decode(\fR\fIarg\fR\fB)\fR .RS 4 Perform base64 decoding on argument.\& See also b64encode().\& .PP Example: .nf .RS 4 blob = \&'binary data\&' print(blob) e = rpm\&.b64encode(blob) print(e) d = rpm\&.b64decode(e) print(d) .fi .RE .PP .RE \fBb64encode(\fR\fIarg\fR [, \fIlinelen\fR]\fB)\fR .RS 4 Perform base64 encoding on argument.\& Line length may be optionally specified via second argument.\& See also b64decode().\& .PP .RE \fBdefine("\fR\fIname\fR \fIbody\fR\fB")\fR .RS 4 Define a global macro \fIname\fR with \fIbody\fR.\& See also \fBMACROS\fR.\& .PP Example: .nf .RS 4 rpm\&.define(\&'foo 1\&') .fi .RE .PP .RE \fBexecute(\fR\fIpath\fR [, \fIarg1\fR [,.\&.\&.\&]\fB)\fR .RS 4 Execute an external command.\& This is handy for executing external helper commands without depending on the shell.\& \fIpath\fR is the command to execute, followed by optional number of arguments to pass to the command.\& .PP For a better control over the process execution and output, see rpm.\&spawn().\& .PP Added: 4.\&15.\&0 .PP Example: .nf .RS 4 rpm\&.execute(\&'ls\&', \&'-l\&', \&'/\&') .fi .RE .RE \fBexpand(\fR\fIarg\fR\fB)\fR .RS 4 Perform RPM macro expansion on \fIarg\fR string.\& See also \fBMACROS\fR.\& .PP Example: .nf .RS 4 rpm\&.expand(\&'%{_libdir}/mydir\&') .fi .RE .PP .RE \fBglob(\fR\fIpattern\fR, [\fIflags\fR]\fB)\fR .RS 4 Return a table of pathnames matching \fIpattern\fR.\& If \fIflags\fR contains \fBc\fR, return \fIpattern\fR in case of no matches.\& .PP Example: .nf .RS 4 for i, p in ipairs(rpm\&.glob(\&'*\&')) do print(p) end .fi .RE .PP .RE \fBinteractive()\fR .RS 4 Launch interactive session for testing and debugging.\& Use \fBrpmlua\fR(1) instead.\& .PP Example: .nf .RS 4 rpm --eval "%{lua: rpm\&.interactive()}" .fi .RE .PP .RE \fBisdefined(\fR\fIname\fR\fB)\fR .RS 4 Test whether a macro \fIname\fR is defined and whether it'\&s parametric, returned in two booleans.\& See also \fBMACROS\fR.\& (Added: 4.\&17.\&0) .PP Example: .nf .RS 4 if rpm\&.isdefined(\&'_libdir\&') then \&.\&.\&. end .fi .RE .PP .RE \fBload(\fR\fIpath\fR\fB)\fR .RS 4 Load a macro file from given path.\& Same as the built-in \fB%{load:.\&.\&.\&}\fR macro.\& .PP Example: .nf .RS 4 rpm\&.load(\&'my\&.macros\&') .fi .RE .PP .RE \fBopen(\fR\fIpath\fR, [\fImode\fR[.\&\fIflags\fR]]\fB)\fR .RS 4 Open a file stream using RPM IO facilities, with support for transparent compression and decompression.\& .PP \fIpath\fR is filename string, optionally followed with \fImode\fR string to specify open behavior: .PD 0 .IP \(bu 4 \fBa\fR: open for append .IP \(bu 4 \fBw\fR: open for writing, truncate .IP \(bu 4 \fBr\fR: open for reading (default) .IP \(bu 4 \fB+\fR: open for reading and writing .IP \(bu 4 \fBx\fR: fail if file exists .PD .PP and optionally followed by \fBrpm-payloadflags\fR(7) for compression and decompression.\& .PP Added: 4.\&17.\&0 .PP Example: .nf .RS 4 f = rpm\&.open(\&'some\&.txt\&.gz\&', \&'r\&.gzdio\&') print(f:read()) .fi .RE .PP The returned rpm.\&fd object has the following methods: .PP \fBfd:close()\fR .PP Close the file stream.\& .PP Example: .nf .RS 4 f = rpm\&.open(\&'file\&') f:close() .fi .RE .PP \fBfd:flush()\fR .PP Flush the file stream.\& .PP Example: .nf .RS 4 f = rpm\&.open(\&'file\&', \&'w\&') f:write(\&'foo\&') f:flush() f:close() .fi .RE .PP \fBfd:read(\fR[\fIlen\fR]\fB)\fR .PP Read data from the file stream up to \fIlen\fR bytes or if not specified, the entire file.\& .PP Example: .nf .RS 4 f = rpm\&.open(\&'/some/file\&') print(f:read()) .fi .RE .PP \fBfd:seek(\fR\fImode\fR, \fIoffset\fR\fB)\fR .PP Reposition the file offset of the stream.\& \fImode\fR is one of \fBset\fR, \fBcur\fR and \fBend\fR, and offset is relative to the mode: absolute, relative to current or relative to end.\& Not all streams support seeking.\& .PP Returns file offset after the operation.\& .PP See also \fBlseek\fR(3).\& .PP Example: .nf .RS 4 f = rpm\&.open(\&'newfile\&', \&'w\&') f:seek(\&'set\&', 555) f:close() .fi .RE .PP \fBfd:write(\fR\fIbuf\fR [, \fIlen\fR]\fB)\fR .PP Write data in \fIbuf\fR to the file stream, either in its entirety or up to \fIlen\fR bytes if specified.\& .PP Example: .nf .RS 4 f = rpm\&.open(\&'newfile\&', \&'w\&') f:write(\&'data data\&') f:close() .fi .RE .PP \fBfd:reopen(\fR\fImode\fR\fB)\fR .PP Reopen a stream with a new mode (see \fBrpm.\&open()\fR).\& .PP Example: .nf .RS 4 rpm\&.open(\&'some\&.txt\&.gz\&') f = f:reopen(\&'r\&.gzdio\&') print(f:read())} .fi .RE .PP .RE \fBredirect2null(\fR\fIfdno\fR\fB)\fR (OBSOLETE) .RS 4 Redirect file descriptor fdno to /dev/null (prior to 4.\&16 this was known as posix.\&redirect2null()) .PP This function is obsolete and only available for RPM v4 packages for backwards compatibility.\& Use `rpm.\&spawn()` or `rpm.\&execute()` instead.\& .PP .nf .RS 4 pid = posix\&.fork() if pid == 0 then posix\&.redirect2null(2) assert(posix\&.exec(\&'/bin/awk\&')) elseif pid > 0 then posix\&.wait(pid) end .fi .RE .PP .RE \fBspawn(\fR{\fIcommand\fR} [, {\fIactions\fR}]\fB)\fR .RS 4 Spawn, aka execute, an external program.\& .PP {\fIcommand\fR} is a table consisting of the command and its arguments.\& An optional second table can be used to pass various actions related to the command execution, currently supported are: .PP .nf .RS 4 | Action | Argument(s) | Description |---------|---------------------- | *stdin* | path | Redirect standard input to path | *stdout*| path | Redirect standard output to path | *stderr*| path | Redirect standard error to path .fi .RE .PP Returns the command exit status: zero on success, or a tuplet of (\fBnil\fR, message, code) on failure.\& .PP Added: 4.\&20 .PP Example: .nf .RS 4 rpm\&.spawn({\&'systemctl\&', \&'restart\&', \&'httpd\&'}, {stderr=\&'/dev/null\&'}) .fi .RE .PP .RE \fBundefine(\fR\fIname\fR\fB)\fR .RS 4 Undefine a macro.\& See also \fBMACROS\fR.\& .PP Note that this is only pops the most recent macro definition by the given name from stack, ie there may be still macro definitions by the same name after an undefine operation.\& .PP Example: .nf .RS 4 rpm\&.undefine(\&'zzz\&') .fi .RE .PP .PP .RE \fBvercmp(\fR\fIv1\fR, \fIv2\fR\fB)\fR .RS 4 Perform RPM version comparison on argument strings.\& Returns -1, 0 or 1 if \fIv1\fR is smaller, equal or larger than \fIv2\fR.\& See \fBrpm-version\fR(7).\& .PP Note: in RPM < 4.\&16 this operated on version segments only, which does not produce correct results on full \fIEVR\fR strings.\& .PP Example: .nf .RS 4 rpm\&.vercmp(\&'1\&.2-1\&', \&'2\&.0-1\&') .fi .RE .PP .RE \fBver(\fR\fIevr\fR\fB)\fR, \fBver(\fR\fIe\fR, \fIv\fR, \fIr\fR\fB)\fR .RS 4 Create RPM version object.\& This takes either an \fIevr\fR string which is parsed to it'\&s components, or epoch, version and release in separate arguments (which can be either strings or numbers).\& The object has three attributes: \fBe\fR for epoch, \fBv\fR for version and \fBr\fR for release, can be printed in it'\&s EVR form and supports native comparison in Lua.\& .PP Added: 4.\&17.\&0 .PP Example: .nf .RS 4 v1 = rpm\&.ver(\&'5:1\&.0-2) v2 = rpm\&.ver(3, \&'5a\&', 1) if v1 < v2 then \&.\&.\&. end if v1\&.e then \&.\&.\&. end .fi .RE .PP .RE .SS posix extension .PP Lua standard library offers fairly limited set of io operations.\& The \fBposix\fR extension greatly enhances what can be done from Lua.\& .PP The following functions are available in the \fBposix\fR namespace, ie to call them use \fBposix.\&function()\fR.\& This documentation concentrates on the Lua API conventions, for further information on the corresponding system calls refer to the system manual, eg \fBaccess\fR(3) for \fBposix.\&access()\fR.\& .PP \fBaccess(\fR\fIpath\fR [, \fImode\fR]\fB)\fR .RS 4 Test accessibility of file/directory \fIpath\fR.\& See \fBaccess\fR(3).\& If \fImode\fR is omitted then existence is tested, otherwise it is a combination of the following tests: .PD 0 .IP \(bu 4 \fBr\fR: readable .IP \(bu 4 \fBw\fR: writable .IP \(bu 4 \fBx\fR: executable .IP \(bu 4 \fBf\fR: exists .PD .PP Example: .nf .RS 4 if posix\&.access(\&'/bin/rpm\&', \&'x\&') then \&.\&.\&. end .fi .RE .PP .RE \fBchdir(\fR\fIpath\fR\fB)\fR .RS 4 Change current working directory to \fIpath\fR.\& See \fBchdir\fR(1).\& .PP Example: .nf .RS 4 posix\&.chdir(\&'/tmp\&') .fi .RE .PP .RE \fBchmod(\fR\fIpath\fR, \fImode\fR\fB)\fR .RS 4 Change file/directory mode.\& Mode can be either an octal number as for \fBchmod\fR(2) system call, or a string presentation similar to \fBchmod\fR(1).\& .PP Example: .nf .RS 4 posix\&.chmod(\&'aa\&', 600) posix\&.chmod(\&'bb\&', \&'rw-\&') posix\&.chmod(\&'cc\&', \&'u+x\&') .fi .RE .PP .RE \fBchown(\fR\fIpath\fR, \fIuser\fR, \fIgroup\fR\fB)\fR .RS 4 Change file/directory owner/group of \fIpath\fR.\& The \fIuser\fR and \fIgroup\fR arguments may be either numeric id values or user/groupnames.\& See \fBchown\fR(2) and \fBchown\fR(1).\& .PP Note: This is a privileged operation.\& .PP Example: .nf .RS 4 posix\&.chown(\&'aa\&', 0, 0) posix\&.chown(\&'bb\&', \&'nobody\&', \&'nobody\&') .fi .RE .PP .RE \fBctermid()\fR .RS 4 Get controlling terminal name.\& See \fBctermid\fR(3).\& .PP Example: .nf .RS 4 print(posix\&.ctermid()) .fi .RE .PP .RE \fBdir(\fR[\fIpath\fR]\fB)\fR .RS 4 Get directory contents - like \fBreaddir\fR(3).\& If \fIpath\fR is omitted, current directory is used.\& .PP Example: .nf .RS 4 for i,p in pairs(posix\&.dir(\&'/\&')) do print(p\&.\&.\&'n\&') end .fi .RE .PP .RE \fBerrno()\fR .RS 4 Get \fBstrerror\fR(3) message and the corresponding number for current \fBerrno\fR(3).\& .PP Example: .nf .RS 4 f = \&'/zzz\&' if not posix\&.chmod(f, 100) then s, n = posix\&.errno() print(f, s) end .fi .RE .PP .RE \fBexec(\fR\fIpath\fR [, \fIargs\fR.\&.\&.\&]\fB)\fR (OBSOLETE) .RS 4 Execute a program.\& This may only be performed after posix.\&fork().\& .PP This function is obsolete and only available for RPM v4 packages for backwards compatibility.\& Use \fBrpm.\&spawn()\fR or \fBrpm.\&execute()\fR instead.\& .PP .RE \fBfiles(\fR[\fIpath\fR]\fB)\fR .RS 4 Iterate over directory contents.\& If path is omitted, current directory is used.\& .PP Example: .nf .RS 4 for f in posix\&.files(\&'/\&') do print(f\&.\&.\&'n\&') end .fi .RE .PP .RE \fBfork()\fR (OBSOLETE) .RS 4 Fork a new process.\& See \fBfork\fR(2).\& .PP This function is obsolete and only available for RPM v4 packages for backwards compatibility.\& Use \fBrpm.\&spawn()\fR or \fBrpm.\&execute()\fR instead.\& .PP Example: .nf .RS 4 pid = posix\&.fork() if pid == 0 then posix\&.exec(\&'/foo/bar\&') elseif pid > 0 then posix\&.wait(pid) end .fi .RE .PP .RE \fBgetcwd()\fR .RS 4 Get current directory.\& See \fBgetcwd\fR(3).\& .PP Example: .nf .RS 4 if posix\&.getcwd() ~= \&'/\&' then \&.\&.\&. endif .fi .RE .PP .RE \fBgetenv(\fR\fIname\fR\fB)\fR .RS 4 Get an environment variable.\& See \fBgetenv\fR(3).\& .PP Example: .nf .RS 4 if posix\&.getenv(\&'HOME\&') ~= posix\&.getcwd() then print(\&'not at home\&') end .fi .RE .PP .RE \fBgetgroup(\fR\fIgroup\fR\fB)\fR .RS 4 Get \fBgroup\fR(5) information for a group.\& \fIgroup\fR may be either a numeric id or group name.\& If omitted, current group is used.\& Returns a table with fields \fBname\fR and \fBgid\fR set to group name and id respectively, and indexes from 1 onwards specifying group members.\& .PP Example: .nf .RS 4 print(posix\&.getgroup(\&'wheel\&')\&.gid) .fi .RE .PP .RE \fBgetlogin()\fR .RS 4 Get login name.\& See \fBgetlogin\fR(3).\& .PP Example: .nf .RS 4 n = posix\&.getlogin() .fi .RE .PP .RE \fBgetpasswd\fR([\fIuser\fR [, \fIselector\fR]]\fB)\fR .RS 4 Get \fBpasswd\fR(5) information for a user account.\& \fIuser\fR may be either a numeric id or username.\& If omitted, current user is used.\& The optional \fIselector\fR argument may be one of: .PD 0 .IP \(bu 4 \fBname\fR .IP \(bu 4 \fBuid\fR .IP \(bu 4 \fBgid\fR .IP \(bu 4 \fBdir\fR .IP \(bu 4 \fBshell\fR .IP \(bu 4 \fBgecos\fR .IP \(bu 4 \fBpasswd\fR .PD .PP If omitted, a table with all these fields is returned.\& .PP Example: .nf .RS 4 pw = posix\&.getpasswd(posix\&.getlogin(), \&'shell\&')| .fi .RE .PP .RE \fBgetprocessid(\fR[\fIselector\fR]\fB)\fR .RS 4 Get information about current process.\& The optional \fIselector\fR argument may be one of .PD 0 .IP \(bu 4 \fBegid\fR: effective group id .IP \(bu 4 \fBeuid\fR: effective user id .IP \(bu 4 \fBgid\fR: group id .IP \(bu 4 \fBuid\fR: user id .IP \(bu 4 \fBpgrp\fR: parent group id .IP \(bu 4 \fBpid\fR: process id .IP \(bu 4 \fBppid\fR: parent pid .PD .PP If omitted, a table with all these fields is returned.\& .PP Example: .nf .RS 4 if posix\&.getprocessid(\&'pid\&') == 1 then \&.\&.\&. end .fi .RE .PP .RE \fBkill(\fR\fIpid\fR [, \fIsignal\fR]\fB)\fR .RS 4 Send a \fBsignal\fR(7) to a process.\& \fIsignal\fR must be a numeric value, eg.\& \fB9\fR for \fBSIGKILL\fR.\& If omitted, \fBSIGTERM\fR is used.\& See also \fBkill\fR(2).\& .PP Example: .nf .RS 4 posix\&.kill(posix\&.getprocessid(\&'pid\&')) .fi .RE .PP .RE \fBlink(\fR\fIoldpath\fR, \fInewpath\fR\fB)\fR .RS 4 Create a new name at \fInewpath\fR for a file at \fIoldpath\fR, aka hard link.\& See also \fBlink\fR(2).\& .PP Example: .nf .RS 4 f = rpm\&.open(\&'aaa\&', \&'w\&') posix\&.link(\&'aaa\&', \&'bbb\&') .fi .RE .PP .RE \fBmkdir(\fR\fIpath\fR\fB)\fR .RS 4 Create a new directory at \fIpath\fR.\& See also \fBmkdir\fR(2).\& .PP Example: .nf .RS 4 posix\&.mkdir(\&'/tmp\&') .fi .RE .PP .RE \fBmkfifo(\fR\fIpath\fR\fB)\fR .RS 4 Create a FIFO aka named pipe at \fIpath\fR.\& See also \fBmkfifo\fR(2).\& .PP Example: .nf .RS 4 posix\&.mkfifo(\&'/tmp/badplace\&') .fi .RE .PP .RE \fBpathconf(\fR\fIpath\fR [, \fIselector\fR]\fB)\fR .RS 4 Get \fBpathconf\fR(3) information for \fIpath\fR.\& The optional \fIselector\fR may be one of .PD 0 .IP \(bu 4 \fBlink_max\fR .IP \(bu 4 \fBmax_canon\fR .IP \(bu 4 \fBmax_input\fR .IP \(bu 4 \fBname_max\fR .IP \(bu 4 \fBpath_max\fR .IP \(bu 4 \fBpipe_buf\fR .IP \(bu 4 \fBchown_restricted\fR .IP \(bu 4 \fBno_trunc\fR .IP \(bu 4 \fBvdisable\fR.\& .PD .PP If omitted, a table with all these fields is returned.\& .PP Example: .nf .RS 4 posix\&.pathconf(\&'/\&', \&'path_max\&') .fi .RE .PP .RE \fBputenv(\fR\fIstring\fR\fB)\fR .RS 4 Change or add an environment variable.\& See also \fBputenv\fR(3).\& .PP Example: .nf .RS 4 posix\&.putenv(\&'HOME=/me\&') .fi .RE .PP .RE \fBreadlink(\fR\fIpath\fR\fB)\fR .RS 4 Read value of the symbolic link at \fIpath\fR.\& See also \fBreadlink\fR(2).\& .PP Example: .nf .RS 4 posix\&.mkdir(\&'aaa\&') posix\&.symlink(\&'aaa\&', \&'bbb\&') print(posix\&.readlink(\&'bbb\&')) .fi .RE .PP .RE \fBrmdir(\fR\fIpath\fR\fB)\fR .RS 4 Remove a directory \fIpath\fR.\& See also \fBrmdir\fR(2).\& .PP Example: .nf .RS 4 posix\&.rmdir(\&'/tmp\&') .fi .RE .PP .RE \fBsetgid(\fR\fIgroup\fR\fB)\fR .RS 4 Set group identity.\& \fIgroup\fR may be specified either as a numeric id or group name.\& See also \fBsetgid\fR(2).\& .PP Note: This is a privileged operation.\& .PP .RE \fBsetuid(\fR\fIuser\fR\fB)\fR .RS 4 Set user identity.\& \fIuser\fR may be specified either as a numeric id or username.\& See also \fBsetuid\fR(2).\& .PP Note: This is a privileged operation.\& .PP Example: .nf .RS 4 posix\&.setuid(\&'nobody\&') .fi .RE .PP .RE \fBsleep(\fR\fIseconds\fR\fB)\fR .RS 4 Sleep for the duration of \fIseconds\fR.\& See also \fBsleep\fR(3).\& .PP Example: .nf .RS 4 posix\&.sleep(5) .fi .RE .PP .RE \fBstat(\fR\fIpath\fR [, \fIselector\fR]\fB)\fR .RS 4 Get file \fBstat\fR(3) information about a file at \fIpath\fR.\& The optional \fIselector\fR may be one of .PD 0 .IP \(bu 4 \fBmode\fR .IP \(bu 4 \fBino\fR .IP \(bu 4 \fBdev\fR .IP \(bu 4 \fBnlink\fR .IP \(bu 4 \fBuid\fR .IP \(bu 4 \fBgid\fR .IP \(bu 4 \fBsize\fR .IP \(bu 4 \fBatime\fR .IP \(bu 4 \fBmtime\fR .IP \(bu 4 \fBctime\fR .IP \(bu 4 \fBtype\fR.\& .PD .PP If omitted, a table with all these fields is returned.\& .PP Example: .nf .RS 4 print(posix\&.stat(\&'/tmp\&', \&'mode\&'))| s1 = posix\&.stat(\&'f1\&') s2 = posix\&.stat(\&'f2\&') if s1\&.ino == s2\&.ino and s1\&.dev == s2\&.dev then \&.\&.\&. end .fi .RE .PP .RE \fBsymlink(\fR\fIoldpath\fR, \fInewpath\fR\fB)\fR .RS 4 Create a symbolic link at \fInewpath\fR to \fIoldpath\fR.\& See also \fBsymlink\fR(2).\& .PP Example: .nf .RS 4 posix\&.mkdir(\&'aaa\&') posix\&.symlink(\&'aaa\&', \&'bbb\&') .fi .RE .PP .RE \fBsysconf(\fR[\fIselector\fR]\fB)\fR .RS 4 Get \fBsysconf\fR(3) information.\& The optional \fIselector\fR argument may be one of: .PD 0 .IP \(bu 4 \fBarg_max\fR .IP \(bu 4 \fBchild_max\fR .IP \(bu 4 \fBclk_tck\fR .IP \(bu 4 \fBngroups_max\fR .IP \(bu 4 \fBstream_max\fR .IP \(bu 4 \fBtzname_max\fR .IP \(bu 4 \fBopen_max\fR .IP \(bu 4 \fBjob_control\fR .IP \(bu 4 \fBsaved_ids\fR .IP \(bu 4 \fBversion\fR.\& .PD .PP If omitted, a table with all these fields is returned.\& .PP Example: .nf .RS 4 posix\&.sysconf(\&'open_max\&')| .fi .RE .PP .RE \fBtimes(\fR[\fIselector\fR]\fB)\fR .RS 4 Get process and waited-for child process \fBtimes\fR(2).\& The optional \fIselector\fR argument may be one of .PD 0 .IP \(bu 4 \fButime\fR .IP \(bu 4 \fBstime\fR .IP \(bu 4 \fBcutime\fR .IP \(bu 4 \fBcstime\fR .IP \(bu 4 \fBelapsed\fR .PD .PP If omitted, a table with all these fields is returned.\& .PP Example: .nf .RS 4 t = posix\&.times() print(t\&.utime, t\&.stime) .fi .RE .PP .RE \fBttyname(\fR[\fIfd\fR]\fB)\fR .RS 4 Get name of a terminal associated with file descriptor \fIfd\fR.\& If \fIfd\fR is omitted, \fB0\fR (aka standard input) is used.\& See \fBttyname\fR(3).\& .PP Example: .nf .RS 4 if not posix\&.ttyname() then \&.\&.\&. endif .fi .RE .PP .RE \fBumask(\fR[\fImode\fR]\fB)\fR .RS 4 Get or set process \fBumask\fR(2).\& \fImode\fR may be specified as an octal number or mode string similarly to \fBposix.\&chmod()\fR.\& .PP Example: .nf .RS 4 print(posix\&.umask()) posix\&.umask(222) posix\&.umask(\&'ug-w\&') posix\&.umask(\&'rw-rw-r--\&') .fi .RE .PP .RE \fBuname(\fR\fIformat\fR\fB)\fR .RS 4 Get \fBuname\fR(2) information about the current system.\& The following format directives are supported: .PP .PD 0 .IP \(bu 4 \fB%m\fR: Name of the hardware type .IP \(bu 4 \fB%n\fR: Name of this node .IP \(bu 4 \fB%r\fR: Current release level of this implementation .IP \(bu 4 \fB%s\fR: Name of this operation system .IP \(bu 4 \fB%v\fR: Current version level of this implementation .PD .PP Example: .nf .RS 4 print(posix\&.uname(\&'%s %r\&')) .fi .RE .PP .RE \fButime(\fR\fIpath\fR [, \fImtime\fR [, \fIctime\fR]]\fB)\fR .RS 4 Change last access and modification times.\& mtime and ctime are expressed seconds since epoch.\& See \fButime\fR(2).\& .PP If \fImtime\fR or \fIctime\fR are omitted, current time is used, similar to \fBtouch\fR(1).\& .PP Example: .nf .RS 4 posix\&.mkdir(\&'aaa\&') posix\&.utime(\&'aaa\&', 0, 0) .fi .RE .PP .RE \fBwait(\fR[\fIpid\fR]\fB)\fR (DEPRECATED) .RS 4 Wait for a child process.\& If \fIpid\fR is specified wait for that particular child.\& See also \fBwait\fR(2).\& .PP This function is obsolete and only available for RPM v4 packages for backwards compatibility.\& Use \fBrpm.\&spawn()\fR or \fBrpm.\&execute()\fR instead.\& .PP Example: .nf .RS 4 pid = posix\&.fork() if pid == 0 then posix\&.exec(\&'/bin/ls\&')) elseif pid > 0 then posix\&.wait(pid) end .fi .RE .PP .PP .RE \fBsetenv(\fR\fIname\fR, \fIvalue\fR [, \fIoverwrite\fR]\fB)\fR .RS 4 Change or add environment variable \fIname\fR.\& The optional \fIoverwrite\fR is a boolean which defines behavior when a variable by the same name already exists.\& See also \fBsetenv\fR(3).\& .PP Example: .nf .RS 4 posix\&.setenv(\&'HOME\&', \&'/me\&', true) .fi .RE .PP .RE \fBunsetenv(\fR\fIname\fR\fB)\fR .RS 4 Remove a variable \fIname\fR from environment.\& See also \fBunsetenv\fR(3).\& .PP Example: .nf .RS 4 posix\&.unsetenv(\&'HOME\&') .fi .RE .PP .RE .SH EXTENDING AND CUSTOMIZING On initialization, RPM executes a global \fIinit.\&lua\fR Lua initialization script from the directory \fB%getconfdir\fR expands to, typically \fI/usr/lib/rpm/init.\&lua\fR.\& This can be used to customize the rpm Lua environment without recompiling RPM.\& .PP For the embedded Lua interpreter, module'\&s loaded with \fBrequire\fR are primarily searched from \fB%{getconfdir}/lua/\fR.\& \fB%_rpmluadir\fR is a shorthand for this path.\& .PP .SH SEE ALSO \fBrpm-macros\fR(7) \fBrpm-payloadflags\fR(7) \fBrpmlua\fR(1) \fBrpm-version\fR(7) .PP \fBhttps://www.\&lua.\&org/\fR