* configure-pending: calculate order

* gettext stuff, i18n
This commit is contained in:
Eray Özkural
2005-10-03 12:15:45 +00:00
parent 771176d134
commit 997542cecb
13 changed files with 147 additions and 83 deletions
+2 -1
View File
@@ -78,7 +78,7 @@ Legend:
- configure-pending (eray) - configure-pending (eray)
/ i18n support / i18n support
- summary,description için doğru dili kullanmak - summary,description için doğru dili kullanmak
- pisi mesajlarının çevrilebilir hale getirilmesi (build.py yi örnek alın) / pisi mesajlarının çevrilebilir hale getirilmesi (build.py yi örnek alın)
- build sistemine .pot oluşturma vs desteği (pygettext) - build sistemine .pot oluşturma vs desteği (pygettext)
- mesajların çevirisinin yapılması (pisi tr.po) - mesajların çevirisinin yapılması (pisi tr.po)
/ query / query
@@ -119,6 +119,7 @@ Legend:
- removable media: media:// - removable media: media://
- partial caching and automatic resume for file download (meren) - partial caching and automatic resume for file download (meren)
- use a separate "partial/" subdir like urpmi - use a separate "partial/" subdir like urpmi
- a helper script for finding dependencies
* low priority * low priority
+62 -40
View File
@@ -17,6 +17,7 @@ import sys
ver = sys.version_info ver = sys.version_info
if ver[0] <= 2 and ver[1] < 4: if ver[0] <= 2 and ver[1] < 4:
from sets import Set as set from sets import Set as set
import gettext import gettext
__trans = gettext.translation('pisi', fallback=True) __trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext _ = __trans.ugettext
@@ -53,7 +54,7 @@ def init(database = True, options = None, ui = None, comar = True):
ctx.comard = comar.Link() ctx.comard = comar.Link()
except ImportError: except ImportError:
raise Error(_("COMAR: comard not fully installed")) raise Error(_("COMAR: comard not fully installed"))
print "skipping COMAR connection for now..." print _("skipping COMAR connection for now...")
except comar.Error: except comar.Error:
raise Error(_("COMAR: comard not running or defunct")) raise Error(_("COMAR: comard not running or defunct"))
@@ -109,10 +110,10 @@ def install_pkg_files(package_URIs):
for x in package_URIs: for x in package_URIs:
if not x.endswith(ctx.const.package_prefix): if not x.endswith(ctx.const.package_prefix):
ctx.ui.error('Mixing file names and package names not supported YET.\n') ctx.ui.error(_('Mixing file names and package names not supported YET.'))
return False return False
if ctx.config.get_option('ignore_dependency'): if ctx.config.get_option(_('ignore_dependency')):
# simple code path then # simple code path then
for x in package_URIs: for x in package_URIs:
operations.install_single_file(x) operations.install_single_file(x)
@@ -164,7 +165,7 @@ def install_pkg_files(package_URIs):
A = d_t.keys() A = d_t.keys()
if len(A)==0: if len(A)==0:
ctx.ui.info('No packages to install.') ctx.ui.info(_('No packages to install.'))
return True return True
# try to construct a pisi graph of packages to # try to construct a pisi graph of packages to
@@ -199,7 +200,7 @@ def install_pkg_files(package_URIs):
for x in order: for x in order:
operations.install_single_file(dfn[x]) operations.install_single_file(dfn[x])
else: else:
raise Error('External dependencies not satisfied') raise Error(_('External dependencies not satisfied'))
return True # everything went OK. return True # everything went OK.
@@ -211,7 +212,7 @@ def install_pkg_names(A):
ctx.ui.debug('A = %s' % str(A)) ctx.ui.debug('A = %s' % str(A))
if len(A)==0: if len(A)==0:
ctx.ui.info('No packages to install.') ctx.ui.info(_('No packages to install.'))
return True return True
# try to construct a pisi graph of packages to # try to construct a pisi graph of packages to
@@ -232,7 +233,7 @@ def install_pkg_names(A):
pkg = packagedb.get_package(x) pkg = packagedb.get_package(x)
print pkg print pkg
for dep in pkg.runtimeDeps: for dep in pkg.runtimeDeps:
print 'checking ', dep ctx.ui.debug('checking %s' % str(dep))
# we don't deal with already *satisfied* dependencies # we don't deal with already *satisfied* dependencies
if not dependency.installed_satisfies_dep(dep): if not dependency.installed_satisfies_dep(dep):
if not dep.package in G_f.vertices(): if not dep.package in G_f.vertices():
@@ -285,7 +286,6 @@ def package_graph(A, ignore_installed = False):
def upgrade(A): def upgrade(A):
upgrade_pkg_names(A) upgrade_pkg_names(A)
def upgrade_pkg_names(A): def upgrade_pkg_names(A):
"""Re-installs packages from the repository, trying to perform """Re-installs packages from the repository, trying to perform
a maximum number of upgrades.""" a maximum number of upgrades."""
@@ -296,9 +296,9 @@ def upgrade_pkg_names(A):
Ap = [] Ap = []
for x in A: for x in A:
if x.endswith('.pisi'): if x.endswith('.pisi'):
ctx.ui.debug("Warning: package *name* ends with '.pisi'") ctx.ui.debug(_("Warning: package *name* ends with '.pisi'"))
if not ctx.installdb.is_installed(x): if not ctx.installdb.is_installed(x):
ctx.ui.info('Package %s is not installed.' % x) ctx.ui.info(_('Package %s is not installed.') % x)
continue continue
(version, release, build) = ctx.installdb.get_version(x) (version, release, build) = ctx.installdb.get_version(x)
pkg = packagedb.get_package(x) pkg = packagedb.get_package(x)
@@ -316,13 +316,13 @@ def upgrade_pkg_names(A):
Ap.append(x) Ap.append(x)
else: else:
#ctx.ui.info('Package %s cannot be upgraded. ' % x) #ctx.ui.info('Package %s cannot be upgraded. ' % x)
ctx.ui.info('Package %s is already at its latest version %s,\ ctx.ui.info(_('Package %s is already at its latest version %s,\
release %s, build %s.' release %s, build %s.')
% (x, pkg.version, pkg.release, pkg.build)) % (x, pkg.version, pkg.release, pkg.build))
A = Ap A = Ap
if len(A)==0: if len(A)==0:
ctx.ui.info('No packages to upgrade.') ctx.ui.info(_('No packages to upgrade.'))
return True return True
ctx.ui.debug('A = %s' % str(A)) ctx.ui.debug('A = %s' % str(A))
@@ -344,7 +344,7 @@ def upgrade_pkg_names(A):
pkg = packagedb.get_package(x) pkg = packagedb.get_package(x)
print pkg print pkg
for dep in pkg.runtimeDeps: for dep in pkg.runtimeDeps:
print 'checking ', dep #print 'checking ', dep
# add packages that can be upgraded # add packages that can be upgraded
if dependency.repo_satisfies_dep(dep): if dependency.repo_satisfies_dep(dep):
if ctx.installdb.is_installed(dep.package): if ctx.installdb.is_installed(dep.package):
@@ -401,11 +401,11 @@ def remove(A):
if ctx.installdb.is_installed(x): if ctx.installdb.is_installed(x):
Ap.append(x) Ap.append(x)
else: else:
ctx.ui.info('Package %s does not exist. Cannot remove.' % x) ctx.ui.info(_('Package %s does not exist. Cannot remove.') % x)
A = Ap A = Ap
if len(A)==0: if len(A)==0:
ctx.ui.info('No packages to remove.') ctx.ui.info(_('No packages to remove.'))
return True return True
# try to construct a pisi graph of packages to # try to construct a pisi graph of packages to
@@ -424,32 +424,53 @@ def remove(A):
Bp = set() Bp = set()
for x in B: for x in B:
pkg = packagedb.get_package(x) pkg = packagedb.get_package(x)
print 'processing', pkg.name #print 'processing', pkg.name
rev_deps = packagedb.get_rev_deps(x) rev_deps = packagedb.get_rev_deps(x)
for (rev_dep, depinfo) in rev_deps: for (rev_dep, depinfo) in rev_deps:
print 'checking ', rev_dep #print 'checking ', rev_dep
# we don't deal with unsatisfied dependencies # we don't deal with unsatisfied dependencies
if dependency.installed_satisfies_dep(depinfo): if dependency.installed_satisfies_dep(depinfo):
if not rev_dep in G_f.vertices(): if not rev_dep in G_f.vertices():
Bp.add(rev_dep) Bp.add(rev_dep)
G_f.add_plain_dep(rev_dep, x) G_f.add_plain_dep(rev_dep, x)
B = Bp B = Bp
G_f.write_graphviz(sys.stdout) #G_f.write_graphviz(sys.stdout)
order = G_f.topological_sort() order = G_f.topological_sort()
print order #FIXME: do something more informative here
#print order
for x in order: for x in order:
if ctx.installdb.is_installed(x): if ctx.installdb.is_installed(x):
operations.remove_single(x) operations.remove_single(x)
else: else:
ctx.ui.info('Package %s is not installed. Cannot remove.' % x) ctx.ui.info(_('Package %s is not installed. Cannot remove.') % x)
return True # everything went OK :) return True # everything went OK :)
def configure_pending(): def configure_pending():
# TODO: not coded yet
# start with pending packages # start with pending packages
# configure them in reverse topological order of configuration dependency # configure them in reverse topological order of dependency
pass A = ctx.installdb.list_pending()
print A
G_f = pgraph.PGraph(packagedb) # construct G_f
for x in A:
G_f.add_package(x)
B = A
#state = {}
while len(B) > 0:
Bp = set()
for x in B:
pkg = packagedb.get_package(x)
print pkg
for dep in pkg.runtimeDeps:
if dep.package in G_f.vertices():
G_f.add_dep(x, dep)
B = Bp
G_f.write_graphviz(sys.stdout)
order = G_f.topological_sort()
order.reverse()
print order
#for x in order:
def info(package): def info(package):
if package.endswith(ctx.const.package_prefix): if package.endswith(ctx.const.package_prefix):
@@ -457,13 +478,13 @@ def info(package):
else: else:
return info_name(package) return info_name(package)
def info_file(package): def info_file(package_fn):
from package import Package from package import Package
if not os.path.exists(package): if not os.path.exists(package_fn):
raise Error ('File %s not found' % package) raise Error (_('File %s not found') % package_fn)
package = Package(package) package = Package(package_fn)
package.read() package.read()
return package.metadata, package.files return package.metadata, package.files
@@ -483,15 +504,15 @@ def info_name(package_name):
files = None files = None
return metadata, files return metadata, files
else: else:
raise Error('Package %s not found' % package_name) raise Error(_('Package %s not found') % package_name)
def index(repo_dir = '.'): def index(repo_dir = '.'):
ctx.ui.info('* Building index of PISI files under %s' % repo_dir) ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir)
index = Index() index = Index()
index.index(repo_dir) index.index(repo_dir)
index.write(ctx.const.pisi_index) index.write(ctx.const.pisi_index)
ctx.ui.info('* Index file written') ctx.ui.info(_('* Index file written'))
def add_repo(name, indexuri): def add_repo(name, indexuri):
@@ -502,16 +523,16 @@ def remove_repo(name):
if ctx.repodb.has_repo(name): if ctx.repodb.has_repo(name):
ctx.repodb.remove_repo(name) ctx.repodb.remove_repo(name)
else: else:
ctx.ui.error('* Repository %s does not exist. Cannot remove.' ctx.ui.error(_('* Repository %s does not exist. Cannot remove.')
% name) % name)
def update_repo(repo): def update_repo(repo):
ctx.ui.info('* Updating repository: %s' % repo) ctx.ui.info(_('* Updating repository: %s') % repo)
index = Index() index = Index()
index.read(ctx.repodb.get_repo(repo).indexuri.get_uri(), repo) index.read(ctx.repodb.get_repo(repo).indexuri.get_uri(), repo)
index.update_db(repo) index.update_db(repo)
ctx.ui.info('* Package database updated.') ctx.ui.info(_('* Package database updated.'))
# build functions... # build functions...
@@ -538,13 +559,14 @@ def prepare_for_build(pspecfile, authInfo=None):
# FIXME: take care of the required buildDeps... # FIXME: take care of the required buildDeps...
# For now just report an error! # For now just report an error!
if dep_unsatis: if dep_unsatis:
ctx.ui.error("Unsatisfied Build Dependencies:") ctx.ui.error(_("Unsatisfied Build Dependencies:"))
for dep in dep_unsatis: for dep in dep_unsatis:
ctx.ui.error(dep.package) ctx.ui.warning(dep.package)
# FIXME: Don't exit for now! It's annoying to test on a system that
# doesn't has all packages made with pisi. # FIXME: Don't exit for now! It's annoying to test on a system that
# Will be enabled on the full-pisi system. # doesn't has all packages made with pisi.
# sys.exit(1) # Will be enabled on the full-pisi system.
# sys.exit(1)
return pb return pb
+5 -1
View File
@@ -17,6 +17,10 @@ import os
import tarfile import tarfile
import zipfile import zipfile
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
# PiSi modules # PiSi modules
import pisi import pisi
import pisi.util as util import pisi.util as util
@@ -61,7 +65,7 @@ class ArchiveTar(ArchiveBase):
elif self.type == 'tarbz2': elif self.type == 'tarbz2':
rmode = 'r:bz2' rmode = 'r:bz2'
else: else:
raise ArchiveError("Archive type not recognized") raise ArchiveError(_("Archive type not recognized"))
tar = tarfile.open(self.file_path, rmode) tar = tarfile.open(self.file_path, rmode)
oldwd = os.getcwd() oldwd = os.getcwd()
+4
View File
@@ -16,6 +16,10 @@
# Authors: Baris Metin <baris@uludag.org.tr # Authors: Baris Metin <baris@uludag.org.tr
# Eray Ozkural <eray@uludag.org.tr> # Eray Ozkural <eray@uludag.org.tr>
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi import pisi
import pisi.context as ctx import pisi.context as ctx
from pisi.configfile import ConfigurationFile from pisi.configfile import ConfigurationFile
+4 -1
View File
@@ -38,6 +38,9 @@
import os import os
from ConfigParser import ConfigParser, NoSectionError from ConfigParser import ConfigParser, NoSectionError
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
class ConfigException(Exception): class ConfigException(Exception):
pass pass
@@ -79,7 +82,7 @@ class ConfigurationSection(object):
elif section == "directories": elif section == "directories":
self.defaults = DirsDefaults self.defaults = DirsDefaults
else: else:
e = "No section by name '%s'" % section e = _("No section by name '%s'") % section
raise ConfigException, e raise ConfigException, e
self.section = section self.section = section
+6 -2
View File
@@ -16,6 +16,10 @@
# Author: Baris Metin <baris@uludag.org.tr # Author: Baris Metin <baris@uludag.org.tr
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi import pisi
class _constant: class _constant:
@@ -25,13 +29,13 @@ class _constant:
def __setattr__(self, name, value): def __setattr__(self, name, value):
if self.__dict__.has_key(name): if self.__dict__.has_key(name):
raise self.ConstError, "Can't rebind constant: %s" % name raise self.ConstError, _("Can't rebind constant: %s") % name
# Binding an attribute once to a const is available # Binding an attribute once to a const is available
self.__dict__[name] = value self.__dict__[name] = value
def __delattr__(self, name): def __delattr__(self, name):
if self.__dict__.has_key(name): if self.__dict__.has_key(name):
raise self.ConstError, "Can't unbind constant: %s" % name raise self.ConstError, _("Can't unbind constant: %s") % name
# we don't have an attribute by this name # we don't have an attribute by this name
raise NameError, name raise NameError, name
+4
View File
@@ -11,6 +11,10 @@
"""a placeholder for data types, might factor elsewhere later""" """a placeholder for data types, might factor elsewhere later"""
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi.xmlfile import pisi.xmlfile
__metaclass__ = xmlfile.autoxml __metaclass__ = xmlfile.autoxml
+7 -3
View File
@@ -12,6 +12,10 @@
# Author: Eray Ozkural <eray@uludag.org.tr> # Author: Eray Ozkural <eray@uludag.org.tr>
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
#import pisi.db as db #import pisi.db as db
import pisi.context as ctx import pisi.context as ctx
import pisi.packagedb as packagedb import pisi.packagedb as packagedb
@@ -47,7 +51,7 @@ class DepInfo:
def has_errors(self): def has_errors(self):
if not self.package: if not self.package:
return [ "Dependency should have a package string" ] return [ _("Dependency should have a package string") ]
return None return None
def satisfies(self, pkg_name, version, release): def satisfies(self, pkg_name, version, release):
@@ -111,7 +115,7 @@ dependency spec"""
def satisfies_dependencies(pkg, deps, sat = installed_satisfies_dep): def satisfies_dependencies(pkg, deps, sat = installed_satisfies_dep):
for dep in deps: for dep in deps:
if not sat(dep): if not sat(dep):
ctx.ui.error('Package %s does not satisfy dependency %s' % ctx.ui.error(_('Package %s does not satisfy dependency %s') %
(pkg,dep)) (pkg,dep))
return False return False
return True return True
@@ -124,7 +128,7 @@ def installable(pkg):
"""calculate if pkg is installable currently """calculate if pkg is installable currently
which means it has to satisfy both install and runtime dependencies""" which means it has to satisfy both install and runtime dependencies"""
if not packagedb.has_package(pkg): if not packagedb.has_package(pkg):
ctx.ui.info("Package " + pkg + " is not present in the package database"); ctx.ui.info(_("Package %s is not present in the package database") % pkg);
return False return False
elif satisfies_runtime_deps(pkg): elif satisfies_runtime_deps(pkg):
return True return True
+7 -3
View File
@@ -20,6 +20,10 @@ import urllib2
import os import os
from base64 import encodestring from base64 import encodestring
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
# pisi modules # pisi modules
import pisi import pisi
import pisi.util as util import pisi.util as util
@@ -59,10 +63,10 @@ class Fetcher:
"""Return value: Fetched file's full path..""" """Return value: Fetched file's full path.."""
if not self.url.filename(): if not self.url.filename():
self.err("filename error") self.err(_("Filename error"))
if not os.access(self.filedest, os.W_OK): if not os.access(self.filedest, os.W_OK):
self.err("no perm to write to dest dir") self.err(_("Access denied to write to dest dir"))
if self.url.is_local_file(): if self.url.is_local_file():
self.fetchLocalFile() self.fetchLocalFile()
@@ -110,7 +114,7 @@ class Fetcher:
url = self.url url = self.url
if not os.access(url.path(), os.F_OK): if not os.access(url.path(), os.F_OK):
self.err("no such file or no perm to read") self.err(_("No such file or no permission to read"))
dest = open(os.path.join(self.filedest, url.filename()) , "w") dest = open(os.path.join(self.filedest, url.filename()) , "w")
totalsize = os.path.getsize(url.path()) totalsize = os.path.getsize(url.path())
+6 -2
View File
@@ -16,6 +16,10 @@
import os import os
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi.context as ctx import pisi.context as ctx
import pisi.metadata as metadata import pisi.metadata as metadata
import pisi.packagedb as packagedb import pisi.packagedb as packagedb
@@ -67,7 +71,7 @@ class Index(XmlFile):
for root, dirs, files in os.walk(repo_uri): for root, dirs, files in os.walk(repo_uri):
for fn in files: for fn in files:
if fn.endswith(ctx.const.package_prefix): if fn.endswith(ctx.const.package_prefix):
ctx.ui.info('Adding ' + fn + ' to package index') ctx.ui.info(_('Adding %s to package index') %s)
self.add_package(os.path.join(root, fn), repo_uri) self.add_package(os.path.join(root, fn), repo_uri)
def update_db(self, repo): def update_db(self, repo):
@@ -93,6 +97,6 @@ class Index(XmlFile):
md.package.packageURI = util.removepathprefix(repo_uri, path) md.package.packageURI = util.removepathprefix(repo_uri, path)
# check package semantics # check package semantics
if md.has_errors(): if md.has_errors():
ctx.ui.error('Package ' + md.package.name + ': metadata corrupt') ctx.ui.error(_('Package %s: metadata corrupt') % md.package.name)
else: else:
self.packages.append(md.package) self.packages.append(md.package)
+26 -22
View File
@@ -16,6 +16,10 @@
import os import os
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi import pisi
import pisi.context as ctx import pisi.context as ctx
@@ -78,9 +82,9 @@ class Installer:
# check dependencies # check dependencies
if not ctx.config.get_option('ignore_dependency'): if not ctx.config.get_option('ignore_dependency'):
if not dependency.installable(self.pkginfo.name): if not dependency.installable(self.pkginfo.name):
ctx.ui.error('Dependencies for ' + self.pkginfo.name + ctx.ui.error(_('Dependencies for %s not satisfied') %
' not satisfied') self.pkginfo.name)
raise InstallError("Package not installable") raise InstallError(_("Package not installable"))
def check_reinstall(self): def check_reinstall(self):
"check reinstall, confirm action, and schedule reinstall" "check reinstall, confirm action, and schedule reinstall"
@@ -104,33 +108,33 @@ class Installer:
if same_ver: if same_ver:
if self.ask_reinstall: if self.ask_reinstall:
if not ctx.ui.confirm('Re-install same version package?'): if not ctx.ui.confirm(_('Re-install same version package?')):
raise InstallError('Package re-install declined') raise InstallError(_('Package re-install declined'))
else: else:
upgrade = False upgrade = False
# is this an upgrade? # is this an upgrade?
# determine and report the kind of upgrade: version, release, build # determine and report the kind of upgrade: version, release, build
if pkg.version > iversion: if pkg.version > iversion:
ctx.ui.info('Upgrading to new upstream version') ctx.ui.info(_('Upgrading to new upstream version'))
upgrade = True upgrade = True
elif pkg.release > irelease: elif pkg.release > irelease:
ctx.ui.info('Upgrading to new distribution release') ctx.ui.info(_('Upgrading to new distribution release'))
upgrade = True upgrade = True
elif ((not ignore_build) and ibuild and pkg.build elif ((not ignore_build) and ibuild and pkg.build
and pkg.build > ibuild): and pkg.build > ibuild):
ctx.ui.info('Upgrading to new distribution build') ctx.ui.info(_('Upgrading to new distribution build'))
upgrade = True upgrade = True
# is this a downgrade? confirm this action. # is this a downgrade? confirm this action.
if self.ask_reinstall and (not upgrade): if self.ask_reinstall and (not upgrade):
if pkg.version < iversion: if pkg.version < iversion:
x = 'Downgrade to old upstream version?' x = _('Downgrade to old upstream version?')
elif pkg.release < irelease: elif pkg.release < irelease:
x = 'Downgrade to old distribution release?' x = _('Downgrade to old distribution release?')
else: else:
x = 'Downgrade to old distribution build?' x = _('Downgrade to old distribution build?')
if not ctx.ui.confirm(x): if not ctx.ui.confirm(x):
raise InstallError('Package downgrade declined') raise InstallError(_('Package downgrade declined'))
# schedule for reinstall # schedule for reinstall
self.old_files = ctx.installdb.files(pkg.name) self.old_files = ctx.installdb.files(pkg.name)
@@ -140,7 +144,7 @@ class Installer:
def extract_install(self): def extract_install(self):
"unzip package in place" "unzip package in place"
ctx.ui.info('Extracting files,') ctx.ui.info(_('Extracting files'))
self.package.extract_dir_flat('install', ctx.config.destdir) self.package.extract_dir_flat('install', ctx.config.destdir)
if self.reinstall: if self.reinstall:
@@ -158,17 +162,17 @@ class Installer:
"""put files.xml, metadata.xml, actions.py and COMAR scripts """put files.xml, metadata.xml, actions.py and COMAR scripts
somewhere in the file system. We'll need these in future...""" somewhere in the file system. We'll need these in future..."""
ctx.ui.info('Storing %s, ' % ctx.const.files_xml) ctx.ui.info(_('Storing %s, ') % ctx.const.files_xml)
self.package.extract_file(ctx.const.files_xml, self.package.pkg_dir()) self.package.extract_file(ctx.const.files_xml, self.package.pkg_dir())
ctx.ui.info('%s.' % ctx.const.metadata_xml) ctx.ui.info(_('%s.') % ctx.const.metadata_xml)
self.package.extract_file(ctx.const.metadata_xml, self.package.pkg_dir()) self.package.extract_file(ctx.const.metadata_xml, self.package.pkg_dir())
for pcomar in self.metadata.package.providesComar: for pcomar in self.metadata.package.providesComar:
fpath = os.path.join(ctx.const.comar_dir, pcomar.script) fpath = os.path.join(ctx.const.comar_dir, pcomar.script)
# comar prefix is added to the pkg_dir while extracting comar # comar prefix is added to the pkg_dir while extracting comar
# script file. so we'll use pkg_dir as destination. # script file. so we'll use pkg_dir as destination.
ctx.ui.info('Storing %s' % fpath) ctx.ui.info(_('Storing %s') % fpath)
self.package.extract_file(fpath, self.package.pkg_dir()) self.package.extract_file(fpath, self.package.pkg_dir())
def register_comar_scripts(self): def register_comar_scripts(self):
@@ -178,7 +182,7 @@ class Installer:
for pcomar in self.metadata.package.providesComar: for pcomar in self.metadata.package.providesComar:
scriptPath = os.path.join(self.package.comar_dir(),pcomar.script) scriptPath = os.path.join(self.package.comar_dir(),pcomar.script)
ctx.ui.info("Registering COMAR script %s" % pcomar.script) ctx.ui.info(_("Registering COMAR script %s") % pcomar.script)
com.register(pcomar.om, com.register(pcomar.om,
self.metadata.package.name, self.metadata.package.name,
@@ -188,15 +192,15 @@ class Installer:
if reply[0] == com.RESULT: if reply[0] == com.RESULT:
break break
else: else:
raise InstallError, "COMAR.register ERROR!" raise InstallError, _("COMAR.register ERROR!")
def comar_run_postinstall(self): def comar_run_postinstall(self):
"run postinstall scripts trough COMAR" "run postinstall scripts trough COMAR"
com = ctx.comard com = ctx.comard
ctx.ui.info("Running postinstall script for %s" % self.metadata.package.name) ctx.ui.info(_("Running postinstall script for %s") % self.metadata.package.name)
com.call_package("System.Package.postInstall", self.metadata.package.name) com.call_package(_("System.Package.postInstall"), self.metadata.package.name)
while 1: while 1:
reply = com.read_cmd() reply = com.read_cmd()
if reply[0] == com.RESULT: if reply[0] == com.RESULT:
@@ -204,11 +208,11 @@ class Installer:
elif reply[0] == com.NONE: # package has no postInstall script elif reply[0] == com.NONE: # package has no postInstall script
break break
elif reply[0] == com.FAIL: elif reply[0] == com.FAIL:
e = "COMAR.call_package(System.Pakcage.postInstall, %s) failed!: %s" % ( e = _("COMAR.call_package(System.Pakcage.postInstall, %s) failed!: %s") % (
self.metadata.package.name, reply[2]) self.metadata.package.name, reply[2])
raise InstallError, e raise InstallError, e
else: else:
raise InstallError, "COMAR.call_package ERROR: %d" % reply[0] raise InstallError, _("COMAR.call_package ERROR: %d") % reply[0]
def update_databases(self): def update_databases(self):
+11 -7
View File
@@ -18,6 +18,10 @@
import os import os
import fcntl import fcntl
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
# PiSi # PiSi
import pisi import pisi
import pisi.context as ctx import pisi.context as ctx
@@ -52,17 +56,17 @@ class InstallInfo:
time_str) time_str)
return s return s
state_map = { 'i': 'installed', 'ip':'installed-pending', 'r:removed' state_map = { 'i': _('installed'), 'ip':_('installed-pending'),
'p': 'purged' } 'r':_('removed'), 'p': _('purged') }
def __str__(self): def __str__(self):
s = "State: %s\nVersion: %s, Release: %s, Build: %s\n" % \ s = _("State: %s\nVersion: %s, Release: %s, Build: %s\n") % \
(InstallInfo.state_map[self.state], self.version, (InstallInfo.state_map[self.state], self.version,
self.release, self.build) self.release, self.build)
import time import time
time_str = time.strftime("%d %b %Y %H:%M", self.time) time_str = time.strftime("%d %b %Y %H:%M", self.time)
s += 'Distribution: %s, Install Time: %s\n' % (self.distribution, s += _('Distribution: %s, Install Time: %s\n') % (self.distribution,
time_str) time_str)
return s return s
@@ -132,8 +136,8 @@ class InstallDB:
"""install package with specific version, release, build""" """install package with specific version, release, build"""
pkg = str(pkg) pkg = str(pkg)
if self.is_installed(pkg): if self.is_installed(pkg):
raise InstallDBError("already installed") raise InstallDBError(_("Already installed"))
if ctx.config.options and ctx.config.options.ignore_comar: if ctx.config.get_option('ignore_comar'):
state = 'ip' state = 'ip'
self.dp[pkg] = True self.dp[pkg] = True
else: else:
+3 -1
View File
@@ -55,7 +55,9 @@ def run_preremove(package_name):
break break
elif reply[1] == com.ERROR: elif reply[1] == com.ERROR:
raise Error, "COMAR.remove failed!" raise Error, "COMAR.remove failed!"
else:
# TODO: store this somewhere
pass
def remove_db(package_name): def remove_db(package_name):
ctx.installdb.remove(package_name) ctx.installdb.remove(package_name)
packagedb.remove_package(package_name) #FIXME: this looks like a mistake! packagedb.remove_package(package_name) #FIXME: this looks like a mistake!