The use cases are legally gray but often defended under fair use / right-to-repair arguments. Piracy is the dominant driver of most PKG download searches.
To install manually downloaded PKG files, the console generally requires compatible with the specific firmware version of the PS4. ps4 pkg download