Download all before installing, report errors
This commit is contained in:
+5
-1
@@ -112,9 +112,13 @@ class RepoDB(lazydb.LazyDB):
|
|||||||
return piksemel.parse(index_path)
|
return piksemel.parse(index_path)
|
||||||
|
|
||||||
def get_repo(self, repo):
|
def get_repo(self, repo):
|
||||||
|
return Repo(pisi.uri.URI(self.get_repo_url(repo)))
|
||||||
|
|
||||||
|
#FIXME: this method is a quick hack around repo_info.indexuri.get_uri()
|
||||||
|
def get_repo_url(self, repo):
|
||||||
urifile_path = pisi.util.join_path(ctx.config.index_dir(), repo, "uri")
|
urifile_path = pisi.util.join_path(ctx.config.index_dir(), repo, "uri")
|
||||||
uri = open(urifile_path, "r").read()
|
uri = open(urifile_path, "r").read()
|
||||||
return Repo(pisi.uri.URI(uri))
|
return uri
|
||||||
|
|
||||||
def add_repo(self, name, repo_info, at = None):
|
def add_repo(self, name, repo_info, at = None):
|
||||||
repo_path = pisi.util.join_path(ctx.config.index_dir(), name)
|
repo_path = pisi.util.join_path(ctx.config.index_dir(), name)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
|
|
||||||
|
import os
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation("pisi", fallback=True)
|
__trans = gettext.translation("pisi", fallback=True)
|
||||||
_ = __trans.ugettext
|
_ = __trans.ugettext
|
||||||
@@ -16,6 +17,7 @@ _ = __trans.ugettext
|
|||||||
import pisi.context as ctx
|
import pisi.context as ctx
|
||||||
import pisi.util
|
import pisi.util
|
||||||
import pisi.db
|
import pisi.db
|
||||||
|
import pisi.fetcher
|
||||||
|
|
||||||
def __listactions(actions):
|
def __listactions(actions):
|
||||||
beinstalled = []
|
beinstalled = []
|
||||||
@@ -30,6 +32,32 @@ def __listactions(actions):
|
|||||||
|
|
||||||
return beinstalled, beremoved
|
return beinstalled, beremoved
|
||||||
|
|
||||||
|
def __getpackageurl(package):
|
||||||
|
packagedb = pisi.db.packagedb.PackageDB()
|
||||||
|
repodb = pisi.db.repodb.RepoDB()
|
||||||
|
|
||||||
|
pkg, ver = pisi.util.parse_package_name(package)
|
||||||
|
reponame = packagedb.which_repo(pkg)
|
||||||
|
repourl = repodb.get_repo_url(reponame)
|
||||||
|
|
||||||
|
ctx.ui.info(_("Package %s found in repository %s") % (pkg, reponame))
|
||||||
|
|
||||||
|
#return _possible_ url for this package
|
||||||
|
return os.path.join(os.path.dirname(repourl), package)
|
||||||
|
|
||||||
|
def fetch_remote_file(package, errors):
|
||||||
|
uri = pisi.file.File.make_uri(__getpackageurl(package))
|
||||||
|
dest = ctx.config.cached_packages_dir()
|
||||||
|
filepath = os.path.join(dest, uri.filename())
|
||||||
|
if not os.path.exists(filepath):
|
||||||
|
try:
|
||||||
|
pisi.fetcher.fetch_url(uri, dest, ctx.ui.Progress)
|
||||||
|
except pisi.fetcher.FetchError, e:
|
||||||
|
errors.append(package)
|
||||||
|
ctx.ui.info(pisi.util.colorize(_("%s could not be found") % (package), "red"))
|
||||||
|
else:
|
||||||
|
ctx.ui.info(_('%s [cached]') % uri.filename())
|
||||||
|
|
||||||
def takeback(operation):
|
def takeback(operation):
|
||||||
|
|
||||||
historydb = pisi.db.historydb.HistoryDB()
|
historydb = pisi.db.historydb.HistoryDB()
|
||||||
@@ -55,3 +83,16 @@ def takeback(operation):
|
|||||||
|
|
||||||
if (beremoved or beinstalled) and not ctx.ui.confirm(_('Do you want to continue?')):
|
if (beremoved or beinstalled) and not ctx.ui.confirm(_('Do you want to continue?')):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
errors = []
|
||||||
|
paths = []
|
||||||
|
for pkg in beinstalled:
|
||||||
|
ctx.ui.info(pisi.util.colorize(_("Downloading %d / %d") % (beinstalled.index(pkg)+1, len(beinstalled)), "yellow"))
|
||||||
|
fetch_remote_file(pkg, errors)
|
||||||
|
paths.append(os.path.join(ctx.config.cached_packages_dir(), pkg))
|
||||||
|
|
||||||
|
if errors:
|
||||||
|
ctx.ui.info(_("\nFollowing packages could not be found in repositories and are not cached:\n") +
|
||||||
|
pisi.util.strlist(errors))
|
||||||
|
if not ctx.ui.confirm(_('Do you want to continue?')):
|
||||||
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user