Adapted from https://projects.archlinux.org/svntogit/packages.git/commit/?h=packages/opal&id=278c8f93262ee8372b05c650a2e6456ad2d04950