summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-10-26 23:57:52 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-10-27 23:24:07 +0530
commit76939762e88f5b73eb430d449031feac4ef1fb8a (patch)
tree2d139fcaf1f68be9d09e58b27a103227a27f8ce6
parentf751ee4d0efb670132d747a4f56485ce843a7679 (diff)
cerbero: Add a new option to fetch: --print-only
This will print all source URLs and tarball names to stdout with a prefix denoting their type. For now, only prints tarballs. The tarball URLs have all been URL-encoded so that, for instance, spaces are converted to %20. This makes it safer to parse stdout for the URL and tarball name. Note that the tarball name can still contain spaces. The recommended way of parsing the output is: * Check if it begins with 'TARBALL: ' * If it does, read till the next space. This is your URL. * Skip the space. Everything till newline is your tarball name. This will be used to implement our tarball mirror setup on fdo.
-rw-r--r--cerbero/build/source.py6
-rw-r--r--cerbero/commands/fetch.py15
2 files changed, 18 insertions, 3 deletions
diff --git a/cerbero/build/source.py b/cerbero/build/source.py
index 4275849b..81f262e4 100644
--- a/cerbero/build/source.py
+++ b/cerbero/build/source.py
@@ -19,6 +19,8 @@
import os
import shutil
import tarfile
+import urllib
+import urlparse
from cerbero.config import Platform
from cerbero.utils import git, svn, shell, _
@@ -98,6 +100,10 @@ class Tarball (Source):
self.tarball_dirname = \
self.replace_name_and_version(self.tarball_dirname)
self.download_path = os.path.join(self.repo_dir, self.tarball_name)
+ # URL-encode spaces and other special characters in the URL's path
+ split = list(urlparse.urlsplit(self.url))
+ split[2] = urllib.quote(split[2])
+ self.url = urlparse.urlunsplit(split)
def fetch(self, redownload=False):
if not os.path.exists(self.repo_dir):
diff --git a/cerbero/commands/fetch.py b/cerbero/commands/fetch.py
index 4fcebc94..7b38f0d4 100644
--- a/cerbero/commands/fetch.py
+++ b/cerbero/commands/fetch.py
@@ -22,6 +22,7 @@ from cerbero.build.cookbook import CookBook
from cerbero.packages.packagesstore import PackagesStore
from cerbero.utils import _, N_, ArgparseArgument, remove_list_duplicates
from cerbero.utils import messages as m
+from cerbero.build.source import Tarball
class Fetch(Command):
@@ -32,9 +33,11 @@ class Fetch(Command):
'dependencies too')))
args.append(ArgparseArgument('--full-reset', action='store_true',
default=False, help=_('reset to extract step if rebuild is needed')))
+ args.append(ArgparseArgument('--print-only', action='store_true',
+ default=False, help=_('print all source URLs to stdout')))
Command.__init__(self, args)
- def fetch(self, cookbook, recipes, no_deps, reset_rdeps, full_reset):
+ def fetch(self, cookbook, recipes, no_deps, reset_rdeps, full_reset, print_only):
fetch_recipes = []
if not recipes:
fetch_recipes = cookbook.get_recipes_list()
@@ -49,6 +52,11 @@ class Fetch(Command):
to_rebuild = []
for i in range(len(fetch_recipes)):
recipe = fetch_recipes[i]
+ if print_only:
+ # For now just print tarball URLs
+ if isinstance(recipe, Tarball):
+ m.message("TARBALL: {} {}".format(recipe.url, recipe.tarball_name))
+ continue
m.build_step(i + 1, len(fetch_recipes), recipe, 'Fetch')
recipe.fetch()
bv = cookbook.recipe_built_version(recipe.name)
@@ -89,7 +97,7 @@ class FetchRecipes(Fetch):
def run(self, config, args):
cookbook = CookBook(config)
return self.fetch(cookbook, args.recipes, args.no_deps,
- args.reset_rdeps, args.full_reset)
+ args.reset_rdeps, args.full_reset, args.print_only)
class FetchPackage(Fetch):
@@ -109,7 +117,8 @@ class FetchPackage(Fetch):
store = PackagesStore(config)
package = store.get_package(args.package[0])
return self.fetch(store.cookbook, package.recipes_dependencies(),
- args.deps, args.reset_rdeps, args.full_reset)
+ args.deps, args.reset_rdeps, args.full_reset,
+ args.print_only)
register_command(FetchRecipes)