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

Re: Novice to Debian packaging



On Thu, Nov 17, 2011 at 03:07:03PM +0000, Ludovic Brenta wrote:

> Nicolas, would you have time to write at least a one-page description of
> ALDH for the novice packager, as an appendix in the Debian Policy for
> Ada? That would make it possible for more packagers to consider using
> it the next time they upgrade their packaging scripts.

Hello. Sorry for the delay.

Working on gtkada, which contains many libraries, revealed other
limitations of the trick for medium-sized packages.

- The macro list may contain numerous unrelated macros (SOVERSION and
DEB_HOST_MULTIARCH for example. I think that I would have seen sooner
that expanding the latter in debian/README.Debian which is installed
in the /usr/share/doc/libNAMESOVERSION arch-indep directory, was an
error if all expansions had been mentioned in debian/rules)

- Related informations are split into separate files (lib*.so and
symlink are separated, lib*.so for different libraries are together)

- The early preprocessing makes it more difficult (yet) to figure in
which order the files are read by the dh/debhelper suite.

In short, I would recommend to use debhelper overrides inside
debian/rules instead of ALDH when possible.

- This is more readable than lots of files containing one line each.

- There is no additional learning or understanding cost, since
understanding overrides is needed anyway for things like dh_strip and
dh_compress.


However, this is only my opinion, and here is an explanation of ALDH
motivation and usage. For example, I will give three ways to install a
library.


With debhelper overrides (I recommend that)
------------------------

# in debian/rules
# assuming the LIB_PKG, SOVERSION and DEB_HOST_MULTIARCH macros are defined
override_dh_install:
	dh_install --package=$(LIB_PKG) lib/lib$(LIB_NAME).so.$(SOVERSION) usr/lib/$(DEB_HOST_MULTIARCH)
        # Probably other install commands here
	dh_install --remaining-packages

The target, if it exists, is called by dh when it reaches this step.


With aux debhelper files (avoid that if you can)
------------------------

# in a file named debian/libfoo4.install
lib/libfoo.so.4 usr/lib/gnu-intel-x86

The file, if it exists, is parsed by any call to dh_install concerning
the libfoo4 package (for example the default dh call when it reaches
this step, or your override, or…). The problem is then that you need
to modify and rename the file each time the SOVERSION changes.


With aux debhelper files and ALDH (the same, but easyer to maintain)
---------------------------------

# Put the ALDH snippet in debian/rules

# in a file named debian/ALDH.LIB_PKG.install, put:
# This file will be preprocessed and renamed by debian/rules.
lib/libLIB_NAME.so.SOVERSION usr/lib/DEB_HOST_MULTIARCH

ALDH is only a short part of the debian/rules Makefile that searches
files whose name starts with "ALDH." in the debian/ subdirectory,
preprocesses them and renames them according to some macros. This
happens before any usual Debian target ( [ build | binary ] - [ arch |
indep ] | install). The file is destroyed when the clean target is
called.

The trick was motivated by the dh_* tools file name convention, but
was useful for debian/ALDH.README.Debian or anything that needs
preprocessing.

The snippet follows. In case you cut and paste it, please check that
the two lines starting with tabulations were preserved, and edit the
ALDH_macros list according to your own needs.


############################
# Ada Library Debian Helper
############################

# Each file named debian/ALDH.oldname is preprocessed and renamed
# according to the following macros, before any build or install.
# The preprocessed file is removed before any clean.
# The macros need to be defined higher in this Makefile.

ALDH_macros := \
  ALIVERSION \
  DBG_PKG \
  DEB_HOST_MULTIARCH \
  DEV_PKG \
  DOC_PKG \
  LIB_NAME \
  LIB_PKG \
  SONAME \
  SOVERSION

# You should not have to read the following, unless you use
# double-colon rules for the usual Debian targets.

ALDH_sed := sed $(foreach ALDH_macro,$(ALDH_macros),\
  -e s/$(ALDH_macro)/$($(ALDH_macro))/g)

clean: ALDH_clean
.PHONY: ALDH_clean

define ALDH_template

build build-arch build-indep binary binary-arch binary-indep install: $(2)
$(2): $(1)
	$(ALDH_sed) $(1) > $(2)

ALDH_clean::
	$(RM) $(2)

endef # ALDH_template

$(foreach ALDH_file,$(wildcard debian/ALDH.*),\
  $(eval $(call ALDH_template,\
    $(ALDH_file),\
    $(shell echo $(ALDH_file) | $(ALDH_sed) -e s/ALDH.//))))


Reply to: