Posts tagged ·



perceptualdiff – compare images perceptually

Comments Off

I recently found myself needing to compare bitmap images, to see if they were about the same. The images were from Gnuplot generate graphs, and I wanted to check whether subtle changes in the data had not introduced unexpected changed to the plot. A simple binary diff told me that there were indeed some differences, however, comparing them manually was not possible.

Enter the handy tool perceptualdiff, which lets you compare TIF and PNG images based on a perceptual metric. It actually goes beyond simple bitwise pixel diff, and tries to compare based on a model of the human visual system. Consider the examples below, and it is clear that it is a useful tool. It makes it easy to see where the small differences were introduced. (As it turns out, it is only the result of the two plots being generated on different machines, with different versions of Gnuplot and possibly also different available fonts).

The tool is in the Fedora repository, so a simple yum is enough:
yum install perceptualdiff

To generate an output diff image, this command does the job:
perceptualdiff -output diff.ppm image1.png image2.png

Comments Off

USB Smart Card Reader

Comments Off

Just got another shipment from Deal Extreme. This time a USB Smart Card Reader. It’s for reading my soon to arrive Free Software Foundation Europe fellowship card. However, all I had to try out with so far were old redundant bank cards. And that seemed to work without problems.

The reader came with a cute mini-CD with Linux drivers, but they were not required to get it running. Following the page at FSFE, the reader was up in minutes. Confirm that these two are installed; in my case they were:

yum install libusb pcsc-lite

Add the udev rules and group as indicated by the FSF howto, and restart X if necessary.

I also installed yum installed pcsc-tools, and could detect cards by running


Comments Off

Anonymous, Decentralized and Uncensored File-Sharing

Comments Off

The file-sharing landscape is slowly adjusting in response to the continued push for more anti-piracy tools, the final Pirate Bay verdict, and the raids and arrests in the Megaupload case“, starts a recent TorrentFreak article. It goes on to introduce Tribler, and RetroShare, which “[creates] a private space on the Internet. A social collaboration network where you can share anything you want. A space that is free from the prying eyes of governments, corporations and advertisers. This is vitally important as our freedom on the Internet is under increasing threat. RetroShare is free from censorship: like Facebook banning ‘obscene’ breast-feeding photographs. A network that allows you to use any pseudonym, without insisting on knowing your real name. A network where you will not face the threat of jail, or being banned from entry into a country for an innocent tweet“.

For RetroShare, there are pre-compiled installs for several OSes and GNU/Linux distributions, however not for Fedora. So I downloaded the source, and tried to compile with a bit of help from this page. First, some dependencies:

yum install qt-devel gpgme-devel libgpg-error-devel libupnp-devel libssl-devel libgnome-keyring-devel openssl-devel glib2-devel libXScrnSaver-devel

It turns out there is an old, widly published bug in the glib-2.0 include path dependencies. To work around it, edit the file libretroshare/src/, find these lines, and add the third line, marked in blue:

# These two lines fixe compilation on ubuntu natty. Probably a ubuntu packaging error.
INCLUDEPATH *= /usr/lib/x86_64-linux-gnu/glib-2.0/include/
INCLUDEPATH *= /usr/lib/i386-linux-gnu/glib-2.0/include/
INCLUDEPATH *= /usr/lib64/glib-2.0/include

Furthermore, there are a couple of missing library dependencies:

Edit retroshare-gui/src/, find the “## Linux ##” section, and add the last three libraries marked in blue:

LIBS += ../../libretroshare/src/lib/libretroshare.a
LIBS += -lssl -lgpgme -lupnp -lixml -lXss -lgnome-keyring -lcrypto -ldl -lX11

Then the make steps should work fine:

cd libbitdht/src
qmake-qt4 && make
cd libretroshare/src
qmake-qt4 && make
cd retroshare-gui/src
qmake-qt4 && make

And to start up:

Comments Off

Pipe Viewer – ETA for pipes

1 comment

DP has a nice write-up on the pv (for pipe viewer) command. One of his examples goes like this; also try it without the redirect to /dev/null.

for i in {1..21}; do date -d "`date +%m`/$i/`date +%Y`"; sleep 1; done | pv -leps 21 > /dev/null

To install on Feodra:

yum install pv

UNetbootin – Create bootable Live USB sticks

Comments Off

UNetbootin is one of those small, not well known, yet extremely useful tools which can save you a lot of time. In a few clicks, it let’s you create a boot image from a long list of distros, and format that right out to a USB stick. With many of the distros, you can choose between Live or Net Install images, and from versions a few years back in time. If you’ve already downloaded the ISO image for you distro, that’s OK, but it will even do that job for you if you like.

The list of supported distros is impressive, from the most popular ones, to more obscure (here in random order): Ubuntu, Debian, Linux Mint, openSUSE, Arch Linux, Damn Small Linux, SliTaz, Puppy Linux, gNewSense, FreeBSD, NetBSD, Fedora, PCLinuxOS, Sabayon Linux, Gentoo, MEPIS, Zenwalk, Slax, Dreamlinux, Elive, CentOS, Mandriva, LinuxConsole, Frugalware Linux, xPUD, Foresight Linux, VectorLinux, Slackware, Smart Boot Manager (SBM), xPUD.

To get going in Fedora:

yum install unetbootin syslinux-extlinux

If you don’t run as root, you will be prompted for the root password:


Comments Off

Git server on Fedora

Comments Off

This covers setting up a SSH access controlled Git server from scratch. It’s assuming there is no other repository to import from. It is loosely based on the instructions from Chapter 4 of the Pro Git book.

Installing Git is simple. You might also want to grab gitk for visualizing your commits and branches, and kdiff3 for merging changes.

yum install git gitk kdiff3

Initial setup might include configuring your name, and editor. “—-global” means that the configuration will be stored under ~/.gitconfig.

git config --global "John Doe"
git config --global

git config --global core.editor emacs

git config --global merge.tool kdiff3

Create an empty repository, and clone it into a “bare” repository. Actually, I’m not sure if the first step is strictly necessary, since the “clone” is “init” + “fetch”.

You might also want to create a root level directory, or alternatively a symbolic link from root, e.g. /git. This will make it easy to reference when cloning and working from remote computers.

mkdir /tmp/git_empty
git init /tmp/git_empty

mkdir /git
cd /git
git clone --bare /tmp/git_empty test.git

Now you can clone (the still empty) repository by the following. Notice the optional port number, if you have SSH running on a different port than the default 22. Notice also, since the port argument is specified, ssh protocol has to be prefixed explicitly.

git clone ssh://

Finally, after adding, changing and committing to the new local clone, these changes can be “pushed” back to the server. Conversely, the updates on the server can be “pulled”.

git push origin master

git pull

Comments Off

Building Android on Fedora


Here’s a brief command-by-command guide to building Android 4 (ICS -Ice Cream Sandwich (with extra sugar on top)) from scratch, and deploying the new images on the Samsung Galaxy Nexus, all from Fedora 16. This is heavily based on the Free your Android article, and of course the instructions at

First, install the supporting packages. (Instead of the OpenJDK version, you might have to download the Oracle one, if you get version conflict errors at the make step below.)

yum groupinstall "Development Tools"
yum install java-1.6.0-openjdk kernel-devel git gnupg flex bison gperf zip curl zlib-devel glibc-devel glibc-devel.i686 ncurses-devel.i686 glib-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686 mesa-libGL-devel.i686 readline-devel.i686 arm-gp2x-linux-gcc-c++ python-markdown xmlto libxslt

Download the source. The final sync command will take about an hour.

curl > ~/bin/repo
chmod a+x ~/bin/repo

mkdir android
cd android

repo init -u
repo sync

Download proprietary binaries and drivers. They are available here:

Assuming the Galaxy Nexus – GSM/HSPA+ (“maguro”), there’s two drivers. (Please check the link above for new versions).

tar zvxf imgtec-maguro-iml74k-a796ffae.tgz
tar zvxf samsung-maguro-iml74k-de1cc439.tgz

Build, still assuming the same phone as above. On my somewhat dated dual core 2.6 GHz CPU, it took almost four hours to compile.

source build/
lunch full_maguro-eng
make -j4

Then, transfer the image files to the phone. Make sure the phone is connected over USB, is unlocked, and has USB debugging enabled. After the images are transferred, and the userdata and cache partitions are erased, the phone will reboot. It will show the Android logo, reboot one ore two times more, and then wait maybe a minute or two before the UI is available. And there it is, your home-built Android OS.

out/host/linux-x86/bin/adb reboot bootloader
sudo out/host/linux-x86/bin/fastboot -w -p maguro flashall

If something, or everything, failed and you are left with a useless phone, here are the factory images from Google. Download and unpack the archive corresponding to your phone, and run the script

For more details on “unbricking” your phone, see Derek Ross’ comment.

Skype on Fedora 16, 64 bits


Skype on Linux was always a bit of a drag to install, and for some reason a 64 bits version is not available for Fedora. It is unlikely to change now that Microsoft bought the whole shop. Luckily, the old 32 bits version still works, with a few tricks.

After downloading the RPM, install with

yum install skype-

Get the 32 bits versions of these libraries:

yum install libv4l.i686 pulseaudio-libs.i686 alsa-plugins-pulseaudio.i686

And finally, make sure you have these binaries:

yum install

Thanks to drjolo and tuxor for these fixes.

Cool Linux games on Fedora

1 comment

Linux might not be famous for its games, however there are still plenty around. You will not find the latest Call of Duty, though. Rather, there is a long list of classics and small and fun games. From the Scumm based offerings from Revolution, to remakes of classics like Freeciv, LinCity, and Ultimates Stunts.

Fedora offers a dedicated “spin” installation for games, which offers more than hundred small and big games. Below is a random pick of a few favourites, along with their RPM package names.

As far as I understand, many of them are OpenGL based, or require a properly configured graphics card to run.

  • Beneath a Steel Sky – beneath-a-steel-sky-cd
  • Lure of the Temptress – lure
  • Flight of the Amazon Queen – flight-of-the-amazon-queen-cd
  • Freeciv – freeciv
  • Glaxium – glaxium
  • Mania Drive – maniadrive
  • Ultimates Stunts – ultimatestunts
  • Tremulous – tremulous
  • Abuse – abuse
  • LinCity – lincity-ng

And to install them all!

yum install beneath-a-steel-sky-cd lure flight-of-the-amazon-queen-cd freeciv glaxium maniadrive ultimatestunts tremulous abuse lincity-ng

Arduino, Fedora 15, and the gpsd incompatibility

1 comment

Even though the Arduino is very popular amongst makers and other electronics hobbyist, it is still a fringe platform in most settings. And even though the arduino package is available through many repositories, more testing would be welcome.

In the latest packages in Fedora 15, things have broken down in several ways. Tom Trebisky does a good job of guiding you through the pitfalls here. He has further useful notes on Arduino here.

What had me going mad was this message: “avrdude: stk500_recv(): programmer is not responding”. Everything seemed to be fine, the lights were blinking when connecting, the logs looked normal, and what’s more, all my boards worked when programmed on another system, but not on my Fedora 15 at home! Furthermore, the error seemed to be half sporadic. Sometimes it would fail at once, while other times it got a bit further before it stopped.

Tom writes: “On a hunch (having watched the messages via dmesg when I plug in my arduino) I get rid of gpsd“. And that was my problem as well. The gpsd daemon was some how conflicting with the ttyUSB device. One option to remove it would be

service gpsd stop
killall gpsd
yum erase gpsd

However, in my case I could not remove the gpsd package because it was a dependency of another application I wanted. In the end, I simply renamed the binary (/usr/sbin/gpsd), so it would not be automatically activated when I plug in the Arduino. Maybe not so elegant, but I could finally get to work with more fun stuff.

Personal Fedora 15 Installation Guide


Here my notes for my Fedora 15 install, again based on Mauriat Miranda’s guide. After you’ve gotten the DVD, this assumes you’re installing on a new 64 bits system, rather than upgrading.

A pleasant addition to the installation process is the ability to add the standard repositories (and any other repositories if you like). This means after a finished install, all basic packages will be up to date.

Third Party Repositories
You’ll need them for various patent encumbered libraries and apps, for playing MP3, DVD, etc.

sudo rpm -ivh
sudo rpm -ivh

Main Packages
For normal use

yum -y install audacity autossh digikam feh geeqie gimp gnupg gnucash gthumb gtkpod htop hugin ImageMagick k3b-extras-freeworld kdebase kdegraphics kino ktorrent lame-mp3x libcddb liberation-fonts-common liberation-mono-fonts liberation-narrow-fonts liberation-sans-fonts liberation-serif-fonts mplayer mencoder mjpegtools mozplugger mp3gain obexfs libreoffice-calc libreoffice-writer parcellite pidgin-otr thunderbird ufraw ufraw-gimp xine xine-lib-extras xine-lib-extras-freeworld xmms xmms-faad2 xmms-mp3 xmms-pulse

For development

yum -y install ant arj bash-completion dosbox dvdauthor dvgrab easymock easytag emacs enblend git gitk gnome-terminal gnome-system-monitor gnuplot htop iftop java-1.6.0-openjdk java-1.6.0-openjdk-javadoc java-1.6.0-openjdk-plugin java-1.6.0-openjdk-src joda-time joda-time-javadoc kdiff3 kover ncftp OpenEXR OpenEXR_Viewers python-dateutil python-mox qemu-launcher qtpfsgui quicksynergy rdesktop rssh subversion transcode unrar vcdimager vdr-mp3 vlc w3m wine wireshark-gnome

MPlayer Codecs

wget -O /tmp/all-20110131.tar.bz2
mkdir -p /usr/lib/codecs
tar -jxvf /tmp/all-20110131.tar.bz2 --strip-components 1 -C /usr/lib/codecs/

DVD Playback

wget -O /tmp/libdvdcss-1.2.10-5.fc15.x86_64.rpm
wget -O /tmp/libdvdcss2-1.2.10-5.fc15.x86_64.rpm
yum --nogpgcheck localinstall /tmp/libdvdcss2-1.2.10-5.fc15.x86_64.rpm /tmp/libdvdcss-1.2.10-5.fc15.x86_64.rpm

Change the SSHD port

You might want to run SSHD on a different port than 22 to avoid the worst influx of random attacks. For this example, let’s go for port 222.

In /etc/ssh/sshd_config, uncomment the Port setting, and change the number to 222.

Port 222

In /etc/sysconfig/iptables, add a line to accept incoming connections on this port. If you like, you can always keep the old as well.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 222 -j ACCEPT

Then, tell SELinux to accept this port by executing as root

semanage port -m -t ssh_port_t -p tcp 222
semanage port -l | grep ssh

Finally, restart the SSHD and iptables daemons. You can now test the new port by logging in locally:
/etc/init.d/sshd restart
/etc/init.d/iptables restart

ssh -p 222 localhost

Adding users

In the last versions of Fedora, the default user and group IDs moved from starting at 500 to start at 1000. However, you might want to keep the old IDs for compatibility with old external drives, NFS mounts, etc. You can and new users with custom user/group IDs simply by

adduser -u 500 myuser

Transferring from an old system

Finally, if you have and old system you need to transfer stuff from, you might want to remember:

  • Crontabs: /var/spool/cron
  • SSH keys: /home/*/.ssh

You might also want to reinstall or retune a few other settings:

Backup over ssh/rsync with rssh restricted user

1 comment

For a backup system to work and be of value when something goes wrong, it needs to have these properties:

  • Fully automated: If you have to think about, you will forget or skip it.
  • Off site storage: RAID will not prevent fire or theft; nor accidentally deleting the wrong file.
  • Secured transfer and access: The backup drive can also be stolen or corrupt.

For the transfer, this already restricts the number of tools to pick from: scp, sftp, rsync. And assuming the files to transfer are large, while bandwidth is limited and/or uptime of source/destination systems are limited is only one left: rsync. It is the only tool which is able to resume a previous transfer.

Rsync can use the ssh protocol to transfer files, thus securing the connection. Furthermore, it can utilize the automated authentication through public key. It does require an ssh server on either source or destination though, which will have to be available on the Internet. Thus it’s necessary to take a few security precautions. Not running sshd on the standard port 22 will already filter out a lot of attacks, so let’s pick another port, e.g. 222.

** First try

For this example, let’s assume a pull-backup, that is the destination machine requests files from the source (user foo at where the original backup file is located. Typically, this will happen on a regular interval, through a cron job. For example, we could imagine running this command every hour (assuming some lock file so we don’t disturb an ongoing sync):

rsync --bwlimit=25 --checksum --partial -e "ssh -p 222" -r /backup

  • bwlimit will limit the transfer to 25 kilo bytes / second, to avoid saturating the line.
  • checksum verifies the file checksum, rather than assuming they are the same only based on size and date.
  • partial enables resuming the download.
  • -e “ssh -p 222″ sets the SSH port used by the source.
  • -r syncs recursivly into directories.

The problem with the last option, though, is that it will overwrite existing files on the destination. Imagine a backup file getting corrupt on the source; it will now propagate the same error to the destination and render both files useless. Thus, instead of syncing a whole directory, we’ll have to find a way to select files to transfer. I wont go into that here, so maybe it will be a later post.

** Automated login

For the above line to work as part of a cron job, the destination has to be automatically authenticated. Public key authentication with SSH is fairly simple to set up. On the destination machine (which is the client in the ssh connection), run this command to generate a key. Do not set a password. Then copy the key over to the source machine (still assuming it runs SSH on port 222).

ssh-keygen -t dsa

scp -P 222 ~/.ssh/

On the source machine, copy the keyfile to its correct location. Assuming .ssh and authorized_keys do not already exist.

mkdir ~/.ssh
chmod 700 ~/.ssh
cp /tmp/ ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

You should now be able to log in from destination to source without having to enter a password:

ssh -p 222

** Restricted shell

The basic feature of ssh is to give you a shell on the remote host. However, in our situation, we’ve just granted the destination machine, and anybody there full access to our machine. We might want to restrict this a bit; only allowing the rsync command to run, without other access. rssh handles this. On the source machine, install rssh, and make sure whatever user is using this shell is in the rsshusers group.

yum install rssh

usermod -a -G rsshusers -s /usr/bin/rssh foo

Modify /etc/rssh.conf and enable rsync access by uncommenting allowrsync.

** Ready to backup

Now everything should be ready to run. I’ll still skip some of the details of the backup script, but assume there is a file on the source machine which lists which file to copy. (Alternatively, lists all file so we can compare what we have and don’t have on the destination). Furthermore, it is assumed that each backup file comes with a corresponding checksum file, e.g. .MD5. The beginning of a script might look like this:

alias backup="rsync --bwlimit=25 --checksum --partial -e 'ssh -p 222' --protocol=29"

backup /tmp
[Determine which file to transfer next, e.g. filename.tar.gz]

backup /backup
backup /backup

There’s a few things to note here:

  • An alias, backup, is used to avoid repeating all the options every time.
  • Since we run sshd on port 222, we have to use the -e option. However rssh will not accept this. The option –protocol 29 is used to work around this incomparability in rsync / rssh. (Unfortunately, it seems rssh is not maintained any more).
  • The list file is assumed to contain the list of available backup files, so we can compare to the files already on the destination machine.
  • The main file and its .md5 file is transferred separately, with the .md5 last. This is so we can use that as a flag to mark a finished transfer. If the transfer of the main file is interrupted, we can resume it when the .md5 is not yet there.

Fedora 15: Upgrade

Comments Off

The latest upgrade of Fedora, to version 15, was anything but smooth this time. The release included so many radical changes, so I’m guessing the focus has been to get the basics working, while skipping corners on minor issues. Apart from the switch to Xfce, and some smaller adjustments to Firefox, here’s the problems I ran into, and some workarounds:

  • I had several packages stuck from older version, some from F12. The CD upgrade did not stall on this, but subsequent yum upgrade did. Removing the packages resolve the issue:yum remove openbios-common joda-time-javadoc flash-plugin
  • gThumb had one of its dependencies broken due to a name change, removing and reinstalling fix that.
    yum remove gthumb libclutter-gtk
    yum install gthumb
  • xine-lib needed manual updating, for some reason
    yum update xine-lib

Finally, there were some hiccups with the video driver and Xinerama in Xfce. The problem was that the ATI Catalyst settings tool kept mis-configuring the xorg.conf file. It was juggling three screens and two video card sections, while I only have two screens attached to the same card. In the end, I had to manually edit the file.

While resolving that, I also bumped into the change to systemd. It no longer reads /etc/inittab, but instead has its configuration under /etc/systemd/system. The concept of runlevels is still transferable, though. And to set another runlevel by default, link in the corresponding target file:
ln -sf /lib/systemd/system/ /etc/systemd/system/
ln -sf /lib/systemd/system/ /etc/systemd/system/

For more on systemd, see the FAQ.

Comments Off

Switching from Gnome to Xfce

1 comment

I’m not the only one stalling on the new Gnome 3 / Shell UI, and looking for alternatives. Also, it seems I’m not the only one settling on Xfce as a replacement for Gnome 2. It’s a lightweight desktop, and strikingly similar to that of old Gnome and KDE. Basic panels, work spaces, window handling and customization is all in place.

To install after a plain Fedora install:

yum groupinstall XFCE

In Fedora 14, version 4.4 was available, while Fedora 15 includes the significant upgrade to Xfce 4.8. This caused a few problems, since I had already started switching in F14, and after upgrading, all my panels and launchers failed.

It was not to hard to transfer from the old Gnome 2 panels, though. Basic plug-in in the notification area was actually brought along fine, including parcellite, networking, and even Dropbox. For the “drawers” in Gnome, Xfce uses “launchers”. It’s the same idea. And what’s more, the 4.8 version also uses the .desktop short-cut files. To copy from a Gnome 2 “panel / drawer” to a Xfce launcher, provided one already exists (It might not work 100%, but you get the idea):

grep -r -l panel_3 $HOME/.gconf/apps/panel | xargs grep stringvalue | grep desktop | tr '<' '>' | cut -f 3 -d '>' | while read f; do d=`locate -n 1 $f`; cp $d $HOME/.config/xfce4/panel/launcher-11.; done

You might also want to style and theme the look a bit, including the buttons on the windows. I set the Window Manager Theme to “Stoneage”, and increased the title font to 11. Under Settings -> Appearance, I’ve gone for “ClearlooksClassic”, “Fedora” icons, and 14 as default font (since I sit far away from the screen).

Under Window Manager Tweaks I was first confused by the “wrap workspaces” options. However, they seem to have been cancelled out by Xinerama or something else.

The default taskbar clock does not have a calendar, so go for the “Orange Clock” instead. I replaced the visible line with “%H:%M”, and the tooltip with “%a %d %b %Y/%V”.

And that’s all there is to it, really. Xfce does not have many “native” application, but all GTK+ based ones run fine, include what I’ve tried from Gnome and KDE: gThumb, K3b, and Gnome Terminal.

Java 7 Released

1 comment

Oracle (finally) released Java 7 today, 4 years and 7 months after the initial release of Java 6. The previous version updates used to be on a 18 months schedule, so that makes this release 37 months late. It’s getting a pretty good bashing on Slashdot, primarily for its current owner, Oracle.

New features includes syntactic sugar like Strings in switch statements; underscores in numeric literals; and type inference for generic instance creation. The Open JDK site lists the same features, so I’m guessing that means everything is open sourced already. However, it seems smaller items on my wish-list did not make it, like the Immutable annotation. (The JSR 305 has been inactive for ages, and still the only implementation is a Google Code hosted project.)

The new Java Doc is here, and latest download from Oracle here. The Open JDK binaries are also available in the repositories of major distributions.

yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel

sudo apt-get install openjdk-7-jre openjdk-7-jdk