Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to package MATLAB for internal distribution, but this could apply to any piece of software with the same architecture. In fact, I'm packaging multiple releases of MATLAB to be installed concurrently. Key things

  • Very large installation size (~4 GB)
  • Composed of a core, and several plugins (toolboxes)

Initially, I created a single "source" package (matlab2011b) that builds several .debs (mainly matlab2011b-core and matlab2011b-toolbox-* for each toolbox). The debian/rules file is just the standard

 dh $@

There is no Makefile; only copying files. I use a number of debian/*.install files to specify files to copy from a copy of an installation to /usr/lib/.

The problem is, every time I build the thing (say, to make a correction to the core package), it recopies every file listed in the *.install file to e.g debian/$packagename/usr/ (the build phase), and then has to bundle that into a .deb file. It takes a long time, on the order of hours, and is doing a lot of extra work.

So my questions are:

  • Can you make dh_install do a hardlink copy (like cp -l) to save time? (AFAICT from the man page, no.) Maybe I should just get it to do this in the Makefile? (That's gonna be a big Makefile.)
  • Can you make debuild only rebuild .debs that need rebuilding? Or specify which .debs to rebuild?
  • Is my approach completely stupid? Should I break each of the toolboxes into its own source package too? (I'll have to do some silly templating or something, because there's hundreds of them. :/)
share|improve this question
up vote 1 down vote accepted

1. You can make dh_install do whatever you want by adding this to debian/rules:

    dh_install # if you still want to use some things via *.install files
    cp -l src/foo debian/$packagename/usr/share/$matlabname/foo
    cp -l tools/bar debian/$packagename/usr/share/$matlabname/tools/bar
    # etc...

I don't know if this is a good idea though...

2. Yes, though not as straightforward as one might wish...

You could call debhelper commands individually:

dh_prep -p$packagname
dh_installdirs -p$packagname
dh_install -p$packagname
dh_installdeb -p$packagname
dh_gencontrol -p$packagname
dh_md5sums -p$packagname
dh_builddeb -p$packagname

Probably needs adjusting for your case, see

man debhelper

for the list of available dh_* commands

3. I think I would prefer doing it all in one package, but I'm unsure, splitting into several source packages has it's own problems...

share|improve this answer
I ended up just leaving it the way it is and letting it take forever to create the packages. I intend to incorporate your ideas eventually. I tinkered with breaking it out into multiple packages, but it meant that I had to maintain a bunch of largely duplicated ./debian directories. I'm making multiple releases of MATLAB, so I ended up making some templating scripts with Python anyway. – nfirvine Oct 18 '12 at 19:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.