Linux


It seems there is little documentation on how to setup Lexmark Pro900 printer driver in linux. Lexmark does provide linux driver,  but it’s only for RPM or DEB based systems, without a manual installation option, which does not help much for installing to a Gentoo distribution.

After jumping through several hoops by reading the various scripts embedded in the install script and postinstall script in RPM, I finally managed to install it manually onto my Gentoo, and add the network printer to CUPS just fine. Test page shows up properly as well.

In order to save other gentoo users (and myself if I need to reinstall this driver), I spent sometime on writing a gentoo ebuild.

To use it, add my overlay first:

layman -f -o http://github.com/liucougar/portage/raw/master/profiles/layman.xml -a liucougar

keyword the package:

echo "net-print/lexmark-inkjet" >> /etc/portage/package.keywords

install it as root and restart cups

emerge net-print/lexmark-inkjet
/etc/init.d/cups restart

go to the web UI of CUPS (make sure the printer is properly setup and accessible via network), and add a printer, now you should see lexmark in the add printer page.

I think this ebuild should support the following printers: Pro200-S500, Pro700, Pro800-Pro900, S300-S400, S600, X2600, X3646, X4900, X5666, X7600, Z2300, Z2400.

There are quite some extra features in the provided binary driver package: scanner support (sane, only locally connected via USB is supported as far as I can tell), firmware updater among other things. There are not yet supported by the ebuild.

DISCLAIM: I only tested with Pro900, so if it does work for you with other printers listed above, please leave a comment below.

It has been quite a while since I started X server in one of my development gentoo virtualbox guest. Today, when I tried to startx, I got the following error:

dlopen: /usr/lib/xorg/modules/drivers/vboxvideo_drv.so: undefined symbol: resVgaShared
(EE) Failed to load /usr/lib/xorg/modules/drivers/vboxvideo_drv.so
(EE) Failed to load module "vboxvideo" (loader failed, 7)

And X failed to start.  I tried to reinstall virtualbox-guest-additions, and rebooted, but X still exists with the same error. It turns out, in order to “properly” re-install virtualbox driver in the guest, I have to re-emerge the following two packages:

emerge x11-drivers/xf86-video-virtualbox x11-drivers/xf86-input-virtualbox

The problem is caused by upgrading xorg-server from 1.6.x to 1.7.x, after which virtualbox guest drivers have to be re-installed (portage does not show a warning, so it took me some time to figure that out).

After some research for a S3 backup strategy, I settled with s3ql which looks to be one of the most promising solutions for a maintained, compressing, de-duplicating, encrypted, chunked, S3/ssh/sftp based, backup filesystem.

However, the installation of s3ql is non-trivial work because there is no ebuild for it, so I decided to write one. I just pushed the ebuilds to the liucougar overlay on github (which currently contains s3ql and two of its dependencies missing in official gentoo portage tree). As of today, unless you are using testing branch of gentoo, in order to install s3ql, the following lines has to be added to /etc/portage/package.keywords:

sys-fs/s3ql
dev-python/pycryptopp
dev-python/pyliblzma
dev-python/unittest2 #only useful if you intend to test the package
dev-python/apsw
dev-cpp/gccxml
dev-db/sqlite

Please report any issues with github.

Note: if you want the contrib scripts shipped with s3ql installed, contrib use flag should be specified when emerging s3ql.

While trying to run our tests in a clean virtualenv (–no-site-packages), psycopg2 (tried both 2.0.13 and 2.0.14) can not be imported with a error traceback like the following:

File "....py", line .., in
  import psycopg2
  File "build/bdist.linux-i686/egg/psycopg2/__init__.py", line 69, in
  File "build/bdist.linux-i686/egg/psycopg2/_psycopg.py", line 7, in
  File "build/bdist.linux-i686/egg/psycopg2/_psycopg.py", line 6, in __bootstrap__
ImportError: can't import mx.DateTime module

However, search python source files in the install psycopg2 package does not yeild any hits on mx, so my conclude was that it’s being imported in the psycopg2 c library.

It becomes clear after I took a look at the setup.py in the source tarball of psycopg2: while building the package, the setup.py will check whether it can find mx header files under the python include dir. If it can, it would just compile in the above import line into its c library. I don’t see any way it can be disabled given you have egenix-mx-base header files installed (even if you don’t have mx python module available, it will still compile in mx.DateTime support)

This would only happen if you have the egenix-mx-base header files install in the global python installation.

One workaround I came up with is to copy over the mx dir under site-packages from the global python installation into the virtualenv environment I am using to do test. Alternatively, don’t install the header files for egenix-mx-base (although in gentoo, that means you have to manually remove the header files). For now, I settled on the former workaround.

I have a USB camera I want to use with Skype to make video calls. The camera has the following lsusb output:

Bus 004 Device 002: ID 0471:0328 Philips SPC 700NC PC Camera

My gentoo is 64bit, using multilib (has 32bit libraries as well). After fiddling with Google to find the proper linux kernel driver for a while, I found a useful website  Linux Kernel Driver DataBase (LKDDb) (the kernel module is called CONFIG_USB_GSPCA_SONIXJ). After installing the kernel driver, reboot, Skype can detect a camera device /dev/video0, but when clicking the test button, nothing show up (the light on the camera comes on briefly then turns off). Further google leads me to this solution: Edit /usr/bin/skype, add the following line before the last line (exec ./skype "$@"):

export LD_PRELOAD=/usr/lib32/libv4l/v4l2convert.so

skype is a pre-built 32-bit binary, so I have to specify the lib32 explicitly above. Note: if you receive any of the following errors:

ERROR: ld.so: object '/usr/lib32/libv4l/v4l1compat.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib64/libv4l/v4l1compat.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib32/libv4l/v4l2convert.so' from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object '/usr/lib64/libv4l/v4l2convert.so' from LD_PRELOAD cannot be preloaded: ignored.

You are probably trying to set LD_PRELOAD on a shell script (the /usr/bin/skype is actually a shell wrapper around /opt/skype/skype, the real binary), so the following would lead to one of the above errors:

LD_PRELOAD=/usr/lib32/libv4l/v4l2convert.so skype

Try to add that line to the script instead as suggested above.

It is well known that Firefox (even the latest 3.x) does not support text-decoration=”underline” on text elements in SVG. However, it bites me hard when I found out imagemagick does not support that either when rastering svg to pixel images.

After digging around, (by looking at the ebuild file) I found out that imagemagick is actually making use of librsvg to do the heavy lifting when dealing with svg files.

librsvg is part of gnome-base packages (as can be seen in gentoo portage). Looking at the source code, I figured that it makes use of pango to render text.

From the days of working on SCIM project, I know for sure that pango is more than capable of rendering text with underlines. So there must be something missing in librsvg to render it. It turns out that, while the svg parser implemented in librsvg does indeed look for text-decoration, and recoganize underline (among strikethrough and overline), it is not actually making use of these parsed info to render the text.

After a bit of tracing the code, I found out how to patch it: the trick is just to add a pango underline attribute to the text layout, and everything else is taken care of by pango.

This bug is reported to upstream, and hopefully it will be merged there soon. The patch is available in that bug report, so you can grab it if you can’t wait. The patch also fixes a bug which is discovered after the underline problem is fixed: when a underlined text has stroke set, the stroke is rendered in wrong position.

Due to better 64bit support, we decided to use VMWare instead of VirtualBox. To prevent of installing a gentoo to a VMWare image, I decided to convert the already working virtualbox image (a vdi file) to VMWare (vmdk). Qemu-img is the command line tool for this task, using the following line, I can get a vmdk:
qemu-img convert -O vmdk gentoo32.vdi gentoo32.vmdk
However, this vmdk is not recognized by VMWare 6.5. I guess it has something to do with the fact that the original vdi file is using dynamic sizing (the file contains a 5G partition, and it only has 1.9G data, so the real size for the vdi file is about 2.1G): the converted vmdk is 1.9G, and VMWare reports that it has 2.1G total size.When booting with this image, VMWare fails to read any data from the virtual disk. After tried another time with the above approach, which also failed, it seems I have to find another way. Luckily, VirtualBox comes with a command line tool called vboxmanage, which can do all sorts of operations on vdi files, including converting vdi to raw disk image, so let’s try that:
vboxmanage internalcommands converttoraw gentoo32.vdi gentoo32.raw
The above command will generate a 5G gentoo32.raw file. Then use qemu-img:
qemu-img convert -O vmdk gentoo32.raw gentoo32.vmdk
To convert the raw file to vmdk. The resulting vmdk file is also 1.9G, but this time VMWare recognize it just fine (reporting its real size as 5G). After changing the root device from /dev/sda1 to /dev/hda1, this image can boot just fine in VMWare, with one exception: the network interface eth0 can not be started. More inspecting reveals that “udev renames network interface eth0 to eth1″. This is caused by the fact that one of the default gentoo udev rule (/etc/udev/rules.d/75-persistent-net-generator.rules) will write another rule file which saves the MAC address for each NIC, and sure enough, the MAC address for the NIC in VirtualBox is different from that of VMWare. However, this is very easy to fix, once you know where the generated udev rule is: Open /etc/udev/rules.d/70-persistent-net.rules and remove all rules in this file, save and reboot, eth0 won’t be renamed to eth1 any more.

For the past several months, I am developing frontend against a bare cherrypy server which also serves all static files, like javascripts/images etc. Without building frontend code (so there are lots of small js files to load), it takes more than 20 seconds to reload the unbuilt frontend application I am working on (which is the main driver behind my hacking on dojo.reload).

Use Apache as proxy server

Today I decided to shield an apache proxy server in front of the cherrypy server to off load all static files serving duties from the latter, in the hope of speeding up reloading speed of the app.

The apache proxy should be setup so that it directly serves any files under /debug and /release, all other requests are dynamic and should be handled by cherrypy server. In addition, our backend app sometimes use HTTP redirects to direct client to a new page. In Apache configuration file, all this can be achieved by:

ProxyPassMatch ^/(?:debug|release)/.* !
ProxyPass / http://127.0.0.1:8000/
 
ProxyPassReverse / http://127.0.0.1:8000/
 
Alias /debug /var/www/htdocs
Alias /release /var/www/htdocs/release

Note: the /debug directory is the unbuilt frontend code, while the /release points to the built frontend code (by default, dojo will put the built version under release directly as peer of dojo dir).

With the above settings, cherrypy is nicely sitting behind the Apache server without worrying about any static files, and the reloading time of the unbuilt frontend code now reduces to about 4 seconds, which is a dramatic improvement.

Try nginx instead

nginx is normally considered to be a faster reverse proxy server than apache, so I want to give it a try.

In nginx configuration file, proxy_pass is used to pass the request to a backend server, while it does not use proxy_pass_reverse, instead the equivalent in nginx is proxy_redirect directive. As long as your host domain name is properly set up, the following nginx directive is equavalent to the above apache directive:

location /debug/ {
    alias /var/www/htdocs;
}
location /release/ {
    alias /var/www/htdocs/release;
}
location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_redirect default;
}

More info on proxy_redirect can be found in official documentation.

Impression of Nginx compared to Apache

While I don’t want to do any thorough comparsion of the two reverse proxy servers, I just tried each of them several times and monitors the net panel output in firebug. It seems, nginx delievers more consistent performance: for the same page, apache sometimes deliver it in 1 second, sometimes in 4 seconds, while nginx always delivers it in 1 second. Thus I guess I will just keep using nginx at least for now.

I just noticed that re-bundling in EC2 instance is not working. Google told me that it is due to the incompatibility between latest rsync and relatively old kernel used by EC2 (2.6.16).

In the thread about this issue, 5 possible workarounds are presented. However, none of them are easy under gentoo without messing up with ebuild/emerge. I found another way, and you don’t need to regenerate the configure file for rsync at all, all you need is to comment the following line in the config.h file (which is generated after you run the configure script):

#define HAVE_LUTIMES 1

then make and make install, all should be fine now.

If you are using a dns service provider with dynamic dns support, and using a gentoo based EC2 AMI, then you may find this script to be useful. It can update the IP address for a specified domain name whenver the gentoo AMI is booted.

To use this script, just extract the file, and place ec2.conf under /etc/conf.d and rename it as ec2, then move file ec2 to /etc/init.d

Before you can use it, you have to set some parameters in file /etc/conf.d/ec2, please consult the comments in that file.

In order to register IP address whenever the AMI is getting booted, a final step is needed:

rc-update add ec2 default

Next Page »