[Pkg-xen-devel] [OCAML 6/7] Create 2 ocaml packages, libxen-4.1-ocaml and libxen-4.1-ocaml-dev.

Jonathan Ludlam Jonathan.Ludlam at eu.citrix.com
Fri Nov 18 14:13:34 UTC 2011


On 18 Nov 2011, at 11:59, Ian Campbell wrote:

> On Wed, 2011-11-16 at 12:04 +0000, Jon Ludlam wrote:
>> This is is an update of patch 6 sent yesterday. Changes are:
>> 
>> * The packages it creates are now named libxen-4.1-ocaml and
>>   libxen-4.1-ocaml-dev as per Stéphane's suggestion. The
>>   dependencies have been tweaked similarly. The generated debs
>>   have fields that look like:
>> 
>> (libxen-4.1-ocaml)
>> Depends: ocaml-base-nox-3.12.0, libc6 (>= 2.4), libxen-4.1 (>= 4.1.2)
>> Provides: libxen-4.1-ocaml-dedh4
>> 
>> (libxen-4.1-ocaml-dev)
>> Depends: libxen-4.1-ocaml (= 4.1.2-1), ocaml-findlib (>= 1.1), ocaml-nox-3.12.0
>> Provides: libxen-4.1-ocaml-dev-dedh4
>> 
>> * Removed a stray explicit '4.1' that should have been $(VERSION)
>>   in the rules.real file 
>> 
>> * Removed the explicit 'Architecture: all' statements in favour 
>>   of letting the autogeneration do it.
>> 
>> * Moved both ocaml packages into the 'ocaml' section.
>> 
>> * Use @ocaml_stdlib_dir@ and @ocaml_dll_dir@ in the template 
>>   install files.
>> 
>> OCAML_STDLIB_DIR and OCAML_DLL_DIR are still not being taken from
>> the standard place (/usr/share/ocaml/ocamlvars.mk or via
>> dh_ocamlinit). The main reason is that the xen debian files
>> already have in place a system for preprocessing the x.install.in
>> files to create x.install files using variable substitution. It
>> would be awkward to have to have _some_ variables substituted by
>> debian/bin/gencontrol.py, generating an intermediate template
>> which is then subjected to additional variable substitutions by
>> dh_ocamlinit. Additionally, dh_ocamlinit attempts to operate on
>> any file underneath the debian/ subdirectory that ends in '.in',
>> so it works on the same set of files that gencontrol.py works
>> on. This doesn't cause problems, but it does litter the templates
>> directory with half-processed unnecessary files.
> 
> Does dh_ocamlinit support the standard debhelper -p<package> option to
> restrict this?
> 

No, I don't think it does.

>> The other available method for getting OCAML_STDLIB_DIR is by
>> including the makefile fragment /usr/share/ocaml/ocamlvars.mk in
>> debian/rules. If we did this, we'd have to pass the value on to
>> gencontrol.py. This is doable, but again a little awkward. It
>> would also require that dh_ocaml was installed on the system on
>> which the control file was being generated, which would not fail
>> gracefully.
> 
> gencontrol.py already depends on linux-support-X.Y and fails in not an
> especially graceful manner:
>        $ ./debian/rules debian/control-real
>        debian/bin/gencontrol.py
>        Traceback (most recent call last):
>          File "debian/bin/gencontrol.py", line 6, in <module>
>            from debian_xen.debian import VersionXen
>          File "/local/scratch/ijc/development/debian/pkg-xen.git/xen/debian/bin/../lib/python/debian_xen/__init__.py", line 19, in <module>
>            _setup()
>          File "/local/scratch/ijc/development/debian/pkg-xen.git/xen/debian/bin/../lib/python/debian_xen/__init__.py", line 16, in _setup
>            raise RuntimeError("Can't find %s, please install the linux-support-%s package" % (support, version))
>        RuntimeError: Can't find /usr/src/linux-support-3.0.0-1, please install the linux-support-3.0.0-1 package
>        make: *** [debian/control-real] Error 1
> 
> compare with:
>        $ git diff
>        diff --git a/xen/debian/rules b/xen/debian/rules
>        index aade4fb..afdd8f9 100755
>        --- a/xen/debian/rules
>        +++ b/xen/debian/rules
>        @@ -3,6 +3,12 @@
>         # Uncomment this to turn on verbose mode.
>         #export DH_VERBOSE=1
> 
>        +ifneq ($(wildcard /nonesistent/foo.mk),/nonesistent/foo.mk)
>        +$(error /nonesistent/foo.mk not found. Please install foo-dev)
>        +else
>        +include /nonesistent/foo.mk
>        +endif
>        +
>         DEB_HOST_ARCH  := $(shell dpkg-architecture -qDEB_HOST_ARCH)
>         DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
> 
>        $ ./debian/rules debian/control-real
>        ./debian/rules:7: *** /nonesistent/foo.mk not found. Please install foo-dev.  Stop.
> 
> (maybe there is a more make-ish way to achieve this)
> 
> In any case you have a similarly opaque dependency on whichever package
> provides ocamlc.
> 

That's true. I'll come up with another version that uses a mechanism like this to get the vars
and passes them into gencontrol.py then - Bastian can then pick whichever one he likes best :-)

>> So the patch below generates the two variables in the same way
>> that both the makefile fragment and dh_ocamlinit do - by
>> executing 'ocamlc -where' and appending /stublibs. I've left a
>> comment immediately above this line stating where to look to find
>> these runes in case they do change.
> 
>> Comments most welcome!
> 
> My comments on the patch are mostly just nitpicking.
> 
>> 
>> Jon
>> 
>> ---
>> xen/debian/bin/gencontrol.py                     |   12 ++++-
>> xen/debian/patches/series                        |    1 +
>> xen/debian/patches/tools-ocaml-fix-build.diff    |   60 ++++++++++++++++++++++
>> xen/debian/rules                                 |    2 +-
>> xen/debian/rules.real                            |   34 ++++++++++++
>> xen/debian/templates/control.main.in             |   16 ++++++
>> xen/debian/templates/control.source.in           |    5 ++-
>> xen/debian/templates/libxen-ocaml-dev.install.in |   25 +++++++++
>> xen/debian/templates/libxen-ocaml.install.in     |   14 +++++
>> 9 files changed, 166 insertions(+), 3 deletions(-)
>> create mode 100644 xen/debian/patches/tools-ocaml-fix-build.diff
>> create mode 100644 xen/debian/templates/libxen-ocaml-dev.install.in
>> create mode 100644 xen/debian/templates/libxen-ocaml.install.in
>> 
>> diff --git a/xen/debian/bin/gencontrol.py b/xen/debian/bin/gencontrol.py
>> index f2b7424..30a9978 100755
>> --- a/xen/debian/bin/gencontrol.py
>> +++ b/xen/debian/bin/gencontrol.py
>> @@ -1,6 +1,6 @@
>> #!/usr/bin/env python
>> 
>> -import os, sys
>> +import os, sys, subprocess
>> sys.path.append(os.path.join(sys.path[0], "../lib/python"))
>> 
>> from debian_xen.debian import VersionXen, PackageFieldList
>> @@ -49,6 +49,11 @@ class Gencontrol(Base):
>>             j = self.substitute(self.templates["xen-utils.%s" % i], vars)
>>             file("debian/%s.%s" % (package_utils_name, i), 'w').write(j)
>> 
>> +	for (i,j) in (('libxen-ocaml.install','libxen-%s-ocaml' % self.version.xen_version), 
>> +		      ('libxen-ocaml-dev.install','libxen-%s-ocaml-dev' % self.version.xen_version)):
>> +	    k = self.substitute(self.templates[i], vars)
>> +	    file("debian/%s.install" % j, 'w').write(k)
> 
> I think either i and j should both include the ".install" suffix or
> neither of them should.
> 

Yeah, that seems reasonable. It was this way due to the evolution of the patch. I'll adjust it accordingly.

>> +
>>         cmds_binary_arch = ["$(MAKE) -f debian/rules.real binary-arch-arch %s" % makeflags]
>>         cmds_build = ["$(MAKE) -f debian/rules.real build-arch %s" % makeflags]
>>         cmds_setup = ["$(MAKE) -f debian/rules.real setup-arch %s" % makeflags]
>> @@ -103,8 +108,13 @@ class Gencontrol(Base):
>>     def process_changelog(self):
>>         changelog = Changelog(version = VersionXen)
>>         self.version = changelog[0].version
>> +        # Nb. Check /usr/share/ocaml/ocamlvars.mk for OCAML_STDLIB_DIR and OCAML_DLL_DIR
>> +        ocaml_stdlib_dir = subprocess.check_output(["ocamlc", "-where"]).rstrip()
>> +        ocaml_dll_dir = ocaml_stdlib_dir + "/stublibs"
>>         self.vars = {
>>             'version': self.version.xen_version,
>> +            'ocaml_stdlib_dir': ocaml_stdlib_dir,
>> +            'ocaml_dll_dir': ocaml_dll_dir,
>>         }
>> 
>> if __name__ == '__main__':
>> diff --git a/xen/debian/patches/series b/xen/debian/patches/series
>> index 8f816da..a576794 100644
>> --- a/xen/debian/patches/series
>> +++ b/xen/debian/patches/series
>> @@ -57,3 +57,4 @@ tools-ocaml-fix-xc-dependencies.diff
>> tools-ocaml-remove-uuid.diff
>> tools-ocaml-remove-log.diff
>> tools-ocaml-fix-xc.diff
>> +tools-ocaml-fix-build.diff
>> diff --git a/xen/debian/patches/tools-ocaml-fix-build.diff b/xen/debian/patches/tools-ocaml-fix-build.diff
>> new file mode 100644
>> index 0000000..52fa7d5
>> --- /dev/null
>> +++ b/xen/debian/patches/tools-ocaml-fix-build.diff
>> @@ -0,0 +1,60 @@
>> +Fix the build of the ocaml libraries 
>> +
>> +Signed-off-by: Jon Ludlam <jonathan.ludlam at eu.citrix.com>
> 
> Please can you also post this to xen-devel. (assuming it is relevant
> there, it looks like it).
> 

Sure. I'll need to check it works first :-)

> Ian.
> 
> -- 
> Ian Campbell
> Current Noise: Zyklon - Two Thousand Years
> 
> Wisdom is knowing what to do with what you know.
> 		-- J. Winter Smith
> 




More information about the Pkg-xen-devel mailing list