When I run the install, I’m getting absolutely no console output at all from either %pre or %post, but I do get an exit code 1 during %post which causes it to halt the install.
I’m not trying to run either of the scripts manually, I simply printed them and visually inspected them. The list of issues are based on guesswork from experience scripting and the little bit of info (or lack of it) produced by the attempted install of the rpm.
If I’m not mistaken, the set -e command causes an immediate exit of a script if either an undefined variable is accessed, or a non-zero exit code occurs and isn’t part of an if or while statement. I believe it’s also inherited by subshells once set.
Assuming that’s accurate, the set -e in the early part of the %pre and %post will get inherited by the subshells the Output function invokes when called, and when it tries to access the undefined variable $2 it will immediately exit. The way to avoid that is to verify $2 exists before using it, usually with a if [ $# -ge 2 ].
I suspect the error check in the %post that verifies the presence of the /tmp file is the cause of my exit code 1 error status, but that’s only an assumption based on the fact that the only other cases that exit with code 1 would have console output first and I don’t have any.