* 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:
+11
-4
@@ -290,6 +290,7 @@ specified a package name, it should exist in a specified repository.
|
|||||||
return ("upgrade", "up")
|
return ("upgrade", "up")
|
||||||
|
|
||||||
def options(self):
|
def options(self):
|
||||||
|
super(Upgrade, self).options()
|
||||||
buildno_opts(self)
|
buildno_opts(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@@ -425,6 +426,8 @@ Usage: list-installed
|
|||||||
def options(self):
|
def options(self):
|
||||||
self.parser.add_option("-l", "--long", action="store_true",
|
self.parser.add_option("-l", "--long", action="store_true",
|
||||||
default=False, help="show in long format")
|
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):
|
def run(self):
|
||||||
self.init(True)
|
self.init(True)
|
||||||
@@ -432,11 +435,15 @@ Usage: list-installed
|
|||||||
list = installdb.list_installed()
|
list = installdb.list_installed()
|
||||||
list.sort()
|
list.sort()
|
||||||
for pkg in list:
|
for pkg in list:
|
||||||
package = pisi.packagedb.get_package(pkg)
|
package = pisi.packagedb.inst_packagedb.get_package(pkg)
|
||||||
if not self.options.long:
|
inst_info = installdb.get_info(pkg)
|
||||||
print package.name, '-', package.summary
|
if self.options.long:
|
||||||
else:
|
|
||||||
print package
|
print package
|
||||||
|
print inst_info
|
||||||
|
elif self.options.detailed:
|
||||||
|
print package.name, '-', inst_info.one_liner()
|
||||||
|
else:
|
||||||
|
print package.name, '-', package.summary
|
||||||
self.finalize()
|
self.finalize()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -61,7 +61,6 @@ class Installer:
|
|||||||
|
|
||||||
def check_requirements(self):
|
def check_requirements(self):
|
||||||
"""check system requirements"""
|
"""check system requirements"""
|
||||||
|
|
||||||
#TODO: IS THERE ENOUGH SPACE?
|
#TODO: IS THERE ENOUGH SPACE?
|
||||||
# what to do if / is split into /usr, /var, etc.
|
# what to do if / is split into /usr, /var, etc.
|
||||||
pass
|
pass
|
||||||
@@ -84,13 +83,14 @@ class Installer:
|
|||||||
' not satisfied\n')
|
' not satisfied\n')
|
||||||
raise InstallError("Package not installable")
|
raise InstallError("Package not installable")
|
||||||
|
|
||||||
|
# FIXME: where is build no?
|
||||||
def reinstall(self):
|
def reinstall(self):
|
||||||
"check reinstall, confirm action, and remove package if reinstall"
|
"check reinstall, confirm action, and remove package if reinstall"
|
||||||
|
|
||||||
pkg = self.pkginfo
|
pkg = self.pkginfo
|
||||||
|
|
||||||
if installdb.is_installed(pkg.name): # is this a reinstallation?
|
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 pkg.version == iversion and pkg.release == irelease:
|
||||||
if self.ask_reinstall:
|
if self.ask_reinstall:
|
||||||
@@ -162,7 +162,9 @@ class Installer:
|
|||||||
# installdb
|
# installdb
|
||||||
installdb.install(self.metadata.package.name,
|
installdb.install(self.metadata.package.name,
|
||||||
self.metadata.package.version,
|
self.metadata.package.version,
|
||||||
self.metadata.package.release)
|
self.metadata.package.release,
|
||||||
|
self.metadata.package.build,
|
||||||
|
self.metadata.package.distribution)
|
||||||
|
|
||||||
# installed packages
|
# installed packages
|
||||||
inst_packagedb.add_package(self.pkginfo)
|
inst_packagedb.add_package(self.pkginfo)
|
||||||
|
|||||||
+53
-19
@@ -30,6 +30,39 @@ class InstallDBError(pisi.Error):
|
|||||||
pass
|
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:
|
class InstallDB:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -47,9 +80,9 @@ class InstallDB:
|
|||||||
|
|
||||||
def files(self, pkg):
|
def files(self, pkg):
|
||||||
pkg = str(pkg)
|
pkg = str(pkg)
|
||||||
(status, version, release) = self.d[pkg]
|
pkginfo = self.d[pkg]
|
||||||
files = Files()
|
files = Files()
|
||||||
files.read(self.files_name(pkg,version,release))
|
files.read(self.files_name(pkg,pkginfo.version,pkginfo.release))
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def is_recorded(self, pkg):
|
def is_recorded(self, pkg):
|
||||||
@@ -59,15 +92,15 @@ class InstallDB:
|
|||||||
def is_installed(self, pkg):
|
def is_installed(self, pkg):
|
||||||
pkg = str(pkg)
|
pkg = str(pkg)
|
||||||
if self.is_recorded(pkg):
|
if self.is_recorded(pkg):
|
||||||
(status, version, release) = self.d[pkg]
|
info = self.d[pkg]
|
||||||
return status=='i' or status=='ip'
|
return info.state=='i' or info.state=='ip'
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def list_installed(self):
|
def list_installed(self):
|
||||||
list = []
|
list = []
|
||||||
for (pkg, (status,version,release)) in self.d.iteritems():
|
for (pkg, info) in self.d.iteritems():
|
||||||
if status=='i':
|
if info.state=='i':
|
||||||
list.append(pkg)
|
list.append(pkg)
|
||||||
return list
|
return list
|
||||||
|
|
||||||
@@ -77,21 +110,25 @@ class InstallDB:
|
|||||||
list.append(pkg)
|
list.append(pkg)
|
||||||
return list
|
return list
|
||||||
|
|
||||||
|
def get_info(self, pkg):
|
||||||
|
pkg = str(pkg)
|
||||||
|
return self.d[pkg]
|
||||||
|
|
||||||
def get_version(self, pkg):
|
def get_version(self, pkg):
|
||||||
pkg = str(pkg)
|
pkg = str(pkg)
|
||||||
(status, version, release) = self.d[pkg]
|
info = self.d[pkg]
|
||||||
return (version, release)
|
return (info.version, info.release, info.build)
|
||||||
|
|
||||||
def is_removed(self, pkg):
|
def is_removed(self, pkg):
|
||||||
pkg = str(pkg)
|
pkg = str(pkg)
|
||||||
if self.is_recorded(pkg):
|
if self.is_recorded(pkg):
|
||||||
(status, version, release) = self.d[pkg]
|
info = self.d[pkg]
|
||||||
return status=='r'
|
return info.state=='r'
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def install(self, pkg, version, release):
|
def install(self, pkg, version, release, build, distro = ""):
|
||||||
"""install package with specific version and release"""
|
"""install package with specific version, release, build"""
|
||||||
pkg = str(pkg)
|
pkg = str(pkg)
|
||||||
from pisi.config import config
|
from pisi.config import config
|
||||||
if self.is_installed(pkg):
|
if self.is_installed(pkg):
|
||||||
@@ -102,21 +139,18 @@ class InstallDB:
|
|||||||
else:
|
else:
|
||||||
state = 'i'
|
state = 'i'
|
||||||
|
|
||||||
self.d[pkg] = ('i', version, release)
|
self.d[pkg] = InstallInfo(state, version, release, build, distro)
|
||||||
|
|
||||||
def remove(self, pkg):
|
def remove(self, pkg):
|
||||||
pkg = str(pkg)
|
pkg = str(pkg)
|
||||||
(status, version, release) = self.d[pkg]
|
info = self.d[pkg]
|
||||||
self.d[pkg] = ('r', version, release)
|
info.state = 'r'
|
||||||
|
self.d[pkg] = info
|
||||||
|
|
||||||
def purge(self, pkg):
|
def purge(self, pkg):
|
||||||
pkg = str(pkg)
|
pkg = str(pkg)
|
||||||
if self.d.has_key(pkg):
|
if self.d.has_key(pkg):
|
||||||
(status, version, release) = self.d[pkg]
|
|
||||||
del self.d[pkg]
|
del self.d[pkg]
|
||||||
|
|
||||||
installdb = InstallDB()
|
installdb = InstallDB()
|
||||||
|
|
||||||
#def init():
|
|
||||||
# installdb = InstallDB()
|
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -62,6 +62,7 @@ def install_single(pkg, upgrade = False):
|
|||||||
else:
|
else:
|
||||||
install_single_name(pkg, upgrade)
|
install_single_name(pkg, upgrade)
|
||||||
|
|
||||||
|
# FIXME: Here and elsewhere pkg_location must be a URI
|
||||||
def install_single_file(pkg_location, upgrade = False):
|
def install_single_file(pkg_location, upgrade = False):
|
||||||
"""install a package file"""
|
"""install a package file"""
|
||||||
from install import Installer
|
from install import Installer
|
||||||
@@ -82,7 +83,7 @@ def install_single_name(name, upgrade = False):
|
|||||||
pkg_path = str(pkg.packageURI)
|
pkg_path = str(pkg.packageURI)
|
||||||
else:
|
else:
|
||||||
pkg_path = os.path.join(os.path.dirname(repo.indexuri.get_uri()),
|
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)
|
ui.debug("Package URI: %s\n" % pkg_path)
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -215,18 +215,18 @@ def upgrade_pkg_names(A):
|
|||||||
if not installdb.is_installed(x):
|
if not installdb.is_installed(x):
|
||||||
ui.info('Package %s is not installed.\n' % x)
|
ui.info('Package %s is not installed.\n' % x)
|
||||||
continue
|
continue
|
||||||
(version, release) = installdb.get_version(x)
|
(version, release, build) = installdb.get_version(x)
|
||||||
(versionp, releasep) = (packagedb.get_package(x).version,
|
pkg = packagedb.get_package(x)
|
||||||
packagedb.get_package(x).release)
|
if (config.options and config.options.ignore_build_no) or (not build):
|
||||||
# FIXME: we should use build instead of release
|
if release < pkg.release:
|
||||||
if release < releasep:
|
Ap.append(x)
|
||||||
|
elif build < pkg.build:
|
||||||
Ap.append(x)
|
Ap.append(x)
|
||||||
else:
|
else:
|
||||||
#ui.info('Package %s cannot be upgraded. ' % x)
|
#ui.info('Package %s cannot be upgraded. ' % x)
|
||||||
# FIXME: where is build no?
|
|
||||||
ui.info('Package %s is already at its latest version %s,\
|
ui.info('Package %s is already at its latest version %s,\
|
||||||
release %s, build ?.\n'
|
release %s, build %s.\n'
|
||||||
% (x, versionp, releasep))
|
% (x, pkg.version, pkg.release, pkg.build))
|
||||||
A = Ap
|
A = Ap
|
||||||
|
|
||||||
if len(A)==0:
|
if len(A)==0:
|
||||||
@@ -256,10 +256,10 @@ def upgrade_pkg_names(A):
|
|||||||
# add packages that can be upgraded
|
# add packages that can be upgraded
|
||||||
if dependency.repo_satisfies_dep(dep):
|
if dependency.repo_satisfies_dep(dep):
|
||||||
if installdb.is_installed(dep.package):
|
if installdb.is_installed(dep.package):
|
||||||
#FIXME: use build no
|
(v,r,b) = installdb.get_version(dep.package)
|
||||||
(v,r) = installdb.get_version(dep.package)
|
|
||||||
rep_pkg = packagedb.get_package(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
|
if r >= rp: # installed already older
|
||||||
continue
|
continue
|
||||||
if not dep.package in G_f.vertices():
|
if not dep.package in G_f.vertices():
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ mkdir -p myrepo
|
|||||||
cd myrepo
|
cd myrepo
|
||||||
../pisi-cli build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml
|
../pisi-cli build ../tests/zip2/pspec.xml ../tests/unzip2/pspec.xml
|
||||||
cd ..
|
cd ..
|
||||||
pisi-cli index myrepo
|
pisi-cli --absolute-uris index myrepo
|
||||||
pisi-cli remove-repo repo1
|
pisi-cli remove-repo repo1
|
||||||
pisi-cli add-repo repo1 pisi-index.xml
|
pisi-cli add-repo repo1 pisi-index.xml
|
||||||
pisi-cli list-repo
|
pisi-cli list-repo
|
||||||
|
|||||||
+3
-3
@@ -3,13 +3,13 @@
|
|||||||
set -x # xtrace
|
set -x # xtrace
|
||||||
set -e # errexit
|
set -e # errexit
|
||||||
|
|
||||||
echo "alpha functionality test script"
|
echo "beta functionality test script"
|
||||||
echo "working directory:" `pwd`
|
echo "working directory:" `pwd`
|
||||||
echo "cleaning destination dir: tmp"
|
echo "cleaning destination dir: tmp"
|
||||||
rm -rf tmp
|
rm -rf tmp
|
||||||
#echo "*** build tests"
|
#echo "*** build tests"
|
||||||
pisi-cli build https://svn.uludag.org.tr/pisi/trunk/z/zip/pspec.xml \
|
pisi-cli build https://svn.uludag.org.tr/pisi/trunk/system/base/zip/pspec.xml \
|
||||||
https://svn.uludag.org.tr/pisi/trunk/u/unzip/pspec.xml
|
https://svn.uludag.org.tr/pisi/trunk/system/base/unzip/pspec.xml
|
||||||
|
|
||||||
#partial-builds
|
#partial-builds
|
||||||
pisi-cli build-dosetup https://svn.uludag.org.tr/pisi/trunk/system/base/hdparm/pspec.xml
|
pisi-cli build-dosetup https://svn.uludag.org.tr/pisi/trunk/system/base/hdparm/pspec.xml
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ class InstallDBTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def testInstall(self):
|
def testInstall(self):
|
||||||
installdb.purge('installtest')
|
installdb.purge('installtest')
|
||||||
installdb.install('installtest', '0.1', '2')
|
installdb.install('installtest', '0.1', '2', '3')
|
||||||
|
|
||||||
def testRemovePurge(self):
|
def testRemovePurge(self):
|
||||||
installdb.install('installtest', '0.1', '2')
|
installdb.install('installtest', '0.1', '2', '3')
|
||||||
self.assert_(installdb.is_installed('installtest'))
|
self.assert_(installdb.is_installed('installtest'))
|
||||||
installdb.remove('installtest')
|
installdb.remove('installtest')
|
||||||
self.assert_(installdb.is_removed('installtest'))
|
self.assert_(installdb.is_removed('installtest'))
|
||||||
|
|||||||
Reference in New Issue
Block a user