Fix takeback problem with packages that has no build nos.
This commit is contained in:
+16
-15
@@ -19,19 +19,28 @@ import pisi.util
|
|||||||
import pisi.db
|
import pisi.db
|
||||||
import pisi.fetcher
|
import pisi.fetcher
|
||||||
|
|
||||||
def __listactions(actions):
|
installdb = pisi.db.installdb.InstallDB()
|
||||||
|
historydb = pisi.db.historydb.HistoryDB()
|
||||||
|
|
||||||
installdb = pisi.db.installdb.InstallDB()
|
def __pkg_already_installed(name, pkginfo):
|
||||||
|
ver, rel, build = str(pkginfo).split("-")
|
||||||
|
if build == '?':
|
||||||
|
build = None
|
||||||
|
else:
|
||||||
|
build = int(build)
|
||||||
|
return (ver, rel, build) == installdb.get_version(name)
|
||||||
|
|
||||||
|
def __listactions(actions):
|
||||||
|
|
||||||
beinstalled = []
|
beinstalled = []
|
||||||
beremoved = []
|
beremoved = []
|
||||||
|
|
||||||
for pkg in actions:
|
for pkg in actions:
|
||||||
action, version = actions[pkg]
|
action, pkginfo = actions[pkg]
|
||||||
if action == "install":
|
if action == "install":
|
||||||
if installdb.has_package(pkg) and str(version) == "%s-%s-%s" % installdb.get_version(pkg):
|
if __pkg_already_installed(pkg, pkginfo):
|
||||||
continue
|
continue
|
||||||
beinstalled.append("%s-%s" % (pkg, version))
|
beinstalled.append("%s-%s" % (pkg, pkginfo))
|
||||||
else:
|
else:
|
||||||
if installdb.has_package(pkg):
|
if installdb.has_package(pkg):
|
||||||
beremoved.append("%s" % pkg)
|
beremoved.append("%s" % pkg)
|
||||||
@@ -69,15 +78,10 @@ def fetch_remote_file(package, errors):
|
|||||||
def get_snapshot_actions(operation):
|
def get_snapshot_actions(operation):
|
||||||
actions = {}
|
actions = {}
|
||||||
snapshot_pkgs = set()
|
snapshot_pkgs = set()
|
||||||
installdb = pisi.db.installdb.InstallDB()
|
|
||||||
|
|
||||||
for pkg in operation.packages:
|
for pkg in operation.packages:
|
||||||
snapshot_pkgs.add(pkg.name)
|
snapshot_pkgs.add(pkg.name)
|
||||||
if installdb.has_package(pkg.name):
|
actions[pkg.name] = ("install", pkg.before)
|
||||||
if not str(pkg.before) == "%s-%s-%s" % installdb.get_version(pkg.name):
|
|
||||||
actions[pkg.name] = ("install", pkg.before)
|
|
||||||
else:
|
|
||||||
actions[pkg.name] = ("install", pkg.before)
|
|
||||||
|
|
||||||
for pkg in set(installdb.list_installed()) - snapshot_pkgs:
|
for pkg in set(installdb.list_installed()) - snapshot_pkgs:
|
||||||
actions[pkg] = ("remove", None)
|
actions[pkg] = ("remove", None)
|
||||||
@@ -86,7 +90,6 @@ def get_snapshot_actions(operation):
|
|||||||
|
|
||||||
def get_takeback_actions(operation):
|
def get_takeback_actions(operation):
|
||||||
actions = {}
|
actions = {}
|
||||||
historydb = pisi.db.historydb.HistoryDB()
|
|
||||||
|
|
||||||
for operation in historydb.get_till_operation(operation):
|
for operation in historydb.get_till_operation(operation):
|
||||||
if operation.type == "snapshot":
|
if operation.type == "snapshot":
|
||||||
@@ -102,8 +105,6 @@ def get_takeback_actions(operation):
|
|||||||
|
|
||||||
def takeback(operation):
|
def takeback(operation):
|
||||||
|
|
||||||
historydb = pisi.db.historydb.HistoryDB()
|
|
||||||
|
|
||||||
op = historydb.get_operation(operation)
|
op = historydb.get_operation(operation)
|
||||||
if op.type == "snapshot":
|
if op.type == "snapshot":
|
||||||
actions = get_snapshot_actions(op)
|
actions = get_snapshot_actions(op)
|
||||||
|
|||||||
Reference in New Issue
Block a user