ferdnyc created an issue (rpm-software-management/rpm#3661)

**Describe the bug**
When viewing the Lua scripting attached to glibc-common on Fedora, the 
displayed Lua code is lacking all of its backslash escapes, with every `\n` 
being displayed as simply `n`.

**To Reproduce**
Steps to reproduce the behavior:
1. On a Fedora 41 system, with the distro's `rpm-4.20.0-1.fc41.x86_64` and 
`glibc-common-2.40-23.fc41.x86_64` installed...
2. Run `rpm -q --filetriggers glibc-common`
3. The displayed script contains lines like,
   ```lua
   io.stdout:write ("Error: Missing " .. iconv_cache .. " file.n")
   ```
   which in the source `glibc.spec` file is:
   ```lua
   io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n")
   ```

`glibc.spec`: https://src.fedoraproject.org/rpms/glibc/raw/rawhide/f/glibc.spec

**Expected behavior**
The script displayed with all code elements ­-- including backslashes -- 
visible.

**Output**
```bash
$ rpm -q --filetriggers glibc-common
transfiletriggerin scriptlet (using <lua>) -- /lib, /lib64, /usr/lib, /usr/lib64

-- We use lua because there may be no shell that we can run during
-- glibc upgrade. We used to implement much of %post as a C program,
-- but from an overall maintenance perspective the lua in the spec
-- file was simpler and safer given the operations required.
-- All lua code will be ignored by rpm-ostree; see:
-- https://github.com/projectatomic/rpm-ostree/pull/1869
-- If we add new lua actions to the %post code we should coordinate
-- with rpm-ostree and ensure that their glibc install is functional.
-- We must not use rpm.execute because this is a RPM 4.15 features and
-- we must still support downstream bootstrap with RPM 4.14 and missing
-- containerized boostrap.

-- Open-code rpm.execute with error message handling.
function post_exec (msg, program, ...)
  if rpm.spawn ~= nil then
    local status = rpm.spawn ({program, ...})
    if status == nil then
      io.stdout:write (msg)
      assert (nil)
    end
  else
    local pid = posix.fork ()
    if pid == 0 then
      posix.exec (program, ...)
      io.stdout:write (msg)
      assert (nil)
    elseif pid > 0 then
      posix.wait (pid)
    end
  end
end

function call_ldconfig ()
  post_exec("Error: call to ldconfig failed.n",
            "ldconfig")
end

function update_gconv_modules_cache ()
  local iconv_dir = "/usr/lib64/gconv"
  local iconv_cache = iconv_dir .. "/gconv-modules.cache"
  local iconv_modules = iconv_dir .. "/gconv-modules"
  if posix.utime(iconv_modules) == 0 then
    if posix.utime (iconv_cache) == 0 then
      post_exec ("Error: call to /usr/sbin/iconvconfig failed.n",
                 "/usr/sbin/iconvconfig",
                 "-o", iconv_cache,
                 "--nostdlib",
                 iconv_dir)
    else
      io.stdout:write ("Error: Missing " .. iconv_cache .. " file.n")
    end
  end
end
call_ldconfig()
transfiletriggerpostun scriptlet (using <lua>) -- /lib, /lib64, /usr/lib, 
/usr/lib64

-- We use lua because there may be no shell that we can run during
-- glibc upgrade. We used to implement much of %post as a C program,
-- but from an overall maintenance perspective the lua in the spec
-- file was simpler and safer given the operations required.
-- All lua code will be ignored by rpm-ostree; see:
-- https://github.com/projectatomic/rpm-ostree/pull/1869
-- If we add new lua actions to the %post code we should coordinate
-- with rpm-ostree and ensure that their glibc install is functional.
-- We must not use rpm.execute because this is a RPM 4.15 features and
-- we must still support downstream bootstrap with RPM 4.14 and missing
-- containerized boostrap.

-- Open-code rpm.execute with error message handling.
function post_exec (msg, program, ...)
  if rpm.spawn ~= nil then
    local status = rpm.spawn ({program, ...})
    if status == nil then
      io.stdout:write (msg)
      assert (nil)
    end
  else
    local pid = posix.fork ()
    if pid == 0 then
      posix.exec (program, ...)
      io.stdout:write (msg)
      assert (nil)
    elseif pid > 0 then
      posix.wait (pid)
    end
  end
end

function call_ldconfig ()
  post_exec("Error: call to ldconfig failed.n",
            "ldconfig")
end

function update_gconv_modules_cache ()
  local iconv_dir = "/usr/lib64/gconv"
  local iconv_cache = iconv_dir .. "/gconv-modules.cache"
  local iconv_modules = iconv_dir .. "/gconv-modules"
  if posix.utime(iconv_modules) == 0 then
    if posix.utime (iconv_cache) == 0 then
      post_exec ("Error: call to /usr/sbin/iconvconfig failed.n",
                 "/usr/sbin/iconvconfig",
                 "-o", iconv_cache,
                 "--nostdlib",
                 iconv_dir)
    else
      io.stdout:write ("Error: Missing " .. iconv_cache .. " file.n")
    end
  end
end
call_ldconfig()
```

**Environment**
 - OS / Distribution: Fedora 41
 - Version: rpm-4.20.0-1.fc41.x85_64


-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/3661
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/issues/3...@github.com>
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
https://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to