* keep track of pending configurations (bug 338)
* list pending packages, too * work in progress * i'm trying to add options to config class, and remove the seemingly unnecessary singleton thing from there
This commit is contained in:
+24
-1
@@ -32,6 +32,7 @@ def cmdObject(cmd, fail=False):
|
||||
"info": Info,
|
||||
"install": Install,
|
||||
"configure-pending": ConfigurePending,
|
||||
"list-pending": ListPending,
|
||||
"list-installed": ListInstalled,
|
||||
"list-available": ListAvailable,
|
||||
"search-available": SearchAvailable,
|
||||
@@ -64,7 +65,12 @@ class Command(object):
|
||||
self.parser = commonopts(self.parser)
|
||||
(self.options, args) = self.parser.parse_args()
|
||||
self.args = args[1:]
|
||||
|
||||
|
||||
# initialize PiSi
|
||||
pisi.config.config = pisi.config.Config(self.options)
|
||||
cli = pisi.ui.CLI(self.options.debug)
|
||||
pisi.ui.ui = cli
|
||||
|
||||
self.checkAuthInfo()
|
||||
|
||||
def options(self):
|
||||
@@ -194,6 +200,7 @@ repositories (with add-repo).
|
||||
"""
|
||||
def __init__(self):
|
||||
super(Install, self).__init__()
|
||||
print pisi.config.config.options
|
||||
|
||||
def run(self):
|
||||
if not self.args:
|
||||
@@ -429,6 +436,22 @@ TODO: desc...
|
||||
print p
|
||||
|
||||
|
||||
class ListPending(Command):
|
||||
"""List pending packages"""
|
||||
|
||||
def __init__(self):
|
||||
super(ListPending, self).__init__()
|
||||
|
||||
def run(self):
|
||||
from pisi.installdb import installdb
|
||||
from pisi.ui import ui
|
||||
|
||||
self.init_db()
|
||||
|
||||
for p in installdb.list_pending():
|
||||
print p
|
||||
|
||||
|
||||
class SearchAvailable(Command):
|
||||
"""Search in available packages
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ list-installed
|
||||
list-available
|
||||
remove
|
||||
configure-pending
|
||||
list-pending
|
||||
add-repo
|
||||
remove-repo
|
||||
list-repo
|
||||
|
||||
@@ -44,7 +44,9 @@ class PisiCLI(object):
|
||||
(options, args) = self.parser.parse_args()
|
||||
#if len(parser.rargs)==0:
|
||||
# self.die()
|
||||
print 'running cmd'
|
||||
cmd = args[0]
|
||||
pisi.config.config = pisi.config.Config(options)
|
||||
cli = pisi.ui.CLI(options.debug)
|
||||
pisi.ui.ui = cli
|
||||
|
||||
|
||||
+27
-38
@@ -22,51 +22,40 @@ from configfile import ConfigurationFile
|
||||
class Config(object):
|
||||
"""Config Singleton"""
|
||||
|
||||
class configimpl:
|
||||
def __init__(self, options = None):
|
||||
if options:
|
||||
print 'wohoo', options
|
||||
self.options = options
|
||||
self.values = ConfigurationFile("/etc/pisi/pisi.conf")
|
||||
self.destdir = self.values.general.destinationdirectory
|
||||
|
||||
def __init__(self):
|
||||
self.values = ConfigurationFile("/etc/pisi/pisi.conf")
|
||||
self.destdir = self.values.general.destinationdirectory
|
||||
# directory accessor functions
|
||||
# here is how it goes
|
||||
# x_dir: system wide directory for storing info type x
|
||||
# pkg_x_dir: per package directory for storing info type x
|
||||
|
||||
# directory accessor functions
|
||||
# here is how it goes
|
||||
# x_dir: system wide directory for storing info type x
|
||||
# pkg_x_dir: per package directory for storing info type x
|
||||
def lib_dir(self):
|
||||
return self.destdir + self.values.dirs.lib_dir
|
||||
|
||||
def lib_dir(self):
|
||||
return self.destdir + self.values.dirs.lib_dir
|
||||
def db_dir(self):
|
||||
return self.destdir + self.values.dirs.db_dir
|
||||
|
||||
def db_dir(self):
|
||||
return self.destdir + self.values.dirs.db_dir
|
||||
def archives_dir(self):
|
||||
return self.destdir + self.values.dirs.archives_dir
|
||||
|
||||
def archives_dir(self):
|
||||
return self.destdir + self.values.dirs.archives_dir
|
||||
def packages_dir(self):
|
||||
return self.destdir + self.values.dirs.packages_dir
|
||||
|
||||
def packages_dir(self):
|
||||
return self.destdir + self.values.dirs.packages_dir
|
||||
def index_dir(self):
|
||||
return self.destdir + self.values.dirs.index_dir
|
||||
|
||||
def index_dir(self):
|
||||
return self.destdir + self.values.dirs.index_dir
|
||||
|
||||
def tmp_dir(self):
|
||||
return self.destdir + self.values.dirs.tmp_dir
|
||||
|
||||
# bu dizini neden kullanıyoruz? Yalnızca index.py içerisinde
|
||||
# kullanılıyor ama /var/tmp/pisi/install gibi bir dizine niye
|
||||
# ihtiyacımız var? (baris)
|
||||
def install_dir(self):
|
||||
return self.tmp_dir() + const.install_dir_suffix
|
||||
|
||||
__configinstance = configimpl()
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return getattr(self.__configinstance, attr)
|
||||
|
||||
def __setattr__(self, attr, value):
|
||||
setattr(self.__configinstance, attr, value)
|
||||
def tmp_dir(self):
|
||||
return self.destdir + self.values.dirs.tmp_dir
|
||||
|
||||
# bu dizini neden kullanıyoruz? Yalnızca index.py içerisinde
|
||||
# kullanılıyor ama /var/tmp/pisi/install gibi bir dizine niye
|
||||
# ihtiyacımız var? (baris)
|
||||
def install_dir(self):
|
||||
return self.tmp_dir() + const.install_dir_suffix
|
||||
|
||||
config = Config()
|
||||
|
||||
@@ -153,6 +153,8 @@ class Installer:
|
||||
def update_databases(self):
|
||||
"update databases"
|
||||
|
||||
print "INSTALL", config.options, config.options.ignore_comar
|
||||
|
||||
# installdb
|
||||
installdb.install(self.metadata.package.name,
|
||||
self.metadata.package.version,
|
||||
|
||||
+17
-3
@@ -9,9 +9,9 @@
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
|
||||
#
|
||||
# installation database
|
||||
|
||||
#
|
||||
# Author: Eray Ozkural <eray@uludag.org.tr>
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class InstallDB:
|
||||
def __init__(self):
|
||||
from os.path import join
|
||||
self.d = shelve.LockedDBShelf('install')
|
||||
self.dp = shelve.LockedDBShelf('configpending')
|
||||
self.files_dir = os.path.join(config.db_dir(), 'files')
|
||||
|
||||
def files_name(self, pkg, version, release):
|
||||
@@ -53,7 +54,7 @@ class InstallDB:
|
||||
pkg = str(pkg)
|
||||
if self.is_recorded(pkg):
|
||||
(status, version, release) = self.d[pkg]
|
||||
return status=='i'
|
||||
return status=='i' or status=='ip'
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -64,6 +65,12 @@ class InstallDB:
|
||||
l.append(pkg)
|
||||
return l
|
||||
|
||||
def list_pending(self):
|
||||
l = []
|
||||
for (pkg, x) in self.dp.iteritems():
|
||||
l.append(pkg)
|
||||
return l
|
||||
|
||||
def get_version(self, pkg):
|
||||
pkg = str(pkg)
|
||||
(status, version, release) = self.d[pkg]
|
||||
@@ -80,8 +87,15 @@ class InstallDB:
|
||||
def install(self, pkg, version, release):
|
||||
"""install package with specific version and release"""
|
||||
pkg = str(pkg)
|
||||
print "INSTALLDB", config.options, config.options.ignore_comar
|
||||
if self.is_installed(pkg):
|
||||
raise InstallDBError("already installed")
|
||||
if config.options.ignore_comar:
|
||||
state = 'ip'
|
||||
self.dp[pkg] = True
|
||||
else:
|
||||
state = 'i'
|
||||
|
||||
self.d[pkg] = ('i', version, release)
|
||||
|
||||
def remove(self, pkg):
|
||||
|
||||
Reference in New Issue
Block a user