Aug 31, 2009

Printing Out Ruby Code

Task: producing a paper copy of a Ruby program to scribble on.

Try 1: a2ps. openSUSE has 4.13 which does not support Ruby (although 4.14 was released on 28-Dec-2007).

Try 2: enscript. No support for Ruby even in upstream (but there exists a patch for that on the Net).

Try 3: emacs. I was not able to produce a highlighted printout from Emacs :-(

Try 4: vim. :hardcopy does it, but it printed the keywords in light yellow on white.

Try 5: kwrite. Success. Yay!

Aug 26, 2009

ruby-dbus 0.2.9

I have released a tarball of 0.2.9 and updated the home page.

From NEWS: Ruby D-Bus "I'm not dead" 0.2.9 - 2009-08-26

Thank you to Paul and Arnaud for starting the project. I, Martin Vidner, am continuing with it on GitHub.
  • Fixed passing an array through a variant (no ticket).
  • Fixed marshalling "av" (Ticket #30).
  • Fixed variant alignment (Ticket #27).
  • Added DBus::Main.quit.
  • Mention the DBus interface in a NameError for an unknown method.
  • Fixed ruby-1.9 "warning: default `to_a' will be obsolete".
  • Added Rakefile and gemspec.

Aug 24, 2009

Git Aliases for Subversion Users

git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.di diff
git config --global alias.dic diff\ --cached

Aug 11, 2009

cnetworkmanager 0.21

As I advertised in a previous post, cnetworkmanager got a complete rewrite, and here is a summary of the changes:

v0.21, User visible changes
  • Added screenshots.html.
  • Output in a tabular form (like Tambet's nmcli); --terse/-t to disable.
  • Added --wireless-enabled/--we.
  • Added --con-info.
  • For unimplemented device types, return "unknown", crash not (Kevin Fenzi).
  • Ignore AlreadyAsleepOrAwake error (-o).
  • Flags with zero value now output its name (NONE) instead of nothing.
v0.20
  • Major rewrite:
  • Created a library wrapping the NM DBus API.
  • Created a generic library wrapping python-dbus.
    (both libraries are still quite messy)
  • Dropped support for NM 0.6.
    (the last trace is in the 'breakup' branch)
  • Connection setting:
    --activate-connection for system settings or another applet
    --connect for exporting a transient connection
  • knetworkmanager (KDE3) config reading dropped
  • Added a (basic) testsuite.
  • Switched to distutils.
BTW, I also pushed the git repo to Github so that you can enjoy the fork graphs. (repo.or.cz stays)

Jul 21, 2009

HackWeek: NetworkManager Python library

It is Hack Week again, a time when we venture into unexplored territories. So why am I returning to cnetworkmanager?

It is because I am doing a complete rewrite, based on an easy-to-use library that hides some rough edges in dbus-python. If you ever thought NM needed some programmatic prodding but were put off by the tedious details, the library might be just the thing for you. For me, it is also an opportunity to learn more Python.

Compare how you get the interface names.
Before:
#! /usr/bin/python
import dbus
bus = dbus.SystemBus()
NM = 'org.freedesktop.NetworkManager'
nm = bus.get_object(NM, '/org/freedesktop/NetworkManager')
for dev_opath in nm.GetDevices(dbus_interface = NM):
dev = bus.get_object(NM, dev_opath)
print dev.Get(NM + '.Device', 'Interface',
dbus_interface='org.freedesktop.DBus.Properties')
After:
#! /usr/bin/python
from networkmanager.networkmanager import NetworkManager
nm = NetworkManager()
for d in nm.GetDevices():
print d["Interface"]
It is in the librarize branch of the git repo. Beware, the code is still messy. Getting it:
git clone git://repo.or.cz/cnetworkmanager.git cnetworkmanager.librarize
cd cnetworkmanager.librarize
git checkout -b librarize origin/librarize
./cnetworkmanager -h

Jul 8, 2009

D-Bus and Ruby

There isn't a canonical D-Bus library for Ruby. I found four projects, two of which are interesting.

First, the two losers:
* dbus-ruby: It wraps the C bindings. It is dead (last release in January 2005).
* pr-dbus: No releases, last SVN commit in April 2007, entirely in Ruby.

Now for the contenders. Both are packaged as RPMs in the OBS YaST:Web project.
The developers know about each other but in 2007 they did not want to merge the projects. The developers are not active but patches do appear.

* ruby-dbus
  • LGPL
  • no test suite (but I've started one together with bug fixes: Github clone)
  • can export services
  • cumbersome API (explicit introspection calls needed, explicit types for variants needed, return value must be an array)
BTW Klaus has two posts about writing a client and a server with ruby-dbus.

* rbus
  • GPL
  • test suite (RSpec, needs a patch)
  • cannot export services
WebYaST is using ruby-dbus so far, but I am looking at rbus too because of the tests and and the nicer API.

Jun 18, 2009

Perl DBus Library

If you want camels in your D-Bus, use perl-Net-DBus by Daniel Berrange. I have just fixed the original packaging done by Illuusio. Enjoy.

Jun 4, 2009

Cool Features in Automake 1.11

Automake is not dead, and version 1.11 will soon be in openSUSE Factory (thx puzel!) I see two new features to like: parallel execution and terse compilation.

The parallel execution is enabled by the environment variable AUTOMAKE_JOBS=n. It reduced the run time for yast2-core from 18s to 7s for me.

As for compilation, how's this (kernel people may yawn now):
make[4]: Entering directory `/home/mvidner/svn/yast/trunk/core/wfm/testsuite'                                                                         
CXX runwfm.o
CXX runc.o
CXXLD runwfm
runc.cc:54: warning: unused parameter ‘name’
CXXLD runc
compared to:
g++ -DHAVE_CONFIG_H -I. -I../.. -I../../libycp/src/include -I../../liby2/src/include -I../../libscr/src/include -I./../src -I../../liby2util-r/src/include -DY2LOG=\"wfm\" -O0 -g3 -W -std=gnu++0x -DHAVE_CXX0X -Wall -Wformat=2 -MT runwfm.o -MD -MP -MF .deps/runwfm.Tpo -c -o runwfm.o runwfm.cc
mv -f .deps/runwfm.Tpo .deps/runwfm.Po
/bin/sh ../../libtool --tag=CXX --mode=link g++ -DY2LOG=\"wfm\" -O0 -g3 -W -std=gnu++0x -DHAVE_CXX0X -Wall -Wformat=2 -o runwfm runwfm.o ../src/libpy2wfm.la ../../scr/src/libpy2scr.la ../../libscr/src/libscr.la ../../libycp/src/libycp.la ../../libycp/src/libycpvalues.la ../../liby2/src/liby2.la ../../liby2util-r/src/liby2util.la


It is enabled by putting this to configure.in:
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
(The ifdef makes for graceful degradation with older automake.)

Use Webpin or the Software Portal to find a package built for your release.

Jun 2, 2009

A Minimal Build Service OSC Plugin

I am trying to make OBS cooperate with my old release scripts*. So far I have this minimal plugin for osc to share:
$ mkdir ~/.osc-plugins
$ cd $_
$ cat > releasecheck.py <<EOF
def do_releasecheck(self, subcmd):
print "Release early, release often."
EOF
$ osc releasecheck
Release early, release often.
*) They are not released, bad me; but they rely on the internal directory layout anyway.

May 18, 2009

Bugzilla Fables: Serving Two Masters

You may know this: spending a few hard days, or even minutes, figuring out a bug and in the end the result is a one line change. What an injustice! So let's expand one such case for the amusement and education of the audience. Fable #501758:

For certain tasks, YaST uses external helpers (agents) communicating via pipes. One of them was causing YaST to hang when cleaning up. Actually no, it was two of them. Either one was not enough, but if two of them had been used, they would both keep on running and YaST would not exit.

It turns out the bug is in YaST not closing unnecessary file descriptors before spawning the agents. So the second child inherits a copy of the pipe that controls the first child. Then YaST closes the first child's commands pipe, expecting it to see EOF and exit. But the pipe is still open in the second child, uselessly. And they all wait. And wait...(*)

Moral: close unnecessary FDs before exec.

If you wonder why we did not see the problem earlier, it is because both agents contained another bug, a banal one of not responding to an explicit Exit message.

*) Actually, only YaST wait(2)s. The other two read(2) ;-)

Feb 26, 2009

Reducing Unprioritized Bugs

This Greasemonkey script, Check Priority, will check whether you are modifying a bug assigned to you and leaving its priority at "P5 - None". It will pop up a confirmation box to remind you to set a real priority.
Thanks to Milan VanĨura for showing us how b.n.c can be improved (check out also the local time script) and for even implementing this one as I stood behind his back!

Jan 17, 2009

Disabling the fetchmsttfonts update

I learned about a new icon of the update applet yesterday, the blue one for optional updates. I wanted to say "I don't want this particular optional update, thank you". But how?
Short: to disable the fetchmsttfonts update, remove pullin-msttf-fonts.
YES # zypper rm pullin-msttf-fonts
Long:
I tried to add a lock on the patch, but it did not seem to have any effect.
NO  # zypper addlock --type=patch fetchmsttfonts     # or al -t patch
After looking in the raw update metadata (updateinfo.xml.gz), I found the solution: remove the package pullin-msttf-fonts, with the first mentioned command.
Curiously enough, also other guesses at adding locks do not work, in a different way:
OK  # zypper al fetchmsttfonts
This adds a lock for the new package that fetches the fonts. The lock actually does what I want, in a different way: it installs the patch but omits the new package. It is also the most obvious command.
NO  # zypper al pullin-msttf-fonts
This is different in that pullin-msttf-fonts is already installed. List-updates still lists the patch as needed but halts on a solver conflict when trying to install it. The locks seem to take effect only when committing the transaction, not when checking for the updates.

But still, I would like to have a clickety way for this. Am I spoiled?

Jan 10, 2009

YaST UI table usability

I've just watched my wife delete a repository in the YaST Qt UI: She right-clicked the table item, nothing. She pressed Delete, nothing. Only then she noticed the Delete push-button below the table.
Obviously we can improve the usability: Delete should be handled the same way as a function key so that YCP receives the `delete event. That would be quite easy. Maybe the context menu is doable too.

Nov 10, 2008

BbOoOoTt: Parallel Dual Boot

On my laptop I have a work partition with a stable release and a test partition with a development release. Here I want to show you how I set it up to work with both of them at once, using VirtualBox.

The idea is that if virtualization enables you to run an additional machine on an additional (virtual) disk represented by an image file, it should also be able to operate on the actual disk and in this way convert dual booting from serialized to parallelized. And indeed VirtualBox can do it and the documentation is in its manual, chapters 9.9 "Using a raw host hard disk from a guest" and 9.9.2 "Access to individual physical hard disk partitions".

Prerequisites

Caution: accessing one file system from two machines at once is a sure way to corrupt it and lose data. VB gives you some protection but you still have to be careful. One thing, you must not share a swap partition between the two systems. Also, make sure that you do not have the other system's partition mounted, especially as a "quickie" on /mnt.

Setting up

Change this according to your needs:
DISK=/dev/sda
SWAP=5
ROOT=6
Give yourself access rights to the other system's partitions (LOGNAME is preset by bash):
sudo setfacl -m u:$LOGNAME:r $DISK
sudo setfacl -m u:$LOGNAME:rw $DISK$SWAP $DISK$ROOT
Copy the bootloader of the other system to a file:
dd if=$DISK$ROOT of=/tmp/boot.bin bs=512 count=1
Create a virtual disk to refer to the other system's partitions:
VBoxManage internalcommands createrawvmdk -register \
-filename ~/.VirtualBox/VDI/other-system.vmdk \
-rawdisk $DISK -partitions $SWAP,$ROOT \
-relative -mbr /tmp/boot.bin
That's quite a mouthful so let's go over the options:
  • register is a convenience setting that attaches the created disk to the VB disk manager.
  • filename is the virtual disk being created and it must be an absolute path.
  • rawdisk is the device of the whole target disk.
  • partitions restricts the access to these partitions. Other partitions will be visible but appear to contain only zeroes.
  • relative means that we will be able to drop access rights to the whole disk (see the next command) and retain only those to the used partitions
  • mbr specifies bootloader code to be used (partition info is still taken from the real MBR). That is important since in my case the real MBR references GRUB's menu.lst from sda1. That partition will appear as empty and GRUB would fail with "Error 17". So I give VB the boot record of the other system which references menu.lst on its own, visible, partition.
Then give up rights we no longer need:
sudo setfacl -x u:$LOGNAME $DISK
Now create a new machine in VB and attach the vmdk to it.
(there is a CLI way but I just clicked in the GUI)

Running it

Make sure that the other partitions are not used: (Hmm, VB should do that by itself. Must file a bug for that...)
sudo swapoff $DISK$SWAP
sudo umount $DISK$ROOT
Click Play and have a lot of fun.

If you used the defaults when partitioning, you will not get very far because the initrd will not find the disk. The bootloader refers to it by its ID but it is no longer /dev/disk/by-id/ata-TOSHIBA_MK8032GAX_Y6EAT0PKT-part6 but rather .../ata-VBOX_HARDDISK_VB22889591-0c34ac94-part6. The workaround is to edit the GRUB menu on the fly (ESC, Enter, (E)dit, ..., (B)oot) and to replace the long strings by the short names like /dev/hda6. The fix is to use paths from /dev/disk/by-uuid.

Aug 28, 2008

Osmarender Tweaks

I have made a couple of simple tweaks to the Osmarender rules and styles: Red Arrows for Oneway Streets, Residential Buildings, Hiking Trails. Images included!

TODO: make it easy to render it yourself.

Coordinates:

Aug 25, 2008

OpenStreetMap Diaries via a GeoRSS Box Filter

OpenStreetMap has this nice feed of its users' diaries, so that you can get all excited about the progress that fellow mappers have done near you. Now if you actually try to follow that feed, you may notice, as did I, that the problem is in the word near, which is the missing piece. It does not help to learn about new developments on another continent.
Fortunately (and unsurprisingly) the feed is GeoRSS so we can filter its contents based on the coordinates supplied with most diary entries. I did not find such service on the Web so I wrote it myself: a GeoRSS Box Filter. You say geofilter.php?url=...&minlat=...&maxlat=...&minlong=...&maxlong=... and it filters the given feed according to the given bounding box. If you omit the url, it defaults to the above mentioned OSM diary feed, and the bounding box defaults to Czechoslovakia.
More examples? How about the United Kingdom? or Georgia? (The Export tab is handy to get the numbers, BTW) To watch for uploaded GPS traces, use geofilter.php?url=http://openstreetmap.org/traces/rss. I wonder what other interesting feeds you can find to experiment with (but I did not try anything else than RSS 2.0).
Oh, and I worked on this all on the company time because it's Hack Week3 now, yay!

Jul 14, 2008

cnetworkmanager 0.7.1

Cnetworkmanager is a command-line client for NetworkManager, intended to supplement and replace the GUI applets. So far it is a single python script. What is new in version 0.7.1:
  • it does not need a configuration file anymore:
    cnetworkmanager -C publicnet
    cnetworkmanager -C myessid --wep-hex 112234445566778899aabbccdd
    cnetworkmanager -C another --wpa-psk-hex \
     112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00
  • it works with NM 0.6 (tested on Ubuntu 8.04 Hardy and a pre-release OLPC) in addition to the older support for NM 0.7pre (tested on openSUSE 11.0)
What is still left to do:
  • sooner:
    • specifying the key as a non-hex passphrase
    • reading the configuration stored by the GNOME nm-applet
    • possibility to quit after a connection is established
  • later:
    • more encryption schemes (WPA2?)
    • more connection types (dial-up, VPN)

Jul 8, 2008

Cultural Exchange 4: First YaST

Managed to compile and run YaST up to nfs-client and ntp-client. Of course it does not work properly, but makes for a nice Potemkin hamlet.

Fresh libzypp needs cmake 2.6 but there is only 2.4 in .debs. Fortunately the cmake authors provide a binary tarball with 2.6, only one has to know where to put the contained directories.

Notes for clean-up: Libzypp should say it needs hal-storage and boost-filesystem too. Python-bindings should check for python-dev, should use python-config. Perl does not seem to respect vendor_arch for ycp.pm?

Jul 7, 2008

Cultural Exchange 3: First .deb

Started to build YaST. Managed to compile yast2-core. Now going to make it repeatable by properly packaging the dependencies. The first one is blocxx. Bleeding edge stuff is in the Build Service: home:mvidner:debian. The post How to make debian standard debs from scratch was much helpful.

Tried to print and failed miserably. The setup tool would not work with a remote CUPS printer, kept asking for my password. Switching AppArmor from enforcement to complain mode did not help, nor did disabling it.

The development package for openssl is libssl-dev (openSUSE: libopenssl-devel). http://packages.debian.org/ helps with that.

Perl packages, named perl-Foo-Bar on openSUSE, are usually named libfoo-bar-perl on Debian.

Packaging system started to complain that packages cannot be verified.

(Cultural Exchange is my long term project of working with Ubuntu instead of openSUSE. TODO: make a permanent index page.)