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

User-visible warning when bro-pkg.meta is in use. #164

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
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
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