Keep repo updates in history... add, remove will come
This commit is contained in:
@@ -640,6 +640,8 @@ def update_repo(repo, force=False):
|
|||||||
repouri = repodb.get_repo(repo).indexuri.get_uri()
|
repouri = repodb.get_repo(repo).indexuri.get_uri()
|
||||||
try:
|
try:
|
||||||
index.read_uri_of_repo(repouri, repo)
|
index.read_uri_of_repo(repouri, repo)
|
||||||
|
pisi.db.historydb.HistoryDB().create_history("repoupdate")
|
||||||
|
pisi.db.historydb.HistoryDB().update_repo(repo, repouri, "update")
|
||||||
except pisi.file.AlreadyHaveException, e:
|
except pisi.file.AlreadyHaveException, e:
|
||||||
ctx.ui.info(_('%s repository information is up-to-date.') % repo)
|
ctx.ui.info(_('%s repository information is up-to-date.') % repo)
|
||||||
if force:
|
if force:
|
||||||
|
|||||||
+4
-1
@@ -25,7 +25,7 @@ import pisi.context as ctx
|
|||||||
import pisi.cli.command as command
|
import pisi.cli.command as command
|
||||||
|
|
||||||
# Operation names for translation
|
# Operation names for translation
|
||||||
opttrans = {"upgrade":_("upgrade"),"remove":_("remove"),"emerge":_("emerge"), "install":_("install"), "snapshot":_("snapshot"), "takeback":_("takeback")}
|
opttrans = {"upgrade":_("upgrade"),"remove":_("remove"),"emerge":_("emerge"), "install":_("install"), "snapshot":_("snapshot"), "takeback":_("takeback"), "repoupdate":_("repository update")}
|
||||||
|
|
||||||
class History(command.PackageOp):
|
class History(command.PackageOp):
|
||||||
"""History of pisi operations
|
"""History of pisi operations
|
||||||
@@ -70,6 +70,9 @@ Lists previous operations."""
|
|||||||
|
|
||||||
if operation.type == "snapshot":
|
if operation.type == "snapshot":
|
||||||
print _(" * There are %d packages in this snapshot.") % len(operation.packages)
|
print _(" * There are %d packages in this snapshot.") % len(operation.packages)
|
||||||
|
if operation.type == "repoupdate":
|
||||||
|
for repo in operation.repos:
|
||||||
|
print " *", repo
|
||||||
else:
|
else:
|
||||||
for pkg in operation.packages:
|
for pkg in operation.packages:
|
||||||
print " *", pkg
|
print " *", pkg
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ expanded to package names.
|
|||||||
repos = pisi.api.list_repos()
|
repos = pisi.api.list_repos()
|
||||||
for repo in repos:
|
for repo in repos:
|
||||||
pisi.api.update_repo(repo)
|
pisi.api.update_repo(repo)
|
||||||
|
# reinitialize after update repo operation
|
||||||
|
pisi.db.historydb.HistoryDB().init()
|
||||||
else:
|
else:
|
||||||
ctx.ui.info(_('Will not update repositories'))
|
ctx.ui.info(_('Will not update repositories'))
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class HistoryDB(lazydb.LazyDB):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.__logs = self.__generate_history()
|
self.__logs = self.__generate_history()
|
||||||
|
self.history = None
|
||||||
|
|
||||||
def __generate_history(self):
|
def __generate_history(self):
|
||||||
logs = filter(lambda x:x.endswith(".xml"), os.listdir(ctx.config.history_dir()))
|
logs = filter(lambda x:x.endswith(".xml"), os.listdir(ctx.config.history_dir()))
|
||||||
@@ -33,6 +34,7 @@ class HistoryDB(lazydb.LazyDB):
|
|||||||
return logs
|
return logs
|
||||||
|
|
||||||
def create_history(self, operation):
|
def create_history(self, operation):
|
||||||
|
if not self.history:
|
||||||
self.history = pisi.history.History()
|
self.history = pisi.history.History()
|
||||||
self.history.create(operation)
|
self.history.create(operation)
|
||||||
|
|
||||||
@@ -58,6 +60,10 @@ class HistoryDB(lazydb.LazyDB):
|
|||||||
destdir = os.path.join(hist_dir, config_file[1:])
|
destdir = os.path.join(hist_dir, config_file[1:])
|
||||||
pisi.util.copy_file_stat(config_file, destdir);
|
pisi.util.copy_file_stat(config_file, destdir);
|
||||||
|
|
||||||
|
def update_repo(self, repo, uri, operation = None):
|
||||||
|
self.history.update_repo(repo, uri, operation)
|
||||||
|
self.update_history()
|
||||||
|
|
||||||
def update_history(self):
|
def update_history(self):
|
||||||
self.history.update()
|
self.history.update()
|
||||||
|
|
||||||
|
|||||||
+26
-2
@@ -31,6 +31,22 @@ class PackageInfo:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.version + "-" + self.release + "-" + (self.build or '?')
|
return self.version + "-" + self.release + "-" + (self.build or '?')
|
||||||
|
|
||||||
|
class Repo:
|
||||||
|
a_operation = [autoxml.String, autoxml.mandatory]
|
||||||
|
|
||||||
|
t_Name = [autoxml.String, autoxml.mandatory]
|
||||||
|
t_Uri = [autoxml.String, autoxml.mandatory]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
# "update", "remove", "add"
|
||||||
|
operation = ""
|
||||||
|
if self.operation == "update":
|
||||||
|
return _("%s repository is updated.") % self.name
|
||||||
|
elif self.operation == "add":
|
||||||
|
pass # TBD
|
||||||
|
elif self.operation == "remove":
|
||||||
|
pass # TBD
|
||||||
|
|
||||||
class Package:
|
class Package:
|
||||||
|
|
||||||
a_operation = [autoxml.String, autoxml.mandatory]
|
a_operation = [autoxml.String, autoxml.mandatory]
|
||||||
@@ -65,7 +81,8 @@ class Operation:
|
|||||||
a_date = [autoxml.String, autoxml.mandatory]
|
a_date = [autoxml.String, autoxml.mandatory]
|
||||||
a_time = [autoxml.String, autoxml.mandatory]
|
a_time = [autoxml.String, autoxml.mandatory]
|
||||||
|
|
||||||
t_Packages = [ [Package], autoxml.mandatory, "Package"]
|
t_Packages = [ [Package], autoxml.optional, "Package"]
|
||||||
|
t_Repos = [ [Repo], autoxml.optional, "Repository"]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.type
|
return self.type
|
||||||
@@ -80,7 +97,7 @@ class History(xmlfile.XmlFile):
|
|||||||
|
|
||||||
def create(self, operation):
|
def create(self, operation):
|
||||||
|
|
||||||
if operation not in ["upgrade", "remove", "emerge", "install", "snapshot", "takeback"]:
|
if operation not in ["upgrade", "remove", "emerge", "install", "snapshot", "takeback", "repoupdate"]:
|
||||||
raise Exception("Unknown package operation")
|
raise Exception("Unknown package operation")
|
||||||
|
|
||||||
opno = self._get_latest()
|
opno = self._get_latest()
|
||||||
@@ -92,6 +109,13 @@ class History(xmlfile.XmlFile):
|
|||||||
self.operation.time = "%02d:%02d" % (hour, minute)
|
self.operation.time = "%02d:%02d" % (hour, minute)
|
||||||
self.operation.no = opno
|
self.operation.no = opno
|
||||||
|
|
||||||
|
def update_repo(self, name, uri, operation=None):
|
||||||
|
repo = Repo()
|
||||||
|
repo.operation = operation
|
||||||
|
repo.name = name
|
||||||
|
repo.uri = uri
|
||||||
|
self.operation.repos.append(repo)
|
||||||
|
|
||||||
# @param otype is currently only used to hold if an upgrade is from "delta"
|
# @param otype is currently only used to hold if an upgrade is from "delta"
|
||||||
def add(self, pkgBefore=None, pkgAfter=None, operation=None, otype=None):
|
def add(self, pkgBefore=None, pkgAfter=None, operation=None, otype=None):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user