535a8074c5 | ||
---|---|---|
.. | ||
README.md | ||
postinst | ||
postrm | ||
prerm |
README.md
Debian Packaging Overview
OSConfig makes use of CPack (CPackDeb) to package the binary into a debian package. Although CPack take care of generating the Debian control file, it does not work well for specifying custom behavior using debhelpers. The Debian Maintainers Guide encourages using the debhelpers to onboard system unit files which CPack doesn't play well with. CPack does provide entrypoints into the mainteannce scripts using the CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA variable, which is what the purpose of the files in this directory.
The scripts contained in this directory are automatically generated by debhelpers but NOT by CPack. See the maintainers guide for more details.
How to generate the debhelpers to feed into CPack
- Install debhelpers -
sudo apt install dh-make dh-systemd
- Generate source package -
cmake --build . --target package
- Move source package into directory named
mkdir <package>-<version>
ex.mkdir osconfig-0.3.0 && cd osconfig-0.3.0 mv osconfig-0.3.0-Linux.tar.gz osconfig-0.3.0 cd osconfig-0.3.0 dh_make -f osconfig-0.3.0-Linux.tar.gz
dh_make
will stage the debian packaging templates:
.
|-- debian
| |-- README.Debian
| |-- README.source
| |-- changelog
| |-- control
| |-- copyright
| |-- manpage.1.ex
| |-- manpage.sgml.ex
| |-- manpage.xml.ex
| |-- osconfig-docs.docs
| |-- osconfig.cron.d.ex
| |-- osconfig.doc-base.EX
| |-- postinst.ex
| |-- postrm.ex
| |-- preinst.ex
| |-- prerm.ex
| |-- rules
| |-- salsa-ci.yml.ex
| |-- source
| | `-- format
| `-- watch.ex
`-- osconfig-0.3.0.tar.gz
- Copy the
osconfig.service
file into thedebian
directory. The debhelpers will automatically detect a service file and use it to stage the the scripts accordingly. - Modify
debian/rules
and add a new target calledoverride_dh_installsystemd
which performs thedh_installsystemd
command like so....
override_dh_installsystemd:
dh_installsystemd --name=osconfig
- Now run
debian/rules binary
, this will generate the debian package. We are not interested in the package as we will be using CPack's package but what is of interest here is the maintenance scripts, namelypostinst
,postrm
andprerm
which we will use to build our own based on these scripts and the templates named accordingly (*.ex).
.
|-- debian
| |-- README.Debian
| |-- README.source
| |-- changelog
| |-- control
| |-- copyright
| |-- debhelper-build-stamp
| |-- files
| |-- manpage.1.ex
| |-- manpage.sgml.ex
| |-- manpage.xml.ex
| |-- osconfig
| | |-- DEBIAN
| | | |-- control
| | | |-- md5sums
| | | |-- postinst <-----------------
| | | |-- postrm <-----------------
| | | `-- prerm <-----------------
| | |-- lib
| | | `-- systemd
| | | `-- system
| | | `-- osconfig.service
| | `-- usr
| | `-- share
| | `-- doc
| | `-- osconfig
| | |-- README.Debian
| | |-- changelog.Debian.gz
| | `-- copyright
| |-- osconfig-docs.docs
| |-- osconfig.cron.d.ex
| |-- osconfig.doc-base.EX
| |-- osconfig.postrm.debhelper
| |-- osconfig.service
| |-- osconfig.substvars
| |-- postinst.ex <---- templates
| |-- postrm.ex <---- templates
| |-- preinst.ex <---- templates
| |-- prerm.ex
| |-- rules
| |-- salsa-ci.yml.ex
| |-- source
| | `-- format
| `-- watch.ex
`-- osconfig-0.3.0.tar.gz
- To builds the scripts in this directory, we use the template as a base and replace the
#DEBHELPER#
with the contents of<build_root>/osconfig-0.3.0/debian/osconfig/DEBIAN/<script>
- These scripts are used in CPack's
CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
variable.