I have been playing with SL4A (the Android scripting layer) and PY4A (Python for Android) and I wanted to see if I could get the readline package working. Readline is based on GNU's libreadline. So I was able to compile libreadline.so, but I was too lazy to build Python properly for bionic (androids version of libc) in order to get a working Python header file. This got me thinking that a standalone pure Python version of readline could be useful for anyone without the Python headers (python.h and pyconfig.h).
Download a tarball of libreadline.so and libhistory.so for bionic from my public dropbox.
FYI: I copied these shared object libraries into /data/data/com.googlecode.pythonforandroid/files/python/lib, made symlinks to remove the version number, changed the permissions to 755 and the ownership to PY4A's username and group, which I represent below as app_XX. Alternately, if you don't have root permission, you still have permissions to use sl4a's folder when using either py4a or their bash shell, so put your shared objects there instead.
/data/data/com.googlecode.androidscripting/files/python/lib
~$ wget https://dl.dropbox.com/u/19049582/rl-6.2_arm_linux_androideabi.tar
~$ tar -xf rl-6.2_arm_linux_androideabi.tar
~$ cp rl-6.2_arm_linux_androideabi.tar/libreadline.so.6.2 /data/data/com.googlecode.pythonforandroid/files/python/lib
~$ cp rl-6.2_arm_linux_androideabi.tar/libhistory.so.6.2 /data/data/com.googlecode.pythonforandroid/files/python/lib
~$ cd /data/data/com.googlecode.pythonforandroid/files/python/lib
/data/data/com.googlecode.pythonforandroid/files/python/lib$ ln libreadline.so.6.2 libreadline.so
/data/data/com.googlecode.pythonforandroid/files/python/lib$ ln libhistory.so.6.2 libhistory.so
/data/data/com.googlecode.pythonforandroid/files/python/lib$ chmod 755 libreadline.so
/data/data/com.googlecode.pythonforandroid/files/python/lib$ chmod 755 libhistory.so
/data/data/com.googlecode.pythonforandroid/files/python/lib$ chown app_XX:app_XX libreadline.so
/data/data/com.googlecode.pythonforandroid/files/python/lib$ chown app_XX:app_XX libhistory.so
You can test them in the SL4A interpreter by running the following script:
>>> from ctypes import *
>>> rl = CDLL("libreadline.so")
>>> rl.rl_initialize()
>>> rl_completer_word_break_characters = c_char_p.in_dll(rl, " rl_completer_word_break_characters")
>>> print rl_completer_word_break_characters
" \t\n\"\\'`@$><=;|&{("
Therefore I present purereadline, an all Python wrapper for libreadline using ctypes. Uh ... it's still in beta, and I don't even know if it will work, but I can't think of any reason why it wouldn't. I can use ctypes fine with the shared object libraries to run functions and get exported variables. The shared object libraries compile very nicely using c4droid although I had to patch setpwent.
See issue #6 on py4a for more information and links.
Showing posts with label bad bsd. Show all posts
Showing posts with label bad bsd. Show all posts
Monday, January 7, 2013
Thursday, April 26, 2012
Mount cd0
Trying to build vmware tools for bsd. Need to mount CD? Try this
mount -t cd9600 /dev/cd0 /cdrom
Thursday, April 19, 2012
Bad BSD
I wanted to try BSD because of it's historical connection to the original UNIX system developed at Bell Labs. I love this chart (courtesy of Wikipedia) that shows the web of OS development.
I downloaded FreeBSD which installs nicely in VMWare Player and VirtualBox. When installing make sure to add yourself as a user, and make sure to add yourself to the wheel group. This will make it possible for you to use su which you'll need to install packages. If you didn't add yourself as a user during the installation, don't worry, login as root, type adduser and answer the questions. Accept the default for almost everything, except, of course, add yourself to the wheel group. If you didn't add yourself to wheel then you need to logout (hit ctrl-D or type exit) and login as root, then type$pw usermod username -G wheel
and now you can use su, which lets you login as root to install your package, then return to your shell when you exit.
To install packages, so far, I've been using pkg_add -r package-name. This downloads the pre-compiled package from a BSD repo. BSD also gives you the option to build packages from source, called ports, and you can download the complete ports during installation. There is a good section in the BSD handbook on the pros and cons of both.
Thanks nixCraft for helping me understand su.
Subscribe to:
Posts (Atom)