dh-make-drupal - Easily debianize Drupal modules, themes

Submitted by gwolf on Tue, 02/10/2009 - 14:51

I have spent a couple of days working into dh-make-drupal. Yes, you guessed right: An idea based on the wonderful dh-make-perl, but applied to the Drupal Content Management System.
Drupal's greatest strengths, IMHO, are:

  • Drupal offers a huge number of modules and themes
  • Drupal has an amazingly sane configuration handling, where -contrary to what usually happens in PHP-land and, in general, among webapps- you set up the code only at a single place, with only the site-specific configuration (usually a single file) handling all of the differences

Yup, even though I am quite fond of its flexibility and power, I fell for Drupal in no small part because of its sysadmin-friendliness.

Now, I hate having non-Debian-packaged files spilled over my /usr/share partition. Drupal modules want to be installed in /usr/share/drupal5/modules/module_name (or s/5/6/ for Drupal6, to which I have not yet migrated). For that reason, over the last year I have been growing my personal apt repository of Drupal stuff. Yes, it is still on, and I don't plan on taking it off. You can access it by adding deb http://www.iiec.unam.mx/apt/ etch drupal to your /etc/apt/sources. However, you can now also do the process locally. Do you fancy the wonderful Biblio module? Or the very nice Abarre theme? Great!

  1. 0 gwolf@mosca『4/tmp$ ~/code/dh-make-drupal/dh-make-drupal --drupal 5 biblio
  2. 0 gwolf@mosca『5/tmp$ cd drupal5-mod-biblio-1.16/
  3. 0 gwolf@mosca『6/tmp/drupal5-mod-biblio-1.16$ debuild -us -uc >& /dev/null
  4. 0 gwolf@mosca『7/tmp/drupal5-mod-biblio-1.16$ cd ..
  5. 0 gwolf@mosca『8/tmp$ su
  6. Password:
  7. 0 root@mosca[1]/tmp# dpkg -i drupal5-mod-biblio_1.16-1_all.deb
  8. Selecting previously deselected package drupal5-mod-biblio.
  9. (Reading|> database ... 275110 files and directories currently installed.)
  10. Unpacking drupal5-mod-biblio (from drupal5-mod-biblio_1.16-1_all.deb) ...
  11. Setting up drupal5-mod-biblio (1.16-1) ...


Yes, still many more things to come (i.e. including the debuild call and whatnot), but... Enjoy!

BTW, this piece of software owes a couple of beers to Why the lucky stiff, author of Hpricot. You are insane (but we are all well aware of that). You deserve to go to the webscraping heaven. Yes, besides the programming-languages-teaching-cartoon heaven. You find out how to split the time between them.

[Update]: Of course, ITP bug #514786 has been filed, and I will soon be uploading this into Debian.

( categories: )
Nadezhda's picture

Nadezhda was here ;) :*

Nadezhda was here ;) :*

Andrey Chernomyrdin's picture

dh-make-drupal not properly work

I try to use dh-make-drupal under unstable
- --
$ dh-make-drupal biblio
ERROR: No suitable version found for Drupal 6 (level>=recommended)
$ dpkg -l dh-make-drupal
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
ii dh-make-drupal 0.4-2 Create Debian packages from Drupal modules a

may be design of page http://drupal.org/project/* was changed and html parse get worng data ?

gwolf's picture

Aware of the fact...

Thanks a lot - this was reported to me as bug #561946 in the Debian BTS. I will look into the problem and upload a new version as soon as possible.

Roel de Cock's picture

Making a local package?

I've had success packaging some standard Drupal mods, like Views, so I thought I might try to package a locally-edited theme as well. To test this, I simply copied the 'pushbutton' theme into a local directory 'testing' and tried to package it as follows:

  1. cd /tmp/t
  2. cp -a /usr/share/drupal6/themes/pushbutton ./testing
  3. mv testing/pushbutton.info testing/testing.info
  4. tar czf testing.tar.gz testing
  5. dh-make-drupal -T Themes -t testing.tar.gz -V '1.0' testing

This makes a directory drupal6-thm-testing-1.0 with the unpacked tarball and a debian/ subdir, and then bails out with "ERROR: can't convert nil into String". I've tried --debug 5, which only gives:

  1. drupal_version: 6
  2. project: !ruby/object:DrupalProject::Project
  3. descr: Generated from a local file - Sorry, cannot even fetch a proper description!
  4. name: testing
  5. p_type: !ruby/object:DrupalProject::ProjType
  6. key: Themes
  7. version: "1.0"
  8. D: Starting Debian package creation
  9. D: Original tarball verified - 53 files included
  10. I: Debian package name: drupal6-thm-testing
  11. D: Author copyright information not found

Am I doing it wrong, or am I touching upon uncharted territory?


gwolf's picture

Copyright information required

Oh! Well, this comes as a surprise, but then again, it does not... that much.

Thing is, Debian packages _require_ having a debian/copyright file. And all Drupal projects include that information in a couple of places:

Has the GPLv2, which is the only license accepted by the Drupal repository. In fact, my code just checks whether it is the exact file (by looking at its MD5 digest), or marks it as unknown
The Drupal web site
The actual name of the author is downloaded from the "profile-full-name" element of the page linked at the "info-page" element of the project's page

So, in short, what do I suggest? Try creating a LICENSE.txt. Even if it contains rubbish. It should work. If it does, please tell me. If it does not, please... Tell me as well! :)

(And, yes, I'm fixing it for the next release)

Roel de Cock's picture

That nailed it...

Thanks for the prompt advice, that worked.

BTW I haven't tried it, but I suppose that dpkg --purge won't have the desired effect with modules that add their own stuff to the Drupal database- you'll still have to use Drupal's own uninstall first to remove any module-specific remainders, right?

Anonymous's picture

More dependencies...

I found a couple unspecified dependencies that I needed (fresh Ubuntu 10.04):

  • dpkg-dev
  • debhelper

After installing those, everything worked great!

Also, I realized that if I specified the Drupal module's name with any capital letters, it would fail... switching to all lower case fixed that problem.

Anyway, thanks for creating and publishing this utility!

gwolf's picture

Fixed since April... Just after that Ubuntu release :-/

dh-make-drupal 0.6-2 includes the needed changes - but I uploaded it in April, by which time Ubuntu 10.04 was already out. Thanks for the report, though!