def remove_pkg(self, pkg_name, remove_path=None, remove_checksum=False): ''' Remove the package from the specified remove_path pkg_name : name of the package (ex: test-sleeptest.tar.bz2, dep-gcc.tar.bz2) remove_path : the location to remove the package from. ''' if remove_path: remove_path_list = [remove_path] elif len(self.upload_paths) > 0: remove_path_list = self.upload_paths else: raise error.PackageRemoveError( "Invalid path to remove the pkg from") checksum_path = self._get_checksum_file_path() if remove_checksum: self.remove_checksum(pkg_name) # remove the package and upload the checksum file to the repos for path in remove_path_list: self.remove_pkg_file(pkg_name, path) self.upload_pkg_file(checksum_path, path)
def remove_pkg_file(self, filename, pkg_dir): ''' Remove the file named filename from pkg_dir ''' try: # Remove the file if pkg_dir.startswith('ssh://'): hostline, remote_path = parse_ssh_path(pkg_dir) path = os.path.join(remote_path, filename) utils.run("ssh %s 'rm -rf %s/%s'" % (hostline, remote_path, path)) else: os.remove(os.path.join(pkg_dir, filename)) except (IOError, os.error), why: raise error.PackageRemoveError("Could not remove %s from %s: %s " % (filename, pkg_dir, why))