[PATCH 2/3] Store older valid packages in separate folder

Vratislav Podzimek vpodzime at redhat.com
Fri Nov 29 07:21:18 UTC 2013


On Thu, 2013-11-28 at 20:06 +0100, Martin Kolman wrote:
> If a package from older release is used
> (as there is no build for the current release
> if the package was not updated for the current release),
> store it in a separate folder called for_<release id>.
> Otherwise the package would be downloaded again each time,
> making the updates image creation slow.
> Without the subfolder makeupdates would not be enable to distinguish
> which cached packages are outdated and should not be used and which
> packages just don't have a new build and should be used.
> 
> Signed-off-by: Martin Kolman <mkolman at redhat.com>
> ---
>  scripts/makeupdates | 41 +++++++++++++++++++++++++++++++++++------
>  1 file changed, 35 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/makeupdates b/scripts/makeupdates
> index 3b4fe63..8d36d79 100755
> --- a/scripts/makeupdates
> +++ b/scripts/makeupdates
> @@ -39,6 +39,7 @@ except ImportError:
>      exit(1)
>  
>  RPM_FOLDER_NAME = os.path.expanduser("~/.anaconda_updates_rpm_cache")
> +RPM_RELEASE_DIR_TEMPLATE = "for_%s"
>  KOJI_BASE_URL = "http://kojipkgs.fedoraproject.org//packages/" \
>                  "%(toplevel_name)s/%(toplevel_version)s/%(release)s/%(arch)s/%(rpm_name)s"
>  
> @@ -190,6 +191,10 @@ def download_to_file(url, path):
>      or None if the download fails for some reason
>      """
>      try:
> +        # try to make sure the folder for the download exists
> +        download_folder = os.path.split(path)[0]
> +        if not os.access(download_folder, os.W_OK):
I think os.path.isdir() would be better here.

> +            os.makedirs(download_folder)
>          result = urllib.urlretrieve(url, path)
>          # return the storage path
>          return result[0]
> @@ -577,9 +582,13 @@ def remove_local_packages(packages, arch, release_id, added_rpms):
>      """Remove locally available RPMs from the list of needed packages,
>      return locally unavailable packages and paths to relevant locally
>      available RPMs for inclusion"""
> +    current_release_dir = RPM_RELEASE_DIR_TEMPLATE % release_id
>      # list all package names and version for the RPMs already in cache
>      folder_glob = os.path.join(RPM_FOLDER_NAME, "*.rpm")
>      folder_glob = os.path.abspath(folder_glob)
> +    release_folder_glob = os.path.join(RPM_FOLDER_NAME, current_release_dir, "*.rpm")
> +    release_folder_glob = os.path.abspath(release_folder_glob)
> +
>      include_rpms = []
>      skipped_packages = []
>  
> @@ -603,7 +612,11 @@ def remove_local_packages(packages, arch, release_id, added_rpms):
>      # currently specified architecture
>      allowed = ("noarch.rpm", "%s.rpm" % arch)
>      relevant_rpms = [x for x in glob.glob(folder_glob) if x.endswith(allowed)]
> -
> +    # also add any RPMS from the current release folder
> +    # (has RPMs from older releases that were not yet rebuilt
> +    # for the current release)
> +    relevant_rpms.extend([x for x in glob.glob(release_folder_glob)
> +                          if x.endswith(allowed)])
You can drop the square brackets here. extend() works with a generator.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list