We have a war file, liquibase xml files, and sha1 checksums we want to package as a Debian script for deployment to one platform: ubuntu 14.1 64bit with tomcat 7 and java 7.
We have trawled through a large number of incomprehensible (for us as java developers) Debian packaging guides, most of which require an "upstream source tar ball" (e.g. this one: https://wiki.debian.org/IntroDebianPackaging ) and/or something generated from doing a make/install.
We have neither, which is the crux of our problem.
We have two phases:
The guides don't mention how to manage these two phases.
Initial installation (what we do now by hand on every server):
The app itself we distribute via a tar file built with Jenkins. In the tar is the following:
We scp the tar file into the /home/foo dir, and run /home/foo/scripts/install.sh which does the following:
The questions we have are:
How does the system manage only sending the updated files, e.g not the liquibase binaries in this case? I assume we would need two packages, one for the base install, and one for the tar, to avoid duplication?
We understand that we need to put artifacts in a special directory structure and that this somehow maps onto the target servers file structure, and we need to build various control files, but not how it gets glued together at the various phases, and what scripts are required.
We have attempted to read the Debian policy manual ( https://www.debian.org/doc/debian-policy/), but this is a reference tome for experience linux package developers. We are sure the answers are in there, but we cant figure out where.
This post: https://help.ubuntu.com/community/Tomcat/PackagingWebapps Has two other options (we opted for "beating the system-wide instance into submission") but gives no clues on how to actually build the packages.
Deb is the installation package format used by all Debian based distributions. The Ubuntu repositories contain thousands of deb packages that can be installed either from the Ubuntu Software Center or from the command line using the apt and apt-get utilities.
The easiest way is to install dh-make
and use that to generate a skeleton debian/
directory to get you started. You can delete the files that are irrelevant (e.g. if you don't provide a man page).
You'll need to edit debian/control
to specify the necessary packages in Depends:
- probably tomcat7
and tomcat7-java
; you don't need to mention sha1sum
because it's in coreutils
, which is an Essential package.
Add the necessary modifications to context.xml
to the postinst
script, if (and only if) you can't override the existing settings by simply adding a file somewhere.
Add a Makefile with an install
target that puts the necessary files into subdirectories of $DESTDIR
:
install:
install -d $(DESTDIR)/var/lib/tomcat7/webapps
install -m 644 app.war $(DESTDIR)/var/lib/tomcat7/webapps
I would hope that Tomcat can be triggered to reload when dependent packages are updated (by mentioning it in debian/triggers
), but if not, you'll need to restart it (using invoke-rc.d
or systemctl
, depending on the target init system) in the postinst and postrm scripts.
To answer the specific questions:
If you need to create a new user, do that in the preinst script (crib from another package, or read the manual). Do you really need another user, or is the tomcat user appropriate?
Package manager installs and uninstalls all the files provided, and runs the preinst, postinst, prerm and postrm scripts provided.
That list isn't comparing like with like - e.g. dpkg
is for managing packages on a system, not for creating packages. With a suitable debian
directory, building can be as simple as
fakeroot debian/rules binary
Tools such as pbuilder are useful for ensuring dependencies such as libraries are installed on the build system, rather than arranging this by hand, which gets tedious if you're building a distribution. You shouldn't need that level of automation.
Packages' files are installed to whichever directory under $DESTDIR
that make install
puts them.
There may be a better way to configure Tomcat than editing files in /etc
. I don't know that server well enough to know that myself.
Target files' permissions and ownership are exactly as make install
sets.
There's a lot to read in the Debian Packaging Manual; I recommend you refer back to that frequently as the mechanism starts to make sense.
I'm not sure what you mean by "sending files". And the package shouldn't need to include the tarball you unpacked from - that would just be duplication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With