Friday, June 27, 2014

Solaris pkgutil is not idempotent

Life would be easier if command line tools would never use exit code different than zero unless as a 'real' error pops up. The fact that I am trying to install again an existing package should not result in an 'error' but Solaris returns status 4 when running 'pkg install' with description "No updates necessary for this image.". You have no other option than handling this in a per package basis like I show below using a Plain Old Bash (POB) recipe:
pkg install libxaw5 || ret=$?
if [ $ret -ne 4 ]; then
echo "$ret is an error exit code. We only skip exit code 4 which means 'no updates necessary'"
exit 1
fi

No comments:

Followers