Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid a nasty crash if a package has a malformed version string #97

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions pisi/atomicoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,24 @@ def check_operation(self):
ipkg = self.installdb.get_package(pkg.name)
(iversion_s, irelease_s, ibuild) = self.installdb.get_version(pkg.name)

# determine if same version
# determine if same distribution release
if pkg.release == irelease_s:
if self.ask_reinstall:
if not ctx.ui.confirm(_("Re-install same version package?")):
if not ctx.ui.confirm(_("Re-install same distribution release of package?")):
raise Error(_("Package re-install declined"))
self.operation = REINSTALL
else:
pkg_version = pisi.version.make_version(pkg.version)
iversion = pisi.version.make_version(iversion_s)

pkg_release = int(pkg.release)
irelease = int(irelease_s)

# is this an upgrade?
# determine and report the kind of upgrade: version, release
if pkg_version > iversion:
ctx.ui.info(_("Upgrading to new upstream version"))
self.operation = UPGRADE
elif pkg_release > irelease:
if pkg_release > irelease:
ctx.ui.info(_("Upgrading to new distribution release"))
self.operation = UPGRADE

# is this a downgrade? confirm this action.
if not self.operation == UPGRADE:
if pkg_version < iversion:
# x = _('Downgrade to old upstream version?')
x = None
elif pkg_release < irelease:
ermo marked this conversation as resolved.
Show resolved Hide resolved
if pkg_release < irelease:
x = _("Downgrade to old distribution release?")
else:
x = None
Expand Down