I have made a debian package for automating the oozie installation. The postinst script, which is basically a shell script, runs after the package is installed. I want to access the environment variable inside this script. Where should I set the environment variables?
Depending on what you are actually trying to accomplish, the proper way to pass in information to the package script is with a Debconf variable.
Briefly, you add a debian/templates
file something like this:
Template: oozie/secret
Type: string
Default: xyzzy
Description: Secret word for teleportation?
Configure the secret word which allows the player to teleport.
and change your postinst script to something like
#!/bin/sh -e
# Source debconf library.
. /usr/share/debconf/confmodule
db_input medium oozie/secret || true
db_go
# Check their answer.
db_get oozie/secret
instead_of_env=$RET
: do something with the variable
You can preseed the Debconf database with a value for oozie/secret
before running the packaging script; then it will not prompt for the value. Simply do something like
debconf-set-selections <<<'oozie oozie/secret string plugh'
to preconfigure it with the value plugh
.
See also http://www.fifi.org/doc/debconf-doc/tutorial.html
There is no way to guarantee that the installer runs in a particular environment or that dpkg
is invoked by a particular user, or from an environment which can be at all manipulatel by the user. Correct packaging requires robustness and predictability in these scenarios; also think about usability.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With