From d4a6de70863fc75007b8fb615d53352158a98cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 18 Jul 2005 13:32:38 +0000 Subject: [PATCH] * reinstall isini calistirtir * bunun icin remove'u da fix et o da calissin ufaktan --- pisi/install.py | 46 +++++++++++++++++++++++----------------------- pisi/installdb.py | 12 +++++++----- pisi/operations.py | 12 ++++++++++-- pisi/package.py | 7 +++++++ 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/pisi/install.py b/pisi/install.py index 258a210b..8a0f62bf 100644 --- a/pisi/install.py +++ b/pisi/install.py @@ -16,6 +16,7 @@ from packagedb import packagedb import dependency from metadata import MetaData import comariface +import operations #import conflicts class InstallError(Exception): @@ -85,38 +86,37 @@ class Installer: raise InstallError("Package not installable") - #TODO: if installdb.is_installed(pkginfo.name): # is this a reinstallation? (iversion, irelease) = installdb.get_version(pkginfo.name) if pkginfo.version == iversion and pkginfo.release == irelease: if not ui.confirm('Re-install same version package?'): raise InstallError('Package re-install declined') + else: + upgrade = False + # is this an upgrade? + # determine and report the kind of upgrade: version, release, build + if pkginfo.version > iversion: + ui.info('Upgrading to new upstream version') + upgrade = True + elif pkginfo.release > irelease: + ui.info('Upgrading to new distribution release') + upgrade = True - upgrade = False - # is this an upgrade? - # determine and report the kind of upgrade: version, release, build - if pkginfo.version > iversion: - ui.info('Upgrading to new upstream version') - upgrade = True - elif pkginfo.release > irelease: - ui.info('Upgrading to new distribution release') - upgrade = True - - # is this a downgrade? confirm this action. - # - # burada bir gariplik var. Tam olarak ne yapmak istediğini - # anlamadığım için bırakıyorm. Ama bu kod çalışmıyor. - if not upgrade: - if pkginfo.version < iversion: - x = 'Downgrade to old upstream version?' - elif pkginfo.release < irelease: - x = 'Downgrade to old distribution release?' - if not ui.confirm(x): - raise InstallError('Package downgrade declined') + # is this a downgrade? confirm this action. + # + # burada bir gariplik var. Tam olarak ne yapmak istediğini + # anlamadığım için bırakıyorm. Ama bu kod çalışmıyor. + if not upgrade: + if pkginfo.version < iversion: + x = 'Downgrade to old upstream version?' + elif pkginfo.release < irelease: + x = 'Downgrade to old distribution release?' + if not ui.confirm(x): + raise InstallError('Package downgrade declined') # remove old package then - remove(pkginfo.name) + operations.remove(pkginfo.name) # unzip package in place self.extractInstall() diff --git a/pisi/installdb.py b/pisi/installdb.py index 6c75e671..8e0b3a43 100644 --- a/pisi/installdb.py +++ b/pisi/installdb.py @@ -7,6 +7,7 @@ import os, fcntl import bsddb.dbshelve as shelve from config import config +from constants import const from files import Files import util @@ -28,8 +29,9 @@ class InstallDB: self.fdummy.close() def files_name(self, pkg, version, release): - fn = pkg + '-' + version + '-' + release + '.xml' - return os.path.join(self.files_dir, fn) + from os.path import join + pkg_dir = join(config.lib_dir(), pkg + '-' + version + '-' + release) + return join(pkg_dir, const.files_xml) def files(self, pkg): pkg = str(pkg) @@ -91,9 +93,9 @@ class InstallDB: pkg = str(pkg) if self.d.has_key(pkg): (status, version, release) = self.d[pkg] - f = self.files_name(pkg, version, release) - if util.check_file(f): - os.unlink(f) + #f = self.files_name(pkg, version, release) + #if util.check_file(f): + # os.unlink(f) del self.d[pkg] installdb = InstallDB() diff --git a/pisi/operations.py b/pisi/operations.py index c0110f5a..70823531 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -1,4 +1,12 @@ +import os + +from config import config +from constants import const +from ui import ui from package import Package +from installdb import installdb +from packagedb import packagedb +from os.path import join # all package operation interfaces are here @@ -8,8 +16,8 @@ def remove(package_name): if not installdb.is_installed(package_name): raise InstallError('Trying to remove nonexistent package ' + package_name) - for fileinfo in installdb.files(package_name): - os.unlink(fileinfo.path) + for fileinfo in installdb.files(package_name).list: + os.unlink( join(config.destdir, fileinfo.path) ) installdb.remove(package_name) diff --git a/pisi/package.py b/pisi/package.py index e2d26da6..6664e618 100644 --- a/pisi/package.py +++ b/pisi/package.py @@ -91,5 +91,12 @@ class Package: return join( config.lib_dir(), packageDir) + def pkg_dir_aux(): + packageDir = self.metadata.package.name + '-' \ + + self.metadata.package.version + '-' \ + + self.metadata.package.release + + return join( config.lib_dir(), packageDir) + def comar_dir(self): return join( self.pkg_dir(), const.comar_dir_suffix)