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