View Single Post
Old 09-07-2014, 10:50 AM   #36
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
LuaJit-2.0.3

OK - the fog has slowly lifted here, since I last posted (and mis-descripted) my own contribution.

The release thread:
https://www.mobileread.com/forums/sho...d.php?t=240616
(you only need the base-* archive for the HF runtime)

The How-To Install it and use it:
https://www.mobileread.com/forums/sho...1&postcount=47
(Either over ssh or from inside kterm)
Note: it installs in */esys rather than under */extensions or */system (a pathlength problem in editing elf files).

The 5cent tour:
Code:
core2quad mszick # telnet ken1
Trying 192.168.15.244...
Connected to ken1.morethan.org.
Escape character is '^]'.

Welcome to Kindle!

#################################################
#  N O T I C E  *  N O T I C E  *  N O T I C E  # 
#################################################
Rootfs is mounted read-only. Invoke mntroot rw to
switch back to a writable rootfs.
#################################################
[root@kindle root]# cd /mnt/us
[root@kindle us]# exec esys/bin/busybox ash
[root@kindle us]# export PATH=/mnt/us/esys/bin:/mnt/us/esys/usr/bin:$PATH
[root@kindle us]# lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> os.exit(0)
[root@kindle us]# luajit
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
JIT: ON ARMv7 VFPv3 fold cse dce fwd dse narrow loop abc sink fuse
> os.exit(0)
Although the prompt did not change, the 'exec' replaced your command line interpreter with ash-1.22.1

The first one (Lua) is Amazon's release from their system tree.
The second one (LuaJit) is from the HF system tree.
(Yes Virginia, you can run two (or more) different system library trees on Linux, concurrently (no chroot required) )

Now try running Amazon's Lua extension module(s):
Code:
[root@kindle us]# luajit
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
JIT: ON ARMv7 VFPv3 fold cse dce fwd dse narrow loop abc sink fuse
> require 'json'
stdin:1: module 'json' not found:
        no field package.preload['json']
        no file './json.lua'
        no file '/usr/share/luajit-2.0.3/json.lua'
        no file '/usr/local/share/lua/5.1/json.lua'
        no file '/usr/local/share/lua/5.1/json/init.lua'
        no file '/usr/share/lua/5.1/json.lua'
        no file '/usr/share/lua/5.1/json/init.lua'
        no file './json.so'
        no file '/usr/local/lib/lua/5.1/json.so'
        no file '/usr/lib/lua/5.1/json.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: at 0x00009c48
>
Phooey!
Amazon installed that extension library in:
Code:
/usr/lib/lua/json.lua
And the default search path is looking in (the proper place):
Code:
/usr/share/lua/5.1/json.lua
Note: /usr/lib/*, /usr/local/lib/* is where the binary modules (should) live; json.lua is a source code module.

The same problem will exist for all the Amazon provided library modules.

A quick and very dirty work-around is to copy the module file(s) to the current working directory:
Code:
[root@kindle us]# cd
[root@kindle root]# cp -a /usr/lib/lua/json.lua .
[root@kindle root]# luajit
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
JIT: ON ARMv7 VFPv3 fold cse dce fwd dse narrow loop abc sink fuse
> require 'json'
>
But that is tiring and error prone.

I should work up a new 'init' file for LuaJit to make its search paths match the Amazon install.
(A WIP)

Well, the source code paths can be handled by:
Code:
[root@kindle root]# luajit
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
JIT: ON ARMv7 VFPv3 fold cse dce fwd dse narrow loop abc sink fuse
> package.path = package.path .. ";/usr/lib/lua/?.lua"
> require 'sqlite3'
> require 'json'
>
And similar for the C binary search paths.

Why?
Because once fixed, this should deal with the "lua ccat is too slow" comments.

Note:
For the interested, the entry point of the ccat extension module is:
/usr/lib/ccat/init.lua

Ref:
Code:
[root@kindle root]# busybox
BusyBox v1.22.1 (2014-06-14 09:41:57 CDT) multi-call binary.
[root@kindle root]# cat /etc/prettyversion.txt
Kindle 5.3.3 (~~otaVersion~~)
[root@kindle root]# uname -a
Linux kindle 2.6.31-rt11-lab126 #1 Tue Jan 8 22:06:21 PST 2013 armv7l GNU/Linux
[root@kindle root]# /mnt/us/esys/lib/libc.so.6
GNU C Library (Buildroot) stable release version 2.19, by Roland McGrath et al.
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.9.0.
Compiled on a Linux 3.0.101 system on 2014-06-14.
Available extensions:
        crypt add-on version 2.1 by Michael Glad and others
        GNU Libidn by Simon Josefsson
        Native POSIX Threads Library by Ulrich Drepper et al
        BIND-8.2.3-T5B
libc ABIs: UNIQUE
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.

Last edited by knc1; 09-07-2014 at 11:44 AM.
knc1 is offline   Reply With Quote