yanlış yere commit etmişim catbox altında deneyip daha sonra merge etmek istiyordum, komple geri alıyorum :(

This commit is contained in:
S.Çağlar Onur
2007-05-14 00:19:20 +00:00
parent 23665371b0
commit c448264e12
20 changed files with 160 additions and 113 deletions
+14 -11
View File
@@ -90,6 +90,7 @@ def init(database = True, write = True,
ctx.stderr = stderr
# FIXME: something is wrong here... see __init__.py also. Why do we import pisi.api in __init__.py
import pisi.config
ctx.config = pisi.config.Config(options)
if signal_handling:
@@ -162,6 +163,8 @@ def list_available(repo = None):
return set(ctx.packagedb.list_packages(repo = repo))
def list_upgradable():
ignore_build = ctx.get_option('ignore_build_no')
return filter(pisi.operations.is_upgradable, ctx.installdb.list_installed())
def package_graph(A, repo = pisi.itembyrepodb.installed, ignore_installed = False):
@@ -355,14 +358,14 @@ def search_in_packages(terms, packages, repo = pisi.itembyrepodb.all):
def check(package):
md, files = info(package, True)
corrupt = []
for f in files.list:
if f.hash and f.type != "config" \
and not os.path.islink('/' + f.path):
ctx.ui.info(_("Checking /%s ") % f.path, noln=True, verbose=True)
for file in files.list:
if file.hash and file.type != "config" \
and not os.path.islink('/' + file.path):
ctx.ui.info(_("Checking /%s ") % file.path, noln=True, verbose=True)
try:
if f.hash != pisi.util.sha1_file('/' + f.path):
corrupt.append(f)
ctx.ui.error(_("\nCorrupt file: %s") % f)
if file.hash != pisi.util.sha1_file('/' + file.path):
corrupt.append(file)
ctx.ui.error(_("\nCorrupt file: %s") % file)
else:
ctx.ui.info(_("OK"), verbose=True)
except pisi.util.FileError,e:
@@ -459,7 +462,7 @@ def rebuild_repo(repo):
def rebuild_db(files=False):
assert not ctx.database
assert ctx.database == False
# Bug 2596
# finds and cleans duplicate package directories under '/var/lib/pisi/package'
@@ -510,7 +513,7 @@ def rebuild_db(files=False):
percent = progress.update(processed),
info = _("Rebuilding package database"))
def reload_indices():
def reload_indices(txn):
index_dir = ctx.config.index_dir()
if os.path.exists(index_dir): # it may have been erased, or we may be upgrading from a previous version -- exa
for repo in os.listdir(index_dir):
@@ -524,7 +527,7 @@ def rebuild_db(files=False):
shelve.check_dbversion('filesdbversion', pisi.__filesdbversion__, write=False)
except KeyboardInterrupt:
raise
except Exception: #FIXME: what exception could we catch here, replace with that.
except Exception, e: #FIXME: what exception could we catch here, replace with that.
files = True # exception means the files db version was wrong
shelve.init_dbenv(write=True, writeversion=True)
destroy(files) # bye bye
@@ -540,7 +543,7 @@ def rebuild_db(files=False):
clean_duplicates()
txn = ctx.dbenv.txn_begin()
reload_packages(files, txn)
reload_indices()
reload_indices(txn)
txn.commit()
############# FIXME: this was a quick fix. ##############################
+17 -14
View File
@@ -15,12 +15,15 @@ import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import sys
import os
import bsddb3.db as db
import shutil
import pisi
import pisi.context as ctx
import pisi.packagedb as packagedb
import pisi.dependency as dependency
import pisi.conflict
import pisi.util as util
import pisi.metadata
@@ -146,7 +149,7 @@ class Install(AtomicOperation):
# check comar
if self.metadata.package.providesComar and ctx.comar:
import pisi.comariface as comariface
comariface.get_comar()
com = comariface.get_comar()
def check_relations(self):
# check dependencies
@@ -162,10 +165,10 @@ class Install(AtomicOperation):
# check file conflicts
file_conflicts = []
for f in self.files.list:
if ctx.filesdb.has_file(f.path):
pkg, existing_file = ctx.filesdb.get_file(f.path)
dst = pisi.util.join_path(ctx.config.dest_dir(), f.path)
for file in self.files.list:
if ctx.filesdb.has_file(file.path):
pkg, existing_file = ctx.filesdb.get_file(file.path)
dst = pisi.util.join_path(ctx.config.dest_dir(), file.path)
if pkg != self.pkginfo.name and not os.path.isdir(dst):
file_conflicts.append( (pkg, existing_file) )
if file_conflicts:
@@ -275,8 +278,8 @@ class Install(AtomicOperation):
fpath = pisi.util.join_path(ctx.config.dest_dir(), config.path)
if os.path.exists(fpath) and not os.path.isdir(fpath):
if os.path.islink(fpath):
f = os.readlink(fpath)
if os.path.exists(f) and pisi.util.sha1_data(f) != config.hash:
file = os.readlink(fpath)
if os.path.exists(file) and pisi.util.sha1_data(file) != config.hash:
changed = True
else:
if pisi.util.sha1_file(fpath) != config.hash:
@@ -355,13 +358,13 @@ class Install(AtomicOperation):
config_overlaps = newconfig & oldconfig
if config_overlaps:
files = filter(lambda x: x.path in config_overlaps, old)
for f in files:
check_config_changed(f)
for file in files:
check_config_changed(file)
else:
for f in self.files.list:
if f.type == 'config':
for file in self.files.list:
if file.type == 'config':
# there may be left over config files
check_config_changed(f)
check_config_changed(file)
if self.package_fname.endswith(ctx.const.delta_package_suffix):
relocate_files()
@@ -508,7 +511,7 @@ class Remove(AtomicOperation):
try:
if pisi.util.sha1_file(fpath) == fileinfo.hash:
os.unlink(fpath)
except pisi.util.FileError:
except pisi.util.FileError, e:
pass
else:
if os.path.isfile(fpath) or os.path.islink(fpath):
@@ -540,7 +543,7 @@ class Remove(AtomicOperation):
def remove_db(self, txn):
ctx.installdb.remove(self.package_name, txn)
ctx.filesdb.remove_files(self.files, txn)
ctx.packagedb.remove_tracking_package(self.package_name, txn)
pisi.packagedb.remove_tracking_package(self.package_name, txn)
def remove_single(package_name):
+8 -7
View File
@@ -13,6 +13,7 @@
# python standard library
import os
import sys
import glob
import copy
import stat
@@ -416,7 +417,7 @@ class Builder:
self.actionLocals[func]()
else:
if mandatory:
raise Error(_("unable to call function from actions: %s") % func)
Error, _("unable to call function from actions: %s") %func
os.chdir(curDir)
return True
@@ -559,7 +560,7 @@ class Builder:
except KeyError:
pisi.util.strip_directory(install_dir)
def gen_metadata_xml(self, package):
def gen_metadata_xml(self, package, build_no=None):
"""Generate the metadata.xml file for build source.
metadata.xml is composed of the information from specfile plus
@@ -662,15 +663,15 @@ class Builder:
ctx.ui.warning('Package file %s may be corrupt. Skipping.' % old_package_fn)
for root, dirs, files in os.walk(ctx.config.compiled_packages_dir()):
for f in files:
locate_old_package(pisi.util.join_path(root,f))
for file in files:
locate_old_package(pisi.util.join_path(root,file))
outdir=ctx.get_option('output_dir')
if not outdir:
outdir = '.'
for f in [pisi.util.join_path(outdir,entry) for entry in os.listdir(outdir)]:
if os.path.isfile(f):
locate_old_package(f)
for file in [pisi.util.join_path(outdir,entry) for entry in os.listdir(outdir)]:
if os.path.isfile(file):
locate_old_package(file)
if not found:
return (1, None)
+26 -24
View File
@@ -99,9 +99,9 @@ class Command(object):
@staticmethod
def commands_string():
s = ''
l = [x.name[0] for x in Command.cmd]
l.sort()
for name in l:
list = [x.name[0] for x in Command.cmd]
list.sort()
for name in list:
commandcls = Command.cmd_dict[name]
trans = gettext.translation('pisi', fallback=True)
summary = trans.ugettext(commandcls.__doc__).split('\n')[0]
@@ -173,12 +173,12 @@ class Command(object):
# make destdir absolute
if self.options.destdir:
d = str(self.options.destdir)
dir = str(self.options.destdir)
import os.path
if not os.path.exists(d):
pisi.cli.printu(_('Destination directory %s does not exist. Creating directory.\n') % d)
os.makedirs(d)
self.options.destdir = os.path.realpath(d)
if not os.path.exists(dir):
pisi.cli.printu(_('Destination directory %s does not exist. Creating directory.\n') % dir)
os.makedirs(dir)
self.options.destdir = os.path.realpath(dir)
def check_auth_info(self):
username = self.options.username
@@ -528,7 +528,7 @@ and creates a delta pisi package with the changed files between two releases.
self.init(database=False, write=False)
if len(self.args) != 2:
if len(self.args) is not 2:
self.help()
return
@@ -728,9 +728,9 @@ expanded to package names.
import os
patterns = []
f = ctx.get_option('exclude_from')
if os.path.exists(f):
for line in open(f, "r").readlines():
file = ctx.get_option('exclude_from')
if os.path.exists(file):
for line in open(file, "r").readlines():
if not line.startswith('#') and not line == '\n':
patterns.append(line.strip())
if patterns:
@@ -750,8 +750,8 @@ expanded to package names.
if not match:
# match pattern in component names
for compare in fnmatch.filter(ctx.componentdb.list_components(), pattern):
packages = packages - set(ctx.componentdb.get_union_packages(compare, walk=True))
for cmp in fnmatch.filter(ctx.componentdb.list_components(), pattern):
packages = packages - set(ctx.componentdb.get_union_packages(cmp, walk=True))
return list(packages)
@@ -966,6 +966,8 @@ Usage: info <package1> <package2> ... <packagen>
ctx.ui.info(_("%s is not installed") % arg)
def print_pkginfo(self, metadata, files, repo = None):
import os.path
if ctx.get_option('short'):
pkg = metadata.package
ctx.ui.info('%15s - %s' % (pkg.name, unicode(pkg.summary)))
@@ -1379,12 +1381,12 @@ all repositories.
component = ctx.get_option('component')
if component:
l = ctx.componentdb.get_packages(component, walk=True, repo=repo)
list = ctx.componentdb.get_packages(component, walk=True, repo=repo)
else:
l = ctx.packagedb.list_packages(repo)
list = ctx.packagedb.list_packages(repo)
installed_list = ctx.installdb.list_installed()
l.sort()
for p in l:
list.sort()
for p in list:
package = ctx.packagedb.get_package(p)
if self.options.long:
ctx.ui.info(unicode(package))
@@ -1422,9 +1424,9 @@ repositories.
self.init(database = True, write = False)
l = ctx.componentdb.list_components()
l.sort()
for p in l:
list = ctx.componentdb.list_components()
list.sort()
for p in list:
component = ctx.componentdb.get_component(p)
if self.options.long:
ctx.ui.info(unicode(component))
@@ -1461,9 +1463,9 @@ Gives a brief list of sources published in the repositories.
self.init(database = True, write = False)
l = ctx.sourcedb.list()
l.sort()
for p in l:
list = ctx.sourcedb.list()
list.sort()
for p in list:
sf, repo = ctx.sourcedb.get_spec_repo(p)
if self.options.long:
ctx.ui.info('[Repository: ' + repo + ']')
+3 -3
View File
@@ -82,9 +82,9 @@ class Config(object):
return self.destdir
def subdir(self, path):
subdir = pisi.util.join_path(self.dest_dir(), path)
pisi.util.check_dir(subdir)
return subdir
dir = pisi.util.join_path(self.dest_dir(), path)
pisi.util.check_dir(dir)
return dir
def lib_dir(self):
return self.subdir(self.values.dirs.lib_dir)
+2
View File
@@ -18,6 +18,8 @@ import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi
class _constant:
"Constant members implementation"
class ConstError(TypeError):
+2
View File
@@ -38,6 +38,8 @@ import cPickle
import bsddb3.db as db
import bsddb3.dbobj as dbobj
import string
import sys
import traceback
import pisi
class CodingError(pisi.Error):
+15 -15
View File
@@ -74,8 +74,8 @@ def create_delta_package(old_package, new_package):
ctx.build_leftover = util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma)
tar = archive.ArchiveTar(util.join_path(ctx.config.tmp_dir(), ctx.const.install_tar_lzma), "tarlzma")
for f in files_delta:
tar.add_to_archive(f.path)
for file in files_delta:
tar.add_to_archive(file.path)
tar.close()
os.chdir(ctx.config.tmp_dir())
@@ -99,34 +99,34 @@ def create_delta_package(old_package, new_package):
def find_delta(oldfiles, newfiles):
hashto_files = {}
for f in newfiles.list:
hashto_files.setdefault(f.hash, []).append(f)
for file in newfiles.list:
hashto_files.setdefault(file.hash, []).append(file)
files_new = sets.Set(map(lambda x:x.hash, newfiles.list))
files_old = sets.Set(map(lambda x:x.hash, oldfiles.list))
files_delta = files_new - files_old
deltas = []
for h in files_delta:
deltas.extend(hashto_files[h])
for hash in files_delta:
deltas.extend(hashto_files[hash])
return deltas
def find_relocations(oldfiles, newfiles):
files_new = {}
for f in newfiles.list:
files_new.setdefault(f.hash, []).append(f)
for file in newfiles.list:
files_new.setdefault(file.hash, []).append(file)
files_old = {}
for f in oldfiles.list:
files_old.setdefault(f.hash, []).append(f)
for file in oldfiles.list:
files_old.setdefault(file.hash, []).append(file)
relocations = []
for h in files_new.keys():
if h and h in files_old:
for i in range(len(files_new[h])):
if files_old[h][0].path != files_new[h][i].path:
relocations.append((files_old[h][0], files_new[h][i]))
for hash in files_new.keys():
if hash and hash in files_old:
for i in range(len(files_new[hash])):
if files_old[hash][0].path != files_new[hash][i].path:
relocations.append((files_old[hash][0], files_new[hash][i]))
return relocations
+5 -6
View File
@@ -282,17 +282,17 @@ class FTPRangeHandler(urllib2.FTPHandler):
path, attrs = urllib.splitattr(req.get_selector())
dirs = path.split('/')
dirs = map(urllib.unquote, dirs)
dirs, f = dirs[:-1], dirs[-1]
dirs, file = dirs[:-1], dirs[-1]
if dirs and not dirs[0]:
dirs = dirs[1:]
try:
fw = self.connect_ftp('', '', host, port, dirs)
t = f and 'I' or 'D'
type = file and 'I' or 'D'
for attr in attrs:
attr, value = urllib.splitattr(attr)
if attr.lower() == 'type' and \
value in ('a', 'A', 'i', 'I', 'd', 'D'):
t = value.upper()
type = value.upper()
rawr = req.headers.get('Range', None)
if rawr:
@@ -300,7 +300,7 @@ class FTPRangeHandler(urllib2.FTPHandler):
else:
rest = 0
fp, retrlen = fw.retrfile(f, t, rest)
fp, retrlen = fw.retrfile(file, type, rest)
fb, lb = rest, retrlen
if retrlen is None or retrlen == 0:
@@ -327,7 +327,7 @@ class FTPRangeHandler(urllib2.FTPHandler):
raise IOError, (_('ftp error'), msg), sys.exc_info()[2]
def connect_ftp(self, user, passwd, host, port, dirs):
fw = ftpwrapper(user, passwd, host, port, dirs)
fw = ftpwrapper('', '', host, port, dirs)
return fw
class ftpwrapper(urllib.ftpwrapper):
@@ -355,7 +355,6 @@ class ftpwrapper(urllib.ftpwrapper):
if str(reason)[:3] == '501':
# workaround for REST not suported error
fp, retrlen = self.retrfile(file, type)
# WTF? No global (RangeableFileObject) found. RangeableFileObject only defined in urlgrabber / caglar
fp = RangeableFileObject(fp, (rest,''))
return (fp, retrlen)
elif str(reason)[:3] != '550':
+3 -3
View File
@@ -44,11 +44,11 @@ class Digraph(object):
def edges(self):
"return a list of edge descriptors"
l = []
list = []
for u in self.__v:
for v in self.__adj[u]:
l.append( (u,v) )
return l
list.append( (u,v) )
return list
def from_list(self, el):
"convert a list of edges (u,v) to graph"
+3
View File
@@ -23,12 +23,15 @@ import pisi
import pisi.context as ctx
import pisi.specfile as specfile
import pisi.metadata as metadata
import pisi.packagedb as packagedb
import pisi.sourcedb as sourcedb
import pisi.util as util
import pisi.package
import pisi.pxml.xmlfile as xmlfile
import pisi.file
import pisi.pxml.autoxml as autoxml
import pisi.component as component
import pisi.specfile as specfile
class Error(pisi.Error):
pass
+10 -6
View File
@@ -13,6 +13,10 @@
# installation database
#
# System
import os
import fcntl
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
@@ -106,20 +110,20 @@ class InstallDB:
def list_installed(self, txn = None):
def proc(txn):
l = []
list = []
for (pkg, info) in self.d.items(txn):
if info.state=='i' or info.state=='ip':
l.append(pkg)
return l
list.append(pkg)
return list
return self.d.txn_proc(proc, txn)
def list_pending(self):
# warning: reads the entire db
d = {}
dict = {}
for (pkg, x) in self.dp.items():
pkginfo = self.d[pkg]
d[pkg] = pkginfo
return d
dict[pkg] = pkginfo
return dict
def get_info(self, pkg):
pkg = str(pkg)
+6
View File
@@ -10,11 +10,16 @@
# Please read the COPYING file.
#
import os
import fcntl
import types
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi
import pisi.util as util
import pisi.context as ctx
import pisi.lockeddbshelve as shelve
@@ -85,6 +90,7 @@ class ItemByRepoDB(object):
if repo == None:
repo = repos
assert repo in [all, repos]
import pisi.repodb
order = [ 'repo-' + x for x in ctx.repodb.list() ]
if repo == all:
order += ['trdparty', 'inst']
+10 -8
View File
@@ -24,6 +24,7 @@ import pisi.util as util
import pisi.dependency as dependency
import pisi.conflict
import pisi.pgraph as pgraph
import pisi.packagedb as packagedb
import pisi.repodb
import pisi.installdb
import pisi.cli
@@ -245,7 +246,7 @@ def calculate_conflicts(order, packagedb):
return (C, D, pkg_conflicts)
def remove_conflicting_packages(conflicts):
if not remove(conflicts, ignore_dep=True, ignore_safety=True):
if remove(conflicts, ignore_dep=True, ignore_safety=True) == False:
raise Error(_("Conflicts remain"))
def check_conflicts(order, packagedb):
@@ -280,7 +281,7 @@ def is_upgradable(name, ignore_build = False):
pkg = ctx.packagedb.get_package(name)
except KeyboardInterrupt:
raise
except Exception: #FIXME: what exception could we catch here, replace with that.
except Exception, e: #FIXME: what exception could we catch here, replace with that.
return False
if ignore_build or (not build) or (not pkg.build):
return pisi.version.Version(release) < pisi.version.Version(pkg.release)
@@ -302,7 +303,7 @@ def upgrade_base(A = set(), ignore_package_conflicts = False):
if extra_upgrades:
ctx.ui.warning(_('Safety switch: Following packages in system.base will be upgraded: ') +
util.strlist(extra_upgrades))
G_f, upgrade_order = plan_upgrade(extra_upgrades)
G_f, upgrade_order = plan_upgrade(extra_upgrades, ignore_build)
# return packages that must be added to any installation
return set(install_order + upgrade_order)
else:
@@ -464,7 +465,7 @@ def upgrade_pkg_names(A = []):
ctx.ui.debug('A = %s' % str(A))
if not ctx.config.get_option('ignore_dependency'):
G_f, order = plan_upgrade(A)
G_f, order = plan_upgrade(A, ignore_build)
else:
G_f = None
order = list(A)
@@ -512,7 +513,7 @@ def upgrade_pkg_names(A = []):
if 'pisi' in order:
upgrade_pisi()
def plan_upgrade(A):
def plan_upgrade(A, ignore_build = False):
# try to construct a pisi graph of packages to
# install / reinstall
@@ -640,6 +641,7 @@ def plan_remove(A):
while len(B) > 0:
Bp = set()
for x in B:
pkg = ctx.packagedb.get_package(x, pisi.itembyrepodb.installed)
rev_deps = ctx.packagedb.get_rev_deps(x, pisi.itembyrepodb.installed)
for (rev_dep, depinfo) in rev_deps:
# we don't deal with uninstalled rev deps
@@ -664,7 +666,7 @@ def expand_src_components(A):
Ap.add(x)
return Ap
def emerge(A):
def emerge(A, rebuild_all = False):
# A was a list, remove duplicates and expand components
A = [str(x) for x in A]
@@ -680,7 +682,7 @@ def emerge(A):
# FIXME: Errr... order_build changes type conditionally and this
# is not good. - baris
if not ctx.config.get_option('ignore_dependency'):
G_f, order_inst, order_build = plan_emerge(A)
G_f, order_inst, order_build = plan_emerge(A, rebuild_all)
else:
G_f = None
order_inst = []
@@ -721,7 +723,7 @@ installed in the respective order to satisfy dependencies:
if 'pisi' in order_build or (('pisi' in U) and pisi_installed):
upgrade_pisi()
def plan_emerge(A):
def plan_emerge(A, rebuild_all):
# try to construct a pisi graph of packages to
# install / reinstall
+7 -1
View File
@@ -17,12 +17,18 @@ we basically store everything in PackageInfo class
yes, we are cheap
"""
import os
import fcntl
import types
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi
import pisi.util as util
import pisi.context as ctx
import pisi.lockeddbshelve as shelve
import pisi.itembyrepodb
class Error(pisi.Error):
@@ -55,7 +61,7 @@ class PackageDB(object):
def get_package(self, name, repo=None, txn = None):
try:
return self.d.get_item(name, repo, txn=txn)
except pisi.itembyrepodb.NotfoundError:
except pisi.itembyrepodb.NotfoundError, e:
raise Error(_('Package %s not found') % name)
def get_package_repo(self, name, repo=None, txn = None):
-1
View File
@@ -76,7 +76,6 @@ class PGraph(graph.Digraph):
pkg2 = self.packagedb.get_package(conflinfo.package, self.repo)
pkg2data = (pkg2.version, pkg2.release)
# FIXME: WTF? /usr/lib/pardus/pisi/pgraph.py:80: Invalid arguments to (add_biedge), got 5, expected between 2 and 3 / caglar
self.add_biedge(str(pkg), str(conflinfo.package), ('c', conflinfo)
, pkg1data, pkg2data )
+7 -3
View File
@@ -10,6 +10,8 @@
# Please read the COPYING file.
#
import os, fcntl
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
@@ -17,6 +19,8 @@ _ = __trans.ugettext
import pisi
import pisi.lockeddbshelve as shelve
import pisi.context as ctx
import pisi.packagedb as packagedb
import pisi.util as util
class Error(pisi.Error):
pass
@@ -97,9 +101,9 @@ class RepoDB(object):
name = str(name)
def proc(txn):
self.d.delete("repo-" + name, txn)
l = self.d.get("order", txn)
l.remove(name)
self.d.put("order", l, txn)
list = self.d.get("order", txn)
list.remove(name)
self.d.put("order", list, txn)
ctx.packagedb.remove_repo(name, txn=txn)
ctx.sourcedb.remove_repo(name, txn=txn)
ctx.componentdb.remove_repo(name, txn=txn)
+7 -2
View File
@@ -20,11 +20,16 @@ store a set of repositories in which the source appears.
the actual guy to take is determined from the repo order.
"""
import os
import fcntl
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi.util as util
import pisi.context as ctx
import pisi.lockeddbshelve as shelve
import pisi.repodb
import pisi.itembyrepodb
@@ -50,13 +55,13 @@ class SourceDB(object):
def get_spec(self, name, repo=None, txn = None):
try:
return self.d.get_item(name, repo, txn)
except pisi.itembyrepodb.NotfoundError:
except pisi.itembyrepodb.NotfoundError, e:
raise NotfoundError(_("Source package %s not found") % name)
def get_spec_repo(self, name, repo=None, txn = None):
try:
return self.d.get_item_repo(name, repo, txn)
except pisi.itembyrepodb.NotfoundError:
except pisi.itembyrepodb.NotfoundError, e:
raise NotfoundError(_("Source package %s not found") % name)
def pkgtosrc(self, name, txn = None):
+5
View File
@@ -12,6 +12,11 @@
# generic user interface
#
import sys
import pisi
import pisi.context as ctx
(installed, upgraded, removed, installing, removing, configuring, configured, extracting,
downloading, packagestogo, updatingrepo, cached) = range(12)
+10 -9
View File
@@ -72,7 +72,7 @@ def multisplit(str, chars):
"""Split str with any of the chars."""
l = [str]
for c in chars:
l = concat(map(lambda x:x.split(c)), l)
l = concat(map(lambda x:x.split(c), l))
return l
def same(l):
@@ -265,12 +265,12 @@ def check_file(file, mode = os.F_OK):
return True
# FIXME: check_dir is not a good name considering it can also create the dir
def check_dir(d):
def check_dir(dir):
"""Make sure given directory path exists."""
# FIXME: What is first strip doing there?
d = d.strip().rstrip("/")
if not os.access(d, os.F_OK):
os.makedirs(d)
dir = dir.strip().rstrip("/")
if not os.access(dir, os.F_OK):
os.makedirs(dir)
def clean_dir(path):
"""Remove all content of a directory."""
@@ -393,8 +393,8 @@ def get_file_hashes(top, excludePrefix=None, removePrefix=None):
continue
#bug 397
for directory in dirs:
d = join_path(root, directory)
for dir in dirs:
d = join_path(root, dir)
if os.path.islink(d) and not has_excluded_prefix(d):
yield (d, sha1_sum(os.readlink(d), True))
excludePrefix.append(remove_prefix(removePrefix, d) + "/")
@@ -455,7 +455,7 @@ def sha1_data(data):
return m.hexdigest()
except KeyboardInterrupt:
raise
except Exception: #FIXME: what exception could we catch here, replace with that.
except Exception, e: #FIXME: what exception could we catch here, replace with that.
raise Error(_("Cannot calculate SHA1 hash of given data"))
def uncompress(patchFile, compressType="gz", targetDir=None):
@@ -607,9 +607,10 @@ def is_package_name(fn, package_name = None):
# get version string, skip separator '-'
verstr = fn[len(package_name) + 1:
len(fn)-len(ctx.const.package_suffix)]
import string
for x in verstr.split('-'):
# weak rule: version components after '-' start with a digit
if x == '' or (not x[0] in string.digits):
if x is '' or (not x[0] in string.digits):
return False
return True
return False