* fix: make local repos work, there was a problem with Index.read(),
it had to be another name. Also, copylocal didn't work, preventing the sha1sum shortcut * add shortcuts for frequently used commands
This commit is contained in:
+6
-6
@@ -368,12 +368,12 @@ def update_repo(repo, force=False):
|
||||
if ctx.repodb.has_repo(repo):
|
||||
repouri = ctx.repodb.get_repo(repo).indexuri.get_uri()
|
||||
try:
|
||||
index.read_uri(repouri, repo)
|
||||
index.read_uri_of_repo(repouri, repo)
|
||||
except pisi.file.AlreadyHaveException, e:
|
||||
ctx.ui.info(_('No updates available for repository %s.') % repo)
|
||||
if force:
|
||||
ctx.ui.info(_('Updating database at any rate as requested'))
|
||||
index.read_uri(repouri, repo, force = force)
|
||||
index.read_uri_of_repo(repouri, repo, force = force)
|
||||
else:
|
||||
return
|
||||
try:
|
||||
@@ -400,10 +400,11 @@ def rebuild_repo(repo):
|
||||
indexpath = pisi.util.join_path(ctx.config.index_dir(), repo, indexname)
|
||||
tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')
|
||||
pisi.util.clean_dir(tmpdir)
|
||||
pisi.util.check_dir(tmpdir)
|
||||
try:
|
||||
index.read(indexpath, tmpdir)
|
||||
except IOError:
|
||||
ctx.ui.warning(_("Repo index file '%s' not found.") % uri_str)
|
||||
index.read_uri(indexpath, tmpdir, force=True) # don't look for sha1sum there
|
||||
except IOError, e:
|
||||
ctx.ui.warning(_("Input/Output error while reading %s: %s") % (indexpath, unicode(e)))
|
||||
return
|
||||
ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
|
||||
ctx.ui.info(_('OK.'))
|
||||
@@ -487,7 +488,6 @@ def rebuild_db(files=False):
|
||||
finalize()
|
||||
# construct new database version
|
||||
init(database=True, options=options, ui=ui, comar=comar)
|
||||
#ctx.txn_proc(reload)
|
||||
clean_duplicates()
|
||||
reload_packages(files, None)
|
||||
reload_indices(None)
|
||||
|
||||
@@ -206,7 +206,7 @@ If run without parameters, it prints the general help."""
|
||||
#self.__doc__ += commands_string()
|
||||
super(Help, self).__init__()
|
||||
|
||||
name = ("help", "h")
|
||||
name = ("help", "?")
|
||||
|
||||
def run(self):
|
||||
|
||||
@@ -249,7 +249,7 @@ class DeleteCache(Command):
|
||||
def __init__(self):
|
||||
super(DeleteCache, self).__init__()
|
||||
|
||||
name = ("delete-cache", None)
|
||||
name = ("delete-cache", "dc")
|
||||
|
||||
def run(self):
|
||||
self.init(database=False, write=True)
|
||||
@@ -1183,7 +1183,7 @@ in summary, description, and package name fields.
|
||||
def __init__(self):
|
||||
super(Search, self).__init__()
|
||||
|
||||
name = ("search", None)
|
||||
name = ("search", "sr")
|
||||
|
||||
def options(self):
|
||||
super(Search, self).options()
|
||||
|
||||
+4
-5
@@ -118,10 +118,10 @@ class File:
|
||||
ctx.ui.info(_("Fetching %s") % uri.get_uri())
|
||||
fetch_url(uri, transfer_dir)
|
||||
else:
|
||||
# copy to transfer dir, it's okay if transfer_dir is the same
|
||||
if not os.path.samefile(uri.get_uri(), join(transfer_dir, uri.filename())):
|
||||
ctx.ui.info(_("Copying %s to transfer dir") % uri.get_uri())
|
||||
shutil.copy(uri.get_uri(), transfer_dir)
|
||||
# copy to transfer dir,
|
||||
localfile = join(transfer_dir, uri.filename())
|
||||
ctx.ui.info(_("Copying %s to transfer dir") % uri.get_uri())
|
||||
shutil.copy(uri.get_uri(), transfer_dir)
|
||||
else:
|
||||
localfile = uri.get_uri() #TODO: use a special function here?
|
||||
if not os.path.exists(localfile):
|
||||
@@ -132,7 +132,6 @@ class File:
|
||||
shutil.copy(oldfn, localfile)
|
||||
|
||||
if sha1sum:
|
||||
|
||||
if (pisi.util.sha1_file(localfile) != newsha1):
|
||||
raise Error(_("File integrity of %s compromised.") % uri)
|
||||
|
||||
|
||||
+7
-6
@@ -54,12 +54,12 @@ class Index(XmlFile):
|
||||
def name():
|
||||
return self.distribution.name + self.distribution.repositoryname
|
||||
|
||||
def read(filename, tmpdir):
|
||||
XmlFile.read(filename, tmpDir=tmpdir, sha1sum=not force,
|
||||
compress=File.auto, sign=File.detached, copylocal = True)
|
||||
def read_uri(self, uri, tmpdir, force = False):
|
||||
self.read(uri, tmpDir=tmpdir, sha1sum=not force,
|
||||
compress=File.auto, sign=File.detached, copylocal = True)
|
||||
|
||||
# read index for a given repo, force means download even if remote not updated
|
||||
def read_uri(self, filename, repo = None, force = False):
|
||||
def read_uri_of_repo(self, uri, repo = None, force = False):
|
||||
"""Read PSPEC file"""
|
||||
if repo:
|
||||
tmpdir = os.path.join(ctx.config.index_dir(), repo)
|
||||
@@ -70,9 +70,10 @@ class Index(XmlFile):
|
||||
|
||||
# write uri
|
||||
urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w')
|
||||
urlfile.write(filename) # uri
|
||||
urlfile.write(uri) # uri
|
||||
urlfile.close()
|
||||
|
||||
self.read(filename, tmpdir)
|
||||
self.read_uri(uri, tmpdir, force)
|
||||
|
||||
if not repo:
|
||||
repo = self.distribution.name()
|
||||
|
||||
@@ -58,11 +58,11 @@ class XmlFile(object):
|
||||
def readxml(self, uri, tmpDir='/tmp', sha1sum=False,
|
||||
compress=None, sign=None, copylocal = False):
|
||||
uri = File.make_uri(uri)
|
||||
try:
|
||||
localpath = File.download(uri, tmpDir, sha1sum=sha1sum,
|
||||
compress=compress,sign=sign, copylocal=copylocal)
|
||||
except IOError:
|
||||
raise Error(_("Cannot access URI %s") % (uri) )
|
||||
#try:
|
||||
localpath = File.download(uri, tmpDir, sha1sum=sha1sum,
|
||||
compress=compress,sign=sign, copylocal=copylocal)
|
||||
#except IOError, e:
|
||||
# raise Error(_("Cannot read URI %s: %s") % (uri, unicode(e)) )
|
||||
try:
|
||||
self.doc = iks.parse(localpath)
|
||||
return self.doc
|
||||
|
||||
Reference in New Issue
Block a user