Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to create my first deb so I don't know much about it yet. This is my 'rules' file at the moment:

#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

%:
        dh $@

At the moment I'm reading documentation and trying to understand how to write more complicated 'rules' files. I'm stuck on 'binary-arch' and 'binary-indep' targets. In short I don't understand what they actually stand for.

The documentation says that package arch is determined by 'Architecture:' line in 'Control' file.

  • If the value is 'all' then the package is an architecture dependent.

  • If the value is 'any' then the package is an architecture
    independent.

I fully understand this part. But then I start reading man files for debhelper tools.

man dpkg-buildpackage says:

  1. It calls debian/rules build followed by fakeroot debian/rules binary-target (unless a source-only build has been requested with -S). Note that binary-target is either binary (default case, or if -b is specified) or binary-arch (if -B is specified) or binary-indep (if -A is specified)

man dh says:

Commands in the binary-indep sequence are passed the "-i" option to ensure they only work on binary independent packages, and commands in the binary-arch sequences are passed the "-a" option to ensure they only work on architecture dependent packages.

then I try to view the default set of commands for 'binary', 'binary-arch' and 'binary-indep' targets by typing

$ dh binary --no-act

$ dh binary-arch --no-act

$ dh binary-indep --no-act 

and get fully equal sets of commands. the only difference is '-i' and '-a' flags after each command.

So the first question is - what is the difference between for example 'dh_auto_build', 'dh_auto_build -a' and 'dh_auto_build -i' ( or some other dh_command ) ?

And another question is - if my 'control' file consists only of packages with 'all' architecture do I need to use binary-indep target, or I can do without it and use only build-arch target in my 'rules' file ?

share|improve this question

1 Answer 1

The Difference

The target binary-indep builds all Architecture: all binary packages in your source package. The target binary-arch builds all other packages, either Architecture: any or packages with an explicit architecture list or some architecture wildcards like Architecture: linux-any.

Why?

The distinction of these two paths inside the build process is relevant if you have a source package which contains both kinds of binary packages, architecture-dependent and -independent: The initial build of the package builds both types of binary packages, but every subsequent build on different architectures only needs to builds the architecture-dependent binary packages as you've already built all architecture-independent packages in the first build.

Example

Imagine you have a source package called foo which builds the binary packages foo-programs and foo-data. While the programs in foo-programs need to be compiled (e.g. because of being written in C) and hence the binary package is of Architecture: any, the data files in foo-data (images, translations, help texts, documentation, textures, game maps, etc.) are the same for all architectures, hence it's Architecture: all. Let's say the upstream version of foo is 1.0 and it's the first Debian package revision of that upstream release.

You first build all the packages on the amd64 architecture for 64-bit PCs, you'll get foo-programs_1.0-1_amd64.deb and foo-data_1.0-1_all.deb. But you also want to be able to run it on 32-bit PCs, hence you also need foo-programs_1.0-1_i386.deb. But you don't need a second foo-data_1.0-1_all.deb, so your build process only requires the *-arch targets, e.g. by calling dpkg-buildpackage -B.

Necessity of Explicit Targets

With the minimal dh style debian/rules it may not needed to explicitly specify targets, since many upstream build systems don't make this distinction, but if they do (e.g. by having a separate make target for building the documentation, you can implement that e.g. like this:

#!/usr/bin/make -f
%:
        dh $@

override_dh_auto_build-indep:
        $(MAKE) -C docs

(Example taken from the dh(7) man page.)

share|improve this answer

Your Answer

 
discard

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.