Running code during package installation
Packages can use scripts as part of their installation and removal process. The included scripts are defined as follows:
preinst
: This executes before unpacking the package. If the package has services, it must stop them for installation or upgrade.postinst
: After unpacking, this typically completes any required configuration of the package. Manypostinst
scripts execute any command necessary to start or restart a service after installation or upgrade.prerm
: It usually stops any daemon associated with a package before removing files associated with the package.postrm
: This commonly modifies links or other files created by the package.
The preinst
and prerm
scripts target complex use cases, such as data migration when updating packages. In the Yocto Project case, postinst
and postrm
are also responsible for stopping and starting the systemd
or sysvinit
services. A default script is provided when we use the systemd...