use -n, option for ln “treat LINK_NAME as a normal file if it is a symbolic link to a directory” it will ensure to not break symlink to /etc/apk/cache when it’s invoked the second time
move copy back instruction to the right place - it has to be invoked only on install time