This site is best viewed in Firefox.

Oona 6 Years Old!

Sunday, 14 June 2009

Wow, this friday (June 12th) my daughter turned six! I can hardly believe it is six years since she came into our lives, time has gone by so quick ... when she was born we still lived in Västerås, now she has a younger brother and we live in a great house in Skultuna.

Happy birthday, Oona! I wish you all the best now that you're starting first year of school after the summer vacation. I know you're thrilled about it, as are we, your proud parents. :-)

Posted by Joachim Nilsson at 21:04 in /personal | Permalink

Editline First Post

Sunday, 14 June 2009

For a while now I've been maintaining a port of Minix editline library libedit. Mainly for my own purposes, or rather on behalf of Westermo WeOS, where it is used in the CLI. This library is the same as the Debian editline package, even though the origin of that package is somewhat unclear to me.

Today I decided to adjust the package name and bump the version number to indicate that my port is the same, and now slightly more advanced, than the Debian version. To that end I've now changed the repository name and prepared for merging with Debian. Getting this work accepted back into Debian is a completely different issue.

Get the code as a Bazaar branch, or view its change log through the Loggerhead web interface:

I now intend to do some further integration work, adapting the debian/ directory from editline-1.12-5 and smoothing out any remaining issues before I release 1.13.0.

Posted by Joachim Nilsson at 20:44 in /hacks | Permalink

HowTo use Git for Collaborative Development

Saturday, 13 June 2009

This is mainly some notes for myself so I don't forget. Having worked with GNU Bazaar before much of Git is still alien to me.

This HowTo is divided into two parts, 1) what happens on your laptop, and 2) what you must do on a remote server where you publish your changes.

laptop> mkdir projectX; cd projectX
laptop> git init
laptop> emacs file1.txt
laptop> git add file1.txt
laptop> git commit -m "Initial commit"

Thus far no suprises, right? Now, some nasty git bits:

laptop> emacs file1.txt
laptop> git commit

Yep, doesn't work. You have to add -a to the command line for "all".

laptop> git commit -a

OK, so next item. How to publish this so others can see? Well, I have a shell account on a remote server, so I naturally try:

laptop> git push sftp://login@example.com/pub/git/projectX.git
fatal: I don't handle protocol 'sftp'

Does not work. OK, next obvious choice:

laptop> git push ssh://login@example.com/pub/git/projectX.git
fatal: '/pub/git/projectX.git': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly

Wow, not a clue as to how I should proceed. After some Google-Foo I found this article detail the steps for remote repos. Very messy, compared to Bazaar.

laptop> ssh login@example.com
server> cd /pub/git
server> mkdir projectX.git; cd projectX.git
server> git --bare init
server> logout
laptop> git remote add origin ssh://crash@vmlinux.org/pub/git/tetris.git
laptop> git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://login@example.com/pub/git/projectX.git'
> git push origin master
Counting objects: 29, done.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (29/29), 9.54 KiB, done.
Total 29 (delta 10), reused 0 (delta 0)
To ssh://login@example.com/pub/git/projectX.git
 * [new branch]      master -> master

Eventually I made it sing. The first "git push" must use the references to origin and master. At least you don't have to care about that later, after the first push command git remembers what you want.

Only one thing left, in the gitweb project overview projectX is listed as having no description. Of course, since I'm starting to get to know git by now, I realised early this is probably not something that is propagated through push — yep, I was right. You have to change that on the server.

laptop> ssh login@example.com
server> cd /pub/git/projectX.git
server> echo "Secret Project-X use ROT13 to decode all source files" >description
server> logout

All done! *phew*

Posted by Joachim Nilsson at 00:36 in /programming | Permalink

Micro Tetris™

Saturday, 13 June 2009

I just published the unobfuscated version of the 1989 IOCCC Best Game entry, Tetris™. See the original author, John Tromp's home page for the game for details. But suffice it to say, this is an extremely bare bones version of the classic game and very similar to the BSD games' version.

Actually, this similarity in board layout, key combinations and feel led me to do some archaeological digging. I dowloaded the BSD games collection and, after having called GNU Indent on the obfuscated code, I started noticing such extreme similarities that just could not be coincidental. The layout and constructs of the code are virtually the same, so I can only conclude that they must share the same ancestor. Maybe this code is that ancestor, considering that the BSD Tetris is copyrighted in 1992 and this version stems from 1989, it is maybe not a completly illogical conclusion.

See for yourself.

Posted by Joachim Nilsson at 00:04 in /hacks | Permalink

Heh

Friday, 12 June 2009

NerdTests.com says I'm a Dorky Nerd God.  Click here to take the Nerd Test, get
                                nerdy images and jokes, and write on the nerd forum!

Posted by Joachim Nilsson at 19:53 in /misc | Permalink

More about Bzrweb and some about Git

Friday, 12 June 2009

OK, I admit it. I cannot decide what version control system (VCS) to use. I'm stuck between the speed and massive snow ball effect of Git and the ease of use and emotional attachment I have to Bazaar.

I've been "maintaining" bzrweb for a while now, not doing a very good job of it though. It's lagging behind considerably to the bzr API. After the upgrade of vmlinux.org to the latest Ubuntu server release bzrweb actually didn't work at all. If it hadn't been for the fixes by Rasmus Toftdahl Olesen I would probably have abandoned it entirely. Thank you Rasmus! Anyway, I've been gleaning at other Bazaar web frontends for a while. The only real option is Loggerhead, but even though I consider myself a computer pro I just cannot seem to wrap my head around how to set it up. I just wanted to setup a local browser for my user, without the need for root access. Like bzrweb supports, after having abandoned that, seemingly radical idea, I tried setting up a site wide shared installation ... no luck so far. :-/

In comparison to Loggerhead I easily managed to setup a Git repository browser, using a /pub/git structure, see git.vmlinux.org. The gitweb package in Ubuntu was very easy to setup, the one only thing I had problem with was the Apache VirtualHost setup. Some sleep cured that, but I should post the conf here, in case someone else experiences trouble.

I'll have another go at setting up Loggerhead later, or perhaps try to fixup bzrweb. I'm currently leaning towards fixing up bzrweb. Fix bugs viewing tree files, refactor tarball export and a new project summary page, are some of the most interesting things I can come up with. If only things could settle down at work for a while — oh well, vacation is coming up. Soon, my precious, soon...

First, however, I will publish the micro vt100/ansi tetris version I found last week. It will be the second project where I use Git, the first one was cons, which is a Xen xm wrapper for non privileged users.

Some Git and Bazaar links:

Posted by Joachim Nilsson at 19:50 in /programming | Permalink

Current Meme

Thursday, 11 June 2009

Posted by Joachim Nilsson at 01:37 in /misc | Permalink

Howto Setup and run Xen

Monday, 08 June 2009

This is an extremly brief and quick Xen tutorial. There are lots of them already, see your <DISTRIBUTION> wiki, HowtoForge or other places for a starter guide. This particular HowTo deals with setting up Xen as easy as possible using Ubuntu 8.04 LTS as host operating system (dom0 in Xen terms) and Ubuntu 9.04 as guest operating systems (domU in Xen lingo).

Ubuntu 8.04 LTS comes with a Xen kernel that can run as dom0. This is quite important, so pay attention to setting that up correctly. For this I recommend the HowtoForge Tutorial.

Note: you will need to upgrade the default Xen 3.2 to 3.3 to be able to run the latest distributions as guest OS. See this Ubuntu question for more insight. To get Xen 3.3, simply activate the Hardy backports repository in your /etc/apt/sources.list and, as usual, pay attention to your /boot/grub/menu.lst so that it points out the Xen 3.3 image in the "defaults=" option.

More useful help can be found in the Debian and Ubuntu wikis:

When done with the basic setup you should install pygrub on your host, this is a truly magic piece of software that makes it possible to boot all guests using their own kernel and modules. See the Debian wiki for some details on install and setup: http://wiki.debian.org/PyGrub. Then ignore what you read and do like this:

# /var/lib/xend/domains/example/config.sxp - Xen domU example.
# Note the order of partitions in disk=[], the first listed partition
# is the partition where your /boot (grub) resides. 
bootloader  = '/usr/bin/pygrub'

builder     = 'linux'
memory      = '2048'
root        = '/dev/xvda1 ro'

disk        = [
 'phy:/dev/disk/by-uuid/df3418f5-2fc3-443c-8e64-4395828dc678,xvda1,w',
 'phy:/dev/disk/by-uuid/acecf01e-c4d9-4a7b-b18a-681c69f71173,xvda2,w',
]

name        = 'example'

vif         = [ 'bridge=eth1' ]
dhcp        = "off"
ip          = "12.34.56.78"
netmask     = "255.255.255.252"
gateway     = "12.34.56.77"
hostname    = "example"

on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
vcpus       = 1
extra       = 'xencons=tty1'

When installing grub on your guest, don't pay any attention to grub complaining about not being able to map /dev/xvda1 to a BIOS disk. pyGrub doesn't care about such wordly things as physical disks. Just make sure the /boot directory's partition (often '/') is the first listed in the disk=[] array above.

You may need to edit the /usr/sbin/update-grub script before installing grub. Search for "in_xen", a fairly long way down. Make sure it's set to in_xen=1 before the big if[]-clause that depends on it. Without this fix the Xen able kernels in Ubuntu 9.04, and later, are not detected.

Now run update-grub and answer yes to the questions. Take good care to verify that the script actually finds one active (server) kernel and adds it properly to your /boot/grub/menu.lst file.

Another common problem is the lack of a console login. Usually you don't need one, but if you'd like to check your domU from within your dom0 you need to add the file "console" to /etc/event.d

# console - getty
#
# This service maintains a getty on the Xen serial console
# from the point the system is started until it is shut
# down again.

start on stopped rc2
start on stopped rc3
start on stopped rc4
start on stopped rc5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec /sbin/getty 38400 console

That should do the trick! If it doesn't, then there's plenty of help to find in the Debian and Ubuntu wikis, see links above. Good luck!

Posted by Joachim Nilsson at 22:05 in /unix | Permalink

In all Fairness...

Monday, 08 June 2009

... I must say that despite the negative comments I've put up here on my blog about Ubuntu it's really a great GNU/Linux distribution! I'm now running 9.04 on my laptop and everything is working just fine, including Network Manager!

Admittedly NM and I haven't really been the best of friends, but our relationship has matured a great deal since we first met.

I've even tried other desktops, KDE, fvwm-crystal, WindowMaker, AfterStep and the ultimate evilwm. All good old acquaintances but I always return to my Gnome desktop, with only a few regressions back to evilwm now and then. The only problem there is I have no NetworkManager! :-)

So, I apoplogize for all the harsh words, Ubuntu!

Posted by Joachim Nilsson at 21:52 in /ubuntu | Permalink

Emacs regexp replace in many files

Tuesday, 02 June 2009

  1. M-x find-dired
  2. Run find in directory: 'top directory to recurse'
  3. Run find (with args): -name *.[ch]
  4. A dired listing pops up
  5. Select/Mark all files, type: % m and press enter
  6. M-x dired-do-query-replace-regexp
  7. Query replace regexp in marked files: 'seach regexp'
  8. Query replace 'NNN' with: 'replacement text'
  9. You will now be prompted for each file with a math to do replace, just like you would a regual M-C-% search.

Note: regexp back references are allowed in the replacement text.

Posted by Joachim Nilsson at 14:44 in /emacs | Permalink