Packaging Script Corrections

Problems I found when going through our packaging scripts. Extracted from #4246 for the stable release.