Friday, November 9, 2012

Shell binaries needed for virtualenvwrapper

[UPDATED 2013-02-07]

You will need fmt from coreutils, make and mktemp. You also need iconv and intl libraries. Your best bet in Git bash is to install base MSYS* (part of MinGW) and then copy or link those files from /c/mingw/msys/1.0/bin/ to your Git bash home bin folder ~/bin since it will always be first on its PATH.

Do not use GnuWin32 because mktemp is broken (see bug), you don't need all 99 coreutils binaries (just fmt) and ideally you want binaries compiled for a POSIX environment (Git bash is built with MSYS),  although the gnuwin32 make binary does work in Git bash, and so does fmt. See my post for the differences between MinGW, MinGW-w64 and GnuWin32.

Coincidentally, make will also be useful for building HTML and pdftex from Sphinx rst files.

*Since, like many other MS Windows users, I've been migrated to Windows7 x64, I now recommend using MinGW-w64 instead of MinGW (aka mingw32). See my post on setting up MSYS home for virtualenvwrapper for more info.

Wednesday, November 7, 2012

Sphinx make latexpdf for MS Windows

Sphinx is an amazing documentation tool. I was up and running with gorgeous html in minutes! But generating a pdf took a little longer to figure out because IMHO on Windows using any open source is always a challenge.

  1. Install Sphinx (1.1.3) - just use pip, easy_install, or setup, whatever you prefer.
    • user@user ~$ pip install sphinx
  2. This will probably also install Pygments and Jinja-2, I can't remember.
  3. Install MikTex package repository binary. This takes care of downloading and updating your LaTeX binaries. Alternately install TeX Live and Lua TeX Windows binaries. I haven't tested this so not sure how well it works, but essentially should be the same as MikTeX since it's the same source.
  4. You will need a working make binary. The easiest one is from GNUwin32, but I would recommend installing MSYS either from MinGW or MinGW-w64. Alternately you could use Cygwin, but that's a different ballgame.
  5. After you've run sphinx-quickstart from the tutorial, type make latexpdf and voila. If you used MikTeX, it will ask you to install several LaTeX packages.
Another option is to go straight to pdf with rst2pdf. First install reportlab binary from the cheese factory. Then use pip to install rst2pdf.

Tuesday, October 9, 2012

Compile binutils on your phone with C4Droid

1. Make your sdcard executable by remounting it as rw, and therefore removing noexec flag.
2. After wget binutils-2.22.tar.gz and extracting it, change shebangs in configure, missing, install-sh and mkinstalldirs to #!/system/bin/sh.
3. I made a shell script in /data/local/bin/ that creates TEMP and TMP environmental variables equal to GCCROOT/tmpdir and then runs arm-linux-androideabi-gcc with any args passed. You could also use a symbolic link or add GCCROOT to your path. Either way do the same for make, ar, as, ld and strip.
4. Run ./configure --prefix=/data/local/ SHELL=/system/bin/sh MAKE_SHELL=/system/bin/sh CFLAGS=-fno-short-enums
5. Forgot to mention patches. (a) unistd.h getpagesize macro isn't detected, so comment out redundant definition in getpagesize.c (b) time returns time_t pointer so cast it from int in archive.c (c) bucomm.c calls mkdtempwhich is never declared in bionic so add extern char * mkdtemp(char * path) to bucomm.h (d) there's one other type mismatch but I can't remember where.
6. Run make and make install and Viola!

How to remove noexec flag from your sdcard

Run mount -o remount, rw /mnt/sdcard/. This will also work on any external storage,  Even an internal mmc card. It won't survive a restart. You could try to modify your vold fstab file. Or add the commands to your .bashrc or profile and reverse it in .bashlogout. You may need to use /storage/sdcard0 or sdcard1 depending what ROM you are running.


Note this will not work on a fuse file system, which unfortunately is the new norm on many new smartphones (EG: Motorola RAZR HD).

Do Not Format Android External Storage

Anything but vfat! If you do Android will not mount any of your external storage and consequently any apps on York sdcard will be unusable until you reformat the offending card, which could actually be internal, back to vfat fs. Unfortunately busybox mkdosfs is broken so the only way to do this without advanced is to use newfs_msdos which just works. This means that you will never be able to make hard or symbolic links from or on your sdcard.

Tuesday, September 18, 2012

SL4A dialogCreateInput vs dialogGetInput

It should seem totally obvious but the main differences between these two are summarized below:

dialogCreateInput

  1. dialogCreateInput also requires dialogGetResponse to get the response inputted into the dialog box. The result attribute of dialogCreateInput is always None, and the actual response is in the result attribute of dialogGetResponse.
  2. dialogCreateInput lets you select the input type: "text", "number", etc. which will also determine the type of soft keyboard used. A number pad is shown for "numbers"
  3. dialogCreateInput does not have any buttons, so the user must use the back arrow or home key to escape if no code is used to dismiss the dialog. The obvious solution would be to use the return key.

dialogGetInput

  1. dialogGetInput returns the input in result attribute. the window
  2. dialogGetInput does not you select the type of input.
  3. dialogGetInput has OK and Cancel buttons to close
SL4A has a UI help page which mentions the difference between these two, but it still might not be immediately obvious. There is some detail under the heading: some notes right before the API references table.
In addition to the above functions, dialogGetInput and dialogGetPassword are convenience functions that create, display and return the relevant dialogs in one call.
There is only ever one instance of a dialog. Any dialogCreate call will cause the existing dialog to be destroyed.
Fork me on GitHub