Allow mentioning tools paths in bindep

yum/dnf package managers do allow mentioning full path to executable
instead of rpm name for installing it.

This allows users to install needed tool regardless what package name
may provide it (which may depend on what repos they have installed or
enabled).

This allows 'package' names to start with slash as this is a requirement
for triggering this feature in yum/rpm.

Practice use-case scenario: user wants docker to be installed but docker
could be installed from docker rpm or from docker-ce rpm if user added
upstream repositories. Both of them provide the same executable, but
the package manager will pick one based on its priorities.

Command line example: yum install -y /usr/bin/docker

Change-Id: I7e47ee956e9496d9f47a98f9595790797c8d1789
This commit is contained in:
Sorin Sbarnea 2019-02-07 17:10:44 +00:00
parent 1568971ca0
commit 0bc70eee07
2 changed files with 10 additions and 1 deletions

View File

@ -47,7 +47,7 @@ rule = <name>:name selector?:selector version?:version ('\n'|comment) -> (
name, selector or [], version or [])
lowercase = ('a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'|'k'|'l'|'m'|'n'|'o'|'p'
|'q'|'r'|'s'|'t'|'u'|'v'|'w'|'x'|'y'|'z')
name = letterOrDigit:start (letterOrDigit|'.'|'+'|'-'|'_'|'/')+:rest
name = (letterOrDigit|'/'):start (letterOrDigit|'.'|'+'|'-'|'_'|'/')+:rest
ws = ' '+
profile = ('!'?:neg <(lowercase|digit|':'|'-'|'.')+>:name) -> (neg!='!', name)
profiles = '(' (ws? profile)*:p ws? ')' -> p

View File

@ -448,6 +448,15 @@ class TestDepends(TestCase):
"""))
self.assertEqual(len(depends.active_rules(['default'])), 3)
def test_parser_accepts_full_path_to_tools(self):
# at least yum/dnf allow these instead of mentioning rpm names
depends = Depends(dedent("""\
/usr/bin/bash
"""))
self.assertEqual(
[("/usr/bin/bash", [], [])],
depends.active_rules(["default"]))
def test_parser_invalid(self):
self.assertRaises(ometa.runtime.ParseError,
lambda: Depends("foo [platform:bar@baz]\n"))