The MacOS code signing issues that were encountered during the 0.21.0 release cycle have shown that it is necessary for us to use a code signing tool for which the source code is available and modifiable by us. Given that there appears to not be such a tool available, I have written such a tool, signapple, that we can use. This tool is able to create a valid MacOS code signature, detach it in a way that we were doing previously, and attach it to the unsigned binary. This tool can also verify that the signature is correct.
This PR implements the usage of that tool in the gitian build for the code signed MacOS binary. The code signer will use this tool to create the detached signature. Gitian builders will use this tool to apply the detached signature. The gitian-osx-signer.yml descriptor has been modified to install this tool so that the detached-sig-apply.sh script can use it. Additionally, the codesign_allocate and pagestuff tools are no longer necessary so they are no longer added to the tarball used in code signing. Lastly, both the detached-sig-create.sh and detached-sig-apply.sh scripts are made to be significantly less complex and to not do unexpected things such as unpacking an already unpacked tarball.
The detached code signature that signapple creates is almost identical to that which we were previously creating. The only difference is that the cpu architecture name is included in the extension (e.g. we have bitcoin-qt.x86_64sign instead of bitcoin-qt.sign). This was done in order to support signing universal binaries which we may want to do in the future. However signapple can still apply existing code signatures as it will accept the .sign extension. If it is desired, it can be modified to produce signatures with just the .sign extension. However I do not think it is necessary to maintain compatibility with the old process.