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:
- 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 ?
Best Answer
The Difference
The target
binary-indep
builds allArchitecture: all
binary packages in your source package. The targetbinary-arch
builds all other packages, eitherArchitecture: any
or packages with an explicit architecture list or some architecture wildcards likeArchitecture: 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 packagesfoo-programs
andfoo-data
. While the programs infoo-programs
need to be compiled (e.g. because of being written in C) and hence the binary package is ofArchitecture: any
, the data files infoo-data
(images, translations, help texts, documentation, textures, game maps, etc.) are the same for all architectures, hence it'sArchitecture: 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 getfoo-programs_1.0-1_amd64.deb
andfoo-data_1.0-1_all.deb
. But you also want to be able to run it on 32-bit PCs, hence you also needfoo-programs_1.0-1_i386.deb
. But you don't need a secondfoo-data_1.0-1_all.deb
, so your build process only requires the*-arch
targets, e.g. by callingdpkg-buildpackage -B
.Necessity of Explicit Targets
With the minimal
dh
styledebian/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 separatemake
target for building the documentation, you can implement that e.g. like this:(Example taken from the
dh(7)
man page.)