diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 2963929c..a1584ad7 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -61,8 +61,9 @@ class AtomicOperation(object): class Install(AtomicOperation): "Install class, provides install routines for pisi packages" - def __init__(self, package_fname): + def __init__(self, package_fname, ignore_dep = None): "initialize from a file name" + super(Install, self).__init__(ignore_dep) self.package = Package(package_fname) self.package.read() self.metadata = self.package.metadata @@ -95,12 +96,6 @@ class Install(AtomicOperation): pass def check_relations(self): - # check if package is in database - # If it is not, put it into 3rd party packagedb - if not packagedb.has_package(self.pkginfo.name): - db = packagedb.thirdparty_packagedb - db.add_package(self.pkginfo) - # check conflicts for pkg in self.metadata.package.conflicts: if ctx.installdb.is_installed(self.pkginfo): @@ -108,11 +103,17 @@ class Install(AtomicOperation): # check dependencies if not ctx.config.get_option('ignore_dependency'): - if not dependency.installable(self.pkginfo.name): + if not self.pkginfo.installable(): ctx.ui.error(_('Dependencies for %s not satisfied') % self.pkginfo.name) raise Error(_("Package not installable")) + # check if package is in database + # If it is not, put it into 3rd party packagedb + if not packagedb.has_package(self.pkginfo.name): + db = packagedb.thirdparty_packagedb + db.add_package(self.pkginfo) + def check_reinstall(self): "check reinstall, confirm action, and schedule reinstall" diff --git a/pisi/dependency.py b/pisi/dependency.py index 5e622afe..f5b99c08 100644 --- a/pisi/dependency.py +++ b/pisi/dependency.py @@ -126,7 +126,7 @@ def satisfies_runtime_deps(pkg): return satisfies_dependencies(pkg, deps) def installable(pkg): - """calculate if pkg is installable currently + """calculate if pkg name is installable currently which means it has to satisfy both install and runtime dependencies""" if not packagedb.has_package(pkg): ctx.ui.info(_("Package %s is not present in the package database") % pkg); @@ -134,6 +134,5 @@ def installable(pkg): elif satisfies_runtime_deps(pkg): return True else: - #ctx.ui.info("package " + pkg + " does not satisfy dependencies\n"); return False diff --git a/pisi/operations.py b/pisi/operations.py index c156a0d3..6db28550 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -47,17 +47,11 @@ def install(packages): # and use install module directly. from pisi.atomicoperations import Error as InstallError - try: - # determine if this is a list of files/urls or names - if packages[0].endswith('.pisi'): # they all have to! - return install_pkg_files(packages) - else: - return install_pkg_names(packages) - - except packagedb.Error, e: - ctx.ui.error(_("Package is not installable.")) - raise e - + # determine if this is a list of files/urls or names + if packages[0].endswith('.pisi'): # they all have to! + return install_pkg_files(packages) + else: + return install_pkg_names(packages) def install_pkg_files(package_URIs): """install a number of pisi package files""" @@ -67,14 +61,13 @@ def install_pkg_files(package_URIs): for x in package_URIs: if not x.endswith(ctx.const.package_prefix): - ctx.ui.error(_('Mixing file names and package names not supported YET.')) - return False + raise Error(_('Mixing file names and package names not supported yet.')) if ctx.config.get_option('ignore_dependency'): # simple code path then for x in package_URIs: atomicoperations.install_single_file(x) - return True + return # short circuit # read the package information into memory first # regardless of which distribution they come from @@ -88,6 +81,8 @@ def install_pkg_files(package_URIs): dfn[name] = x def satisfiesDep(dep): + # is dependency satisfied among available packages + # or packages to be installed? return dependency.installed_satisfies_dep(dep) \ or dependency.dict_satisfies_dep(d_t, dep) @@ -123,7 +118,7 @@ def install_pkg_files(package_URIs): if len(A)==0: ctx.ui.info(_('No packages to install.')) - return True + return # try to construct a pisi graph of packages to # install / reinstall @@ -172,7 +167,7 @@ def install_pkg_names(A): if len(A)==0: ctx.ui.info(_('No packages to install.')) - return True + return # try to construct a pisi graph of packages to # install / reinstall @@ -211,8 +206,6 @@ in the respective order to satisfy dependencies: return False for x in order: atomicoperations.install_single_name(x) - - return True # everything went OK :) def upgrade(A): upgrade_pkg_names(A) @@ -309,9 +302,6 @@ version %s, release %s, build %s.') return False for x in order: atomicoperations.install_single_name(x, True) - - return True # everything went OK :) - def remove(A): """remove set A of packages from system (A is a list of package names)""" @@ -328,7 +318,7 @@ def remove(A): if len(A)==0: ctx.ui.info(_('No packages to remove.')) - return True + return # try to construct a pisi graph of packages to # install / reinstall @@ -365,11 +355,10 @@ in the respective order to satisfy dependencies: """) + util.strlist(order)) if len(order) > len(A_0): if not ctx.ui.confirm('Do you want to continue?'): + ctx.ui.warning(_('Package removal declined')) return False for x in order: if ctx.installdb.is_installed(x): atomicoperations.remove_single(x) else: ctx.ui.info(_('Package %s is not installed. Cannot remove.') % x) - - return True # everything went OK :) diff --git a/pisi/specfile.py b/pisi/specfile.py index c598211a..f06b3280 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -384,6 +384,12 @@ class PackageInfo: return join( config.lib_dir(), packageDir) + def installable(self): + """calculate if pkg is installable currently""" + import pisi.dependency + deps = self.runtimeDeps + return pisi.dependency.satisfies_dependencies(self.name, deps) + class SpecFile(XmlFile): """A class for reading/writing from/to a PSPEC (PISI SPEC) file.""" diff --git a/tests/beta.sh b/tests/beta.sh index 6e6a2eca..baea18d0 100755 --- a/tests/beta.sh +++ b/tests/beta.sh @@ -8,34 +8,30 @@ set -x # xtrace set -e # errexit rm -rf tmp #echo "*** build tests" -pisi-cli build https://svn.uludag.org.tr/pisi/trunk/system/base/zip/pspec.xml \ - https://svn.uludag.org.tr/pisi/trunk/system/base/unzip/pspec.xml +pisi-cli -Dtmp build http://svn.uludag.org.tr/pardus/pardus-devel/system/base/zip/pspec.xml http://svn.uludag.org.tr/pardus/pardus-devel/system/base/unzip/pspec.xml #partial-builds -pisi-cli build-setup https://svn.uludag.org.tr/pisi/trunk/system/base/hdparm/pspec.xml -pisi-cli build-build https://svn.uludag.org.tr/pisi/trunk/system/base/hdparm/pspec.xml -pisi-cli build-install https://svn.uludag.org.tr/pisi/trunk/system/base/hdparm/pspec.xml -pisi-cli build-package https://svn.uludag.org.tr/pisi/trunk/system/base/hdparm/pspec.xml +pisi-cli -Dtmp build-setup http://svn.uludag.org.tr/pardus/pardus-devel/system/base/hdparm/pspec.xml +pisi-cli -Dtmp build-build http://svn.uludag.org.tr/pardus/pardus-devel/system/base/hdparm/pspec.xml +pisi-cli -Dtmp build-install http://svn.uludag.org.tr/pardus/pardus-devel/system/base/hdparm/pspec.xml +pisi-cli -Dtmp build-package http://svn.uludag.org.tr/pardus/pardus-devel/system/base/hdparm/pspec.xml #echo "*** repository tests" -pisi-cli index . -pisi-cli add-repo repo1 pisi-index.xml -pisi-cli update-repo repo1 -pisi-cli list-repo - -pisi-cli build https://svn.uludag.org.tr/pisi/trunk/system/base/grep/pspec.xml \ - https://svn.uludag.org.tr/pisi/trunk/system/base/flex/pspec.xml +pisi-cli -Dtmp index . +pisi-cli -Dtmp add-repo repo1 pisi-index.xml +pisi-cli -Dtmp update-repo repo1 +pisi-cli -Dtmp list-repo #echo "*** package ops" -pisi-cli info *.pisi +pisi-cli -Dtmp info *.pisi # pisi-cli list-available -pisi-cli install --ignore-comar zip -pisi-cli list-installed -pisi-cli remove --ignore-comar unzip -pisi-cli install --ignore-comar zip*.pisi -pisi-cli install --ignore-comar hdparm*.pisi flex*.pisi grep*.pisi -pisi-cli remove-repo repo1 +pisi-cli -Dtmp install --ignore-comar zip +pisi-cli -Dtmp list-installed +pisi-cli -Dtmp remove --ignore-comar unzip +pisi-cli -Dtmp install --ignore-comar zip*.pisi +pisi-cli -Dtmp install --ignore-comar hdparm*.pisi flex*.pisi grep*.pisi +pisi-cli -Dtmp remove-repo repo1 # pisi-cli list-available echo "*** database contents"