--- smart/channels/yast2.py +++ smart/channels/yast2.py @@ -30,9 +30,10 @@ import os class YaST2Channel(PackageChannel): - def __init__(self, baseurl, *args): + def __init__(self, baseurl, compressed, *args): super(YaST2Channel, self).__init__(*args) self._baseurl = baseurl + self._compressed = compressed def getCacheCompareURLs(self): return [posixpath.join(self._baseurl, "media.1/media")] @@ -40,9 +41,9 @@ def getFetchSteps(self): return 4 - def __fetchFile(self, file, fetcher, progress): + def __fetchFile(self, file, fetcher, progress, uncompress=False): fetcher.reset() - item = fetcher.enqueue(file) + item = fetcher.enqueue(file,uncomp=uncompress) fetcher.run(progress=progress) failed = item.getFailedReason() if failed: @@ -77,21 +78,27 @@ self.removeLoaders() descrdir = "suse/setup/descr" datadir = "RPMS" + uncompress = self._compressed for line in open(fetched.getTargetPath()): if line.startswith("DESCRDIR"): descrdir = line[9:-1] if line.startswith("DATADIR"): datadir = line[8:-1] + # autodetect compressed/uncompressed SuSEtags metadata + if line.strip().endswith("packages"): uncompress = False + if line.strip().endswith("packages.gz"): uncompress = True # Fetch package information (req, dep, prov, etc) fetchitem = posixpath.join(self._baseurl, (("%s/packages") % descrdir)) - fetched = self.__fetchFile(fetchitem, fetcher, progress) + if uncompress: fetchitem += ".gz" + fetched = self.__fetchFile(fetchitem, fetcher, progress, uncompress) if not fetched or fetched.getStatus() == FAILED: return False self.removeLoaders() pkginfofile = fetched.getTargetPath() if open(pkginfofile).read(9) == "=Ver: 2.0": fetchitem = posixpath.join(self._baseurl, (("%s/packages.en") % descrdir)) - fetched = self.__fetchFile(fetchitem, fetcher, progress) + if uncompress: fetchitem += ".gz" + fetched = self.__fetchFile(fetchitem, fetcher, progress, uncompress) if not fetched or fetched.getStatus() == FAILED or open(fetched.getTargetPath()).read(9) != "=Ver: 2.0": raise Error, "YaST2 package descriptions not loaded." loader = YaST2Loader(self._baseurl, datadir, pkginfofile) @@ -109,6 +116,7 @@ def create(alias, data): return YaST2Channel(data["baseurl"], + data["compressed"], data["type"], alias, data["name"], --- smart/channels/yast2_info.py +++ smart/channels/yast2_info.py @@ -30,6 +30,8 @@ """) fields = [("baseurl", _("Base URL"), str, None, - _("Base URL of YaST2 repository, where the 'content' file is located."))] + _("Base URL of YaST2 repository, where the 'content' file is located.")), + ("compressed", _("Compressed SuSETags"), bool, True, + _("Use compressed SuSETags metadata)"))] # ("medias", _("Medias"), str, "", # _("Space separated list of medias. (NOT IN USE YET)"))]