[OpenWrt-Devel] [PATCH 0/1] libubox installs incorrectly on Ubuntu due to incorrect LUAPATH

Sergey Ponomarev stokito at gmail.com
Thu Nov 29 12:48:41 EST 2018


Hi and thank for the review,

We have two situations: installing from source (and in this situation
it's ok to use /usr/local/) and installation as part generating a *.deb
package and here we can't use /usr/local.

I checked my system and lua is installed properly but lua's
package.cpath anyway returns /usr/local as first path. What I get from
documentation this is properly behavior.

So I just decided to set LUAPATH manually and I think that would be ok.

Thank you


On 11/29/18 6:17 PM, Petr Štetiar wrote:
> Sergey Ponomarev <stokito at gmail.com> [2018-11-29 17:20:07]:
>
> Hi,
>
>> I'm working on porting openwrt utils like UCI and UHTTPD to Ubuntu and trying to create a PPA.
>> During creation of a debian package for libubox it's build failed with:
>>     dh_install: Cannot find (any matches for) "/usr/lib/x86_64-linux-gnu/lua/5.1/uloop.so" (tried in ., debian/tmp)
>> After investigation it turned out that LUAPATH variable was evaluated as /usr/local/lib/lua/5.1 while correct path is /usr/lib/x86_64-linux-gnu/lua/5.1.
> That's wrong, see bellow.
>
>> The LUAPATH is evaluated by the command:
>>     $ lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
>> So it looks for array package.cpath and gets a first line which starts with / (this is why k:sub(1,1) == \"/\").
>> To see all pathes let's change the command a little bit:
>>     $ lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do print(k) end"
>>     .
>>     /usr/local/lib/lua/5.1
>>     /usr/lib/x86_64-linux-gnu/lua/5.1
>>     /usr/lib/lua/5.1
> All 4 paths are valid, Lua would search for dynamic loadable libraries in those
> paths.
>
>> So on Ubuntu 18.10 and maybe in other distros the LUAPATH variable will receive the /usr/local/lib/lua/5.1 as first path.
>> To fix that all what we need to do is just to get path which starts with not just / but with /usr/lib/ i.e.
>>     $ lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,9) == \"/usr/lib/\" then print(k) break end end"
>> So this parch is intended to fix that.
> No, this is not a fix, it's a hack for Ubuntu. You're probably breaking half of
> the world where you've stuff usually installed in /usr/local and other
> locations, like BSDs (and maybe OSX?) for example:
>
>  ynezz at meh:~$ head -1 /etc/motd
>  OpenBSD 6.4 (GENERIC) #349: Thu Oct 11 13:25:13 MDT 2018
>
>  ynezz at meh:~$ lua51 -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
>  /usr/local/lib/lua/5.1
>
>  ynezz at meh:~$ lua51 -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,9) == \"/usr/lib/\" then print(k) break end end"
>
> -- ynezz

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list