![]() | Note |
---|---|
In this section we prepare the files that will form a package around the daemon. The purpose of some parts of the code shown here will not become obvious until you read later sections. |
That being said... the libraries are there, the binary runs. If there is no quirky use of libssl in the program[6], we should be good to go. Let's package it for Ubuntu Precise.
apprentice@packager:~/packaging/res-am-agent$ alien --generate --scripts --keep-version --fixperms res-am-agent-6.5-0.89780.x86_64.rpm
Warning: alien is not running as root!
Warning: Ownerships of files in the generated packages will probably be wrong.
Directories res-am-agent-6.5 and res-am-agent-6.5.orig prepared.
apprentice@packager:~/packaging/res-am-agent$ find res-am-agent-6.5 -type f
res-am-agent-6.5/etc/init.d/resamad
res-am-agent-6.5/usr/local/bin/resamad
res-am-agent-6.5/debian/postinst
res-am-agent-6.5/debian/compat
res-am-agent-6.5/debian/changelog
res-am-agent-6.5/debian/rules
res-am-agent-6.5/debian/prerm
res-am-agent-6.5/debian/copyright
res-am-agent-6.5/debian/control
If you don't have alien
, you might as well use rpm2cpio
as shown in the previous section.
Of what alien creates, we 're nog going to leave anything standing but the executable usr/local/bin/resamad
.
Putting resamad
in /usr/local
is not correct behaviour for an Ubuntu package.
And we're going to replace /etc/init.d/resamad
later on.
To do that, we need a Makefile:
#!/usr/bin/make -f # Don't forget this, or dpkg-buildpackage will try to install at build time all: install: echo DESTDIR $(DESTDIR) install -m 755 -d $(DESTDIR)/etc/res install -m 755 -t $(DESTDIR)/usr/sbin usr/local/bin/resamad install -m 755 -d $(DESTDIR)/usr/share/res-am-agent install -m 755 -t $(DESTDIR)/usr/share/res-am-agent init-resamad.exp clean: rm -rf $(DESTDIR)/usr/share/res-am-agent $(DESTDIR)/etc/res rm -f $(DESTDIR)/usr/sbin/resamad
![]() | Note |
---|---|
In a more procedural setup, I would add the Makefile using quilt. For now, I put it in the source dir without further ado. |
The daemon will not do anything unless it knows which server (a so-called “dispatcher”) to contact.
This can be configured with a file /etc/res/resamad.xml
, but I suspect that that file may need altering when the server changes.
According to the docs, the agent can be started with the name of the server as a parameter. It will then write a configuration file. That is good.
But when started thusly, the agent is in interactive mode, needing user input:
sudo resamad -dd192.168.3.4
1. res-am@sqlserver.mydomain.org
Enter value: 1
In case of unattended installs, that is not so good.
So to avoid having to type numbers when installing the daemon, we will later use debconf
.
Right now, we create an expect
script.
It is only needed later on, but I show it here because we are now still doing what would count as patching the source if we had the actual source.
From what autoexpect
generates, we create this script, and save it in init-resamad.exp
:
#!/usr/bin/expect -f set force_conservative 0 ;# set to 1 to force conservative mode even if ;# script wasn't run conservatively originally if {$force_conservative} { set send_slow {1 .1} proc send {ignore arg} { sleep .1 exp_send -s -- $arg } } set timeout -1 set send_slow {1 .1} spawn resamad -dd$env(DISPATCHERS) match_max 100000 expect -exact "Enter value: " sleep .1 send -s -- "1\r" expect eof
The package as prepared by alien
still lacks manpages, and the pre- and post-install and -rm scripts are not to my liking.
Running dh_make quickly provides me with sensible templates.
But if you want to skip this step and create them by hand, feel free to do so.
apprentice@packager:~/packaging/res-am-agent/res-am-agent-6.5$ dh_make -s -a --createorig
Maintainer name : Jurjen Bokma
Email-Address : j.bokma@rug.nl
Date : Thu, 29 Mar 2012 16:59:31 +0200
Package Name : res-am-agent
Version : 6.5
License : blank
Type of Package : Single
Hit <enter> to confirm:
Currently there is no top level Makefile. This may require additional tuning.
File changelog exists, skipping.
File compat exists, skipping.
File copyright exists, skipping.
File control exists, skipping.
File rules already exists, skipping.
Done. Please edit the files in the debian/ subdirectory now. You should also
check that the res-am-agent Makefiles install into $DESTDIR and not in / .
apprentice@packager:~/packaging/res-am-agent/res-am-agent-6.5$ rm -rf debian/{README.*,emacsen*.ex,manpage.sgml.ex,manpage.1.ex,res-am-agent.doc-base.EX,res-am-agent.default.ex,res-am-agent.cron.d.ex,menu.ex,watch.ex,docs}
To create a package beyond what alien
gives us, we need a subdirectory debian/
with contents.
General packaging for Debian/Ubuntu is well beyond the scope of this example, though.
These are the files under debian/
:
ls -1 debian/
changelog
control
rules
copyright
compat
dirs
res-am-agent.manpages
resamad.8.xml
init.d
preinst
postinst
prerm
postrm
config
templates
shlibs.local
I'll show most of these files, albeit not all in this section...
The file debian/changelog
needs to exist, with a rather unforgiving format:
res-am-agent (6.5-0.89780) experimental; urgency=low * Converted from .rpm format to .deb by alien version 8.85 -- Jurjen Bokma <j.bokma@rug.nl> Thu, 29 Mar 2012 16:49:58 +0200
debian/compat
7
We manually specify libssl0.9.8
as a dependency.
We also depend on expect
because it is used when the package is installed, and on debconf
.
The *xsl* build-dependencies are for generating the manpage from XML.
The rest of the library dependencies is resolved by shlibdeps.
libssl0.9.8 Is a build-time dependency as well, or the sneaky symlink 'libssl.so.6' we create in the rules
file will point to nothing, leading to a failed 'build'.
All this is specified in debian/control
:
Source: res-am-agent Section: admin Priority: extra Maintainer: Jurjen Bokma <j.bokma@rug.nl> Build-Depends: debhelper (>= 8.0.0), libssl0.9.8 (>=0.9.8), docbook-xsl, docbook-xml, xsltproc Package: res-am-agent Architecture: amd64 Depends: ${shlibs:Depends}, libssl0.9.8, lsb-base (>= 3.0-6), debconf, expect Description: RES AM Agent RES Automation Manager Agent (Converted from a rpm package by alien version 8.85.) Allows a remote RES server to manage the machine on which this package is installed. (E.g. to run commands on it.)
debian/copyright
Copyright 1998-2012 RES Software This package was debianized by the alien program by converting a binary .rpm package on Thu, 29 Mar 2012 16:49:58 +0200 Copyright: Commercial Information from the binary package: Name : res-am-agent Version : 6.5 Release : 0.89780 Architecture: x86_64 Install Date: (not installed) Group : System/Management Size : 486184 License : Commercial Signature : (none) Source RPM : res-am-agent-6.5-0.89780.src.rpm Build Date : vr 03 feb 2012 13:00:12 CET Build Host : bld-rh53x64 Relocations : (not relocatable) Vendor : RES Software Summary : RES AM Agent Description : RES Automation Manager Agent
In debian/rules
, we need two overrides:
#!/usr/bin/make -f %: dh $@ # This override needed to get around missing SSL library at 'build' time override_dh_shlibdeps: install -d /tmp/fake_ssl ln -s /lib/x86_64-linux-gnu/libssl.so.0.9.8 /tmp/fake_ssl/libssl.so.6 LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):/tmp/fake_ssl" dh_shlibdeps rm -rf /tmp/fake_ssl # This override needed because we use docbook XML for manpages override_dh_auto_build: xsltproc --nonet \ --param make.year.ranges 1 \ --param make.single.year.ranges 1 \ --param man.charmap.use.subset 0 \ -o debian/ \ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl \ debian/resamad.8.xml dh_auto_build
These overrides are not enough.
Shlibdeps still cannot find symbols for the library when it goes by the soname of libssl.so.6
.
So we provide the necessary information in debian/shlibs.local
:
libssl 6 libssl0.9.8
Directories that 'make install' assumes present are listed in debian/dirs
:
/etc/init.d /usr/sbin
In debian/res-am-agent.manpages
we list manpages to install.
The one listed is generated from xml at package build time.
debian/resamad.8