Re: How should the systemd setup in a postinst script look?
>>>>> Eugene Zhukov <eugene@debian.org>:
> The service will be enabled and started automatically upon package
> install, you don't need to do that.
> Just put your <package_name>.service file into debian/ folder and the
> rest will be handled by Debian tools.
> The line in debian/rules quoted below is also needed. Don't forget to
> add dh-systemd into build-depends of your package.
Thanks!
I did the following:
1. Moved the karaf.service file to the debian/ directory
2. Made build-depend to version 10 or larger of debhelper
3. Removed all systemd enabling, start, update and purge from
debian/karaf.postinst and debian/karaf.postrm
4. Changed the "%:" rule of debian/rules to be
dh $@ --with systemd
Then I ran dpkg-buildpackage
Then I ran lintian on the package:
sb@lorenzo:~/git/karaf-debian$ lintian ~/git/karaf_4.1.4-8~9.30_all.deb
W: karaf: init.d-script-not-marked-as-conffile etc/init.d/karaf
E: karaf: init.d-script-not-included-in-package etc/init.d/karaf
W: karaf: codeless-jar usr/share/karaf/system/org/apache/aries/blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0/org.apache.aries.blueprint.core.compatibility-1.0.0.jar
W: karaf: codeless-jar usr/share/karaf/system/org/apache/karaf/demos/4.1.4/demos-4.1.4.jar
sb@lorenzo:~/git/karaf-debian$
(Note: I'm not concerned with the codeless jars right now. That's for
later. There are more of them than the two jars reported above...)
When I look in the debian/directory, there are some new files with
extension .debhelper:
...
-rw-r--r-- 1 sb sb 560 Jan 26 17:14 karaf.postinst
-rw-r--r-- 1 sb sb 257 Jan 26 17:18 karaf.postinst.debhelper
-rw-r--r-- 1 sb sb 274 Jan 26 17:15 karaf.postrm
-rw-r--r-- 1 sb sb 340 Jan 26 17:18 karaf.postrm.debhelper
-rw-r--r-- 1 sb sb 690 Jan 22 22:23 karaf.prerm
-rw-r--r-- 1 sb sb 148 Jan 26 17:18 karaf.prerm.debhelper
-rw-r--r-- 1 sb sb 1151 Jan 25 20:23 karaf.service
...
Looking at the karaf.postinst.debhelper script it tries to create a SYSV
service for karaf:
# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
if [ -x "/etc/init.d/karaf" ]; then
update-rc.d karaf defaults >/dev/null
invoke-rc.d karaf start || exit $?
fi
fi
# End automatically added section
What am I missing?
The karaf.postrm.debhelper removes a SYSV initd service in purge, and
does a "systemctl --system daemon-reload" after that (ie. for all
invocations of the script).
The karaf.prerm.debhelper stops a SYSV initd service.
Thanks in advance, for pointers and hints to what I'm doing wrong.
- Steinar
PS Since they didn't work as expected, I haven't yet pushed my latest changes to
https://github.com/steinarb/karaf-debian
Reply to: