create new tag
view all tags

Using the LCFG Build Tools on Debian

Support for building Debian packages with the LCFG Build Tools was added in version 0.9.18 which was released on Friday 18th January 2019.

For useful information on Debian packaging see DebianPackaging

Creating Debian packaging metadata

To build a project as a Debian package there needs to be a debian sub-directory which contains all the necessary metadata. This is the equivalent of the RPM specfile with which people will already be familar. The biggest difference from a specfile being that with Debian packages there are separate files for each aspect of packaging (e.g. the build/install process, controlling which files appear in a package, handling package scripts).

A tool to generate the necessary Debian package metadata is provided. This uses the lcfg metadata (stored in the lcfg.yml file) and examines the contents of the project directory, it does NOT make any attempt to parse the specfile. What is generated is intended to be a good starting point, it should be adequate for a standard LCFG component package or a simple project with a single package. For more complex projects with various sub-packages the Debian metadata will need to be editted manually.

The metadata is generated using the gendeb command like this:

% lcfg-reltool gendeb
No version-control information in the LCFG metafile for this project.
Auto-detected that the SVN module should be used.
LCFG: Creating debian/compat metadata file
LCFG: Creating debian/control metadata file
LCFG: Creating debian/copyright metadata file
LCFG: Creating debian/docs metadata file
LCFG: Creating debian/postinst metadata file
LCFG: Creating debian/postrm metadata file
LCFG: Creating debian/prerm metadata file
LCFG: Creating debian/rules metadata file
LCFG: Creating debian/lcfg-file.service metadata file
LCFG: Creating debian/source/format metadata file
LCFG: Creating debian directory 'debian'
LCFG: Please review the debian directory for this project

The tool attempts to add all the new files to the version-control system. It's a good idea to review what has changed before committing:

% svn status
A       debian
A       debian/compat
A       debian/control
A       debian/copyright
A       debian/docs
A       debian/lcfg-file.service
A       debian/postinst
A       debian/postrm
A       debian/prerm
A       debian/rules
A       debian/source
A       debian/source/format

Anything in the debian sub-directory which has a ? (question mark) prefix will need adding if it is required.

Once you are happy with the changes then they should be committed and a new release should be tagged:

% svn commit -m "Added debian packaging metadata" debian
% lcfg-reltool minor

Once the debian sub-directory exists the behaviour of the LCFG build tools will be changed. For example, whenever a release is tagged the debian/changelog file will be updated and Debian source files will be generated whenever commands such as pack and devpack are used (which are called be rpm and devrpm).

Building Debian Packages Manually

When the source for a project is packed (e.g. as part of calling pack, devpack, rpm or devrpm) the Debian source files will be generated. This avoids bootstrapping issues by making it possible to pack the source on a non-Debian machine and then copy the files over to a Debian machine for building the binary packages. This can be done like this:

% cd lcfg-example
% lcfg-reltool pack
No version-control information in the LCFG metafile for this project.
Auto-detected that the SVN module should be used.
LCFG: Successfully exported the source tree.
LCFG: Successfully generated cmake files.
Successfully generated metadata files for RPM
LCFG: Successfully generated source tar file.
LCFG: Tar file is: /afs/inf.ed.ac.uk/user/s/squinney/lcfgbuild/lcfg-example-1.2.40/lcfg-example-1.2.40.tar.gz
LCFG: Debian Tar file is: /afs/inf.ed.ac.uk/user/s/squinney/lcfgbuild/lcfg-example-1.2.40/lcfg-example_1.2.40-1.debian.tar.gz
LCFG: Debian DSC file is: /afs/inf.ed.ac.uk/user/s/squinney/lcfgbuild/lcfg-example-1.2.40/lcfg-example_1.2.40-1.dsc
Successfully generated metadata files for Debian

The output shows that this generated 3 files which are needed for building a Debian package: lcfg-example-1.2.40.tar.gz, lcfg-example_1.2.40-1.debian.tar.gz and lcfg-example_1.2.40-1.dsc

These are:

Project source
This is the .orig.tar.gz file, it contains all the source code for your project, it will NOT contain the debian sub-directory.
Debian metadata
This is the .debian.tar.gz file, it contains the debian sub-directory.
Debian source control
This is the .dsc file, it is used to control the build process.

Note that Debian expects a very specific naming style for these files. The project name will always be lower-cased and there must be an _ (underscore) between the name and version strings.

Assuming those 3 files have already been copied over to the target machine, manually building a Debian package can be done something like this:

% dpkg-source --extract lcfg-example_1.2.40-1.dsc
dpkg-source: warning: extracting unsigned source package (lcfg-example_1.2.40-1.dsc)
dpkg-source: info: extracting lcfg-example in lcfg-example-1.2.40
dpkg-source: info: unpacking lcfg-example_1.2.40.orig.tar.gz
dpkg-source: info: unpacking lcfg-example_1.2.40-1.debian.tar.gz
% cd lcfg-example-1.2.40
% debuild --no-sign
% cd ..

If all has gone well you now have a Debian binary package named like lcfg-example_1.2.40-1_all.deb. There are other output files, one which is quite useful is the .build file which contains a log of the whole build process, that can be useful when trying to locate the cause of a build failure.

Building Debian Packages using Build Tools

If you have the LCFG build tools installed on a Debian machine then the binary packages can be generated simply like this:

% cd lcfg-example
% lcfg-reltool deb


% cd lcfg-example
% lcfg-reltool devdeb

These work in a similar way to the familiar rpm and devrpm tools that are used for building RPMs.

-- squinney - 2019-01-18

Topic revision: r2 - 2019-02-06 - squinney
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback