I Might Be Wrong

Howto build a trivial Debian package with dh_make

Posted in Debian, Ubuntu by Leif Ryge on May 18, 2011

Building a Debian package can be complicated. If you’re in a hurry to build a really simple package, you might find the available documentation (such as the Debian New Maintainers’ Guide) overwhelming. Maybe you just want to install some files with dpkg. Maybe you don’t want to deal with Makefiles. Maybe you discovered the source package for hello-debhelper (the “Hello World” of Debian packaging) uncompresses to 3.1MB. Maybe these instructions will be more helpful. Then again, maybe not.

This example will create an architecture-independent package called foo which will install an empty file at /usr/share/example/file. To install other files, just place them wherever you want them to go under the example-src directory.

mkdir foo-0.1
cd foo-0.1
dh_make --createorig --indep # this will prompt you to hit enter
mkdir essentials
mv debian/{changelog,compat,rules,control} essentials
rm -r debian
mv essentials debian
echo './example-src/* ./' > debian/foo.install
mkdir -p example-src/usr/share/example
touch example-src/usr/share/example/file # create the empty file to be installed
dpkg-buildpackage -uc -tc -rfakeroot
dpkg --contents ../foo_0.1-1_all.deb # inspect the resulting Debian package


  • In addition to these steps, you probably want to edit the debian/control and debian/changelog files.
  • The version of the package is defined by the changelog entry, which must conform to the Debian changelog format. (dh_make wrote the first entry for you, with the version taken from the name of the directory you ran it in.)
  • For reasons I haven’t investigated, if you try to put files under /usr/local/ this recipe won’t work. (There are probably other directories this will also not work for; /usr/share and /var are all that I’ve tried successfully.)
  • These instructions were tested using debhelper 8.0.0ubuntu1 and dh-make 0.55; if you find that they do not work in some newer version please leave a note in the comments.
Tagged with: , , , , , ,

Notes on dual-booting Ubuntu and MeeGo on an ExoPC

Posted in Howto, Ubuntu by Leif Ryge on April 30, 2011

I attended an Intel developer marketing event last thursday promoting MeeGo and their AppUp program, where everyone received an ExoPC tablet. Officially these are not gifts, but rather a three year loan “for engineering purposes only”: after three years we are supposed to destroy them or return them to Intel. (They said it is up to us which of those options to choose.)

I hope MeeGo is a success, and I hope to make some apps for it (although, as I am not at all interested in the AppUp DRM regime, I was glad to hear that they will allow apps to be listed in their catalog without using the AppUp apis), but first I wanted to see how a modern version of Ubuntu fares on this keyboardless tablet. The short version of this post is: it works quite well!

I was pleased to find that ubuntu-11.04-desktop-amd64.iso (copied to a USB stick with usb-creator-gtk) supports the ExoPC’s touchscreen, audio, video and wifi without any hassle. Unfortunately gparted (and thus the Ubuntu installer) does not yet support resizing btrfs, which is what MeeGo uses as its root filesystem. Luckily it wasn’t too difficult to do this manually.

I shrunk the btrfs partition down to 10GB using these commands in a root shell in the Ubuntu live environment:

mkdir /meego
mount /dev/sda2 /meego
btrfs resize 10G /meego
umount /meego

Then, using fdisk I then deleted (“d”) sda2 and recreated it (“n”) with a size of 10G, and created a new (“n”) partition sda4 in the new free space. I wrote the changes to disk (“w”), quit fdisk (“q”), and ran partprobe. Then, I ran the ubuntu installer and told it to format sda4 and use it as / and to use meego’s swap partition (sda3) for swap and to use the meego /boot (sda1) as its /boot but not to format it. Somewhat to my surprise, this all worked out fine, and I am now dual-booting MeeGo and Ubuntu from the Ubuntu grub2 menu!

I was going to create an LVM-on-LUKS crypto layer under the Ubuntu filesystem (I recently retaught myself how to do that manually from the desktop installer CD – something else I should write up a blog post about) but then realized that would mean I’d need a hardware keyboard to boot up since the passphrase is needed long before X starts. So, I held my nose and went with the “encrypt home directory” (ecryptfs) option instead.

Three caveats about dual-booting: First, interacting with grub obviously requires a usb keyboard. Second, MeeGo (aka “Unknown linux distro on sda2”) is listed twice, first with the MeeGo kernel and then with Ubuntu’s. Finally, to actually boot MeeGo it is necessary to edit the boot options to add “insmod btrfs”. I could put that line in grub.cfg so I wouldn’t need to do that every time, but it will just get overwritten on the next kernel upgrade… I haven’t yet figured out the correct way to make this type of setting stick with Ubuntu’s grub2.

I think my next step with MeeGo might be to try to boot its partition in VirtualBox using raw disk mode; if that works then I could do development on the device in Ubuntu and test on the same MeeGo system which I can also boot natively. But for now, I’m more interested in using Ubuntu. :)

I played with the new Unity desktop shell for a while, but soon switched to “Ubuntu classic” (the familiar GNOME desktop).

I installed the “Grab and Drag” firefox extension, which is nice once you get used to its physics. It should have more positions on the various sliders in its settings.

I was very pleased to discover that, when properly configured, the “onboard” software keyboard makes Ubuntu quite usable without a hardware keyboard! Unfortunately, unless I’m missing something, adding a launcher for it ironically requires another keyboard to type its name – it comes preinstalled, but is not listed in the menus or UI anywhere except on the login screen. I was especially pleased to discover the “show onboard when unlocking the screen” checkbox in its settings! Onboard also provides right-click and middle-click functionality which works in many but not all contexts.

I also installed the florence onscreen keyboard, which is nicer looking than onboard but much less usable. For instance, the firefox awesome bar steals every other keypress from florence while with onboard it works fine.

In the Appearance settings, under Fonts, I changed the dpi from the default of 96 to 135 (which is what wikipedia says the ExoPC’s screen is). This made lots of text larger, and generally made the whole UI more finger-friendly.

The ExoPC has a single button sensor at the top left of the screen. By default in Ubuntu it launches the audio player. I remapped it to the “Hide all windows and show the desktop” toggle in Keyboard Shortcuts.

I haven’t yet figured out how to get the brightness to stop changing when it is on battery power, and sometimes when I plug it back in the brightness does not return until I go to power management and use the slider. This is irritating.

I haven’t installed the broadcom CrystalHD driver yet, but I understand that doing so will improve flash video performance which is presently not great.

If you’re running Ubuntu on an ExoPC, here are some other resources with useful info:

How to extract text from PDF files using poppler and GOCR on Ubuntu

Posted in Howto, Ubuntu by Leif Ryge on July 11, 2010

Poppler provides a suite of utilities for working with PDF files. If you’re using Ubuntu, you’ve already got it installed; otherwise, see if your operating system provides a poppler-utils package.

If your PDF file contains text, you can use the pdftotext command:

pdftotext foo.pdf

If the PDF contains images of the text which you wish to use OCR on, you’ll need to extract them first:

pdfimages foo.pdf foo-page

…which will give you a bunch of files called foo-page-nnn.pbm (read man pdfimages if you’d like to only extract certain pages)

If, as in my case, the resulting images are of white text on a black background, you can correct this using the convert command from ImageMagick (run sudo apt-get install imagemagick)

for i in *pbm; do convert -negate $i $i; done

(I used the shell to iterate through the files because the convert command’s batch functionality doesn’t seem to work with pbm files.)

And, finally, use GOCR to recognize the text in the images:

for i in *pbm; do echo gocr $i; gocr $i > $i.txt; done

Note: I wrote this early last year and just today noticed it still sitting in my drafts. I’m not sure why I didn’t post it before, so I will now. Hopefully these instructions are still accurate!

Tagged with: , , , , ,