def getVersion(self, packageName): if not self.cache: import apt_pkg apt_pkg.init() self.cache = apt_pkg.Cache() packages = self.cache.packages for package in packages: if package.name == packageName: verString = re.match('.*Ver:\'(.*)-.*\' Section:', str(package.current_ver)).group(1) return Version.fromString(verString) raise PackageNotFoundError(packageName)
def getVersion(self, packageName): # the portage utilities are almost always going to be in # /usr/lib/portage/pym import sys sys.path.append('/usr/lib/portage/pym') import portage # FIXME: this takes the first package returned in the list, in the # case that there are slotted packages, and removes the leading # category such as 'sys-apps' gentooPackageName = portage.db["/"]["vartree"].dbapi.match(packageName)[0].split('/')[1] # this removes the distribution specific versioning returning only the # upstream version upstreamVersion = portage.pkgsplit(gentooPackageName)[1] # print("Version of package is: " + upstreamVersion) return Version.fromString(upstreamVersion)
def getVersion(self, packageName): # the portage utilities are almost always going to be in # /usr/lib/portage/pym import sys sys.path.append('/usr/lib/portage/pym') import portage # FIXME: this takes the first package returned in the list, in the # case that there are slotted packages, and removes the leading # category such as 'sys-apps' gentooPackageName = portage.db["/"]["vartree"].dbapi.match( packageName)[0].split('/')[1] # this removes the distribution specific versioning returning only the # upstream version upstreamVersion = portage.pkgsplit(gentooPackageName)[1] # print("Version of package is: " + upstreamVersion) return Version.fromString(upstreamVersion)
def getVersion(self, packageName): import rpm ts = rpm.TransactionSet() for header in ts.dbMatch("name", packageName): return Version.fromString(header["version"]) raise PackageNotFoundError(packageName)