Saturday, September 13, 2014

Dart Content Shell on Debian


I am a fan of Debian for public server installs. It includes no “junk” services that might expose the server to additional attack vectors, leaving just the services that I really want available. I rarely even bother with firewalls or iptables—the only active ports are those that would be available directly through a firewall anyway. That said, Debian is not without its challenges.

I had hoped to get the Dart test build for Patterns in Polymer running without any difficulties, but alas. Part of this is a problem of my own creation. I am installing on a 32 bit version of Debian 7. There are Debian packages for 64 bit installs (though I do not know if they include the content_shell tool for Dart testing).

Some of the difficulty is Debian's rather slow release cycle. For instance, the version of the shared libc library that Dart expects is not present on a default Debian 7 install:
$ ./dart/dart-sdk/bin/dart
./dart/dart-sdk/bin/dart: /lib/i386-linux-gnu/i686/cmov/libc.so.6: version `GLIBC_2.15' not found (required by ./dart/dart-sdk/bin/dart)
There really seems no other way around this than to add the testing sources to the systems /etc/apt/sources.list:
$ tail -1 /etc/apt/sources.list
deb http://ftp.debian.org/debian testing main
After a apt-get update and reinstall, things are OK:
$ sudo apt-get update
$ sudo apt-get install --reinstall debconf libc6 locales
$ ./dart/dart-sdk/bin/dart --version
Dart VM version: 1.6.0 (Tue Aug 26 13:57:28 2014) on "linux_ia32"
I am already used to installing fonts to support content_shell, so I get that out of the way up front. The following is taken from Chromium's layout tests for Linux:
sudo apt-get install wdiff ttf-indic-fonts \
    ttf-mscorefonts-installer \
    ttf-dejavu-core ttf-kochi-gothic ttf-kochi-mincho \
    ttf-thai-tlwg
I am not installing Apache, because this is a minimal Debian system. I have also swapped the Microsoft Core Fonts Ubuntu package name for the equivalent on Debian.

Even after that, I still do not seem to have everything:
You are missing /usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf. Try re-running build/install-build-deps.sh. Also see http://code.google.com/p/chromium/wiki/LayoutTestsLinux
Hrm... that helpful link is not going to be much help since I just followed its font installation instructions to get to this point. The install script is not actually part of the Dart distribution, so that is not helpful either.

Taking a closer look at the error, I note that the missing font seems to be coming from the ttf-indic-fonts package, which I did install. Ugh... on Debian, this is a transitional package. In other words, the fonts did get installed, but by other packages that have superseded it—and are likely installing the fonts in different locations.

My options are to attempt to install the Ubuntu package or manually recreate the usr/share/fonts/truetype/ttf-indic-fonts-core directory on this Debian system. Even though it could take me some time, I opt for the latter. Risking package conflicts (either now or after subsequent updates) feels like something that I would want to avoid.

Thankfully, it does not require too much effort to recreate the Indic fonts required for content_shell:
$ cd /usr/share/fonts/truetype
$ sudo mkdir ttf-indic-fonts-core
$ cd ttf-indic-fonts-core
$ sudo ln -s ../lohit-punjabi/Lohit-Punjabi.ttf lohit_hi.ttf
$ sudo ln -s ../lohit-tamil/Lohit-Tamil.ttf lohit_ta.ttf
$ sudo ln -s ../fonts-beng-extra/MuktiNarrow.ttf
$ sudo ln -s ../lohit-punjabi/Lohit-Punjabi.ttf lohit_pa.ttf
I am not 100% sure that those are the corresponding fonts. Well, it seems a safe bet that I got the right MuktiNarrow.ttf since the name remained the same. But the others are just guesses. I am especially unsure about the lohit_hi.ttf font as there does not seem to be an obvious match. In the end, it does not make much of a difference to me—unless I am testing Dart code that uses that particular font. Since I have never heard of it, I think I am safe.

Safe from layout errors, but I still cannot get my tests passing. Or running:
$ content_shell --dump-render-tree test/index.html
[1870:1870:0100/000000:29999461:ERROR:zygote_linux.cc(587)] write: Broken pipe
This is due to a lack of an X server. Thankfully, I have already installed Xvfb. I am able to run content_shell with the xvfb-run wrapper script:
$ xvfb-run -s '-screen 0 1024x768x24' content_shell --dump-render-tree test/index.html 
CONSOLE MESSAGE: unittest-suite-wait-for-done
CONSOLE MESSAGE: PASS: [defaults] it has no toppings
CONSOLE MESSAGE: PASS: [adding toppings] updates the pizza state accordingly
CONSOLE MESSAGE: 
CONSOLE MESSAGE: All 2 tests passed.
CONSOLE MESSAGE: unittest-suite-success
CONSOLE WARNING: line 213: PASS
Content-Type: text/plain
PASS
With that, I finally have a failing build on my Jenkins CI server:



This might not seem like cause for celebration, but I am aware that some tests are failing—some project chapters in Patterns in Polymer are still following an older Polymer.dart project format. Now I have a build to tell me when I have them fixed (and to ensure that they stay functional).

And that's where I will pick up tomorrow.


Day #182

1 comment:

  1. Massive thanks! Facing the same problem and the regular places on the internet where such problems are shown didn't help.

    ReplyDelete