* update tests

* more reorg, lemme know if anything's broken
This commit is contained in:
Eray Özkural
2005-10-20 22:23:42 +00:00
parent 43106ef33b
commit c6228278d1
8 changed files with 132 additions and 103 deletions
+7 -11
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-3.8.dtd">
<!-- Project file for project pisi -->
<!-- Saved: 2005-10-19, 20:42:26 -->
<!-- Saved: 2005-10-20, 23:32:54 -->
<!-- Copyright (C) 2005 PiSi Development Team, -->
<Project version="3.8">
<ProgLanguage mixed="0">Python</ProgLanguage>
@@ -246,10 +246,6 @@
<Dir>pisi</Dir>
<Name>sourcedb.py</Name>
</Source>
<Source>
<Dir>pisi</Dir>
<Name>install.py</Name>
</Source>
<Source>
<Dir>pisi</Dir>
<Name>installdb.py</Name>
@@ -344,10 +340,6 @@
<Dir>po</Dir>
<Name>tr.po</Name>
</Source>
<Source>
<Dir>tools</Dir>
<Name>ChangeLogGenerator.py</Name>
</Source>
<Source>
<Dir>pisi</Dir>
<Name>oo.py</Name>
@@ -364,6 +356,10 @@
<Dir>tests</Dir>
<Name>dependencytests.py</Name>
</Source>
<Source>
<Dir>pisi</Dir>
<Name>atomicoperations.py</Name>
</Source>
</Sources>
<Forms>
</Forms>
@@ -401,10 +397,10 @@
<VcsOtherData>{'standardLayout': 1}</VcsOtherData>
</Vcs>
<FiletypeAssociations>
<FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ui.h" type="FORMS" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
<FiletypeAssociation pattern="*.ui" type="FORMS" />
<FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
</FiletypeAssociations>
</Project>
+13 -1
View File
@@ -66,10 +66,22 @@ def init(database = True, options = None, ui = None, comar = True):
ctx.filesdb = pisi.files.FilesDB()
packagedb.init_db()
#TODO: sourcedb
# import pisi.sourcedb
# pisi.sourcedb.init()
else:
ctx.repodb = None
ctx.installdb = None
ctx.filesdb = None
def finalize():
def delete_db(db):
if db:
del db
for x in [ctx.repodb, ctx.installdb, ctx.filesdb]:
delete_db(x)
packagedb.finalize_db()
def list_upgradable():
ignore_build = ctx.config.options and ctx.config.options.ignore_build_no
+77 -62
View File
@@ -42,11 +42,13 @@ from pisi.uri import URI
class Error(pisi.Error):
pass
# single package operations
class AtomicOperation(object):
def __init__(self, package, ignore_dep = None):
self.package = package
if not ignore_dep:
def __init__(self, ignore_dep = None):
#self.package = package
if ignore_dep==None:
self.ignore_dep = ctx.config.get_option('ignore_dependency')
else:
self.ignore_dep = ignore_dep
@@ -55,6 +57,7 @@ class AtomicOperation(object):
"perform an atomic package operation"
pass
class Install(AtomicOperation):
"Install class, provides install routines for pisi packages"
@@ -163,7 +166,7 @@ class Install(AtomicOperation):
# schedule for reinstall
self.old_files = ctx.installdb.files(pkg.name)
self.reinstall = True
run_preremove(pkg.name)
Remove(pkg.name).run_preremove()
def extract_install(self):
"unzip package in place"
@@ -180,7 +183,7 @@ class Install(AtomicOperation):
for fileinfo in self.old_files.list:
old_fileinfo[str(fileinfo.path)] = fileinfo
for path in leftover:
remove_file( old_fileinfo[path] )
Remove.remove_file( old_fileinfo[path] )
def store_pisi_files(self):
"""put files.xml, metadata.xml, actions.py and COMAR scripts
@@ -212,7 +215,7 @@ class Install(AtomicOperation):
"update databases"
if self.reinstall:
remove_db(self.metadata.package.name)
Remove(self.metadata.package.name).remove_db()
# installdb
ctx.installdb.install(self.metadata.package.name,
@@ -227,60 +230,6 @@ class Install(AtomicOperation):
# installed packages
packagedb.inst_packagedb.add_package(self.pkginfo)
# single package operations
# remove stuff
def Remove(AtomicOperation):
pass
def remove_file(fileinfo):
fpath = pisi.util.join_path(ctx.config.dest_dir(), fileinfo.path)
# TODO: We have to store configuration files for futher
# usage. Currently we'are doing it like rpm does, saving
# with a prefix and leaving the user to edit it. In the future
# we'll have a plan for these configuration files.
if fileinfo.type == ctx.const.conf:
if os.path.isfile(fpath):
os.rename(fpath, fpath + ".pisi")
else:
# check if file is removed manually.
# And we don't remove directories!
# TODO: remove directory if there is nothing under it?
if os.path.isfile(fpath) or os.path.islink(fpath):
os.unlink(fpath)
else:
ctx.ui.warning(_('Not removing non-file, non-link %s') % fpath)
def run_preremove(package_name):
if ctx.comar:
import pisi.comariface as comariface
comariface.run_preremove(package_name)
else:
# TODO: store this somewhere
pass
def remove_db(package_name):
ctx.installdb.remove(package_name)
packagedb.remove_package(package_name) #FIXME: this looks like a mistake!
def remove_single(package_name):
"""Remove a single package"""
inst_packagedb = packagedb.inst_packagedb
#TODO: check dependencies
ctx.ui.info(_('Removing package %s') % package_name)
if not ctx.installdb.is_installed(package_name):
raise Exception(_('Trying to remove nonexistent package ')
+ package_name)
run_preremove(package_name)
for fileinfo in ctx.installdb.files(package_name).list:
remove_file(fileinfo)
remove_db(package_name)
def install_single(pkg, upgrade = False):
"""install a single package from URI or ID"""
@@ -296,7 +245,6 @@ def install_single(pkg, upgrade = False):
# FIXME: Here and elsewhere pkg_location must be a URI
def install_single_file(pkg_location, upgrade = False):
"""install a package file"""
from pisi.atomicoperations import Install
Install(pkg_location).install(not upgrade)
def install_single_name(name, upgrade = False):
@@ -320,5 +268,72 @@ def install_single_name(name, upgrade = False):
# Package will handle remote file for us!
install_single_file(pkg_path, upgrade)
else:
ctx.ui.error(_("Package %s not found in any active repository.") % pkg)
raise Error(_("Package %s not found in any active repository.") % pkg)
class Remove(AtomicOperation):
def __init__(self, package_name, ignore_dep = None):
super(Remove, self).__init__(ignore_dep)
self.package_name = package_name
def run(self):
"""Remove a single package"""
inst_packagedb = packagedb.inst_packagedb
ctx.ui.info(_('Removing package %s') % self.package_name)
if not ctx.installdb.is_installed(self.package_name):
raise Exception(_('Trying to remove nonexistent package ')
+ self.package_name)
self.check_dependencies()
self.run_preremove()
for fileinfo in ctx.installdb.files(self.package_name).list:
self.remove_file(fileinfo)
self.remove_db()
def check_dependencies(self):
#we only have to check the dependencies to ensure the
#system will be consistent after this removal
pass
# is there any package who depends on this package?
def remove_file(fileinfo):
fpath = pisi.util.join_path(ctx.config.dest_dir(), fileinfo.path)
# TODO: We have to store configuration files for futher
# usage. Currently we'are doing it like rpm does, saving
# with a prefix and leaving the user to edit it. In the future
# we'll have a plan for these configuration files.
if fileinfo.type == ctx.const.conf:
if os.path.isfile(fpath):
os.rename(fpath, fpath + ".pisi")
else:
# check if file is removed manually.
# And we don't remove directories!
# TODO: remove directory if there is nothing under it?
if os.path.isfile(fpath) or os.path.islink(fpath):
os.unlink(fpath)
else:
ctx.ui.warning(_('Not removing non-file, non-link %s') % fpath)
remove_file = staticmethod(remove_file)
def run_preremove(self):
if ctx.comar:
import pisi.comariface as comariface
comariface.run_preremove(self.package_name)
else:
# TODO: store this somewhere
pass
def remove_db(self):
ctx.installdb.remove(self.package_name)
#FIXME: this looks like a mistake!
packagedb.remove_package(self.package_name)
def remove_single(package_name):
Remove(package_name).run()
+2 -2
View File
@@ -75,7 +75,7 @@ class Command(object):
p = self.parser
p.add_option("-D", "--destdir", action="store", default = None,
help = _("change the system root for pisi commands"))
p.add_option("", "--yes-all", action="store_true",
p.add_option("-y", "--yes-all", action="store_true",
default=False, help = _("assume yes in all yes/no queries"))
p.add_option("-u", "--username", action="store")
p.add_option("-p", "--password", action="store")
@@ -143,7 +143,7 @@ class Command(object):
def finalize(self):
"""do cleanup work for PiSi components"""
pass
pisi.api.finalize()
def get_name(self):
return self.__class__.name
+6
View File
@@ -157,3 +157,9 @@ def init_db():
pisi.packagedb.thirdparty_packagedb = PackageDB('thirdparty')
if not pisi.packagedb.inst_packagedb:
pisi.packagedb.inst_packagedb = PackageDB('installed')
def finalize_db():
if pisi.packagedb.thirdparty_packagedb:
del pisi.packagedb.thirdparty_packagedb
if pisi.packagedb.inst_packagedb:
del pisi.packagedb.inst_packagedb
+14 -13
View File
@@ -4,20 +4,21 @@ pwd
PATH=$PATH:.
set -x -e
pisi-cli --ignore-build-no build tests/zip/pspec.xml tests/unzip/pspec.xml
pisi-cli --yes-all --ignore-comar install unzip-5.50-1.pisi zip-2.3-1.pisi
pisi-cli -Dtmp -E --ignore-build-no build tests/zip/pspec.xml tests/unzip/pspec.xml
pisi-cli -Dtmp --yes-all --ignore-comar install unzip-5.50-1.pisi zip-2.3-1.pisi
mkdir -p myrepo
cd myrepo
../pisi-cli --ignore-build-no build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml
mkdir -p tmp
../pisi-cli -Dtmp -E --ignore-build-no build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml
cd ..
pisi-cli --absolute-uris index myrepo
pisi-cli remove-repo repo1
pisi-cli add-repo repo1 pisi-index.xml
pisi-cli list-repo
pisi-cli update-repo repo1
pisi-cli list-available
pisi-cli --install-info list-installed
pisi-cli list-upgrades
pisi-cli --ignore-comar upgrade zip
pisi-cli --install-info list-installed
pisi-cli -Dtmp --absolute-uris index myrepo
pisi-cli -Dtmp remove-repo repo1
pisi-cli -Dtmp add-repo repo1 pisi-index.xml
pisi-cli -Dtmp list-repo
pisi-cli -Dtmp update-repo repo1
pisi-cli -Dtmp list-available
pisi-cli -Dtmp --install-info list-installed
pisi-cli -Dtmp list-upgrades
pisi-cli -Dtmp --ignore-comar upgrade zip
pisi-cli -Dtmp --install-info list-installed
+6 -7
View File
@@ -24,13 +24,6 @@
<Dependency>sed</Dependency>
<Dependency>patch</Dependency>
</BuildDependencies>
<History>
<Update>
<Date>2005-08-10</Date>
<Version>5.52</Version>
<Release>2</Release>
</Update>
</History>
</Source>
<Package>
@@ -44,6 +37,12 @@
<Path fileType="doc">/usr/share/man</Path>
</Files>
</Package>
<History>
<Update release="2">
<Date>2005-08-10</Date>
<Version>5.52</Version>
</Update>
</History>
</PISI>
+7 -7
View File
@@ -25,13 +25,6 @@
<Dependency>unzip</Dependency>
<Dependency>patch</Dependency>
</BuildDependencies>
<History>
<Update>
<Date>2005-08-11</Date>
<Version>2.4</Version>
<Release>3</Release>
</Update>
</History>
</Source>
<Package>
@@ -46,5 +39,12 @@
</Files>
</Package>
<History>
<Update release="3">
<Date>2005-08-11</Date>
<Version>2.4</Version>
</Update>
</History>
</PISI>