[Yum-devel] [PATCH 4/4] save metadata in pkg order

James Antill james at fedoraproject.org
Tue Nov 27 18:35:39 UTC 2012


On Fri, 2012-11-23 at 16:28 +0100, Zdeněk Pavlas wrote:
> ---
>  createrepo/__init__.py |   33 ++++++++++++++++++++++-----------
>  1 files changed, 22 insertions(+), 11 deletions(-)
> 
> diff --git a/createrepo/__init__.py b/createrepo/__init__.py
> index 0f1cfee..e1836c7 100644
> --- a/createrepo/__init__.py
> +++ b/createrepo/__init__.py
> @@ -543,6 +543,7 @@ class MetaDataGenerator:
>          # go on their merry way
>          
>          newpkgs = []
> +        keptpkgs = []
>          if self.conf.update:
>              # if we're in --update mode then only act on the new/changed pkgs
>              for pkg in pkglist:
> @@ -558,11 +559,7 @@ class MetaDataGenerator:
>                      if self.conf.verbose:
>                          self.callback.log(_("Using data from old metadata for %s")
>                                              % pkg)
> -
> -                    old_po.basepath = self.conf.baseurl # reset baseurl in the old pkg
> -                    self.primaryfile.write(old_po.xml_dump_primary_metadata())
> -                    self.flfile.write(old_po.xml_dump_filelists_metadata())
> -                    self.otherfile.write(old_po.xml_dump_other_metadata())
> +                    keptpkgs.append((pkg, old_po))
>  
>                      #FIXME - if we're in update and we have deltas enabled
>                      # check the presto data for this pkg and write its info back out
> @@ -594,15 +591,23 @@ class MetaDataGenerator:
>                  self.read_pkgs.append(pkg)
>              
>              if po:
> -                self.primaryfile.write(po.xml_dump_primary_metadata())
> -                self.flfile.write(po.xml_dump_filelists_metadata())
> -                self.otherfile.write(po.xml_dump_other_metadata(
> -                                     clog_limit=self.conf.changelog_limit))
> +                keptpkgs.append((pkg, po))
>                  continue
>                  
>              pkgfiles.append(pkg)
> -            
> -       
> +
> +        # this is going to be merged..
> +        keptpkgs.sort(reverse=True)
> +        def save_keptpkgs(upto=None):
> +            while keptpkgs and (upto is None or keptpkgs[-1][0] < upto):
> +                po = keptpkgs.pop()[1]

 I am kind of confused about the two different pkgs. here, why we
compare against one and write the other out ... also:

> +                # reset baseurl in the old pkg
> +                po.basepath = self.conf.baseurl
> +                self.primaryfile.write(po.xml_dump_primary_metadata())
> +                self.flfile.write(po.xml_dump_filelists_metadata())
> +                self.otherfile.write(po.xml_dump_other_metadata(
> +                    clog_limit=self.conf.changelog_limit))
> +
>          if pkgfiles:
>              # divide that list by the number of workers and fork off that many
>              # workers to tmpdirs
> @@ -613,6 +618,7 @@ class MetaDataGenerator:
>              if self.conf.workers < 1:
>                  self.conf.workers = num_cpus_online()
>              worker_chunks = [[] for i in range(self.conf.workers)]
> +            pkgfiles.sort()

 Would it not be possible to merge the pkgfiles and keptpkgs lists at
this point?

>              for i, pkg in enumerate(pkgfiles):
>                  worker_chunks[i % self.conf.workers].append(pkg)
>              worker_cmd_dict = {}
> @@ -651,6 +657,9 @@ class MetaDataGenerator:
>              
>              files = self.primaryfile, self.flfile, self.otherfile
>              for i, pkg in enumerate(pkgfiles):
> +                # merge keptpkgs
> +                save_keptpkgs(pkg)




More information about the Yum-devel mailing list