Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/awelzel/warn-on-bro-pkg-meta'
Browse files Browse the repository at this point in the history
* origin/topic/awelzel/warn-on-bro-pkg-meta:
  User-visible warning when bro-pkg.meta is in use.
  • Loading branch information
awelzel committed Jun 27, 2023
2 parents 7145064 + b5e089d commit c152666
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testing/baselines/tests.install-bro-pkg-warning/stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
XXXX-XX-XX XX:XX:XX WARNING Package one/alice/foo is using the legacy bro-pkg.meta metadata file. It will soon stop working unless updated to use zkg.meta instead. Please report this to the package maintainers.
3 changes: 3 additions & 0 deletions testing/tests/install-bro-pkg-warning
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @TEST-EXEC: (cd packages/foo; git mv zkg.meta bro-pkg.meta; git commit -m 'Use bro-pkg.meta')
# @TEST-EXEC: zkg install foo 2> stderr
# @TEST-EXEC: TEST_DIFF_CANONIFIER='sed -r "s/[0-9]{2}/XX/g"' btest-diff stderr
17 changes: 17 additions & 0 deletions zeekpkg/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3303,6 +3303,9 @@ def _parse_package_metadata(parser, metadata_file):
return ""


_legacy_metadata_warnings = set()


def _info_from_clone(clone, package, status, version):
"""Retrieves information about a package.
Expand Down Expand Up @@ -3335,6 +3338,20 @@ def _info_from_clone(clone, package, status, version):
default_branch=default_branch,
)

# Remove in v3.0 by either silently ignoring LEGACY_METADATA_FILENAME
# completely or error with helpful instructions about zkg.meta.
if (
os.path.basename(metadata_file) == LEGACY_METADATA_FILENAME
and package.qualified_name() not in _legacy_metadata_warnings
):
LOG.warning(
"Package %s is using the legacy bro-pkg.meta metadata file. "
"It will soon stop working unless updated to use zkg.meta instead. "
"Please report this to the package maintainers.",
package.qualified_name(),
)
_legacy_metadata_warnings.add(package.qualified_name())

metadata = _get_package_metadata(metadata_parser)

return PackageInfo(
Expand Down

0 comments on commit c152666

Please sign in to comment.