List all Gentoo packages built against the old Lua or specific version

After similar articles about Python (List all Gentoo packages built against the old python or specific version) under Gentoo and Ruby List all Gentoo packages built against the old ruby or specific version, the Lua upgrade in Gentoo may have similar problems, so this article shows how to list old Lua modules and packages built against old Lua environments. Despite a clean upgrade without any blockers or masked packages, sometimes, on old machines, there might be packages left still built against an old version of Lua, which is even no longer available on the system!

main menu
equery USE lua_targets_lua5-4

On Gentoo, there are two important flags in the configuration make.conf file:

LUA_TARGETS="lua5-1 lua5-4"

The LUA_TARGETS controls the support of multiple Lua versions installed on the system. When the Gentoo package has a use flag lua, the builder emerge will build the Lua module for all the Lua versions in LUA_TARGETS. Some programs or libraries may not support multiple versions to be installed on the system and they may require to specify just one Lua library target, against which they are going to be built and that’s why LUA_SINGLE_TARGET exists. In most cases, the LUA_SINGLE_TARGET should be the active (default in the system) Lua version.

When building the Gentoo packages expand these variables as USE flags of the kind – lua_targets_lua5-1, lua_targets_lua5-4 and for the single target one – lua_single_target_lua5-4. So the user may search for Gentoo installed packages with USE flags lua_targets_lua5-1 and lua_targets_lua5-3 or the luajit lua_targets_luajit, which may be left from previous installations.
For example, to search installed Gentoo packages, which are built against Lua version 5.1, search for USE flags lua_targets_lua5-1 using the equerytool from app-portage/gentoolkit.
First, install the equery tool by building the package app-portage/gentoolkit:

emerge -va app-portage/gentoolkit

And then, search for packages with:

root@srv ~ # equery h lua_targets_lua5-1
 * Searching for USE flag lua_targets_lua5-1 ... 
[I--] [??] dev-lua/LuaBitOp-1.0.2-r103:0
[IP-] [  ] dev-lua/lgi-0.9.2-r100:0
[IP-] [  ] dev-lua/lpeg-1.0.2-r101:0
[I--] [??] dev-lua/luaexpat-1.3.0-r103:0
[I--] [??] dev-lua/luajson-1.3.4-r100:0
[I--] [??] dev-lua/luasocket-3.0_rc1_p20200328-r102:0
[I--] [??] net-analyzer/rrdtool-1.7.2-r100:0/8.0.0

As shown, there are 7 packages, in which Lua modules are still built against the old Ruby 5.1 version, which may not even exist anymore on the system!
It’s worth mentioning, that the above packages may be built not only against one but multiple Ruby versions thanks to multiple versions in LUA_TARGETS. So the modules above may function properly for the LUA versions, which are still in use in the system but may be a big problem for the emerge dependency tree when a world upgrade is performed.

All of the above packages should be rebuilt if Lua 5.1 is not installed (i.e. it was removed from the system) or is going to be removed because the user removed it from the LUA_TARGETS.
Most of the above packages may have newer versions and here is how to check what Lua version they support:

root@srv ~ # equery u dev-lua/luaexpat
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for dev-lua/luaexpat-1.5.1:
 U I
 + + lua_targets_lua5-1 : Build with Lua 5.1
 - - lua_targets_lua5-3 : Build with Lua 5.3
 + + lua_targets_lua5-4 : Build with Lua 5.4
 - - lua_targets_luajit : Build with LuaJIT

So the new version of the Lua module dev-lua/luaexpat may be built only against Lua versions 5.1, 5.3, 5.4 and LuaJIT.

After the Lua upgrade in Gentoo always check with equery for modules and packages built against the old Ruby versions.

In some cases, the old packages should be removed from the system, because they are legacy and the new ruby depends on a newer one:

root@srv ~ # emerge -pv --depclean =dev-lua/luaexpat-1.3.0-r103:0

Calculating dependencies... done!
  dev-lua/luaexpat-1.3.0-r103 pulled in by:
    media-libs/libquvi-scripts-0.9.20131130-r100 requires >=dev-lua/luaexpat-1.3.0-r1[lua_targets_lua5-1(-)]

>>> No packages selected for removal by depclean
Packages installed:   3380
Packages in world:    4738
Packages in system:   49
Required packages:    3380
Number to remove:     0

root@srv ~ # emerge -av dev-lua/luaexpat

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] dev-lua/luaexpat-1.5.1::gentoo [1.3.0-r103::gentoo] LUA_TARGETS="lua5-1 lua5-4* -lua5-3 -luajit" 53 KiB

Total: 1 package (1 upgrade), Size of downloads: 53 KiB

Would you like to merge these packages? [Yes/No] Yes
>>> Completed installing dev-lua/luaexpat-1.5.1 into /var/tmp/portage/dev-lua/luaexpat-1.5.1/image

 * Final size of build directory: 1236 KiB (1.2 MiB)
 * Final size of installed tree:   396 KiB

strip: x86_64-pc-linux-gnu-strip --strip-unneeded -N __gentoo_check_ldflags__ -R .comment -R .GCC.command.line -R

The library is a dependency of another package, so it cannot be removed, but it may be upgraded to a newer version.
The two library built against different versions of Lua are installed in /usr/lib64/lua/5.1/ and /usr/lib64/lua/5.4/ as shown above.

Leave a Reply

Your email address will not be published. Required fields are marked *