For historical reasons, the image build scripts are full of direct calls to sys.exit(1). That makes adding new errors more difficult than it should be, and clutters the code.
We should replace them with an exception (or an exception hierachy) and handle it in the main function.