*fix: instead of relying on inserting the package that is being installed
in the packagedb, just look at the pkginfo that we've got. that wasn't a reliable method, because it skipped the case when the package to be installed did not match the one in the database (which is rare, but will not be rare for developers!) * improve exception handling * update test
This commit is contained in:
@@ -61,8 +61,9 @@ class AtomicOperation(object):
|
|||||||
class Install(AtomicOperation):
|
class Install(AtomicOperation):
|
||||||
"Install class, provides install routines for pisi packages"
|
"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"
|
"initialize from a file name"
|
||||||
|
super(Install, self).__init__(ignore_dep)
|
||||||
self.package = Package(package_fname)
|
self.package = Package(package_fname)
|
||||||
self.package.read()
|
self.package.read()
|
||||||
self.metadata = self.package.metadata
|
self.metadata = self.package.metadata
|
||||||
@@ -95,12 +96,6 @@ class Install(AtomicOperation):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def check_relations(self):
|
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
|
# check conflicts
|
||||||
for pkg in self.metadata.package.conflicts:
|
for pkg in self.metadata.package.conflicts:
|
||||||
if ctx.installdb.is_installed(self.pkginfo):
|
if ctx.installdb.is_installed(self.pkginfo):
|
||||||
@@ -108,11 +103,17 @@ class Install(AtomicOperation):
|
|||||||
|
|
||||||
# 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 self.pkginfo.installable():
|
||||||
ctx.ui.error(_('Dependencies for %s not satisfied') %
|
ctx.ui.error(_('Dependencies for %s not satisfied') %
|
||||||
self.pkginfo.name)
|
self.pkginfo.name)
|
||||||
raise Error(_("Package not installable"))
|
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):
|
def check_reinstall(self):
|
||||||
"check reinstall, confirm action, and schedule reinstall"
|
"check reinstall, confirm action, and schedule reinstall"
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -126,7 +126,7 @@ def satisfies_runtime_deps(pkg):
|
|||||||
return satisfies_dependencies(pkg, deps)
|
return satisfies_dependencies(pkg, deps)
|
||||||
|
|
||||||
def installable(pkg):
|
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"""
|
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 %s is not present in the package database") % 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):
|
elif satisfies_runtime_deps(pkg):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
#ctx.ui.info("package " + pkg + " does not satisfy dependencies\n");
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
+13
-24
@@ -47,17 +47,11 @@ def install(packages):
|
|||||||
# and use install module directly.
|
# and use install module directly.
|
||||||
from pisi.atomicoperations import Error as InstallError
|
from pisi.atomicoperations import Error as InstallError
|
||||||
|
|
||||||
try:
|
# determine if this is a list of files/urls or names
|
||||||
# determine if this is a list of files/urls or names
|
if packages[0].endswith('.pisi'): # they all have to!
|
||||||
if packages[0].endswith('.pisi'): # they all have to!
|
return install_pkg_files(packages)
|
||||||
return install_pkg_files(packages)
|
else:
|
||||||
else:
|
return install_pkg_names(packages)
|
||||||
return install_pkg_names(packages)
|
|
||||||
|
|
||||||
except packagedb.Error, e:
|
|
||||||
ctx.ui.error(_("Package is not installable."))
|
|
||||||
raise e
|
|
||||||
|
|
||||||
|
|
||||||
def install_pkg_files(package_URIs):
|
def install_pkg_files(package_URIs):
|
||||||
"""install a number of pisi package files"""
|
"""install a number of pisi package files"""
|
||||||
@@ -67,14 +61,13 @@ 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.'))
|
raise Error(_('Mixing file names and package names not supported yet.'))
|
||||||
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:
|
||||||
atomicoperations.install_single_file(x)
|
atomicoperations.install_single_file(x)
|
||||||
return True
|
return # short circuit
|
||||||
|
|
||||||
# read the package information into memory first
|
# read the package information into memory first
|
||||||
# regardless of which distribution they come from
|
# regardless of which distribution they come from
|
||||||
@@ -88,6 +81,8 @@ def install_pkg_files(package_URIs):
|
|||||||
dfn[name] = x
|
dfn[name] = x
|
||||||
|
|
||||||
def satisfiesDep(dep):
|
def satisfiesDep(dep):
|
||||||
|
# is dependency satisfied among available packages
|
||||||
|
# or packages to be installed?
|
||||||
return dependency.installed_satisfies_dep(dep) \
|
return dependency.installed_satisfies_dep(dep) \
|
||||||
or dependency.dict_satisfies_dep(d_t, dep)
|
or dependency.dict_satisfies_dep(d_t, dep)
|
||||||
|
|
||||||
@@ -123,7 +118,7 @@ def install_pkg_files(package_URIs):
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
# try to construct a pisi graph of packages to
|
# try to construct a pisi graph of packages to
|
||||||
# install / reinstall
|
# install / reinstall
|
||||||
@@ -172,7 +167,7 @@ def install_pkg_names(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
|
||||||
|
|
||||||
# try to construct a pisi graph of packages to
|
# try to construct a pisi graph of packages to
|
||||||
# install / reinstall
|
# install / reinstall
|
||||||
@@ -212,8 +207,6 @@ in the respective order to satisfy dependencies:
|
|||||||
for x in order:
|
for x in order:
|
||||||
atomicoperations.install_single_name(x)
|
atomicoperations.install_single_name(x)
|
||||||
|
|
||||||
return True # everything went OK :)
|
|
||||||
|
|
||||||
def upgrade(A):
|
def upgrade(A):
|
||||||
upgrade_pkg_names(A)
|
upgrade_pkg_names(A)
|
||||||
|
|
||||||
@@ -310,9 +303,6 @@ version %s, release %s, build %s.')
|
|||||||
for x in order:
|
for x in order:
|
||||||
atomicoperations.install_single_name(x, True)
|
atomicoperations.install_single_name(x, True)
|
||||||
|
|
||||||
return True # everything went OK :)
|
|
||||||
|
|
||||||
|
|
||||||
def remove(A):
|
def remove(A):
|
||||||
"""remove set A of packages from system (A is a list of package names)"""
|
"""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:
|
if len(A)==0:
|
||||||
ctx.ui.info(_('No packages to remove.'))
|
ctx.ui.info(_('No packages to remove.'))
|
||||||
return True
|
return
|
||||||
|
|
||||||
# try to construct a pisi graph of packages to
|
# try to construct a pisi graph of packages to
|
||||||
# install / reinstall
|
# install / reinstall
|
||||||
@@ -365,11 +355,10 @@ in the respective order to satisfy dependencies:
|
|||||||
""") + util.strlist(order))
|
""") + util.strlist(order))
|
||||||
if len(order) > len(A_0):
|
if len(order) > len(A_0):
|
||||||
if not ctx.ui.confirm('Do you want to continue?'):
|
if not ctx.ui.confirm('Do you want to continue?'):
|
||||||
|
ctx.ui.warning(_('Package removal declined'))
|
||||||
return False
|
return False
|
||||||
for x in order:
|
for x in order:
|
||||||
if ctx.installdb.is_installed(x):
|
if ctx.installdb.is_installed(x):
|
||||||
atomicoperations.remove_single(x)
|
atomicoperations.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 :)
|
|
||||||
|
|||||||
@@ -384,6 +384,12 @@ class PackageInfo:
|
|||||||
|
|
||||||
return join( config.lib_dir(), packageDir)
|
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):
|
class SpecFile(XmlFile):
|
||||||
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
||||||
|
|
||||||
|
|||||||
+16
-20
@@ -8,34 +8,30 @@ set -x # xtrace
|
|||||||
set -e # errexit
|
set -e # errexit
|
||||||
rm -rf tmp
|
rm -rf tmp
|
||||||
#echo "*** build tests"
|
#echo "*** build tests"
|
||||||
pisi-cli build https://svn.uludag.org.tr/pisi/trunk/system/base/zip/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
|
||||||
https://svn.uludag.org.tr/pisi/trunk/system/base/unzip/pspec.xml
|
|
||||||
|
|
||||||
#partial-builds
|
#partial-builds
|
||||||
pisi-cli build-setup 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 build-build https://svn.uludag.org.tr/pisi/trunk/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 build-install https://svn.uludag.org.tr/pisi/trunk/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 build-package https://svn.uludag.org.tr/pisi/trunk/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"
|
#echo "*** repository tests"
|
||||||
|
|
||||||
pisi-cli index .
|
pisi-cli -Dtmp index .
|
||||||
pisi-cli add-repo repo1 pisi-index.xml
|
pisi-cli -Dtmp add-repo repo1 pisi-index.xml
|
||||||
pisi-cli update-repo repo1
|
pisi-cli -Dtmp update-repo repo1
|
||||||
pisi-cli list-repo
|
pisi-cli -Dtmp 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
|
|
||||||
|
|
||||||
#echo "*** package ops"
|
#echo "*** package ops"
|
||||||
pisi-cli info *.pisi
|
pisi-cli -Dtmp info *.pisi
|
||||||
# pisi-cli list-available
|
# pisi-cli list-available
|
||||||
pisi-cli install --ignore-comar zip
|
pisi-cli -Dtmp install --ignore-comar zip
|
||||||
pisi-cli list-installed
|
pisi-cli -Dtmp list-installed
|
||||||
pisi-cli remove --ignore-comar unzip
|
pisi-cli -Dtmp remove --ignore-comar unzip
|
||||||
pisi-cli install --ignore-comar zip*.pisi
|
pisi-cli -Dtmp install --ignore-comar zip*.pisi
|
||||||
pisi-cli install --ignore-comar hdparm*.pisi flex*.pisi grep*.pisi
|
pisi-cli -Dtmp install --ignore-comar hdparm*.pisi flex*.pisi grep*.pisi
|
||||||
pisi-cli remove-repo repo1
|
pisi-cli -Dtmp remove-repo repo1
|
||||||
# pisi-cli list-available
|
# pisi-cli list-available
|
||||||
|
|
||||||
echo "*** database contents"
|
echo "*** database contents"
|
||||||
|
|||||||
Reference in New Issue
Block a user