shlib.sh: refactor some code to make get_mirror_type() available