This patch is based on https://github.com/alpinelinux/aports/pull/1305, but includes only changes relevant to the upgrade (I'll apply the rest separately).