Tweaking the build script a bit [ci skip]
Port joomla/joomla-platform#1839
Port joomla/joomla-platform#1831