openbsd_pkg: Use correct part of name in match. (#3151)

* openbsd_pkg: Use correct part of name in match.

Previously this part of the code could assume that the name was a stem
with nothing else attached (like "autoconf"). With the introduction of the
branch syntax ("autoconf%2.13") this is no longer true.

Check if the package name was identified as using a "branch" style name,
and base the match on the leading part of the name if that is the case.

While here remove unnecessary "pass" and tidy up debug log message.

Problem reported by @jasperla.

* openbsd_pkg: Add missing "." in comment.
This commit is contained in:
Patrik Lundin 2016-10-15 09:01:48 +02:00 committed by Matt Clay
parent 00adb6e5d4
commit 896dec44a6

View file

@ -176,11 +176,14 @@ def package_present(name, installed_state, pkg_spec, module):
# "file:/local/package/directory/ is empty" message on stderr
# while still installing the package, so we need to look for
# for a message like "packagename-1.0: ok" just in case.
match = re.search("\W%s-[^:]+: ok\W" % name, stdout)
if pkg_spec['style'] == 'branch':
match = re.search("\W%s-[^:]+: ok\W" % pkg_spec['pkgname'], stdout)
else:
match = re.search("\W%s-[^:]+: ok\W" % name, stdout)
if match:
# It turns out we were able to install the package.
module.debug("package_present(): we were able to install package")
pass
module.debug("package_present(): we were able to install the package")
else:
# We really did fail, fake the return code.
module.debug("package_present(): we really did fail")
@ -353,6 +356,10 @@ def parse_package_name(name, pkg_spec, module):
pkg_spec['style'] = 'branch'
# Key names from description in pkg_add(1).
pkg_spec['pkgname'] = pkg_spec['stem'].split('%')[0]
pkg_spec['branch'] = pkg_spec['stem'].split('%')[1]
# Sanity check that there are no trailing dashes in flavor.
# Try to stop strange stuff early so we can be strict later.
if pkg_spec['flavor']: