Good afternoon,
I was able to build my project into a deb package using:
fakeroot dpkg-deb --build mypackage
Next, I can install the package using
dpkg -i mypackage.deb
Everything is installed and copied correctly when I do this, however I would like to run a few bash commands after the package is installed.
I understand this needs to be done using the postinst file in the mypackage/DEBIAN directory
I have seen a few examples of this script online, but no clear explanation of how to write one and how to include it in the build.
How do I make sure fakeroot dpkg-deb includes this script, is placing it into DEBIAN directory enough?
There is a case structure in the postinst script, what is this for, and where do I place the bash commands to execute in that script
If I install the package with dpkg - i mypackage.deb is this enough to run that script?
An example script I would like to make is shown below.
What do "configure, abort-upgrade, abort-remove, and abort-deconfigure" stand for.
What does the "update-alternatives" line do.
Thank you for your help,
postinst file below.
#!/bin/sh
set -e
case "$1" in
configure)
# EXECUTE MY BASH COMMAND
echo /usr/local/lib > /etc/ld.so.conf && ldconfig
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
update-alternatives --install /usr/bin/fakeroot fakeroot /usr/bin/fakeroot-ng 5 \
--slave /usr/share/man/man1/fakeroot.1.gz \
fakeroot.1.gz /usr/share/man/man1/fakeroot-ng.1.gz
exit 0