[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

how to build a package conditionally?



Hi,

I'm maintaining a package (geomview) whose source is free, but parts
of it require a non-free library (xforms) to compile.  Currently, the
debian source package builds a single package that omits the programs
that require xforms.  There is a wishlist bug requesting that a second
package be created containing the extra bits.  That seems like a
reasonable request.  How do I do it?

The current geomview package is in "main", because it is DFSG free.
The second package, however, would need to be in "contrib", since it
uses the non-free "xforms" package.  To me, the main problem is that I
don't want to build the second ("geomview-contrib") package
unconditionally, because of the autobuilders.  I'd like to have the
default behaviour of running "dpkg-buildpackage" to be that only the
main geomview package is built.  But one should be able to trigger a
build of both the main and the contrib packages.

Is there a recommended way to achieve this?

I thought about using a special target.  But the building scripts,
like "dpkg-buildpackage" or "debuild" seem to only operate on the
"binary" target of debian/rules.  Using a special target becomes
awkward: you'd have to sign the packages by hand, for example.

Instead, I settled on using an environment variable to conditionally
define the "binary" target, as follows:

	ifeq (contrib,$(findstring contrib,$(DEB_BUILD_OPTIONS)))
	binary-arch: binary-geomview binary-geomview-contrib
	else
	binary-arch: binary-geomview
	endif

This seems to do precisely what I want.  But is using
DEB_BUILD_OPTIONS okay?  If so, is there a string that is generally
used to trigger builds of optional packages?  

-Steve


P.S. Can I do anything about the different "Build-Depends"
requirements for the contrib package?



Reply to: