* installdb'ye bir iki ek bilgi koy, build no ornegin

* install info icin gereksiz bir class yaz :)
* build no'yu install ve upgrade'de dikkate al (#362'yle ilgili)
* ignore build no'yu da implement et bir iki yerde
* fix: unicode sacmaligi, operations'da
* test'leri biraz update et
* --detailed diye bir option ekle list-installed'a
This commit is contained in:
Eray Özkural
2005-08-15 16:43:53 +00:00
parent 4dde6f68f0
commit 26232679f5
8 changed files with 91 additions and 47 deletions
+11 -4
View File
@@ -290,6 +290,7 @@ specified a package name, it should exist in a specified repository.
return ("upgrade", "up")
def options(self):
super(Upgrade, self).options()
buildno_opts(self)
def run(self):
@@ -425,6 +426,8 @@ Usage: list-installed
def options(self):
self.parser.add_option("-l", "--long", action="store_true",
default=False, help="show in long format")
self.parser.add_option("", "--detailed", action="store_true",
default=False, help="show detailed install info")
def run(self):
self.init(True)
@@ -432,11 +435,15 @@ Usage: list-installed
list = installdb.list_installed()
list.sort()
for pkg in list:
package = pisi.packagedb.get_package(pkg)
if not self.options.long:
print package.name, '-', package.summary
else:
package = pisi.packagedb.inst_packagedb.get_package(pkg)
inst_info = installdb.get_info(pkg)
if self.options.long:
print package
print inst_info
elif self.options.detailed:
print package.name, '-', inst_info.one_liner()
else:
print package.name, '-', package.summary
self.finalize()
+7 -5
View File
@@ -61,7 +61,6 @@ class Installer:
def check_requirements(self):
"""check system requirements"""
#TODO: IS THERE ENOUGH SPACE?
# what to do if / is split into /usr, /var, etc.
pass
@@ -77,20 +76,21 @@ class Installer:
for pkg in self.metadata.package.conflicts:
if installdb.is_installed(self.pkginfo):
raise InstallError("Package conflicts " + pkg)
# check dependencies
if not dependency.installable(self.pkginfo.name):
ui.error('Dependencies for ' + self.pkginfo.name +
' not satisfied\n')
raise InstallError("Package not installable")
# FIXME: where is build no?
def reinstall(self):
"check reinstall, confirm action, and remove package if reinstall"
pkg = self.pkginfo
if installdb.is_installed(pkg.name): # is this a reinstallation?
(iversion, irelease) = installdb.get_version(pkg.name)
(iversion, irelease, ibuild) = installdb.get_version(pkg.name)
if pkg.version == iversion and pkg.release == irelease:
if self.ask_reinstall:
@@ -162,7 +162,9 @@ class Installer:
# installdb
installdb.install(self.metadata.package.name,
self.metadata.package.version,
self.metadata.package.release)
self.metadata.package.release,
self.metadata.package.build,
self.metadata.package.distribution)
# installed packages
inst_packagedb.add_package(self.pkginfo)
+53 -19
View File
@@ -30,6 +30,39 @@ class InstallDBError(pisi.Error):
pass
class InstallInfo:
# some data is replicated from packagedb.inst_packagedb
# we store as an object, hey, we can waste O(1) space.
# this is also easier to modify in the future, without
# requiring database upgrades! wow!
def __init__(self, state, version, release, build, distribution):
self.state = state
self.version = version
self.release = release
self.build = build
self.distribution = distribution
from time import localtime, strftime
self.time = localtime()
def one_liner(self):
time_str = strftime("%d %b %Y %H:%M", self.time)
s = '%s,%s,%s,%s,%s,%s' % (self.state, self.version, self.release,
self.self.build, self.distribution,
time_str)
return s
state_map = { 'i': 'installed', 'ip':'installed-pending', 'r:removed'
'p': 'purged' }
def __str__(self):
s = "State: %s\nVersion: %s, Release: %s, Build: %s\n" % \
(state_map[self.state], self.version, self.release, self.build)
time_str = strftime("%d %b %Y %H:%M", self.time)
s += 'Distribution: %s, Install Time: %s\n' % (self.distribution,
time_str)
return s
class InstallDB:
def __init__(self):
@@ -47,9 +80,9 @@ class InstallDB:
def files(self, pkg):
pkg = str(pkg)
(status, version, release) = self.d[pkg]
pkginfo = self.d[pkg]
files = Files()
files.read(self.files_name(pkg,version,release))
files.read(self.files_name(pkg,pkginfo.version,pkginfo.release))
return files
def is_recorded(self, pkg):
@@ -59,15 +92,15 @@ class InstallDB:
def is_installed(self, pkg):
pkg = str(pkg)
if self.is_recorded(pkg):
(status, version, release) = self.d[pkg]
return status=='i' or status=='ip'
info = self.d[pkg]
return info.state=='i' or info.state=='ip'
else:
return False
def list_installed(self):
list = []
for (pkg, (status,version,release)) in self.d.iteritems():
if status=='i':
for (pkg, info) in self.d.iteritems():
if info.state=='i':
list.append(pkg)
return list
@@ -77,21 +110,25 @@ class InstallDB:
list.append(pkg)
return list
def get_info(self, pkg):
pkg = str(pkg)
return self.d[pkg]
def get_version(self, pkg):
pkg = str(pkg)
(status, version, release) = self.d[pkg]
return (version, release)
info = self.d[pkg]
return (info.version, info.release, info.build)
def is_removed(self, pkg):
pkg = str(pkg)
if self.is_recorded(pkg):
(status, version, release) = self.d[pkg]
return status=='r'
info = self.d[pkg]
return info.state=='r'
else:
return False
def install(self, pkg, version, release):
"""install package with specific version and release"""
def install(self, pkg, version, release, build, distro = ""):
"""install package with specific version, release, build"""
pkg = str(pkg)
from pisi.config import config
if self.is_installed(pkg):
@@ -102,21 +139,18 @@ class InstallDB:
else:
state = 'i'
self.d[pkg] = ('i', version, release)
self.d[pkg] = InstallInfo(state, version, release, build, distro)
def remove(self, pkg):
pkg = str(pkg)
(status, version, release) = self.d[pkg]
self.d[pkg] = ('r', version, release)
info = self.d[pkg]
info.state = 'r'
self.d[pkg] = info
def purge(self, pkg):
pkg = str(pkg)
if self.d.has_key(pkg):
(status, version, release) = self.d[pkg]
del self.d[pkg]
installdb = InstallDB()
#def init():
# installdb = InstallDB()
+2 -1
View File
@@ -62,6 +62,7 @@ def install_single(pkg, upgrade = False):
else:
install_single_name(pkg, upgrade)
# FIXME: Here and elsewhere pkg_location must be a URI
def install_single_file(pkg_location, upgrade = False):
"""install a package file"""
from install import Installer
@@ -82,7 +83,7 @@ def install_single_name(name, upgrade = False):
pkg_path = str(pkg.packageURI)
else:
pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()),
pkg_uri.path())
str(pkg_uri.path()))
ui.debug("Package URI: %s\n" % pkg_path)
+12 -12
View File
@@ -215,18 +215,18 @@ def upgrade_pkg_names(A):
if not installdb.is_installed(x):
ui.info('Package %s is not installed.\n' % x)
continue
(version, release) = installdb.get_version(x)
(versionp, releasep) = (packagedb.get_package(x).version,
packagedb.get_package(x).release)
# FIXME: we should use build instead of release
if release < releasep:
Ap.append(x)
(version, release, build) = installdb.get_version(x)
pkg = packagedb.get_package(x)
if (config.options and config.options.ignore_build_no) or (not build):
if release < pkg.release:
Ap.append(x)
elif build < pkg.build:
Ap.append(x)
else:
#ui.info('Package %s cannot be upgraded. ' % x)
# FIXME: where is build no?
ui.info('Package %s is already at its latest version %s,\
release %s, build ?.\n'
% (x, versionp, releasep))
release %s, build %s.\n'
% (x, pkg.version, pkg.release, pkg.build))
A = Ap
if len(A)==0:
@@ -256,10 +256,10 @@ def upgrade_pkg_names(A):
# add packages that can be upgraded
if dependency.repo_satisfies_dep(dep):
if installdb.is_installed(dep.package):
#FIXME: use build no
(v,r) = installdb.get_version(dep.package)
(v,r,b) = installdb.get_version(dep.package)
rep_pkg = packagedb.get_package(dep.package)
(vp,rp) = (rep_pkg.version, rep_pkg.release)
(vp,rp,bp) = (rep_pkg.version, rep_pkg.release,
rep_pkg.build)
if r >= rp: # installed already older
continue
if not dep.package in G_f.vertices():
+1 -1
View File
@@ -11,7 +11,7 @@ mkdir -p myrepo
cd myrepo
../pisi-cli build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml
cd ..
pisi-cli index myrepo
pisi-cli --absolute-uris index myrepo
pisi-cli remove-repo repo1
pisi-cli add-repo repo1 pisi-index.xml
pisi-cli list-repo
+3 -3
View File
@@ -3,13 +3,13 @@
set -x # xtrace
set -e # errexit
echo "alpha functionality test script"
echo "beta functionality test script"
echo "working directory:" `pwd`
echo "cleaning destination dir: tmp"
rm -rf tmp
#echo "*** build tests"
pisi-cli build https://svn.uludag.org.tr/pisi/trunk/z/zip/pspec.xml \
https://svn.uludag.org.tr/pisi/trunk/u/unzip/pspec.xml
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
#partial-builds
pisi-cli build-dosetup https://svn.uludag.org.tr/pisi/trunk/system/base/hdparm/pspec.xml
+2 -2
View File
@@ -26,10 +26,10 @@ class InstallDBTestCase(unittest.TestCase):
def testInstall(self):
installdb.purge('installtest')
installdb.install('installtest', '0.1', '2')
installdb.install('installtest', '0.1', '2', '3')
def testRemovePurge(self):
installdb.install('installtest', '0.1', '2')
installdb.install('installtest', '0.1', '2', '3')
self.assert_(installdb.is_installed('installtest'))
installdb.remove('installtest')
self.assert_(installdb.is_removed('installtest'))