Install DB changes and API methods for needs{Restart,Reboot} feature.
pisi.api.list_needs_{reboot,restart}()
pisi.api.add_needs_{reboot,restart}(package)
pisi.api.remove_needs_{reboot,restart}(package)
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
2009-12-07 Bahadır Kandemir <bahadir@pardus.org.tr>
|
||||
* pisi/api.py, pisi/db/install.db, pisi/constants.py: Install DB
|
||||
changes and API methods for needs{Restart,Reboot} feature.
|
||||
|
||||
2009-12-04 Bahadır Kandemir <bahadir@pardus.org.tr>
|
||||
* pisi/scenarioapi/pspec.py: Reverted AnyDependency changes.
|
||||
|
||||
|
||||
+36
@@ -156,6 +156,42 @@ def set_options(options):
|
||||
"""
|
||||
ctx.config = pisi.config.Config(options)
|
||||
|
||||
def list_needs_restart():
|
||||
"""
|
||||
Return a list of packages that need a service restart.
|
||||
"""
|
||||
return pisi.db.installdb.InstallDB().list_needs_restart()
|
||||
|
||||
def list_needs_reboot():
|
||||
"""
|
||||
Return a list of packages that need a system reboot.
|
||||
"""
|
||||
return pisi.db.installdb.InstallDB().list_needs_reboot()
|
||||
|
||||
def add_needs_restart(package):
|
||||
"""
|
||||
Add a new package to service restart list.
|
||||
"""
|
||||
pisi.db.installdb.InstallDB().mark_needs_restart(package)
|
||||
|
||||
def add_needs_reboot(package):
|
||||
"""
|
||||
Add a new package to system reboot list.
|
||||
"""
|
||||
pisi.db.installdb.InstallDB().mark_needs_reboot(package)
|
||||
|
||||
def remove_needs_restart(package):
|
||||
"""
|
||||
Remove a package from service restart list. Passing "*" will clear whole list.
|
||||
"""
|
||||
pisi.db.installdb.InstallDB().clear_needs_restart(package)
|
||||
|
||||
def remove_needs_reboot(package):
|
||||
"""
|
||||
Remove a package from system reboot list. Passing "*" will clear whole list.
|
||||
"""
|
||||
pisi.db.installdb.InstallDB().clear_needs_reboot(package)
|
||||
|
||||
def list_pending():
|
||||
"""
|
||||
Return a list of configuration pending packages -> list_of_strings
|
||||
|
||||
@@ -87,6 +87,8 @@ class Constants:
|
||||
self.__c.sandbox_conf = "/etc/pisi/sandbox.conf"
|
||||
self.__c.blacklist = "/etc/pisi/blacklist"
|
||||
self.__c.config_pending = "configpending"
|
||||
self.__c.needs_restart = "needs_restart"
|
||||
self.__c.needs_reboot = "needs_reboot"
|
||||
self.__c.files_db = "files.db"
|
||||
self.__c.repos = "repos"
|
||||
|
||||
|
||||
@@ -80,6 +80,18 @@ class InstallDB(lazydb.LazyDB):
|
||||
return open(pending_info_path, "r").read().split()
|
||||
return []
|
||||
|
||||
def __get_needs_restart(self):
|
||||
restart_info_path = os.path.join(ctx.config.info_dir(), ctx.const.needs_restart)
|
||||
if os.path.exists(restart_info_path):
|
||||
return open(restart_info_path, "r").read().split()
|
||||
return []
|
||||
|
||||
def __get_needs_reboot(self):
|
||||
reboot_info_path = os.path.join(ctx.config.info_dir(), ctx.const.needs_reboot)
|
||||
if os.path.exists(reboot_info_path):
|
||||
return open(reboot_info_path, "r").read().split()
|
||||
return []
|
||||
|
||||
def __add_to_revdeps(self, package, revdeps):
|
||||
metadata_xml = os.path.join(self.package_path(package), ctx.const.metadata_xml)
|
||||
meta_doc = piksemel.parse(metadata_xml)
|
||||
@@ -244,6 +256,18 @@ class InstallDB(lazydb.LazyDB):
|
||||
config_pending.append(package)
|
||||
self.__write_config_pending(config_pending)
|
||||
|
||||
def mark_needs_restart(self, package):
|
||||
needs_restart = self.__get_needs_restart()
|
||||
if package not in needs_restart:
|
||||
needs_restart.append(package)
|
||||
self.__write_needs_restart(needs_restart)
|
||||
|
||||
def mark_needs_reboot(self, package):
|
||||
needs_reboot = self.__get_needs_reboot()
|
||||
if package not in needs_reboot:
|
||||
needs_reboot.append(package)
|
||||
self.__write_needs_reboot(needs_reboot)
|
||||
|
||||
def add_package(self, pkginfo):
|
||||
self.installed_db[pkginfo.name] = "%s-%s" % (pkginfo.version, pkginfo.release)
|
||||
self.__add_to_revdeps(pkginfo.name, self.rev_deps_db)
|
||||
@@ -256,12 +280,34 @@ class InstallDB(lazydb.LazyDB):
|
||||
def list_pending(self):
|
||||
return self.__get_config_pending()
|
||||
|
||||
def list_needs_restart(self):
|
||||
return self.__get_needs_restart()
|
||||
|
||||
def list_needs_reboot(self):
|
||||
return self.__get_needs_reboot()
|
||||
|
||||
def clear_pending(self, package):
|
||||
config_pending = self.__get_config_pending()
|
||||
if package in config_pending:
|
||||
config_pending.remove(package)
|
||||
self.__write_config_pending(config_pending)
|
||||
|
||||
def clear_needs_restart(self, package):
|
||||
needs_restart = self.__get_needs_restart()
|
||||
if package == "*":
|
||||
self.__write_needs_restart([])
|
||||
elif package in needs_restart:
|
||||
needs_restart.remove(package)
|
||||
self.__write_needs_restart(needs_restart)
|
||||
|
||||
def clear_needs_reboot(self, package):
|
||||
needs_reboot = self.__get_needs_reboot()
|
||||
if package == "*":
|
||||
self.__write_needs_reboot([])
|
||||
elif package in needs_reboot:
|
||||
needs_reboot.remove(package)
|
||||
self.__write_needs_reboot(needs_reboot)
|
||||
|
||||
def __write_config_pending(self, config_pending):
|
||||
pending_info_file = os.path.join(ctx.config.info_dir(), ctx.const.config_pending)
|
||||
pending = open(pending_info_file, "w")
|
||||
@@ -269,6 +315,20 @@ class InstallDB(lazydb.LazyDB):
|
||||
pending.write("%s\n" % pkg)
|
||||
pending.close()
|
||||
|
||||
def __write_needs_restart(self, needs_restart):
|
||||
restart_info_file = os.path.join(ctx.config.info_dir(), ctx.const.needs_restart)
|
||||
restart = open(restart_info_file, "w")
|
||||
for pkg in set(needs_restart):
|
||||
restart.write("%s\n" % pkg)
|
||||
restart.close()
|
||||
|
||||
def __write_needs_reboot(self, needs_reboot):
|
||||
reboot_info_file = os.path.join(ctx.config.info_dir(), ctx.const.needs_reboot)
|
||||
reboot = open(reboot_info_file, "w")
|
||||
for pkg in set(needs_reboot):
|
||||
reboot.write("%s\n" % pkg)
|
||||
reboot.close()
|
||||
|
||||
def package_path(self, package):
|
||||
|
||||
if self.installed_db.has_key(package):
|
||||
|
||||
Reference in New Issue
Block a user