Yeah, I agree. By default, permissions in the webfolder are set to 750 for folders, and 640 for files, which the http user can't access. That's why I was resetting all the permissions.

Looking at it now, using `cp -pR` when copying to the web folder should preserve the original permissions (755/644 for most packages, with a bit of luck), and hopefully it works from there without too much changes to the original code.