def from_name(name): # download package and return an installer object # find package in repository repo = packagedb.which_repo(name) if repo: repo = ctx.repodb.get_repo(repo) pkg = packagedb.get_package(name) # FIXME: let pkg.packageURI be stored as URI type rather than string pkg_uri = URI(pkg.packageURI) if pkg_uri.is_absolute_path(): pkg_path = str(pkg.packageURI) else: pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()), str(pkg_uri.path())) ctx.ui.debug(_("Package URI: %s") % pkg_path) return Install(pkg_path) else: raise Error(_("Package %s not found in any active repository.") % name)
def install_single_name(name, upgrade = False): """install a single package from ID""" # find package in repository repo = packagedb.which_repo(name) if repo: repo = ctx.repodb.get_repo(repo) pkg = packagedb.get_package(name) # FIXME: let pkg.packageURI be stored as URI type rather than string pkg_uri = URI(pkg.packageURI) if pkg_uri.is_absolute_path(): pkg_path = str(pkg.packageURI) else: pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()), str(pkg_uri.path())) ctx.ui.debug(_("Package URI: %s") % pkg_path) # Package will handle remote file for us! install_single_file(pkg_path, upgrade) else: raise Error(_("Package %s not found in any active repository.") % name)