Current temporary directory creation is predictable and non-atomic. Therefore, it's not secure. It is possible for another user to pre-create the directory and poison it's contents. Using mktemp avoids this vulnerability.
Also, the conditional logic requires a copy of the cleanup command at the end of every place where installation may abort after temporary directory creation. It is better to set up a trap on EXIT in one place immediately after directory creation. Thus, additional changes to conditional logic can't accidentally omit correct cleanup logic.
Current temporary directory creation is predictable and non-atomic. Therefore, it's not secure. It is possible for another user to pre-create the directory and poison it's contents. Using mktemp avoids this vulnerability.
Also, the conditional logic requires a copy of the cleanup command at the end of every place where installation may abort after temporary directory creation. It is better to set up a trap on EXIT in one place immediately after directory creation. Thus, additional changes to conditional logic can't accidentally omit correct cleanup logic.