# Copyright John N. Laliberte # LICENSE - GPL2 # gnome module import ftp_module, package_module, string, simple_cache_module import clioptions_module DEBUG=False class GNOME: def __init__(self): options = clioptions_module.Options() args = options.get_arguments() self.major_release = ".".join( args.release_number.split(".")[:2] ) self.full_release = args.release_number self.ftpserver = "ftp.gnome.org" self.release_directories = ["pub/GNOME/admin/" + self.major_release + "/" + self.full_release + "/", "pub/GNOME/platform/" + self.major_release + "/" + self.full_release + "/", "pub/GNOME/desktop/" + self.major_release + "/" + self.full_release + "/", "pub/GNOME/bindings/" + self.major_release + "/" + self.full_release + "/"] def generate_data(self): # connect to ftp and get the list of all the packages in the release directories walker = ftp_module.FTPWalker(self.ftpserver,"anonymous","test@test.com") files = [] for directory in self.release_directories: f_files = ftp_module.find_files(walker, directory,"","") files.extend(f_files) # filter out bad files files = self.filter_files(files) # create package objects for the files release_packages = [] # the packages that are required for a release for package_name in files: release_package = package_module.Package(package_name) release_packages.append(release_package) # while connected, find out the latest version of the packages that we found in the # release directories latest_packages = [] # the latest versions of packages on the gnome ftp. for package in release_packages: file_list = ftp_module.find_files(walker, "pub/GNOME/sources" + "/" + package.raw_name + "/" + package.major_minor,"","") # if maintainers release tarballs late, they will not get picked up # therefore, if the tarball is 1 less than the y of the x.y you # specify, lets also check to see if there are any files for # the actual release number. major = package.major_minor.split(".")[0] minor = package.major_minor.split(".")[1] options = clioptions_module.Options() args = options.get_arguments() release_minor = args.release_number.split(".")[1] if minor == (int(release_minor) -1): file_list_future = ftp_module.find_files(walker, "pub/GNOME/sources" + "/" + package.raw_name + "/" + major + "." + str(int(minor+1)),"","") # if there are results, replace the old list. if file_list_future.count > 0: file_list = file_list_future # make sure we don't try to do this on directories with no files, # or on directories that don't exist # create package objects for the files if file_list.count > 0: latest = self.filter_latest_only(file_list) latest_package = package_module.Package(package.name + "-" + latest) latest_packages.append(latest_package) # disconnect from the ftp # cache the results cache = simple_cache_module.SimpleCache() for release_package in release_packages: latest_package = self.findpackage(release_package.name, latest_packages) if latest_package != None: cache.write_to_queue(release_package.name_plus_version_plus_revision, latest_package.name_plus_version_plus_revision) else: print "No matching latest package!" + str(release_package.name) cache.flush_queue() return (release_packages, latest_packages) def filter_files(self, files): # we want to filter out all the bad files. newfiles = [] for file in files: # only keep files with .tar.bz2 ending. if ( 0 < file.find(".tar.") and 0 < file.find(".bz2") ): file = string.replace(file,".tar.bz2","") newfiles.append(file) return newfiles # this needs to be fixed so that if a directory doesn't have LATEST-IS-, it returns an error def filter_latest_only(self, lines): latest_string = "LATEST-IS-" latest = "" for item in lines: if 0 <= string.rfind(item,latest_string): latest = item try: return_latest = latest[10:] except: return_latest = "" return return_latest def findpackage(self, name, packages): for package in packages: if package.name == name: return package return None import portage_module def compare_packages(release_packages, latest_packages, packages_in_portage): # we care about 5 cases # 1. portage version is less than the release version. (RED) # 2. portage version is equal to the release version, but less than the latest version. (LIGHT GREEN) # 3. portage version is equal to the release version and the latest version. (GREEN) # 4. portage version is greater than the release version (GREEN) # 5. package does not exist in portage (GREY) # again, we choose release_packages as the enumerator for the package names # since it will have ALL packages ( for example, if we used portage_packages, we # might miss the packages that do not exist in portage ) status_packages = [] for package in release_packages: color = None release_package = package latest_package = GNOME().findpackage(package.name, latest_packages) portage_package = GNOME().findpackage(package.name, packages_in_portage) if portage_package == None: status = package_module.Status.NotFound # we need to create a phony package since findpackage # returns None portage_package = package_module.Package(package.name) elif portage_module.best_version_test(portage_package.name_plus_version, \ release_package.name_plus_version) == 2: status = package_module.Status.NeedUpdate elif portage_module.best_version_test(portage_package.name_plus_version, \ latest_package.name_plus_version) == 0: status = package_module.Status.Compliant elif portage_module.best_version_test(portage_package.name_plus_version, \ release_package.name_plus_version) == 1: status = package_module.Status.Compliant else: status = package_module.Status.NewerVersion #if portage_package != None: if DEBUG: print "package: " + str(release_package.name) + \ " | pp: " + str(portage_package.version) + \ " | rp: " + str(release_package.version) + \ " | lp: " + str(latest_package.version) + \ " | status: " + str(status) status_packages.append(package_module.PackageStatus(release_package.name, str(portage_package.version), str(release_package.version), str(latest_package.version), status)) return status_packages