<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_tarball(self, tarball, package):
 """Add a tarball, possibly creating the directory if needed."""

        if tarball is None:
            logger.error(
                "No tarball found for %s: probably a renamed project?",
                package)
            return
        target_dir = os.path.join(self.root_directory, package)
        if not os.path.exists(target_dir):
            os.mkdir(target_dir)
            logger.info("Created %s", target_dir)
        logger.info("Copying tarball to %s", target_dir)
        shutil.copy(tarball, target_dir)