Ejemplo n.º 1
0
Archivo: drpm.py Proyecto: pnasrat/yum
    def _wait(self, block=False):
        num = 0

        while self.jobs:
            if block:
                pid, code = os.wait()
            else:
                pid, code = os.waitpid(-1, os.WNOHANG)
                if not pid:
                    break

            # urlgrabber spawns child jobs, too.  But they exit synchronously,
            # so we should never see an unknown pid here.
            assert pid in self.jobs
            po = self.jobs.pop(pid)
            if self.progress:
                self.done += po.rpm.size
                self.progress.update(self.done)
            if code != 0:
                unlink_f(po.rpm.localpath)
                self.adderror(po, _('Delta RPM rebuild failed'))
            elif not po.rpm.verifyLocalPkg():
                self.adderror(po, _('Checksum of the delta-rebuilt RPM failed'))
            else:
                os.unlink(po.localpath)
                po.localpath = po.rpm.localpath # for --downloadonly
            num += 1
        return num
Ejemplo n.º 2
0
    def _wait(self, block=False):
        num = 0

        while self.jobs:
            if block:
                pid, code = os.wait()
            else:
                pid, code = os.waitpid(-1, os.WNOHANG)
                if not pid:
                    break

            # urlgrabber spawns child jobs, too.  But they exit synchronously,
            # so we should never see an unknown pid here.
            assert pid in self.jobs
            po = self.jobs.pop(pid)
            if self.progress:
                self.done += po.rpm.size
                self.progress.update(self.done)
            if code != 0:
                unlink_f(po.rpm.localpath)
                self.adderror(po, _('Delta RPM rebuild failed'))
            elif not po.rpm.verifyLocalPkg():
                self.adderror(po,
                              _('Checksum of the delta-rebuilt RPM failed'))
            else:
                # done with drpm file, unlink when local
                if po.localpath.startswith(po.repo.pkgdir):
                    os.unlink(po.localpath)
                po.localpath = po.rpm.localpath  # for --downloadonly
            num += 1

            # when blocking, one is enough
            if block:
                break
        return num
Ejemplo n.º 3
0
    def doCommand(self, base, basecmd, extcmds):
        removed = 0
        for repo in base.repos.listEnabled():
            base.verbose_logger.log(logginglevels.INFO_2,
                'Cleaning up %s repository', repo)
            packages = []

            path = getattr(repo, 'pkgdir')
            if os.path.exists(path) and os.path.isdir(path):
                for item in misc.getFileList(path, 'rpm', []):
                    try:
                        packages.append(YumLocalPackage(ts=base.ts, filename=item))
                    except:
                        base.logger.critical('Cannot load package file %s', item)
                        continue

            if len(packages) is 0:
                base.verbose_logger.log(logginglevels.INFO_2, '')
                continue

            packages = sorted(packages, key=lambda x: x.name)
            packages = sorted(packages, key=lambda x: x.arch)

            last_package = packages[0]
            for package in packages:
                if last_package.name is not package.name or \
                   last_package.arch is not package.arch:
                    last_package = package
                    continue

                version_cmp = package.verCMP(last_package)
                if version_cmp < 0:
                    older_package = package
                    newer_package = last_package
                elif version_cmp > 0:
                    older_package = last_package
                    newer_package = package
                    last_package = package
                else:
                    last_package = package
                    continue

                base.verbose_logger.log(logginglevels.DEBUG_2,
                    '%s.%s %s is older than %s',
                    older_package.name, older_package.arch,
                    older_package.printVer(), newer_package.printVer())

                try:
                    misc.unlink_f(older_package.localPkg())
                except OSError, e:
                    base.logger.critical('Cannot remove package file %s', older_package.localPkg())
                    continue
                else:
                    removed += 1
                    base.verbose_logger.log(logginglevels.DEBUG_4,
                        'Package file %s removed', older_package.localPkg())

            base.verbose_logger.log(logginglevels.INFO_2, '')
Ejemplo n.º 4
0
Archivo: drpm.py Proyecto: dmnks/yum
    def _wait(self, block=False):
        num = 0

        while self.jobs:
            if block:
                pid, code = os.wait()
            else:
                pid, code = os.waitpid(-1, os.WNOHANG)
                if not pid:
                    break

            # urlgrabber spawns child jobs, too.  But they exit synchronously,
            # so we should never see an unknown pid here.
            assert pid in self.jobs
            po = self.jobs.pop(pid)
            if self.progress:
                self.done += po.rpm.size
                self.progress.update(self.done)
            if code != 0:
                unlink_f(po.rpm.localpath)
                self.adderror(po, _("Delta RPM rebuild failed"))
            elif not po.rpm.verifyLocalPkg():
                self.adderror(po, _("Checksum of the delta-rebuilt RPM failed"))
            else:
                # done with drpm file, unlink when local
                if po.localpath.startswith(po.repo.pkgdir):
                    os.unlink(po.localpath)
                # rename the rpm if --downloadonly
                if po.rpm.localpath.endswith(".tmp"):
                    rpmfile = po.rpm.localpath.rsplit(".", 2)[0]
                    os.rename(po.rpm.localpath, rpmfile)
                    po.rpm.localpath = rpmfile
            num += 1

            # when blocking, one is enough
            if block:
                break
        return num
Ejemplo n.º 5
0
 def adderror(po, msg):
     errors.setdefault(po, []).append(msg)
     if po.localpath.endswith('.tmp'):
         misc.unlink_f(po.localpath) # won't resume this..
Ejemplo n.º 6
0
 def adderror(po, msg):
     errors.setdefault(po, []).append(msg)
     if po.localpath.endswith('.tmp'):
         misc.unlink_f(po.localpath)  # won't resume this..