mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
openbsd_pkg: fix build=true corner case.
* Fix bug where we were actually checking for the availability of the requested package name and not 'sqlports' even if that was the goal. * Add check that the sqlports database file exists before using it. * Sprinkle some debug messages for an easier time following the code when developing.
This commit is contained in:
parent
f686994af6
commit
24eab14695
1 changed files with 11 additions and 2 deletions
|
@ -365,9 +365,14 @@ def get_package_source_path(name, pkg_spec, module):
|
||||||
return 'databases/sqlports'
|
return 'databases/sqlports'
|
||||||
else:
|
else:
|
||||||
# try for an exact match first
|
# try for an exact match first
|
||||||
conn = sqlite3.connect('/usr/local/share/sqlports')
|
sqlports_db_file = '/usr/local/share/sqlports'
|
||||||
|
if not os.path.isfile(sqlports_db_file):
|
||||||
|
module.fail_json(msg="sqlports file '%s' is missing" % sqlports_db_file)
|
||||||
|
|
||||||
|
conn = sqlite3.connect(sqlports_db_file)
|
||||||
first_part_of_query = 'SELECT fullpkgpath, fullpkgname FROM ports WHERE fullpkgname'
|
first_part_of_query = 'SELECT fullpkgpath, fullpkgname FROM ports WHERE fullpkgname'
|
||||||
query = first_part_of_query + ' = ?'
|
query = first_part_of_query + ' = ?'
|
||||||
|
module.debug("package_package_source_path(): query: %s" % query)
|
||||||
cursor = conn.execute(query, (name,))
|
cursor = conn.execute(query, (name,))
|
||||||
results = cursor.fetchall()
|
results = cursor.fetchall()
|
||||||
|
|
||||||
|
@ -377,11 +382,14 @@ def get_package_source_path(name, pkg_spec, module):
|
||||||
query = first_part_of_query + ' LIKE ?'
|
query = first_part_of_query + ' LIKE ?'
|
||||||
if pkg_spec['flavor']:
|
if pkg_spec['flavor']:
|
||||||
looking_for += pkg_spec['flavor_separator'] + pkg_spec['flavor']
|
looking_for += pkg_spec['flavor_separator'] + pkg_spec['flavor']
|
||||||
|
module.debug("package_package_source_path(): flavor query: %s" % query)
|
||||||
cursor = conn.execute(query, (looking_for,))
|
cursor = conn.execute(query, (looking_for,))
|
||||||
elif pkg_spec['style'] == 'versionless':
|
elif pkg_spec['style'] == 'versionless':
|
||||||
query += ' AND fullpkgname NOT LIKE ?'
|
query += ' AND fullpkgname NOT LIKE ?'
|
||||||
|
module.debug("package_package_source_path(): versionless query: %s" % query)
|
||||||
cursor = conn.execute(query, (looking_for, "%s-%%" % looking_for,))
|
cursor = conn.execute(query, (looking_for, "%s-%%" % looking_for,))
|
||||||
else:
|
else:
|
||||||
|
module.debug("package_package_source_path(): query: %s" % query)
|
||||||
cursor = conn.execute(query, (looking_for,))
|
cursor = conn.execute(query, (looking_for,))
|
||||||
results = cursor.fetchall()
|
results = cursor.fetchall()
|
||||||
|
|
||||||
|
@ -465,8 +473,9 @@ def main():
|
||||||
# build sqlports if its not installed yet
|
# build sqlports if its not installed yet
|
||||||
pkg_spec = {}
|
pkg_spec = {}
|
||||||
parse_package_name('sqlports', pkg_spec, module)
|
parse_package_name('sqlports', pkg_spec, module)
|
||||||
installed_state = get_package_state(name, pkg_spec, module)
|
installed_state = get_package_state('sqlports', pkg_spec, module)
|
||||||
if not installed_state:
|
if not installed_state:
|
||||||
|
module.debug("main(): installing sqlports")
|
||||||
package_present('sqlports', installed_state, pkg_spec, module)
|
package_present('sqlports', installed_state, pkg_spec, module)
|
||||||
|
|
||||||
if name == '*':
|
if name == '*':
|
||||||
|
|
Loading…
Reference in a new issue