diff --git a/www/docs/tips.md b/www/docs/tips.md index d7786b02..aa390a63 100644 --- a/www/docs/tips.md +++ b/www/docs/tips.md @@ -1,29 +1,30 @@ # Tips, Hints and useful information ## General maintainability of your packages -* Try hard to make all files work on all platforms you support. - * Maintaining separate scripts, config, service files, etc for each platform - quickly becomes difficult -* Put as much conditional logic in the pre/post install scripts as possible + +- Try hard to make all files work on all platforms you support. + - Maintaining separate scripts, config, service files, etc for each platform + quickly becomes difficult +- Put as much conditional logic in the pre/post install scripts as possible instead of trying to build it into the nfpm.yaml -* *if* you need to know the packaging system I have found it useful to add a +- _if_ you need to know the packaging system I have found it useful to add a `/etc/path-to-cfg/package.env` that contains `_INSTALLED_FROM=apk|deb|rpm` which can be sourced into the pre/post install/remove scripts -* *if/when* you need to ask questions during the installation process, create an +- _if/when_ you need to ask questions during the installation process, create an `install.sh` || `setup.sh` script that asks those questions and stores the answers as env vars in `/etc/path-to-cfg/package.env` for use by the pre/post install/remove scripts - * If you only need to support deb packages you can use the debconf - template/config feature, but since rpm does not support this I would try to - unify the way you ask questions. + - If you only need to support deb packages you can use the debconf + template/config feature, but since rpm does not support this I would try to + unify the way you ask questions. ## Pre/post install scripts Here are some useful links for how these scripts work in each packager: -* [APK Docs](https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package#install) -* [RPM Docs](https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/) -* [DEB Docs](https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html) +- [APK Docs](https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package#install) +- [RPM Docs](https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/) +- [DEB Docs](https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html) ### Examples @@ -118,7 +119,6 @@ cleanup -
Example Multi platform (RPM & Deb) post-remove script @@ -163,8 +163,8 @@ esac
- ### Execution order + On upgrade, the scripts are being executed in the following order: 1. `pretrans` of new package (only applies to RPM) @@ -177,25 +177,24 @@ On upgrade, the scripts are being executed in the following order: ## SystemD and upstart/init ### upstart / init -* try to just say no to supporting this, but if you must make sure you have a + +- try to just say no to supporting this, but if you must make sure you have a single script that works on all platforms you need to support. - * as the `post-install` script above does. + - as the `post-install` script above does. ### SystemD -* The docs you find for SystemD are generally for the latest and greatest +- The docs you find for SystemD are generally for the latest and greatest version, and it can be hard to find docs for older versions. - * In the above `post-install` script you see I am doing a SystemD version - check to correct the `ExecStartPre=+...` and `ExecStop=+...` lines -* You should always use + - In the above `post-install` script you see I am doing a SystemD version + check to correct the `ExecStartPre=+...` and `ExecStop=+...` lines +- You should always use [automatic directory creation and environment variables](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#id-1.14.4.3.6.2) - * With the note that only `RuntimeDirectory` is used in SystemD < 231 -* `/bin/bash -c "$(which ...) ...` is a great way to make your single service + - With the note that only `RuntimeDirectory` is used in SystemD < 211 +- `/bin/bash -c "$(which ...) ...` is a great way to make your single service file work on all platforms since RHEL and Debian-based systems have standard - executables in differing locations and complain about `executable path is not - absolute` - * e.g. `/bin/bash -c '$(which mkdir) -p /var/log/your-service'` - + executables in differing locations and complain about `executable path is not absolute` + - e.g. `/bin/bash -c '$(which mkdir) -p /var/log/your-service'` ## Debian packages @@ -222,7 +221,6 @@ You can read more in [lintian's documentation](https://lintian.debian.org/manual If you need a `copyright` file, you can add it using the `contents` directive: - ```yaml # nfpm.yaml contents: @@ -232,4 +230,3 @@ contents: file_info: mode: 0644 ``` -