public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) {
		$tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename));
		if(!file_exists($tempPath)) mkdir($tempPath);

		// Execute these in sequence until there's a failure
		$processes = array(
			// Export the relevant SHA into a temp folder
			new Process("git archive $sha | tar -x -C " . escapeshellarg($tempPath), $baseDir),
			// Run build script
			new Process($this->buildScript, $tempPath, null, null, 3600),
			// Compress the result
			new Process("tar -czf " . escapeshellarg($outputFilename) . " " . escapeshellarg(basename($tempPath)), dirname($tempPath)),
		);

		// Call at the end, regardless of success or failure
		$cleanup = array(
			// Delete the temporary staging folder
			new Process("rm -rf " . escapeshellarg($tempPath)),
		);

		try {
			$this->executeProcesses($processes, $log);
		} catch(Exception $e) {
			// Execute cleanup on failure
			$this->executeProcesses($cleanup, $log);
			throw $e;
		}

		// Execute cleanup on success
		$this->executeProcesses($cleanup, $log);
		return true;
	}