// Dynamic debian/control and launchpad recipes

Problem

Avoid build of a specific package (remmina-plugin-spice) for a specific ubuntu serie (trusty) and for a specific hardware architecture (armhf) remaining compatible with launchpad recipe building system.

14.04 (Trusty) 15.04 (Wily) 16.04 (Xenial) 16.10 (Yakkety)
amd64 (Ok) (Ok) (Ok) (Ok)
i386 (Ok) (Ok) (Ok) (Ok)
armhf (Ko) (Ok) (Ok) (Ok)

(non) bash script solution

The most natural way to solve the problem was create a debian/control template where put placeholders and set them with a script accordingly with the ubuntu serie and the hardware architecture where the build was made.

Few minutes and the solution was working but … the launchpad recipes building system not allow to run scripts so it wasn't a viable solution.

debian/rules script solution

No on-line documentation handle the argument so I scratched my head for a while looking possible solutions.

Looking around I found some debian/control.in files in already downloaded ubuntu package sources and in particular libgtk-3-0 has this kind of solution.

build system

Launchpad recipes are based on a bazaar plugin named bzr-builder with the limitation that the run command is disabled (that could have saved us).

The sistem architecture is, for each ubuntu serie a package source is created and uploaded on different hardware architectures of the same serie to be built.

debian/rules solution

Luckily we can customize the debian/rules makefile to create a different debian/control during the source package creation of each ubuntu serie.

implementation

identify the ubuntu serie

the too comfortable lsb-release is not available in the reduced building system so you must manipulate the /etc/os-version file to extract the ubuntu serie:

UBUNTU_SERIE=$(shell grep '^VERSION=' /etc/os-release | sed 's/^[^"]*"//g;s/".*//g;s/^[^,]*, *//g;s/ .*//g;s/\(.*\)/\L\1/g')

Now you can use the UBUNTU_SERIE variable to assign conditionally other variables:

ifeq ($(UBUNTU_SERIE),trusty)
        REMMINA_PLUGIN_SPICE_ARCHITECTURES=amd64 i386
        REMMINA_PLUGIN_SPICE_BUILDDEPS_ARCHS=[!armhf]
else
        REMMINA_PLUGIN_SPICE_ARCHITECTURES=amd64 i386 armhf
        REMMINA_PLUGIN_SPICE_BUILDDEPS_ARCHS=
endif

create different debian/control

During the source package preparation the clean target of debian/rules is required, attaching to it a dependency to debian/control file in the proper way guarantees that code associate to it in the makefile script will be called before source packaging; to do it the target clean is defined with the special the special double column suffix :: syntax.

Double column allow to define rules that are always called also if other target matches the target.

    . . .
debian/control::
        dh_testdir
        sed \
                -e "s#@REMMINA_PLUGIN_SPICE_BUILDDEPS_ARCHS@#$(REMMINA_PLUGIN_SPICE_BUILDDEPS_ARCHS)#g" \
                -e "s#@REMMINA_PLUGIN_SPICE_ARCHITECTURES@#$(REMMINA_PLUGIN_SPICE_ARCHITECTURES)#g" \
                $@.in > $@

%:
        dh $@ --dbg-package=remmina-dbg

clean:: debian/control
        # gross kludge to force control generation with the %.in target
        touch debian/control.in
    . . .

The complete example could be found in this branch of my remmina fork.

The working recipe could be found on lounchpad, here.

QR Code: URL of current page
QR Code: URL of current page start (generated for current page)
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported