Esempio n. 1
0
    def fetch(self, fetcher, progress):

        fetcher.reset()

        # Fetch packages file
        url = posixpath.join(self._baseurl, "PACKAGES.TXT")
        item = fetcher.enqueue(url)
        fetcher.run(progress=progress)
        if item.getStatus() == SUCCEEDED:
            localpath = item.getTargetPath()
            digest = getFileDigest(localpath)
            if digest == self._digest:
                return True
            self.removeLoaders()
            loader = SlackSiteLoader(localpath, self._baseurl)
            loader.setChannel(self)
            self._loaders.append(loader)
        elif fetcher.getCaching() is NEVER:
            lines = [_("Failed acquiring information for '%s':") % self,
                     u"%s: %s" % (item.getURL(), item.getFailedReason())]
            raise Error, "\n".join(lines)
        else:
            return False

        self._digest = digest

        return True
Esempio n. 2
0
    def fetch(self, fetcher, progress):

        fetcher.reset()

        # Fetch packages file
        url = posixpath.join(self._baseurl, "PACKAGES.TXT")
        item = fetcher.enqueue(url)
        fetcher.run(progress=progress)
        if item.getStatus() == SUCCEEDED:
            localpath = item.getTargetPath()
            digest = getFileDigest(localpath)
            if digest == self._digest:
                return True
            self.removeLoaders()
            loader = SlackSiteLoader(localpath, self._baseurl)
            loader.setChannel(self)
            self._loaders.append(loader)
        elif fetcher.getCaching() is NEVER:
            lines = [
                _("Failed acquiring information for '%s':") % self,
                u"%s: %s" % (item.getURL(), item.getFailedReason())
            ]
            raise Error, "\n".join(lines)
        else:
            return False

        self._digest = digest

        return True
Esempio n. 3
0
    def fetch(self, fetcher, progress):

        fetcher.reset()

        if self._compressed:
            PACKAGES_TXT = "PACKAGES.TXT.gz"
            CHECKSUMS_md5 = "CHECKSUMS.md5.gz"
        else:
            PACKAGES_TXT = "PACKAGES.TXT"
            CHECKSUMS_md5 = "CHECKSUMS.md5"

        # Fetch packages file
        url = posixpath.join(self._baseurl, PACKAGES_TXT)
        item = fetcher.enqueue(url, uncomp=self._compressed)
        fetcher.run(progress=progress)
        if item.getStatus() == SUCCEEDED:
            localpath = item.getTargetPath()
            digest = getFileDigest(localpath)
            if digest == self._digest:
                return True
            fetcher.reset()
            url = posixpath.join(self._baseurl, CHECKSUMS_md5)
            item = fetcher.enqueue(url, uncomp=self._compressed)
            if self._fingerprint:
                gpgurl = posixpath.join(self._baseurl, CHECKSUMS_md5 + ".asc")
                gpgitem = fetcher.enqueue(gpgurl)
            fetcher.run(progress=progress)
            if item.getStatus() == SUCCEEDED:
                checksumpath = item.getTargetPath()
            else:
                checksumpath = None
            if self._fingerprint:
                if gpgitem.getStatus() is SUCCEEDED:
                    try:
                        status, output = commands.getstatusoutput(
                            "gpg --batch --no-secmem-warning --status-fd 1 "
                            "--verify %s %s" %
                            (gpgitem.getTargetPath(), item.getTargetPath()))

                        badsig = False
                        goodsig = False
                        validsig = None
                        for line in output.splitlines():
                            if line.startswith("[GNUPG:]"):
                                tokens = line[8:].split()
                                first = tokens[0]
                                if first == "VALIDSIG":
                                    validsig = tokens[1]
                                elif first == "GOODSIG":
                                    goodsig = True
                                elif first == "BADSIG":
                                    badsig = True
                        if badsig:
                            raise Error, _(
                                "Channel '%s' has bad signature") % self
                        if not goodsig or validsig != self._fingerprint:
                            raise Error, _("Channel '%s' signed with unknown key") \
                                         % self
                    except Error, e:
                        progress.add(self.getFetchSteps() - 2)
                        progress.show()
                        if fetcher.getCaching() is NEVER:
                            raise
                        else:
                            return False
            self.removeLoaders()
            loader = SlackSiteLoader(localpath, checksumpath, self._baseurl)
            loader.setChannel(self)
            self._loaders.append(loader)
Esempio n. 4
0
    def fetch(self, fetcher, progress):

        fetcher.reset()

        if self._compressed:
            PACKAGES_TXT="PACKAGES.TXT.gz"
            CHECKSUMS_md5="CHECKSUMS.md5.gz"
        else:
            PACKAGES_TXT="PACKAGES.TXT"
            CHECKSUMS_md5="CHECKSUMS.md5"

        # Fetch packages file
        url = posixpath.join(self._baseurl, PACKAGES_TXT)
        item = fetcher.enqueue(url, uncomp=self._compressed)
        fetcher.run(progress=progress)
        if item.getStatus() == SUCCEEDED:
            localpath = item.getTargetPath()
            digest = getFileDigest(localpath)
            if digest == self._digest:
                return True
            fetcher.reset()
            url = posixpath.join(self._baseurl, CHECKSUMS_md5)
            item = fetcher.enqueue(url, uncomp=self._compressed)
            if self._fingerprint:
                gpgurl = posixpath.join(self._baseurl, CHECKSUMS_md5 + ".asc")
                gpgitem = fetcher.enqueue(gpgurl)
            fetcher.run(progress=progress)
            if item.getStatus() == SUCCEEDED:
                checksumpath = item.getTargetPath()
            else:
                checksumpath = None
            if self._fingerprint:
                if gpgitem.getStatus() is SUCCEEDED:
                    try:
                        status, output = commands.getstatusoutput(
                            "gpg --batch --no-secmem-warning --status-fd 1 "
                            "--verify %s %s" % (gpgitem.getTargetPath(),
                                                item.getTargetPath()))
    
                        badsig = False
                        goodsig = False
                        validsig = None
                        for line in output.splitlines():
                            if line.startswith("[GNUPG:]"):
                                tokens = line[8:].split()
                                first = tokens[0]
                                if first == "VALIDSIG":
                                    validsig = tokens[1]
                                elif first == "GOODSIG":
                                    goodsig = True
                                elif first == "BADSIG":
                                    badsig = True
                        if badsig:
                            raise Error, _("Channel '%s' has bad signature") % self
                        if not goodsig or validsig != self._fingerprint:
                            raise Error, _("Channel '%s' signed with unknown key") \
                                         % self
                    except Error, e:
                        progress.add(self.getFetchSteps()-2)
                        progress.show()
                        if fetcher.getCaching() is NEVER:
                            raise
                        else:
                            return False
            self.removeLoaders()
            loader = SlackSiteLoader(localpath, checksumpath, self._baseurl)
            loader.setChannel(self)
            self._loaders.append(loader)