WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Solved] lua 5.4.6 for TCL14 x86_64  (Read 4679 times)

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
[Solved] lua 5.4.6 for TCL14 x86_64
« on: August 18, 2023, 10:33:59 AM »
Hi, Juanito and jazzbiker. Messaging system is not letting me send PMs right now, so I will continue the discussion here.

Thank you both very much for your input. I think I have everything I need to move forward.

lua-5.4.tcz will contain executables called lua5.4 and luac5.4 and will happily coexist with lua-5.3.tcz

lua-5.4-lib.tcz and lua-5.4-dev.tcz I will just submit as-is. It seems too complicated to make any special provisions for concurrent different versions.

User can load lua-5.3-lib.tcz and lua-5.4-lib.tcz at same time if needed. The only clash will be liblua.so, which is just a link anyway. Without manual intervention, whichever version of the lib extension is loaded last will win with regard to where liblua.so is pointing.

Inside /usr/local/lib/pkgconfig/lua.pc there are variables for version and release as well as hardcoded paths to include/lua5.3 or include/lua5.4. I think having different versions of the dev extension loaded at the same time will not be a good idea.
« Last Edit: August 19, 2023, 08:40:03 AM by Rich »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: lua 5.4.6 for TCL14 x86_64
« Reply #1 on: August 18, 2023, 10:54:03 AM »
Hi Bruno and Juanito,

Here's how I imagine the tce.installed for lua-x.y-lib.tcz:
Code: [Select]
LIBLUA_LATEST=$(ls -r /usr/local/lib/liblua.so.?.?.? | sed 1q )
ln -sf $(readlink $LIBLUA_LATEST) /usr/local/lib/liblua.so
What's Your opinion, is it correct code?
« Last Edit: August 18, 2023, 10:56:15 AM by jazzbiker »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: lua 5.4.6 for TCL14 x86_64
« Reply #2 on: August 18, 2023, 11:10:51 AM »
Inside /usr/local/lib/pkgconfig/lua.pc there are variables for version and release as well as hardcoded paths to include/lua5.3 or include/lua5.4. I think having different versions of the dev extension loaded at the same time will not be a good idea.

It would be nice for lua-5.4-dev.tcz to contain /usr/local/lib/pkgconfig/lua-5.4.pc instead of lua.pc. Such lua.pc and lua-5.4.pc files can coexist and contain differing paths.

In fact lua.pc is usually not necessary, still it would be nice to keep it existing.

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
Re: lua 5.4.6 for TCL14 x86_64
« Reply #3 on: August 18, 2023, 11:19:05 AM »
What if version has two digits somewhere? I'd use * to cover for that. Also, sorting version numbers is tricky. Best to let "sort -V" handle it than rely on ls.

How about this?

Code: [Select]
LIBLUA_LATEST=$(ls /usr/local/lib/liblua.so.*.*.* | sort -V | tail -n1)
ln -sf $(readlink $LIBLUA_LATEST) /usr/local/lib/liblua.so

Regarding the .pc file, you are the lua expert. Let's go with lua-5.4.pc, then.
« Last Edit: August 18, 2023, 11:21:21 AM by GNUser »

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
Re: lua 5.4.6 for TCL14 x86_64
« Reply #4 on: August 18, 2023, 11:33:20 AM »
Okay, I submitted the following extensions:
* lua-5.4.tcz (with binaries renamed to lua5.4 and luac5.4)
* lua-5.4-lib.tcz (with startup script that points lualib.so to highest version of liblua.so.*.*.*)
* lua-5.4-dev.tcz (with lua.pc renamed to lua-5.4.pc)

Thanks for all your input, guys. If we discover this is not the very best solution, we can always tweak. But it seems really solid to me.
« Last Edit: August 18, 2023, 11:40:15 AM by GNUser »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: lua 5.4.6 for TCL14 x86_64
« Reply #5 on: August 18, 2023, 11:46:15 AM »
Great!

You can make some tests. For example install new lua-5.4.tcz and lua-5.4-lib.tcz aside with lua-5.3.tcz and lua-lib.tcz. Then load and install vis.tcz and see does vis editor will actually run.

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
Re: lua 5.4.6 for TCL14 x86_64
« Reply #6 on: August 18, 2023, 11:52:24 AM »
You can make some tests. For example install new lua-5.4.tcz and lua-5.4-lib.tcz aside with lua-5.3.tcz and lua-lib.tcz.
I just did.

Then load and install vis.tcz and see does vis editor will actually run.
It sure does :)

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: lua 5.4.6 for TCL14 x86_64
« Reply #7 on: August 18, 2023, 12:06:32 PM »
It was compiled against the present lua-5.3. So liblua.so.5.3.6 is accessible, everything seems to be ok. Include files are separated by original lua installer and lua-5.4.pc is ready to use. Seems like now You have the choice of lua versions, even for development.

Thanks, great!

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: lua 5.4.6 for TCL14 x86_64
« Reply #8 on: August 18, 2023, 12:30:15 PM »
I think the only thing to be tested is
Code: [Select]
readlink /usr/local/lib/liblua.so

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
Re: lua 5.4.6 for TCL14 x86_64
« Reply #9 on: August 18, 2023, 01:41:49 PM »
Hi, jazzbiker.

Loading old version of the library then loading new version works as expected:

Code: [Select]
$ tce-load -i lua-5.3-lib
lua-5.3-lib.tcz: OK
$ readlink /usr/local/lib/liblua.so
/tmp/tcloop/lua-5.3-lib/usr/local/lib/liblua.so
$ tce-load -i lua-5.4-lib
lua-5.4-lib.tcz: OK
$ readlink /usr/local/lib/liblua.so
/tmp/tcloop/lua-5.4-lib/usr/local/lib/liblua.so.5.4.6

Then I make sure onboot.lst has no lua-*-lib extensions, and reboot.

Next test: Load new version of the library, then load the old version:

Code: [Select]
$ tce-load -i lua-5.4-lib
lua-5.4-lib.tcz: OK
$ readlink /usr/local/lib/liblua.so
/tmp/tcloop/lua-5.4-lib/usr/local/lib/liblua.so.5.4.6
$ tce-load -i lua-5.3-lib
lua-5.3-lib.tcz: OK
$ readlink /usr/local/lib/liblua.so
/tmp/tcloop/lua-5.4-lib/usr/local/lib/liblua.so.5.4.6

This test also gives us the result we want (liblua.so pointing to newest version), but it is somewhat unexpected. I would have expected that loading lua-5.3.lib (which does not have a startup script for smart liblua.so) would have clobbered liblua.so with its own version (i.e., the one that points to /tmp/tcloop/lua-5.3-lib/usr/local/lib/liblua.so which in turns points to /tmp/tcloop/lua-5.3-lib/usr/local/lib/liblua.so.5.3.6).
« Last Edit: August 18, 2023, 01:48:59 PM by GNUser »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: lua 5.4.6 for TCL14 x86_64
« Reply #10 on: August 18, 2023, 01:46:42 PM »
Very nice!
If lua-lib is installed after lua-5.4-lib, /usr/local/lib/liblua.so link already exists, and is not overwritten.

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
Re: lua 5.4.6 for TCL14 x86_64
« Reply #11 on: August 18, 2023, 01:50:06 PM »
Very nice!
If lua-lib is installed after lua-5.4-lib, /usr/local/lib/liblua.so link already exists, and is not overwritten.
Aha! I didn't realize that loading extensions did not overwrite existing files. I did some tests and can confirm this is true.

Rich, do you know where in the tce-load script is the logic that prevents existing files from being overwritten when extensions are loaded? I can't seem to find it.
« Last Edit: August 18, 2023, 02:10:52 PM by GNUser »

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
Re: lua 5.4.6 for TCL14 x86_64
« Reply #12 on: August 18, 2023, 02:08:45 PM »
I found it: Lines 11 and 143 in /usr/bin/tce-load:
Code: [Select]
FORCE="n"  # Overwrite system files default to no. Use -f to force overwrite.
Code: [Select]
yes "$FORCE" | sudo /bin/cp -ais /tmp/tcloop/"$APPNAME"/* / 2>/dev/null
« Last Edit: August 18, 2023, 02:18:12 PM by GNUser »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 934
Re: lua 5.4.6 for TCL14 x86_64
« Reply #13 on: August 18, 2023, 02:58:34 PM »
Hi GNUser,

What's Your opinion about adding tce.installed to lua-5.4.tcz?
Code: [Select]
LUA_LATEST=$(ls /usr/local/bin/lua*.* | sort -V | tail -n1)
ln -sf $(readlink $LUA_LATEST) /usr/local/bin/lua
LUAC_LATEST=$(ls /usr/local/bin/luac*.* | sort -V | tail -n1)
ln -sf $(readlink $LUAC_LATEST) /usr/local/bin/luac

and to lua-5.4-dev.tcz:
Code: [Select]
LUA_LATEST=$(ls /usr/local/lib/pkgconfig/lua-*.*.pc | sort -V | tail -n1)
ln -sf $(readlink $LUA_LATEST) /usr/local/lib/pkgconfig/lua.pc

I expect they will work nice.

EDIT: maybe the naming scheme needs to be changen in order for sort -V to work correctly. I mean
lua.5.4
luac.5.4
lua.5.4.pc

EDIT2: experiments show that it is not necessary.
« Last Edit: August 18, 2023, 03:17:16 PM by jazzbiker »

Offline GNUser

  • Hero Member
  • *****
  • Posts: 1378
Re: lua 5.4.6 for TCL14 x86_64
« Reply #14 on: August 18, 2023, 03:23:29 PM »
Hi jazzbiker. These are very nice ideas but I already submitted the new set of extensions and am too burned out right now to create yet a third set of extensions.

If Juanito wants to swoop in and add the startup scripts to lua-5.4.tcz and lua-5.4-dev.tcz I would not object ;D

My only small objection is that lua.5.4 etc is a bit ugly and difficult to type. My vote is keep binary names as lua5.3, luac5.3, lua5.4, luac5.4, etc. Besides, sort -V works just fine with such names:
Code: [Select]
$ cd /tmp/dummy
$ touch lua5.3
$ touch lua5.4
$ touch lua10.2 # version from the future!
$ ls | sort -V
lua5.3
lua5.4
lua10.2