Hello,
I have recently had to rebuild a Raspberry Pi, and it would appear that a package is also needed in addition to the other pacman-key commands:
$this->bbcode_second_pass_code('', 'pacman -S archlinux-keyring')
This should resolve "Fix 'invalid or corrupted package (PGP signature)' error in Arch Linux" on new deployments.