diff options
author | Richard Hughes <richard@hughsie.com> | 2014-07-09 17:41:28 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-07-09 17:41:28 +0100 |
commit | 2a1d0c6eafdb5c9bad087af79fbd011575f91a02 (patch) | |
tree | 32e5323ef2bb7732e5f2f2771622a817d6dd0359 /contrib | |
parent | 005449e241787d951ed9b736b04805f1a83879eb (diff) | |
download | appstream-glib-2a1d0c6eafdb5c9bad087af79fbd011575f91a02.tar.gz |
fedora: Always download data files for each application
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/packages/fedora-download-cache.py | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/contrib/packages/fedora-download-cache.py b/contrib/packages/fedora-download-cache.py index aa8dd64..cf555ba 100755 --- a/contrib/packages/fedora-download-cache.py +++ b/contrib/packages/fedora-download-cache.py @@ -89,6 +89,33 @@ def search_package_list(pkg): return True return False +def ensure_pkg_exists(yb, existing, pkg): + + # get base name without the slash + relativepath = pkg.returnSimple('relativepath') + pos = relativepath.rfind('/') + if pos != -1: + relativepath = relativepath[pos+1:] + + # is in cache? + path = './packages/' + relativepath + if os.path.exists(path) and os.path.getsize(path) == int(pkg.returnSimple('packagesize')): + print("INFO: %s up to date" % pkg.nvra) + return + + # make sure the metadata exists + repo = yb.repos.getRepo(pkg.repoid) + + # download now + print("INFO: downloading %s" % os.path.basename(path)) + pkg.localpath = path + repo.getPackage(pkg) + + # do we have an old version of this? + if existing.has_key(pkg.name) and os.path.exists(existing[pkg.name]): + print("INFO: deleting %s" % os.path.basename(existing[pkg.name])) + os.remove(existing[pkg.name]) + def update(): # create if we're starting from nothing @@ -173,35 +200,19 @@ def update(): if pkg.arch not in basearch_list: continue - # make sure the metadata exists - repo = yb.repos.getRepo(pkg.repoid) - # don't download packages without desktop files if not search_package_list(pkg) and pkg.name not in extra_packages: continue - # get base name without the slash - relativepath = pkg.returnSimple('relativepath') - pos = relativepath.rfind('/') - if pos != -1: - relativepath = relativepath[pos+1:] - - # is in cache? - path = './packages/' + relativepath - if os.path.exists(path) and os.path.getsize(path) == int(pkg.returnSimple('packagesize')): - #print("INFO: %s up to date" % pkg.nvra) - downloaded[pkg.name] = True - else: - pkg.localpath = path - - # download now - print("INFO: downloading %s" % os.path.basename(path)) - repo.getPackage(pkg) - - # do we have an old version of this? - if existing.has_key(pkg.name) and os.path.exists(existing[pkg.name]): - print("INFO: deleting %s" % os.path.basename(existing[pkg.name])) - os.remove(existing[pkg.name]) + # ensure this package exists + ensure_pkg_exists(yb, existing, pkg) + for require in pkg.strong_requires_names: + if require.startswith(pkg.name): + #print("INFO: " + pkg.name + " also needs " + require) + for dep in newest_packages: + if dep.name == require: + ensure_pkg_exists(yb, existing, dep) + downloaded[dep.name] = True downloaded[pkg.name] = True if len(downloaded) == 0: |