The files are reorganized into a directory structure that the target system recognizes.
If you provide the you're working with (e.g., "PS3 EBOOT.BIN to CFW PKG", "raw ARM binary to Yocto .pkg", or "Windows .bin to macOS .pkg"), I can give you an exact step-by-step tailored script. bin to pkg