├── zkg.py ├── README ├── VERSION ├── README.rst ├── doc ├── ext │ └── sphinxarg │ │ ├── __init__.py │ │ ├── README │ │ ├── LICENSE │ │ └── parser.py ├── docutils.conf ├── api │ ├── manager.rst │ ├── package.rst │ ├── source.rst │ ├── uservar.rst │ ├── template.rst │ └── index.rst ├── index.rst ├── _templates │ ├── layout.html │ └── breadcrumbs.html ├── _static │ └── theme_overrides.css ├── overview.rst ├── zkg.rst ├── source.rst └── Makefile ├── testing ├── packages │ ├── rot13 │ │ ├── CHANGES │ │ ├── VERSION │ │ ├── scripts │ │ │ ├── init.zeek │ │ │ ├── types.zeek │ │ │ ├── Demo │ │ │ │ └── Rot13 │ │ │ │ │ └── __load__.zeek │ │ │ ├── __preload__.zeek │ │ │ └── __load__.zeek │ │ ├── testing │ │ │ ├── btest.cfg │ │ │ ├── Baseline │ │ │ │ ├── tests.rot13 │ │ │ │ │ └── output │ │ │ │ └── tests.main │ │ │ │ │ └── output │ │ │ └── tests │ │ │ │ ├── main │ │ │ │ └── rot13 │ │ ├── README │ │ ├── zkg.meta │ │ ├── CMakeLists.txt │ │ ├── src │ │ │ ├── Plugin.h │ │ │ ├── Plugin.cc │ │ │ └── rot13.bif │ │ ├── configure.plugin │ │ ├── Makefile │ │ ├── COPYING.edit-me │ │ └── configure │ ├── bar │ │ ├── zkg.meta │ │ └── __load__.zeek │ ├── baz │ │ ├── zkg.meta │ │ └── __load__.zeek │ ├── foo │ │ ├── zkg.meta │ │ └── __load__.zeek │ ├── qux │ │ ├── zkg.meta │ │ └── __load__.zeek │ ├── corge │ │ ├── zkg.meta │ │ └── __load__.zeek │ ├── grault │ │ ├── zkg.meta │ │ └── __load__.zeek │ ├── quux │ │ ├── zkg.meta │ │ └── __load__.zeek │ └── i-have-no-scripts │ │ └── zkg.meta ├── sources │ ├── two │ │ └── eve │ │ │ └── zkg.index │ └── one │ │ ├── bob │ │ └── zkg.index │ │ └── alice │ │ └── zkg.index ├── templates │ └── foo │ │ ├── readme │ │ ├── README │ │ └── README.md │ │ ├── package │ │ ├── scripts │ │ │ ├── __load__.zeek │ │ │ └── main.zeek │ │ └── zkg.meta │ │ └── __init__.py ├── .gitignore ├── tests │ ├── create │ ├── install-bro-pkg-warning │ ├── remove │ ├── builtin-pin │ ├── uninstall │ ├── builtin-info │ ├── builtin-test │ ├── builtin-remove │ ├── builtin-unload │ ├── builtin-unpin │ ├── builtin-install │ ├── unsatisfied-version-tag-dependency │ ├── metadata-script_dir │ ├── builtin-list │ ├── install-reserved │ ├── metadata-aliases │ ├── install-extra │ ├── branch-based-dependency │ ├── template-info │ ├── purge │ ├── aliases-bad │ ├── plugin_tarfile │ ├── load-zeek-dependency │ ├── package_base │ ├── load │ ├── search-config │ ├── builtin-spicy │ ├── builtin-spicy-version │ ├── install-force-build-fail │ ├── validate-manifest │ ├── bundled-zkg │ ├── builtin-spicy-version-error │ ├── bindir-install │ ├── bindir-relocate │ ├── installed-dependency-conflict │ ├── package-submodule │ ├── test │ ├── install-force-test-fail │ ├── install-on-tty │ ├── info-submodules │ ├── list │ ├── builtin-spicy-bundle │ ├── search-extra │ ├── install-invalid │ ├── bundle-missing-dependency │ ├── plugin │ ├── aliases-conflict │ ├── user_vars │ ├── bundle-unsatisfied-dependency │ ├── upgrade-test-fail │ ├── upgrade │ ├── info │ ├── metadata-config_files │ ├── dependency-management │ ├── user-mode │ ├── pin │ ├── metadata-depends │ ├── bundle │ ├── metadata-suggests │ ├── template-create │ ├── install │ ├── refresh │ └── dependency-ordering ├── baselines │ ├── tests.list │ │ ├── after_upgrade.out │ │ ├── loaded.out │ │ ├── outdated.out │ │ ├── unloaded.out │ │ ├── installed.out │ │ ├── not_installed.out │ │ └── all.out │ ├── tests.builtin-spicy │ │ ├── output │ │ └── package.log │ ├── tests.load-zeek-dependency │ │ ├── nothing-loaded.out │ │ └── foo-loaded.out │ ├── tests.install │ │ ├── grault.1.0.1 │ │ ├── grault.detached │ │ ├── grault.info │ │ ├── grault.detached.head │ │ ├── corge.master │ │ ├── scripts.packages.baz.__load__.zeek │ │ ├── scripts.packages.corge.__load__.zeek │ │ ├── scripts.packages.foo.__load__.zeek │ │ ├── scripts.packages.qux.__load__.zeek │ │ ├── scripts.packages.grault.__load__.zeek │ │ └── scripts.packages.bar.__load__.zeek │ ├── tests.pin │ │ ├── bar_after_unpin.out │ │ ├── foo_after_unpin.out │ │ ├── scripts.packages.foo.__load__.zeek │ │ └── scripts.packages.bar.__load__.zeek │ ├── tests.bindir-install │ │ └── output │ ├── tests.bindir-relocate │ │ └── output │ ├── tests.bundle-missing-dependency │ │ ├── package.log │ │ ├── output │ │ └── .stderr │ ├── tests.bundle-unsatisfied-dependency │ │ ├── package.log │ │ ├── output │ │ └── .stderr │ ├── tests.metadata-config_files │ │ ├── bar_backup.zeek │ │ ├── barconfig2.zeek │ │ ├── foo_backup.zeek │ │ ├── scripts.bar.config.zeek │ │ └── scripts.foo.config.zeek │ ├── tests.refresh │ │ ├── outdated.out │ │ ├── search.out │ │ ├── list.out │ │ ├── list_after_agg.out │ │ ├── agg.fail.out │ │ ├── agg.out │ │ ├── agg.fail.errout │ │ └── agg.errout │ ├── tests.builtin-list │ │ └── out │ ├── tests.builtin-pin │ │ └── out │ ├── tests.upgrade │ │ ├── scripts.packages.foo.__load__.zeek │ │ └── scripts.packages.bar.__load__.zeek │ ├── tests.builtin-remove │ │ └── out │ ├── tests.builtin-unload │ │ └── out │ ├── tests.builtin-unpin │ │ └── out │ ├── tests.metadata-aliases │ │ ├── scripts.foo.__load__.zeek │ │ ├── scripts.foo2.__load__.zeek │ │ └── scripts.foo3.__load__.zeek │ ├── tests.metadata-depends │ │ ├── no_depends.out │ │ ├── bundle_depends.out │ │ ├── install_depends.out │ │ └── upgrade_depends.out │ ├── tests.metadata-script_dir │ │ └── scripts.foo.__load__.zeek │ ├── tests.metadata-suggests │ │ ├── no_suggests.out │ │ ├── bundle_suggests.out │ │ ├── install_suggests.out │ │ └── upgrade_suggests.out │ ├── tests.builtin-install │ │ └── out │ ├── tests.builtin-test │ │ └── out │ ├── tests.package-submodule │ │ ├── foo.install │ │ └── foo.upgrade │ ├── tests.user_vars │ │ ├── state.testing.foo.clones.test.log │ │ ├── state.logs.foo-build.log1 │ │ └── state.logs.foo-build.log2 │ ├── tests.aliases-bad-2 │ │ └── .stderr │ ├── tests.aliases-bad-3 │ │ └── .stderr │ ├── tests.bundled-zkg │ │ └── output │ ├── tests.template-create │ │ ├── out3.README │ │ ├── out3.scripts.main.zeek │ │ ├── out3.zkg.meta │ │ ├── out4.zkg.meta │ │ └── output │ ├── tests.builtin-spicy-version │ │ ├── package.log │ │ └── output │ ├── tests.package_base │ │ ├── state.logs.foo-build.log │ │ └── state.testing.foo.clones.test.log │ ├── tests.validate-manifest │ │ └── packages.txt │ ├── tests.install-reserved │ │ └── output │ ├── tests.aliases-bad │ │ └── .stderr │ ├── tests.builtin-spicy-bundle │ │ ├── package.log │ │ ├── .stderr │ │ ├── bundle.manifest.txt │ │ └── output │ ├── tests.branch-based-dependency │ │ └── installed.out │ ├── tests.installed-dependency-conflict │ │ ├── installed-final.out │ │ ├── installed-initial.out │ │ └── conflict.out │ ├── tests.purge │ │ └── scripts.packages.packages.zeek │ ├── tests.bundle │ │ ├── args.out │ │ ├── manifest.out │ │ └── snapshot.out │ ├── tests.load │ │ ├── after_unload.out │ │ ├── after_load.out │ │ ├── after_loading_no_scripts.out │ │ └── scripts.packages.packages.zeek │ ├── tests.aliases-conflict │ │ ├── packages.zeek.1 │ │ ├── packages.zeek.2 │ │ └── out │ ├── tests.remove │ │ └── scripts.packages.packages.zeek │ ├── tests.uninstall │ │ └── scripts.packages.packages.zeek │ ├── tests.unsatisfied-version-tag-dependency │ │ └── fail.out │ ├── tests.builtin-spicy-version-error │ │ └── output │ ├── tests.dependency-ordering │ │ └── build.log │ ├── tests.info-submodules │ │ └── clonetest.info │ ├── tests.plugin │ │ └── scripts.packages.rot13.__load__.zeek │ ├── tests.install-bro-pkg-warning │ │ └── stderr │ ├── tests.plugin_tarfile │ │ └── scripts.packages.rot13.__load__.zeek │ ├── tests.install-force-build-fail │ │ └── out │ ├── tests.template-info │ │ ├── output.plain │ │ ├── output.json │ │ └── output.git │ ├── tests.info │ │ ├── foo.info │ │ ├── installed.info │ │ └── bar.info │ ├── tests.install-force-test-fail │ │ └── out │ ├── tests.builtin-info │ │ └── out │ ├── tests.upgrade-test-fail │ │ └── out │ ├── tests.install-invalid │ │ └── output │ ├── tests.dependency-management │ │ └── out │ └── tests.user-mode │ │ └── output ├── scripts │ ├── diff-remove-cwd │ ├── diff-remove-zkg-version │ ├── diff-remove-abspath │ ├── diff-canonifier │ ├── diff-remove-zkg-meta-commit │ ├── diff-remove-timestamps │ ├── git │ ├── zkg │ ├── zkg-zeek │ ├── setup-zeek-and-home │ └── initializer ├── Makefile └── btest.cfg ├── .gitignore ├── .git-blame-ignore-revs ├── setup.py ├── .github └── workflows │ ├── pre-commit.yml │ └── test.yml ├── requirements.txt ├── .update-changes.cfg ├── .readthedocs.yaml ├── zeekpkg ├── __init__.py ├── source.py └── uservar.py ├── Makefile ├── .pre-commit-config.yaml ├── CMakeLists.txt ├── pyproject.toml ├── COPYING └── zkg.config /zkg.py: -------------------------------------------------------------------------------- 1 | zkg -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | doc/overview.rst -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 3.1.0-13 2 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | doc/overview.rst -------------------------------------------------------------------------------- /doc/ext/sphinxarg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testing/packages/rot13/CHANGES: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testing/packages/rot13/VERSION: -------------------------------------------------------------------------------- 1 | 0.1 2 | -------------------------------------------------------------------------------- /testing/packages/bar/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | -------------------------------------------------------------------------------- /testing/packages/baz/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | -------------------------------------------------------------------------------- /testing/packages/foo/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | -------------------------------------------------------------------------------- /testing/packages/qux/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | -------------------------------------------------------------------------------- /testing/packages/rot13/scripts/init.zeek: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testing/packages/rot13/scripts/types.zeek: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testing/packages/rot13/testing/btest.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /testing/sources/two/eve/zkg.index: -------------------------------------------------------------------------------- 1 | quux 2 | -------------------------------------------------------------------------------- /testing/packages/corge/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | -------------------------------------------------------------------------------- /testing/packages/grault/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | -------------------------------------------------------------------------------- /testing/packages/quux/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | -------------------------------------------------------------------------------- /testing/templates/foo/readme/README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /doc/docutils.conf: -------------------------------------------------------------------------------- 1 | [parsers] 2 | smart_quotes: no 3 | -------------------------------------------------------------------------------- /testing/packages/baz/__load__.zeek: -------------------------------------------------------------------------------- 1 | print "baz loaded"; 2 | -------------------------------------------------------------------------------- /testing/packages/foo/__load__.zeek: -------------------------------------------------------------------------------- 1 | print "foo loaded"; 2 | -------------------------------------------------------------------------------- /testing/packages/qux/__load__.zeek: -------------------------------------------------------------------------------- 1 | print "qux loaded"; 2 | -------------------------------------------------------------------------------- /testing/sources/one/bob/zkg.index: -------------------------------------------------------------------------------- 1 | corge 2 | grault 3 | -------------------------------------------------------------------------------- /testing/.gitignore: -------------------------------------------------------------------------------- 1 | diag.log 2 | .btest.failed.dat 3 | .tmp 4 | -------------------------------------------------------------------------------- /testing/packages/corge/__load__.zeek: -------------------------------------------------------------------------------- 1 | print "corge loaded"; 2 | -------------------------------------------------------------------------------- /testing/packages/quux/__load__.zeek: -------------------------------------------------------------------------------- 1 | print "quux loaded"; 2 | -------------------------------------------------------------------------------- /testing/packages/grault/__load__.zeek: -------------------------------------------------------------------------------- 1 | print "grault loaded"; 2 | -------------------------------------------------------------------------------- /testing/templates/foo/package/scripts/__load__.zeek: -------------------------------------------------------------------------------- 1 | @load ./main 2 | -------------------------------------------------------------------------------- /testing/packages/i-have-no-scripts/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | plugin_dir = . 3 | -------------------------------------------------------------------------------- /testing/packages/bar/__load__.zeek: -------------------------------------------------------------------------------- 1 | event zeek_init() { print "bar loaded"; } 2 | -------------------------------------------------------------------------------- /testing/templates/foo/readme/README.md: -------------------------------------------------------------------------------- 1 | This is the @NAME@ package. 2 | @README@ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.egg-info 3 | *.swp 4 | .state 5 | doc/_build 6 | build 7 | dist 8 | -------------------------------------------------------------------------------- /testing/sources/one/alice/zkg.index: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | qux 5 | i-have-no-scripts 6 | -------------------------------------------------------------------------------- /testing/packages/rot13/testing/Baseline/tests.rot13/output: -------------------------------------------------------------------------------- 1 | Uryyb 2 | rot13 plugin is loaded 3 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Migrate code style to Black 2 | 99520f9201340d57d2cc9cf6f45992b994eff7c4 3 | -------------------------------------------------------------------------------- /testing/packages/rot13/testing/Baseline/tests.main/output: -------------------------------------------------------------------------------- 1 | rot13 plugin is loaded 2 | rot13 script is loaded 3 | -------------------------------------------------------------------------------- /testing/packages/rot13/README: -------------------------------------------------------------------------------- 1 | 2 | Demo::Rot13 3 | ================================= 4 | 5 | 6 | -------------------------------------------------------------------------------- /testing/templates/foo/package/scripts/main.zeek: -------------------------------------------------------------------------------- 1 | module @MODULE@; 2 | 3 | event zeek_init() 4 | { 5 | print "Hello world!"; 6 | } 7 | -------------------------------------------------------------------------------- /testing/tests/create: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Test creating a default package. 2 | # 3 | # @TEST-EXEC: echo name | zkg create --packagedir packagedir 4 | -------------------------------------------------------------------------------- /testing/packages/rot13/testing/tests/main: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zeek rot13 > output 2 | # @TEST-EXEC: TEST_DIFF_CANONIFIER="sort -s" btest-diff output 3 | -------------------------------------------------------------------------------- /testing/packages/rot13/testing/tests/rot13: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zeek %INPUT > output 2 | # @TEST-EXEC: btest-diff output 3 | 4 | print Demo::rot13("Hello"); 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.list/after_upgrade.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | -------------------------------------------------------------------------------- /testing/scripts/diff-remove-cwd: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Replace occurrences of the current working directory with "<...>" 4 | 5 | sed "s#$(pwd)#<...>#g" 6 | -------------------------------------------------------------------------------- /testing/packages/rot13/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | script_dir = scripts/Demo/Rot13 3 | build_command = ./configure && make 4 | test_command = cd testing && btest -d tests 5 | -------------------------------------------------------------------------------- /doc/api/manager.rst: -------------------------------------------------------------------------------- 1 | zeekpkg.manager module 2 | ====================== 3 | 4 | .. automodule:: zeekpkg.manager 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /doc/api/package.rst: -------------------------------------------------------------------------------- 1 | zeekpkg.package module 2 | ====================== 3 | 4 | .. automodule:: zeekpkg.package 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /doc/api/source.rst: -------------------------------------------------------------------------------- 1 | zeekpkg.source module 2 | ===================== 3 | 4 | .. automodule:: zeekpkg.source 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /doc/api/uservar.rst: -------------------------------------------------------------------------------- 1 | zeekpkg.uservar module 2 | ====================== 3 | 4 | .. automodule:: zeekpkg.uservar 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy/output: -------------------------------------------------------------------------------- 1 | Running unit tests for "one/alice/foo" 2 | Installing "one/alice/foo" 3 | Installed "one/alice/foo" (main) 4 | Loaded "one/alice/foo" 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.load-zeek-dependency/nothing-loaded.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | -------------------------------------------------------------------------------- /doc/api/template.rst: -------------------------------------------------------------------------------- 1 | zeekpkg.template module 2 | ======================= 3 | 4 | .. automodule:: zeekpkg.template 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/grault.1.0.1: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "grault 1.0.1"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/grault.detached: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "grault 1.0.2"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/grault.info: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | tracking_method = commit 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.pin/bar_after_unpin.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "bar++ loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.pin/foo_after_unpin.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo 1.0.4"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.bindir-install/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | from exec1 3 | from exec2 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.bindir-relocate/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | from exec1 3 | from exec2 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle-missing-dependency/package.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Building foo 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/grault.detached.head: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "grault 1.0.0"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.list/loaded.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/foo (installed: main) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.list/outdated.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/foo (installed: main) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.list/unloaded.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: master) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle-unsatisfied-dependency/package.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Building foo 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-config_files/bar_backup.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "bar mod"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-config_files/barconfig2.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "bar 2.0.0"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-config_files/foo_backup.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo mod"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/outdated.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/foo (installed: main) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-list/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | zeek-builtin/spicy-plugin (installed: X.X.X) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-pin/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | cannot pin "spicy-plugin": built-in package 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/corge.master: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "corge loaded"; 3 | print "hello"; 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.pin/scripts.packages.foo.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo 1.0.2"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.upgrade/scripts.packages.foo.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo 1.0.4"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-remove/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | cannot remove "spicy-plugin": built-in package 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-unload/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | cannot unload "spicy-plugin": built-in package 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-unpin/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | cannot unpin "spicy-plugin": built-in package 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/scripts.packages.baz.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "baz loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/scripts.packages.corge.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "corge loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/scripts.packages.foo.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/scripts.packages.qux.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "qux loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-aliases/scripts.foo.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-aliases/scripts.foo2.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-aliases/scripts.foo3.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-config_files/scripts.bar.config.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "bar mod"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-config_files/scripts.foo.config.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo new"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-depends/no_depends.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/foo (installed: main) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-script_dir/scripts.foo.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "foo loaded"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-suggests/no_suggests.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/foo (installed: main) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.upgrade/scripts.packages.bar.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "bar++ loaded"; 3 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | .. include:: overview.rst 2 | 3 | .. toctree:: 4 | :hidden: 5 | :numbered: 6 | 7 | quickstart 8 | zkg 9 | package 10 | source 11 | api/index 12 | developers 13 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-install/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | cannot install "spicy-plugin": built-in package 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy/package.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Building foo 3 | Testing foo 4 | Building foo 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-test/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | cannot run tests for "spicy-plugin": built-in package 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/scripts.packages.grault.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | print "grault 1.0.2"; 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.load-zeek-dependency/foo-loaded.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/foo (installed: main) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.package-submodule/foo.install: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | event zeek_init() { print "bar loaded"; } 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.user_vars/state.testing.foo.clones.test.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Initial description is here 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.aliases-bad-2/.stderr: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: invalid package "foo": invalid alias ".hidden" 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.aliases-bad-3/.stderr: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: invalid package "foo": invalid alias "/aaa" 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundled-zkg/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | /tests.bundled-zkg/install-dir/bin/zkg 3 | zkg xxx 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.template-create/out3.README: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | This is the test3 package. 3 | This is a README. 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy-version/package.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Building foo 3 | Testing foo 4 | Building foo 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.package_base/state.logs.foo-build.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | === STDERR === 3 | === STDOUT === 4 | foo 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.package_base/state.testing.foo.clones.test.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | <...>/state/testing/foo/clones 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.pin/scripts.packages.bar.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | event zeek_init() { print "bar loaded"; } 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.install/scripts.packages.bar.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | event zeek_init() { print "bar loaded"; } 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.package-submodule/foo.upgrade: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | event zeek_init() { print "bar upgrade is loaded"; } 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.validate-manifest/packages.txt: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | 0 alice foo one 3 | 1 alice bar one 4 | 2 alice baz one 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.install-reserved/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: invalid package ".": Package name 'packages' is not valid. 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.list/installed.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: master) 3 | one/alice/foo (installed: main) 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.aliases-bad/.stderr: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: invalid package "foo": invalid alias "../../../../../../../../bad" 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy-bundle/package.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Building foo 3 | Testing foo 4 | Building foo 5 | Building foo 6 | -------------------------------------------------------------------------------- /testing/templates/foo/package/zkg.meta: -------------------------------------------------------------------------------- 1 | [package] 2 | script_dir = scripts 3 | summary = TODO: A summary of @NAME@ in one line 4 | description = TODO: A more detailed description of @NAME@. 5 | It can span multiple lines, with this indentation. 6 | -------------------------------------------------------------------------------- /testing/scripts/diff-remove-zkg-version: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Suppress lines including our zkg version, based on the VERSION file 4 | # at the toplevel of the source tree. 5 | 6 | ver=$(cat $TEST_BASE/../VERSION) 7 | grep -v "$ver" 8 | exit 0 9 | -------------------------------------------------------------------------------- /testing/baselines/tests.user_vars/state.logs.foo-build.log1: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | === STDERR === 3 | === STDOUT === 4 | /home/jon/sandbox 5 | /usr/local 6 | /usr 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.branch-based-dependency/installed.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: release/1.0) 3 | one/alice/foo (installed: release/1.0) 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle-missing-dependency/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Loaded "/one/alice/foo" 3 | Unbundling complete. 4 | /one/alice/foo (installed: main) 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.installed-dependency-conflict/installed-final.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/foo (installed: 1.0.0) 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.installed-dependency-conflict/installed-initial.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/foo (installed: 1.0.0) 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.purge/scripts.packages.packages.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.template-create/out3.scripts.main.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | module TEST3; 3 | 4 | event zeek_init() 5 | { 6 | print "Hello world!"; 7 | } 8 | -------------------------------------------------------------------------------- /testing/tests/install-bro-pkg-warning: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: (cd packages/foo; git mv zkg.meta bro-pkg.meta; git commit -m 'Use bro-pkg.meta') 2 | # @TEST-EXEC: zkg install foo 2> stderr 3 | # @TEST-EXEC: TEST_DIFF_CANONIFIER='sed -r "s/[0-9]{2}/XX/g"' btest-diff stderr 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle-unsatisfied-dependency/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Loaded "/one/alice/foo" 3 | Unbundling complete. 4 | /one/alice/foo (installed: main) 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle/args.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.2) 3 | one/alice/baz (installed: master) 4 | one/alice/foo (installed: 1.0.2) 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.list/not_installed.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/baz 3 | one/alice/i-have-no-scripts 4 | one/alice/qux 5 | one/bob/corge 6 | one/bob/grault 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.load/after_unload.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./bar 5 | -------------------------------------------------------------------------------- /testing/packages/rot13/scripts/Demo/Rot13/__load__.zeek: -------------------------------------------------------------------------------- 1 | # 2 | # This is loaded when a user activates the plugin. Include scripts here that should be 3 | # loaded automatically at that point. 4 | # 5 | 6 | 7 | 8 | event zeek_init() { print "rot13 script is loaded"; } 9 | -------------------------------------------------------------------------------- /testing/tests/remove: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo bar baz 2 | # @TEST-EXEC: test -f scripts/packages/foo/__load__.zeek 3 | 4 | # @TEST-EXEC: zkg remove foo 5 | # @TEST-EXEC: test ! -d scripts/packages/foo 6 | # @TEST-EXEC: btest-diff scripts/packages/packages.zeek 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle/manifest.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.1) 3 | one/alice/baz (installed: master) 4 | one/alice/foo (installed: 1.0.0) 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle/snapshot.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/baz (installed: master) 4 | one/alice/foo (installed: 1.0.2) 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.aliases-conflict/packages.zeek.1: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./foo 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy-bundle/.stderr: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Switched to a new branch 'main' 3 | Switched to a new branch 'drop-corge' 4 | Switched to branch 'master' 5 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy-bundle/bundle.manifest.txt: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | [bundle] 3 | <...>/foo = main 4 | 5 | [meta] 6 | builtin_packages = spicy-plugin=X.X.X 7 | 8 | -------------------------------------------------------------------------------- /testing/baselines/tests.load/after_load.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./bar 5 | @load ./foo 6 | -------------------------------------------------------------------------------- /testing/baselines/tests.user_vars/state.logs.foo-build.log2: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | === STDERR === 3 | === STDOUT === 4 | /home/jon/sandbox2 5 | /usr/local 6 | Initial description is here 7 | -------------------------------------------------------------------------------- /testing/tests/builtin-pin: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure that pinning spicy-plugin fails if it's built-in (default for 6.0) 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC-FAIL: zkg pin spicy-plugin >out 2>&1 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/tests/uninstall: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo bar baz 2 | # @TEST-EXEC: test -f scripts/packages/foo/__load__.zeek 3 | 4 | # @TEST-EXEC: zkg uninstall --force foo 5 | # @TEST-EXEC: test ! -d scripts/packages/foo 6 | # @TEST-EXEC: btest-diff scripts/packages/packages.zeek 7 | -------------------------------------------------------------------------------- /doc/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | 3 | {% if READTHEDOCS and current_version %} 4 | {% if current_version == "latest" or current_version == "stable" %} 5 | {% set current_version = current_version ~ " (" ~ version ~ ")" %} 6 | {% endif %} 7 | {% endif %} 8 | -------------------------------------------------------------------------------- /testing/tests/builtin-info: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Using info on a built-in package works 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC: zkg info spicy-plugin | sed -E 's/[0-9]+\.[0-9]+\.[0-9]+/X.X.X/g' >out 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/tests/builtin-test: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure that testing spicy-plugin fails if it's built-in (default for 6.0) 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC-FAIL: zkg test spicy-plugin >out 2>&1 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.aliases-conflict/packages.zeek.2: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./baz 5 | @load ./corge 6 | -------------------------------------------------------------------------------- /testing/baselines/tests.list/all.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar 3 | one/alice/baz 4 | one/alice/foo 5 | one/alice/i-have-no-scripts 6 | one/alice/qux 7 | one/bob/corge 8 | one/bob/grault 9 | -------------------------------------------------------------------------------- /testing/baselines/tests.load/after_loading_no_scripts.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./bar 5 | @load ./foo 6 | -------------------------------------------------------------------------------- /testing/tests/builtin-remove: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure that removing spicy-plugin fails if it's built-in (default for 6.0) 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC-FAIL: zkg remove spicy-plugin >out 2>&1 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/tests/builtin-unload: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure that unloading spicy-plugin fails if it's built-in (default for 6.0) 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC-FAIL: zkg unload spicy-plugin >out 2>&1 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/tests/builtin-unpin: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure that unpinning spicy-plugin fails if it's built-in (default for 6.0) 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC-FAIL: zkg unpin spicy-plugin >out 2>&1 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.load/scripts.packages.packages.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./bar 5 | @load ./foo 6 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/search.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/foo (installed: main) - This is the foo package description 3 | one/alice/new_pkg - This is the new_pkg package description 4 | -------------------------------------------------------------------------------- /testing/baselines/tests.remove/scripts.packages.packages.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./bar 5 | @load ./baz 6 | -------------------------------------------------------------------------------- /testing/tests/builtin-install: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure that installing spicy-plugin fails if it's built-in (default for 6.0) 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC-FAIL: zkg install spicy-plugin >out 2>&1 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/tests/unsatisfied-version-tag-dependency: -------------------------------------------------------------------------------- 1 | 2 | # @TEST-EXEC: bash %INPUT 3 | 4 | # @TEST-EXEC-FAIL: zkg install foo >fail.out 2>&1 5 | # @TEST-EXEC: btest-diff fail.out 6 | 7 | cd packages/foo 8 | echo 'depends = bar =1.0.0' >> zkg.meta 9 | git commit -am 'depend on bar 1.0.0' 10 | -------------------------------------------------------------------------------- /testing/baselines/tests.uninstall/scripts.packages.packages.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # WARNING: This file is managed by zkg. 3 | # Do not make direct modifications here. 4 | @load ./bar 5 | @load ./baz 6 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy-version/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Running unit tests for "one/alice/foo" 3 | Installing "one/alice/foo" 4 | Installed "one/alice/foo" (main) 5 | Loaded "one/alice/foo" 6 | -------------------------------------------------------------------------------- /testing/scripts/diff-remove-abspath: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Replace absolute paths with the basename. 4 | 5 | if [ `uname` == "Linux" ]; then 6 | sed="sed -r" 7 | else 8 | sed="sed -E" 9 | fi 10 | 11 | $sed 's#/+#/#g' | \ 12 | $sed 's#/([^ :/]{1,}/){1,}([^ :/]{1,})#<...>/\2#g' 13 | -------------------------------------------------------------------------------- /doc/ext/sphinxarg/README: -------------------------------------------------------------------------------- 1 | Modified version of sphinx-argparse 0.1.15: 2 | 3 | https://github.com/ribozz/sphinx-argparse 4 | 5 | Added Sphinx extension hooks to check for whether the python module 6 | associated with an argparse directive is outdated and so the .rst file 7 | it is used in needs to be re-read. 8 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | from setuptools import setup 4 | 5 | 6 | def version() -> str: 7 | return pathlib.Path("VERSION").read_text().replace("-", ".dev", 1).strip() 8 | 9 | 10 | setup( 11 | version=version(), 12 | data_files=[ 13 | ("output_dir", ["VERSION"]), 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /testing/tests/metadata-script_dir: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash %INPUT 2 | # @TEST-EXEC: zkg install foo 3 | # @TEST-EXEC: btest-diff scripts/foo/__load__.zeek 4 | 5 | cd packages/foo 6 | mkdir scripts 7 | echo 'script_dir = scripts' >> zkg.meta 8 | mv __load__.zeek scripts/ 9 | git add * 10 | git commit -m 'new stuff' 11 | -------------------------------------------------------------------------------- /testing/baselines/tests.unsatisfied-version-tag-dependency/fail.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: failed to resolve dependencies: "one/alice/bar" has no version satisfying dependencies: 3 | "one/alice/foo" requires: "=1.0.0" 4 | 5 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | name: pre-commit 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: [master] 7 | 8 | jobs: 9 | pre-commit: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: actions/setup-python@v4 14 | - uses: pre-commit/action@v3.0.0 15 | -------------------------------------------------------------------------------- /testing/scripts/diff-canonifier: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Default canonifier that combines several others. 4 | 5 | DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" 6 | 7 | $DIR/diff-remove-timestamps \ 8 | | $DIR/diff-remove-zkg-version \ 9 | | $DIR/diff-remove-abspath 10 | 11 | exit 0 12 | -------------------------------------------------------------------------------- /doc/api/index.rst: -------------------------------------------------------------------------------- 1 | Python API Reference 2 | ==================== 3 | 4 | .. automodule:: zeekpkg 5 | 6 | The following Python modules are all provided as part of the ``zeekpkg`` 7 | public interface: 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | manager 13 | package 14 | source 15 | template 16 | uservar 17 | -------------------------------------------------------------------------------- /testing/packages/rot13/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.15) 3 | 4 | project(Plugin) 5 | 6 | include(ZeekPlugin) 7 | 8 | zeek_plugin_begin(Demo Rot13) 9 | zeek_plugin_cc(src/Plugin.cc) 10 | zeek_plugin_bif(src/rot13.bif) 11 | zeek_plugin_dist_files(README CHANGES COPYING VERSION) 12 | zeek_plugin_end() 13 | -------------------------------------------------------------------------------- /testing/tests/builtin-list: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Listing packages with --include-builtin shows built-in packages. 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC: zkg list --include-builtin | grep spicy-plugin | sed -E 's/[0-9]+\.[0-9]+\.[0-9]+/X.X.X/g' >out 6 | # @TEST-EXEC: btest-diff out 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.installed-dependency-conflict/conflict.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: failed to resolve dependencies: unsatisfiable dependency: "one/alice/bar" (1.0.0) is installed, but "one/alice/foo" requires =2.0.0 (1.0.0 not in =2.0.0) 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy-version-error/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: failed to resolve dependencies: unsatisfiable dependency: "zeek-builtin/spicy-plugin" (X.X.X) is installed, but "one/alice/foo" requires output 3 | # @TEST-EXEC: btest-diff output 4 | 5 | CONFIG=$(pwd)/config 6 | mkdir -p reserved 7 | cp -R ./packages/bar ./reserved/packages 8 | 9 | cd ./reserved/packages && zkg --config=$CONFIG install --force . 10 | -------------------------------------------------------------------------------- /testing/scripts/diff-remove-zkg-meta-commit: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Suppress the SHA commit string in a zkg.meta's template.commit line. 4 | 5 | # Get us "modern" regexps with sed. 6 | if [ `uname` == "Linux" ]; then 7 | sed="sed -r" 8 | else 9 | sed="sed -E" 10 | fi 11 | 12 | $sed -e 's/commit = [0-9a-z]{8}/commit = xxxxxxxx/' 13 | -------------------------------------------------------------------------------- /testing/baselines/tests.dependency-ordering/build.log: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | building grault 3 | building corge 4 | building baz 5 | building bar 6 | building foo 7 | building grault 8 | building corge 9 | building baz 10 | building bar 11 | building foo 12 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-depends/bundle_depends.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/baz (installed: 2.0.0) 4 | one/alice/foo (installed: main) 5 | one/bob/corge (installed: 1.0.1) 6 | one/bob/grault (installed: master) 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-depends/install_depends.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/baz (installed: 2.0.0) 4 | one/alice/foo (installed: main) 5 | one/bob/corge (installed: 1.0.1) 6 | one/bob/grault (installed: master) 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-depends/upgrade_depends.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/baz (installed: 2.0.0) 4 | one/alice/foo (installed: main) 5 | one/bob/corge (installed: 1.0.1) 6 | one/bob/grault (installed: master) 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-suggests/bundle_suggests.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/baz (installed: 2.0.0) 4 | one/alice/foo (installed: main) 5 | one/bob/corge (installed: 1.0.1) 6 | one/bob/grault (installed: master) 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-suggests/install_suggests.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/baz (installed: 2.0.0) 4 | one/alice/foo (installed: main) 5 | one/bob/corge (installed: 1.0.1) 6 | one/bob/grault (installed: master) 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.metadata-suggests/upgrade_suggests.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bar (installed: 1.0.0) 3 | one/alice/baz (installed: 2.0.0) 4 | one/alice/foo (installed: main) 5 | one/bob/corge (installed: 1.0.1) 6 | one/bob/grault (installed: master) 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/list.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bad_pkg 3 | one/alice/bar 4 | one/alice/baz 5 | one/alice/foo (installed: main) 6 | one/alice/i-have-no-scripts 7 | one/alice/new_pkg 8 | one/alice/qux 9 | one/bob/corge 10 | one/bob/grault 11 | -------------------------------------------------------------------------------- /testing/tests/metadata-aliases: -------------------------------------------------------------------------------- 1 | 2 | # @TEST-EXEC: bash %INPUT 3 | # @TEST-EXEC: zkg install foo 4 | # @TEST-EXEC: btest-diff scripts/foo/__load__.zeek 5 | # @TEST-EXEC: btest-diff scripts/foo2/__load__.zeek 6 | # @TEST-EXEC: btest-diff scripts/foo3/__load__.zeek 7 | 8 | cd packages/foo 9 | echo 'aliases = foo foo2 foo3' >> zkg.meta 10 | git commit -am 'new stuff' 11 | -------------------------------------------------------------------------------- /testing/packages/rot13/src/Plugin.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace plugin { 7 | namespace Demo_Rot13 { 8 | 9 | class Plugin : public zeek::plugin::Plugin 10 | { 11 | protected: 12 | // Overridden from plugin::Plugin. 13 | virtual zeek::plugin::Configuration Configure(); 14 | }; 15 | 16 | extern Plugin plugin; 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-spicy-bundle/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Running unit tests for "one/alice/foo" 3 | Installing "one/alice/foo" 4 | Installed "one/alice/foo" (main) 5 | Loaded "one/alice/foo" 6 | Bundle successfully written: bundle.tar 7 | Loaded "one/alice/foo" 8 | Unbundling complete. 9 | -------------------------------------------------------------------------------- /testing/baselines/tests.info-submodules/clonetest.info: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | "<...>/clonetest" info: 3 | url: <...>/clonetest 4 | versions: [] 5 | metadata (from version "master"): 6 | build_command = ./configure && make 7 | description = Zeek package with a broken submodule for testing 'zkg info' 8 | 9 | -------------------------------------------------------------------------------- /testing/baselines/tests.plugin/scripts.packages.rot13.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # 3 | # This is loaded when a user activates the plugin. Include scripts here that should be 4 | # loaded automatically at that point. 5 | # 6 | 7 | 8 | 9 | event zeek_init() { print "rot13 script is loaded"; } 10 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle-missing-dependency/.stderr: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Switched to a new branch 'main' 3 | Switched to a new branch 'drop-corge' 4 | Switched to branch 'master' 5 | Switched to a new branch 'origin/main' 6 | XXXX-XX-XX XX:XX:XX WARNING dependency "zkg-test-plugin" of bundled "<...>/foo" missing 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.install-bro-pkg-warning/stderr: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | XXXX-XX-XX XX:XX:XX WARNING Package one/alice/foo is using the legacy bro-pkg.meta metadata file. While bro-pkg.meta still functions, it is recommended to use zkg.meta instead for future-proofing. Please report this to the package maintainers. 3 | -------------------------------------------------------------------------------- /testing/baselines/tests.plugin_tarfile/scripts.packages.rot13.__load__.zeek: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | # 3 | # This is loaded when a user activates the plugin. Include scripts here that should be 4 | # loaded automatically at that point. 5 | # 6 | 7 | 8 | 9 | event zeek_init() { print "rot13 script is loaded"; } 10 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # NOTE: Dependencies should go into `pyproject.toml`. We keep this file to e.g., support RTD. 2 | 3 | # Requirements for general zkg usage 4 | GitPython>=3.1.43 5 | semantic_version>=2.10.0 6 | # Technically not a zkg dependency, but typically expected by users to be present. 7 | btest>=1.1 8 | # Requirements for development (e.g. building docs) 9 | Sphinx>=7.2.6 10 | sphinx_rtd_theme>=2.0.0 11 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/list_after_agg.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | one/alice/bad_pkg 3 | one/alice/bar 4 | one/alice/baz 5 | one/alice/foo (installed: main) 6 | one/alice/i-have-no-scripts 7 | one/alice/new_pkg - This is the new_pkg package description 8 | one/alice/qux 9 | one/bob/corge 10 | one/bob/grault 11 | -------------------------------------------------------------------------------- /testing/tests/install-extra: -------------------------------------------------------------------------------- 1 | # Install from an extra source 2 | # @TEST-EXEC: zkg --extra-source two=`pwd`/sources/two search quux > search.out 3 | # @TEST-EXEC: grep -q -m 1 two/eve/quux search.out 4 | 5 | # scripts/zkg doesn't add --force for us, do it by hand 6 | # @TEST-EXEC: zkg --extra-source two=`pwd`/sources/two install quux --force 7 | # @TEST-EXEC: zkg list > list.out 8 | # @TEST-EXEC: grep -q -m 1 'two/eve/quux' list.out 9 | -------------------------------------------------------------------------------- /testing/baselines/tests.bundle-unsatisfied-dependency/.stderr: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Switched to a new branch 'main' 3 | Switched to a new branch 'drop-corge' 4 | Switched to branch 'master' 5 | Switched to a new branch 'origin/main' 6 | XXXX-XX-XX XX:XX:XX WARNING dependency "spicy-plugin" (X.X.X) of "<...>/foo" not compatible with "<6.0.0" 7 | -------------------------------------------------------------------------------- /testing/baselines/tests.install-force-build-fail/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Installing "one<...>/foo" 3 | error: incomplete installation, the follow packages failed to be installed: 4 | one<...>/foo (main) 5 | Failed installing "one<...>/foo": package build_command failed, see log in <...>/foo-build.log 6 | have_load_bar=1 7 | have_load_foo=0 8 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/agg.fail.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Refresh package source: one 3 | No membership changes 4 | WARNING: Metadata aggregated, but excludes the following packages due to described problems: 5 | <...>/bad_pkg: missing zkg.meta (or bro-pkg.meta) metadata file 6 | Refresh installed packages 7 | No new outdated packages 8 | -------------------------------------------------------------------------------- /testing/scripts/diff-remove-timestamps: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Replace timestamps in the zkg log with XXXs. Note, this is different 4 | # from the canonifier used in the Zeek distribution. 5 | 6 | # Get us "modern" regexps with sed. 7 | if [ `uname` == "Linux" ]; then 8 | sed="sed -r" 9 | else 10 | sed="sed -E" 11 | fi 12 | 13 | $sed -e 's/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/XXXX-XX-XX XX:XX:XX/' 14 | -------------------------------------------------------------------------------- /testing/packages/rot13/scripts/__preload__.zeek: -------------------------------------------------------------------------------- 1 | # 2 | # This is loaded unconditionally at Zeek startup before any of the BiFs that the 3 | # plugin defines become available. 4 | # 5 | # This is primarily for defining types that BiFs already depend on. If you need 6 | # to do any other unconditional initialization (usually that's just for other BiF 7 | # elemets), that should go into __load__.zeek instead. 8 | # 9 | 10 | @load ./types.zeek 11 | -------------------------------------------------------------------------------- /testing/tests/branch-based-dependency: -------------------------------------------------------------------------------- 1 | 2 | # @TEST-EXEC: bash %INPUT 3 | 4 | # @TEST-EXEC: zkg install --version release/1.0 foo 5 | # @TEST-EXEC: zkg list installed > installed.out 6 | # @TEST-EXEC: btest-diff installed.out 7 | 8 | cd packages/foo 9 | git checkout -b release/1.0 10 | echo 'depends = bar branch=release/1.0' >> zkg.meta 11 | git commit -am 'depend on bar release/1.0' 12 | 13 | cd ../bar 14 | git checkout -b release/1.0 15 | -------------------------------------------------------------------------------- /testing/baselines/tests.template-info/output.plain: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | API version: 1.0.0 3 | features: readme 4 | origin: not a git repository 5 | provides package: true 6 | user vars: 7 | name: the name of the package, e.g. "FooBar", no default, used by package 8 | readme: Content of the README file, This is a README., used by readme 9 | versions: 10 | -------------------------------------------------------------------------------- /testing/packages/rot13/scripts/__load__.zeek: -------------------------------------------------------------------------------- 1 | # 2 | # This is loaded unconditionally at Zeek startup. Include scripts here that should 3 | # always be loaded. 4 | # 5 | # Normally, that will be only code that initializes built-in elements. Load 6 | # your standard scripts in 7 | # scripts///__load__.zeek instead. 8 | # 9 | 10 | @load ./init.zeek 11 | 12 | 13 | 14 | event zeek_init() { print "rot13 plugin is loaded"; } 15 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/agg.out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Refresh package source: one 3 | No membership changes 4 | WARNING: Metadata aggregated, but excludes the following packages due to described problems: 5 | <...>/bad_pkg: missing zkg.meta (or bro-pkg.meta) metadata file 6 | Pushed aggregated metadata 7 | Refresh installed packages 8 | No new outdated packages 9 | -------------------------------------------------------------------------------- /testing/packages/rot13/src/Plugin.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "Plugin.h" 3 | 4 | namespace plugin { namespace Demo_Rot13 { Plugin plugin; } } 5 | 6 | using namespace plugin::Demo_Rot13; 7 | 8 | zeek::plugin::Configuration Plugin::Configure() 9 | { 10 | zeek::plugin::Configuration config; 11 | config.name = "Demo::Rot13"; 12 | config.description = ""; 13 | config.version.major = 0; 14 | config.version.minor = 1; 15 | return config; 16 | } 17 | -------------------------------------------------------------------------------- /testing/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: btest-installation-check 3 | @btest -j -f diag.log 4 | 5 | .PHONY: btest-installation-check 6 | btest-installation-check: 7 | @type btest > /dev/null 2>&1 || \ 8 | { \ 9 | echo "btest was not located in PATH."; \ 10 | echo "Install it and/or make sure it is in PATH."; \ 11 | echo "E.g. you could use the following command to install it:"; \ 12 | echo "\tpip3 install btest"; \ 13 | echo ; \ 14 | exit 1; \ 15 | } 16 | -------------------------------------------------------------------------------- /testing/tests/template-info: -------------------------------------------------------------------------------- 1 | # This test verifies template info retrieval via "zkg template info". 2 | 3 | # @TEST-EXEC: zkg template info --json --jsonpretty 4 $TEMPLATES/foo >output.json 4 | # @TEST-EXEC: btest-diff output.json 5 | 6 | # @TEST-EXEC: zkg template info $TEMPLATES/foo >output.plain 7 | # @TEST-EXEC: btest-diff output.plain 8 | 9 | # @TEST-EXEC: zkg template info --json --jsonpretty 4 templates/foo >output.git 10 | # @TEST-EXEC: btest-diff output.git 11 | -------------------------------------------------------------------------------- /testing/baselines/tests.info/foo.info: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | "one<...>/foo" info: 3 | versions: ['1.0.0', '1.0.1', '1.0.2'] 4 | install status: 5 | current_version = main 6 | is_loaded = True 7 | is_outdated = True 8 | is_pinned = False 9 | tracking_method = branch 10 | metadata file: <...>/zkg.meta 11 | metadata (from version "main"): 12 | 13 | 14 | -------------------------------------------------------------------------------- /testing/tests/purge: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo bar baz 2 | # @TEST-EXEC: test -f scripts/packages/foo/__load__.zeek 3 | # @TEST-EXEC: test -f scripts/packages/bar/__load__.zeek 4 | # @TEST-EXEC: test -f scripts/packages/baz/__load__.zeek 5 | 6 | # @TEST-EXEC: zkg purge 7 | # @TEST-EXEC: test ! -d scripts/packages/foo 8 | # @TEST-EXEC: test ! -d scripts/packages/bar 9 | # @TEST-EXEC: test ! -d scripts/packages/baz 10 | # @TEST-EXEC: btest-diff scripts/packages/packages.zeek 11 | -------------------------------------------------------------------------------- /testing/baselines/tests.info/installed.info: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | "one<...>/foo" info: 3 | versions: ['1.0.0', '1.0.1', '1.0.2'] 4 | install status: 5 | current_version = main 6 | is_loaded = True 7 | is_outdated = True 8 | is_pinned = False 9 | tracking_method = branch 10 | metadata file: <...>/zkg.meta 11 | metadata (from version "main"): 12 | 13 | 14 | -------------------------------------------------------------------------------- /doc/_static/theme_overrides.css: -------------------------------------------------------------------------------- 1 | /* 2 | Prevent sphinx-argparse option output (e.g. --version) from wrapping. 3 | */ 4 | span.option { 5 | white-space: nowrap; 6 | } 7 | 8 | /* override table width restrictions */ 9 | html body div.wy-table-responsive table td, 10 | html body div.wy-table-responsive table th { 11 | white-space: normal; 12 | } 13 | 14 | html body div.wy-table-responsive { 15 | margin-bottom: 24px; 16 | max-width: 100%; 17 | overflow: visible; 18 | } 19 | -------------------------------------------------------------------------------- /testing/baselines/tests.install-force-test-fail/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | === install without skiptests 3 | error: failed to run tests for one<...>/foo: test_command failed with exit code 1 4 | Running unit tests for "one<...>/foo" 5 | have_load_foo=0 6 | === install with skiptests 7 | Installing "one<...>/foo" 8 | Installed "one<...>/foo" (main) 9 | Loaded "one<...>/foo" 10 | have_load_foo=1 11 | -------------------------------------------------------------------------------- /testing/baselines/tests.info/bar.info: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | "one<...>/bar" info: 3 | versions: ['1.0.0'] 4 | install status: 5 | current_version = 1.0.0 6 | is_loaded = True 7 | is_outdated = False 8 | is_pinned = False 9 | tracking_method = version 10 | metadata file: <...>/zkg.meta 11 | metadata (from version "1.0.0"): 12 | description = bar bar bar 13 | tags = sega sunset 14 | 15 | -------------------------------------------------------------------------------- /testing/baselines/tests.builtin-info/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | "zeek-builtin/spicy-plugin" info: 3 | url: zeek-builtin://spicy-plugin 4 | versions: ['X.X.X'] 5 | install status: 6 | current_hash = None 7 | current_version = X.X.X 8 | is_loaded = True 9 | is_outdated = False 10 | is_pinned = True 11 | tracking_method = builtin 12 | metadata (from version ""): 13 | 14 | 15 | -------------------------------------------------------------------------------- /testing/baselines/tests.upgrade-test-fail/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Installing "one<...>/foo" 3 | Installed "one<...>/foo" (1.0.2) 4 | Loaded "one<...>/foo" 5 | === upgrade without skiptests 6 | error: failed to run tests for one<...>/foo: test_command failed with exit code 1 7 | Running unit tests for "one<...>/foo" 8 | === upgrade with skiptest 9 | Upgraded "one<...>/foo" (1.0.3) 10 | print "foo 1.0.3"; 11 | -------------------------------------------------------------------------------- /testing/scripts/git: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # Git wrapper script for use during testing. 3 | 4 | # Use original path so we find the system's installed git, not this wrapper. 5 | PATH="$ORIGPATH" 6 | 7 | # Unsetting the following prevents git from reading ~/.gitconfig, 8 | # including potential githooks. 9 | HOME= 10 | XDG_CONFIG_HOME= 11 | 12 | git -c init.defaultBranch=master \ 13 | -c protocol.file.allow=always \ 14 | -c user.name=zkg \ 15 | -c user.email=zkg@zeek.org \ 16 | "$@" 17 | -------------------------------------------------------------------------------- /testing/btest.cfg: -------------------------------------------------------------------------------- 1 | [btest] 2 | TestDirs = tests 3 | TmpDir = %(testbase)s/.tmp 4 | IgnoreDirs = .svn CVS .tmp .git 5 | IgnoreFiles = *.tmp *.swp .DS_Store .gitignore 6 | BaselineDir = baselines 7 | Initializer = %(testbase)s/scripts/initializer 8 | MinVersion = 0.63 9 | 10 | [environment] 11 | ORIGPATH=%(default_path)s 12 | PATH=%(testbase)s/scripts:%(default_path)s 13 | SCRIPTS=%(testbase)s/scripts 14 | SOURCES=%(testbase)s/sources 15 | PACKAGES=%(testbase)s/packages 16 | TEMPLATES=%(testbase)s/templates 17 | -------------------------------------------------------------------------------- /testing/tests/aliases-bad: -------------------------------------------------------------------------------- 1 | 2 | # @TEST-EXEC: bash %INPUT 3 | # @TEST-EXEC-FAIL: zkg install foo 4 | # @TEST-EXEC: TEST_DIFF_CANONIFIER='grep ^error' btest-diff .stderr 5 | 6 | cd packages/foo 7 | echo 'aliases = ../../../../../../../../bad' >> zkg.meta 8 | git commit -am 'new stuff' 9 | 10 | # @TEST-START-NEXT 11 | cd packages/foo 12 | echo 'aliases = .hidden' >> zkg.meta 13 | git commit -am 'new stuff' 14 | 15 | # @TEST-START-NEXT 16 | cd packages/foo 17 | echo 'aliases = /aaa' >> zkg.meta 18 | git commit -am 'new stuff' 19 | -------------------------------------------------------------------------------- /.update-changes.cfg: -------------------------------------------------------------------------------- 1 | # Automatically adapt version in files. 2 | 3 | function replace_python_package_version 4 | { 5 | file=$1 6 | version=$2 7 | 8 | cat $file | sed "s#^\\( *__version__ *= *\\)\"\\([0-9.-]\\{1,\\}\\)\"#\1\"$version\"#g" >$file.tmp 9 | cat $file.tmp >$file 10 | rm -f $file.tmp 11 | git add $file 12 | } 13 | 14 | function new_version_hook 15 | { 16 | version=$1 17 | replace_python_package_version zeekpkg/__init__.py $version 18 | 19 | make man 20 | git add ./doc/man 21 | } 22 | -------------------------------------------------------------------------------- /testing/packages/rot13/configure.plugin: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Hooks to add custom options to the configure script. 4 | # 5 | 6 | plugin_usage() 7 | { 8 | : # Do nothing 9 | # cat <= 0.63. 2 | [package] 3 | script_dir = scripts 4 | summary = TODO: A summary of test3 in one line 5 | description = TODO: A more detailed description of test3. 6 | It can span multiple lines, with this indentation. 7 | 8 | [template] 9 | source = foo 10 | version = unversioned 11 | features = readme 12 | 13 | [template_vars] 14 | name = test3 15 | readme = This is a README. 16 | 17 | -------------------------------------------------------------------------------- /testing/baselines/tests.template-create/out4.zkg.meta: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | [package] 3 | script_dir = scripts 4 | summary = TODO: A summary of test4 in one line 5 | description = TODO: A more detailed description of test4. 6 | It can span multiple lines, with this indentation. 7 | 8 | [template] 9 | source = https://example.com/zeek/package-template 10 | version = master 11 | commit = xxxxxxxx 12 | 13 | [template_vars] 14 | name = test4 15 | 16 | -------------------------------------------------------------------------------- /testing/scripts/zkg: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | force="" 4 | 5 | case "$1" in 6 | install) 7 | force="--force" 8 | ;; 9 | upgrade) 10 | force="--force" 11 | ;; 12 | bundle) 13 | force="--force" 14 | ;; 15 | unbundle) 16 | force="--force" 17 | ;; 18 | remove) 19 | force="--force" 20 | ;; 21 | unload) 22 | force="--force" 23 | ;; 24 | purge) 25 | force="--force" 26 | ;; 27 | esac 28 | 29 | $TEST_BASE/../zkg --configfile=config "$@" $force 30 | -------------------------------------------------------------------------------- /testing/tests/plugin_tarfile: -------------------------------------------------------------------------------- 1 | # @TEST-REQUIRES: type zeek-config 2 | 3 | # @TEST-EXEC: bash %INPUT 4 | # @TEST-EXEC: zkg install rot13 5 | 6 | # @TEST-EXEC: test -f plugins/packages/rot13/__bro_plugin__ || test -f plugins/packages/rot13/__zeek_plugin__ 7 | # @TEST-EXEC: btest-diff scripts/packages/rot13/__load__.zeek 8 | 9 | cd packages/rot13 10 | echo "plugin_dir = build/Demo_Rot13.tgz" >> zkg.meta 11 | git commit -am 'new stuff' 12 | 13 | cd ../.. 14 | 15 | echo "$(pwd)/packages/rot13" >> sources/one/bob/zkg.index 16 | cd sources/one 17 | git commit -am 'add rot13 package' 18 | -------------------------------------------------------------------------------- /testing/baselines/tests.install-invalid/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | error: invalid package ".": Package name ' fronting-whitespace' is not valid. 3 | error: invalid package ".": Package name 'trailing-whitespace ' is not valid. 4 | error: path ./packages/doesntexist is not a git repository 5 | error: path ./packages/notagitrepo is not a git repository 6 | error: local git clone at ./packages/dirtyrepo is dirty 7 | error: local git clone at dirtyrepo is dirty 8 | error: local git clone at ./dirtyrepo is dirty 9 | -------------------------------------------------------------------------------- /testing/tests/load-zeek-dependency: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash %INPUT 2 | 3 | # @TEST-EXEC: zkg install foo 4 | # @TEST-EXEC: zkg unload foo 5 | # @TEST-EXEC: zkg list loaded >nothing-loaded.out 6 | # @TEST-EXEC: btest-diff nothing-loaded.out 7 | # @TEST-EXEC: zkg load foo 8 | # @TEST-EXEC: zkg list loaded >foo-loaded.out 9 | # @TEST-EXEC: btest-diff foo-loaded.out 10 | 11 | # The logic for dependency-aware (un)loading should just silently ignore "zeek" 12 | # as a special dependency and not a real package to consider (un)loading. 13 | 14 | cd packages/foo 15 | echo 'depends = zeek *' >> zkg.meta 16 | git commit -am 'new stuff' 17 | -------------------------------------------------------------------------------- /testing/tests/package_base: -------------------------------------------------------------------------------- 1 | # This test involves package testing, for which zkg internally requires 2 | # zeek-config. So require a Zeek install: 3 | # @TEST-REQUIRES: type zeek-config 4 | 5 | # @TEST-EXEC: bash %INPUT 6 | 7 | # @TEST-EXEC: zkg install foo 8 | # @TEST-EXEC: btest-diff state/logs/foo-build.log 9 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-cwd btest-diff state/testing/foo/clones/test.log 10 | 11 | cd packages/foo 12 | echo 'build_command = cd "%(package_base)s" && ls' >> zkg.meta 13 | echo 'test_command = echo "%(package_base)s" > %(package_base)s/test.log' >> zkg.meta 14 | git commit -am 'new stuff' 15 | -------------------------------------------------------------------------------- /testing/packages/rot13/src/rot13.bif: -------------------------------------------------------------------------------- 1 | %%{ 2 | #include 3 | #include 4 | #include "zeek/util.h" 5 | #include "zeek/ZeekString.h" 6 | #include "zeek/Val.h" 7 | %%} 8 | 9 | module Demo; 10 | 11 | function rot13%(s: string%) : string 12 | %{ 13 | char* rot13 = util::copy_string(s->CheckString()); 14 | 15 | for ( char* p = rot13; *p; p++ ) 16 | { 17 | char b = islower(*p) ? 'a' : 'A'; 18 | *p = (*p - b + 13) % 26 + b; 19 | } 20 | 21 | auto zs = new zeek::String(1, reinterpret_cast(rot13), strlen(rot13)); 22 | return make_intrusive(zs); 23 | %} 24 | -------------------------------------------------------------------------------- /testing/tests/load: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo bar 2 | # @TEST-EXEC: btest-diff scripts/packages/packages.zeek 3 | 4 | # @TEST-EXEC: zkg unload foo 5 | # @TEST-EXEC: cp scripts/packages/packages.zeek after_unload.out 6 | # @TEST-EXEC: btest-diff after_unload.out 7 | 8 | # @TEST-EXEC: zkg load foo 9 | # @TEST-EXEC: cp scripts/packages/packages.zeek after_load.out 10 | # @TEST-EXEC: btest-diff after_load.out 11 | 12 | # @TEST-EXEC: zkg install i-have-no-scripts 13 | # @TEST-EXEC: zkg load i-have-no-scripts 14 | # @TEST-EXEC: cp scripts/packages/packages.zeek after_loading_no_scripts.out 15 | # @TEST-EXEC: btest-diff after_loading_no_scripts.out 16 | -------------------------------------------------------------------------------- /testing/tests/search-config: -------------------------------------------------------------------------------- 1 | # Tests that using a branch works in the config. 2 | # 3 | # @TEST-EXEC: bash %INPUT 4 | echo "\ 5 | [sources] 6 | one = $(pwd)/sources/one@drop-corge 7 | two = $(pwd)/sources/two 8 | 9 | [paths] 10 | state_dir = $(pwd)/state 11 | script_dir = $(pwd)/scripts 12 | plugin_dir = $(pwd)/plugins 13 | " >> my.config 14 | 15 | # No more corge to be found 16 | # @TEST-EXEC: zkg --config my.config search corge > search.out 17 | # @TEST-EXEC: grep -m 1 'no matches' search.out 18 | 19 | # quux is in source two 20 | # @TEST-EXEC: zkg --config my.config search quux > search.out 21 | # @TEST-EXEC: grep -m 1 'two/eve/quux' search.out 22 | -------------------------------------------------------------------------------- /testing/tests/builtin-spicy: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure a package that requires spicy-plugin installs when spicy-plugin is built-in 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC: bash %INPUT 6 | # @TEST-EXEC: zkg install foo > output 7 | # @TEST-EXEC: btest-diff output 8 | # @TEST-EXEC: btest-diff package.log 9 | # 10 | 11 | export LOG=$(pwd)/package.log 12 | 13 | ( 14 | cd packages/foo 15 | cat >>zkg.meta <> $LOG 17 | build_command = echo "Building foo" >> $LOG 18 | depends = 19 | spicy-plugin * 20 | EOF 21 | git commit -am 'foo: depends on spicy-plugin' 22 | ) 23 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Set the version of Python and other tools you might need 9 | build: 10 | os: ubuntu-22.04 11 | tools: 12 | python: "3.11" 13 | 14 | # Build documentation in the docs/ directory with Sphinx 15 | sphinx: 16 | configuration: doc/conf.py 17 | 18 | # We recommend specifying your dependencies to enable reproducible builds: 19 | # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html 20 | python: 21 | install: 22 | - requirements: ./requirements.txt 23 | -------------------------------------------------------------------------------- /testing/scripts/zkg-zeek: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Invokes zkg to get the same behavior as with a Zeek-bundled install: 4 | # no config file is spelled out by default, but a config and state 5 | # directory are set as with the installation via CMake. 6 | 7 | # Pretend a different home directory, as created by setup-zeek-and-home 8 | export HOME=$(pwd)/home/testuser 9 | 10 | # Make zkg use the (pseudo) Zeek-bundled locations created by setup-zeek 11 | export ZEEK_ZKG_CONFIG_DIR=$(pwd)/zeekroot/etc/zkg 12 | export ZEEK_ZKG_STATE_DIR=$(pwd)/zeekroot/var/lib/zkg 13 | 14 | # Don't use a default package source in zkg: 15 | export ZKG_DEFAULT_SOURCE= 16 | 17 | $TEST_BASE/../zkg "$@" 18 | -------------------------------------------------------------------------------- /testing/tests/builtin-spicy-version: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure a package that requires a certain spicy-plugin version works with built-in spicy. 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC: bash %INPUT 6 | # @TEST-EXEC: zkg install foo > output 7 | # @TEST-EXEC: btest-diff output 8 | # @TEST-EXEC: btest-diff package.log 9 | # 10 | 11 | export LOG=$(pwd)/package.log 12 | 13 | ( 14 | cd packages/foo 15 | cat >>zkg.meta <> $LOG 17 | build_command = echo "Building foo" >> $LOG 18 | depends = 19 | spicy-plugin >=6.0.0 20 | EOF 21 | git commit -am 'foo: depends on spicy-plugin' 22 | ) 23 | -------------------------------------------------------------------------------- /testing/tests/install-force-build-fail: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Test that a failing build_command fails the package installation, no matter what. 2 | # @TEST-REQUIRES: type zeek-config 3 | # 4 | # @TEST-EXEC: bash %INPUT 5 | 6 | # @TEST-EXEC: zkg install bar 7 | # 8 | # @TEST-EXEC-FAIL: zkg install --force --skiptests foo >>out 2>&1 9 | # @TEST-EXEC: echo "have_load_bar=$(grep -c '@load.*bar' ./scripts/packages/packages.zeek)" >>out 10 | # @TEST-EXEC: echo "have_load_foo=$(grep -c '@load.*foo' ./scripts/packages/packages.zeek)" >>out 11 | # 12 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out 13 | 14 | cd packages/foo 15 | echo 'build_command = exit 1' >> zkg.meta 16 | git commit -am 'build fails' 17 | -------------------------------------------------------------------------------- /testing/tests/validate-manifest: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: List installed_packages in manifest.json - regression test for adding built-in packages. 2 | 3 | # @TEST-EXEC: zkg install foo 4 | # @TEST-EXEC: zkg install alice/bar 5 | # @TEST-EXEC: zkg install one/alice/baz 6 | 7 | # @TEST-EXEC: python3 read-manifest.py ./state/manifest.json > packages.txt 8 | # @TEST-EXEC: btest-diff packages.txt 9 | # 10 | @TEST-START-FILE read-manifest.py 11 | import json, sys 12 | 13 | with open(sys.argv[1]) as f: 14 | manifest = json.load(f) 15 | for i, pkg in enumerate(manifest["installed_packages"]): 16 | pkg_dict = pkg["package_dict"] 17 | print(i, pkg_dict["directory"], pkg_dict["name"], pkg_dict["source"]) 18 | 19 | @TEST-END-FILE 20 | -------------------------------------------------------------------------------- /doc/_templates/breadcrumbs.html: -------------------------------------------------------------------------------- 1 | {% extends "!breadcrumbs.html" %} 2 | 3 | {% block breadcrumbs_aside %} 4 |
  • 5 | {% if pagename != "search" %} 6 | {% if display_github %} 7 | {% if github_version == "master" %} 8 | {{ _('Edit on GitHub') }} 9 | {% endif %} 10 | {% elif show_source and has_source and sourcename %} 11 | {{ _('View page source') }} 12 | {% endif %} 13 | {% endif %} 14 |
  • 15 | {% endblock %} 16 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/agg.fail.errout: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | XXXX-XX-XX XX:XX:XX DEBUG found source clone of "one" at <...>/one 3 | XXXX-XX-XX XX:XX:XX DEBUG refresh "one": pulling <...>/one 4 | XXXX-XX-XX XX:XX:XX WARNING <...>/bro-pkg.meta: missing metadata file 5 | XXXX-XX-XX XX:XX:XX WARNING skipping aggregation of <...>/bad_pkg: bad metadata: missing zkg.meta (or bro-pkg.meta) metadata file 6 | XXXX-XX-XX XX:XX:XX DEBUG metadata refresh: 8 additions (alice/bar, alice/baz, alice/foo, alice/i-have-no-scripts, alice/new_pkg, alice/qux, bob/corge, bob/grault), 0 changes, 0 removals 7 | XXXX-XX-XX XX:XX:XX DEBUG fetch package one<...>/foo 8 | -------------------------------------------------------------------------------- /testing/tests/bundled-zkg: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Simulate bundling of zkg in Zeek and ensure zkg works. This got broken during a cleanup previously. 2 | # @TEST-EXEC: bash %INPUT > output 3 | # @TEST-EXEC: btest-diff output 4 | 5 | set -eu 6 | 7 | # Place zkg and zeekpkg into bin and lib/python directories and do 8 | # the templating. 9 | mkdir -p install-dir/{bin,lib/python} 10 | cp -R $TEST_BASE/../zeekpkg ./install-dir/lib/python 11 | cp $TEST_BASE/../zkg ./install-dir/bin 12 | sed -i -e "s,@PY_MOD_INSTALL_DIR@,$(pwd)/install-dir/lib/python," ./install-dir/bin/zkg 13 | 14 | export PATH=$(pwd)/install-dir/bin:$PATH 15 | # Ensure we're using the right zkg 16 | command -v zkg | sed -E 's,^.*/(.*/.*/.*/zkg),/\1,' 17 | zkg --version | sed 's/zkg [0-9.-]*/zkg xxx/' 18 | -------------------------------------------------------------------------------- /testing/scripts/setup-zeek-and-home: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # Helper script that establishes a skeletal equivalent of a 4 | # Zeek-bundled zkg state & config, and provides an alternative home 5 | # directory. 6 | 7 | zeek_zkg_config_dir=$(pwd)/zeekroot/etc/zkg 8 | zeek_zkg_state_dir=$(pwd)/zeekroot/var/lib/zkg 9 | zeek_site_dir=$(pwd)/zeekroot/share/zeek/site 10 | zeek_plugins_dir=$(pwd)/zeekroot/lib/zeek/plugins 11 | 12 | mkdir -p home/testuser ${zeek_zkg_config_dir} ${zeek_zkg_state_dir} \ 13 | ${zeek_site_dir} ${zeek_plugins_dir} 14 | 15 | echo "\ 16 | [sources] 17 | one = $(pwd)/sources/one 18 | [paths] 19 | state_dir = ${zeek_zkg_state_dir} 20 | script_dir = ${zeek_site_dir} 21 | plugin_dir = ${zeek_plugins_dir} 22 | " >> ${zeek_zkg_config_dir}/config 23 | -------------------------------------------------------------------------------- /testing/tests/builtin-spicy-version-error: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Package depends for built-in Spicy cannot be fulfilled with built-in package. 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # 5 | # @TEST-EXEC: bash %INPUT 6 | # @TEST-EXEC-FAIL: zkg install foo >output.orig 2>&1 7 | # @TEST-EXEC: sed -r 's/[0-9]+\.[0-9]+\.[0-9]+/X.X.X/g' output 8 | # @TEST-EXEC: btest-diff output 9 | # @TEST-EXEC: test ! -f package.log 10 | # 11 | 12 | export LOG=$(pwd)/package.log 13 | 14 | ( 15 | cd packages/foo 16 | cat >>zkg.meta <> $LOG 18 | build_command = echo "Building foo" >> $LOG 19 | depends = 20 | spicy-plugin <6.0.0 21 | EOF 22 | git commit -am 'foo: depends on old spicy-plugin' 23 | ) 24 | -------------------------------------------------------------------------------- /testing/baselines/tests.refresh/agg.errout: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | XXXX-XX-XX XX:XX:XX DEBUG found source clone of "one" at <...>/one 3 | XXXX-XX-XX XX:XX:XX DEBUG refresh "one": pulling <...>/one 4 | XXXX-XX-XX XX:XX:XX WARNING <...>/bro-pkg.meta: missing metadata file 5 | XXXX-XX-XX XX:XX:XX WARNING skipping aggregation of <...>/bad_pkg: bad metadata: missing zkg.meta (or bro-pkg.meta) metadata file 6 | XXXX-XX-XX XX:XX:XX DEBUG metadata refresh: 8 additions (alice/bar, alice/baz, alice/foo, alice/i-have-no-scripts, alice/new_pkg, alice/qux, bob/corge, bob/grault), 0 changes, 0 removals 7 | XXXX-XX-XX XX:XX:XX INFO committed package source "one" metadata update 8 | XXXX-XX-XX XX:XX:XX DEBUG fetch package one<...>/foo 9 | -------------------------------------------------------------------------------- /testing/tests/bindir-install: -------------------------------------------------------------------------------- 1 | # "zkg test" internally requires zeek-config 2 | # @TEST-REQUIRES: type zeek-config 3 | 4 | # @TEST-EXEC: bash %INPUT 5 | # 6 | # @TEST-EXEC: zkg test foo 7 | # 8 | # @TEST-EXEC: zkg install foo 9 | # @TEST-EXEC: test -d bin 10 | # @TEST-EXEC: test -L bin/exec1 && test -L bin/exec2 11 | # @TEST-EXEC: ./bin/exec1 >>output 12 | # @TEST-EXEC: ./bin/exec2 >>output 13 | # @TEST-EXEC: btest-diff output 14 | # 15 | # @TEST-EXEC: zkg remove foo 16 | # @TEST-EXEC: test '!' -e bin/exec1 && test '!' -e bin/exec2 17 | 18 | cd packages/foo 19 | echo "test_command = true" >>zkg.meta 20 | echo "executables = x/exec1 x/exec2 " >>zkg.meta 21 | 22 | mkdir x 23 | echo "echo from exec1" >x/exec1 24 | echo "echo from exec2" >x/exec2 25 | chmod +x x/exec1 x/exec2 26 | 27 | git add * 28 | git commit -m 'new stuff' 29 | -------------------------------------------------------------------------------- /zeekpkg/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | This package defines a Python interface for installing, managing, querying, 3 | and performing other operations on Zeek Packages and Package Sources. 4 | The main entry point is the :class:`Manager ` class. 5 | 6 | This package provides a logger named ``LOG`` to which logging stream handlers 7 | may be added in order to help log/debug applications. 8 | """ 9 | 10 | import logging 11 | 12 | __version__ = "3.1.0-13" 13 | __all__ = ["manager", "package", "source", "template", "uservar"] # noqa: F405 14 | 15 | LOG: logging.Logger = logging.getLogger(__name__) 16 | LOG.addHandler(logging.NullHandler()) 17 | 18 | from .manager import * # noqa: F403 19 | from .package import * # noqa: F403 20 | from .source import * # noqa: F403 21 | from .uservar import * # noqa: F403 22 | -------------------------------------------------------------------------------- /testing/tests/bindir-relocate: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash %INPUT 2 | # 3 | # @TEST-EXEC: zkg install foo 4 | # @TEST-EXEC: test -L bin/exec1 && test -L bin/exec2 5 | # 6 | # @TEST-EXEC: sed -i.bak 's/\(^bin_dir.*\)/\1-new/g' config 7 | # @TEST-EXEC: zkg list 8 | # @TEST-EXEC: test -L bin-new/exec1 && test -L bin-new/exec2 9 | # @TEST-EXEC: ./bin-new/exec1 >>output 10 | # @TEST-EXEC: ./bin-new/exec2 >>output 11 | # @TEST-EXEC: test '!' -e bin/exec1 && test '!' -e bin/exec2 12 | # @TEST-EXEC: test '!' -d bin 13 | # 14 | # @TEST-EXEC: btest-diff output 15 | 16 | cd packages/foo 17 | echo "test_command = true" >>zkg.meta 18 | echo "executables = x/exec1 x/exec2 " >>zkg.meta 19 | 20 | mkdir x 21 | echo "echo from exec1" >x/exec1 22 | echo "echo from exec2" >x/exec2 23 | chmod +x x/exec1 x/exec2 24 | 25 | git add * 26 | git commit -m 'new stuff' 27 | -------------------------------------------------------------------------------- /testing/tests/installed-dependency-conflict: -------------------------------------------------------------------------------- 1 | 2 | # @TEST-EXEC: bash %INPUT 3 | 4 | # @TEST-EXEC: zkg install --version 1.0.0 foo 5 | # @TEST-EXEC: zkg list installed > installed-initial.out 6 | 7 | # @TEST-EXEC-FAIL: zkg install --version 2.0.0 foo >conflict.out 2>&1 8 | # @TEST-EXEC: zkg list installed > installed-final.out 9 | 10 | # @TEST-EXEC: btest-diff installed-initial.out 11 | # @TEST-EXEC: btest-diff conflict.out 12 | # @TEST-EXEC: btest-diff installed-final.out 13 | 14 | cd packages/foo 15 | echo 'depends = bar =1.0.0' >> zkg.meta 16 | git commit -am 'depend on bar 1.0.0' 17 | git tag -a 1.0.0 -m 1.0.0 18 | git checkout HEAD~1 19 | echo 'depends = bar =2.0.0' >> zkg.meta 20 | git commit -am 'depend on bar 2.0.0' 21 | git tag -a 2.0.0 -m 2.0.0 22 | 23 | cd ../bar 24 | git tag -a 1.0.0 -m 1.0.0 25 | git tag -a 2.0.0 -m 2.0.0 26 | -------------------------------------------------------------------------------- /testing/packages/rot13/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Convenience Makefile providing a few common top-level targets. 3 | # 4 | 5 | cmake_build_dir=build 6 | arch=`uname -s | tr A-Z a-z`-`uname -m` 7 | 8 | all: build-it 9 | 10 | build-it: 11 | @test -e $(cmake_build_dir)/config.status || ./configure 12 | -@test -e $(cmake_build_dir)/CMakeCache.txt && \ 13 | test $(cmake_build_dir)/CMakeCache.txt -ot `cat $(cmake_build_dir)/CMakeCache.txt | grep ZEEK_DIST | cut -d '=' -f 2`/build/CMakeCache.txt && \ 14 | echo Updating stale CMake cache && \ 15 | touch $(cmake_build_dir)/CMakeCache.txt 16 | 17 | ( cd $(cmake_build_dir) && make ) 18 | 19 | install: 20 | ( cd $(cmake_build_dir) && make install ) 21 | 22 | clean: 23 | ( cd $(cmake_build_dir) && make clean ) 24 | 25 | distclean: 26 | rm -rf $(cmake_build_dir) 27 | 28 | test: 29 | make -C tests 30 | -------------------------------------------------------------------------------- /testing/tests/package-submodule: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash setup_foo 2 | 3 | # @TEST-EXEC: zkg install foo 4 | 5 | # @TEST-EXEC: cp scripts/packages/foo/__load__.zeek foo.install 6 | # @TEST-EXEC: btest-diff foo.install 7 | 8 | # @TEST-EXEC: bash %INPUT 9 | 10 | # @TEST-EXEC: zkg refresh 11 | # @TEST-EXEC: zkg upgrade 12 | 13 | # @TEST-EXEC: cp scripts/packages/foo/__load__.zeek foo.upgrade 14 | # @TEST-EXEC: btest-diff foo.upgrade 15 | 16 | @TEST-START-FILE setup_foo 17 | cd packages/foo 18 | echo 'script_dir = scripts' >> zkg.meta 19 | git submodule add $(pwd)/../bar scripts 20 | git commit -am 'add submodule' 21 | @TEST-END-FILE 22 | 23 | cd packages/bar 24 | echo 'event zeek_init() { print "bar upgrade is loaded"; }' > __load__.zeek 25 | git commit -am 'new stuff' 26 | 27 | cd ../foo/scripts 28 | git pull 29 | cd .. 30 | git commit -am 'update submodule' 31 | -------------------------------------------------------------------------------- /testing/baselines/tests.template-info/output.json: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | { 3 | "api_version": "1.0.0", 4 | "features": [ 5 | "readme" 6 | ], 7 | "has_repo": false, 8 | "origin": "not a git repository", 9 | "provides_package": true, 10 | "user_vars": { 11 | "name": { 12 | "default": null, 13 | "description": "the name of the package, e.g. \"FooBar\"", 14 | "used_by": [ 15 | "package" 16 | ] 17 | }, 18 | "readme": { 19 | "default": "This is a README.", 20 | "description": "Content of the README file", 21 | "used_by": [ 22 | "readme" 23 | ] 24 | } 25 | }, 26 | "versions": [] 27 | } 28 | -------------------------------------------------------------------------------- /testing/baselines/tests.template-info/output.git: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | { 3 | "api_version": "1.0.0", 4 | "features": [ 5 | "readme" 6 | ], 7 | "has_repo": true, 8 | "origin": "https://example.com/zeek/package-template", 9 | "provides_package": true, 10 | "user_vars": { 11 | "name": { 12 | "default": null, 13 | "description": "the name of the package, e.g. \"FooBar\"", 14 | "used_by": [ 15 | "package" 16 | ] 17 | }, 18 | "readme": { 19 | "default": "This is a README.", 20 | "description": "Content of the README file", 21 | "used_by": [ 22 | "readme" 23 | ] 24 | } 25 | }, 26 | "versions": [] 27 | } 28 | -------------------------------------------------------------------------------- /testing/tests/test: -------------------------------------------------------------------------------- 1 | # "zkg test" internally requires zeek-config 2 | # @TEST-REQUIRES: type zeek-config 3 | 4 | # @TEST-EXEC: bash %INPUT 5 | # @TEST-EXEC: zkg test rot13 6 | 7 | # @TEST-EXEC: bash we_need_to_go_deeper 8 | # @TEST-EXEC-FAIL: zkg test rot13 9 | 10 | echo "$(pwd)/packages/rot13" >> sources/one/bob/zkg.index 11 | cd sources/one 12 | git commit -am 'add rot13 package' 13 | 14 | cd ../../packages/rot13 15 | echo 'depends = bar *' >> zkg.meta 16 | echo -e "@load bar\n$(cat scripts/Demo/Rot13/__load__.zeek)" > scripts/Demo/Rot13/__load__.zeek 17 | 18 | cd testing/Baseline/tests.main 19 | echo "rot13 plugin is loaded" > output 20 | echo "bar loaded" >> output 21 | echo "rot13 script is loaded" >> output 22 | 23 | git commit -am 'new stuff' 24 | 25 | @TEST-START-FILE we_need_to_go_deeper 26 | cd packages/rot13 27 | echo 'hello' > testing/Baseline/tests.rot13/output 28 | git commit -am 'new stuff' 29 | @TEST-END-FILE 30 | -------------------------------------------------------------------------------- /testing/tests/install-force-test-fail: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Test that a failing test_command with --force causes zkg install to fail and the package is not loaded. Also, verify that --skiptests can override that. 2 | # @TEST-REQUIRES: type zeek-config 3 | # 4 | # @TEST-EXEC: bash %INPUT 5 | 6 | # @TEST-EXEC: echo "=== install without skiptests" >>out 7 | # @TEST-EXEC-FAIL: zkg install --force foo >>out 2>&1 8 | # @TEST-EXEC: echo "have_load_foo=$(grep -c '@load.*foo' ./scripts/packages/packages.zeek)" >>out 9 | # 10 | # @TEST-EXEC: rm -rf ./state 11 | # @TEST-EXEC: echo "=== install with skiptests" >>out 12 | # @TEST-EXEC: zkg install --force --skiptests foo >>out 2>&1 13 | # @TEST-EXEC: echo "have_load_foo=$(grep -c '@load.*foo' ./scripts/packages/packages.zeek)" >>out 14 | # 15 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out 16 | 17 | cd packages/foo 18 | echo 'test_command = exit 1' >> zkg.meta 19 | git commit -am 'add a test' 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VERSION=`cat VERSION` 2 | 3 | .PHONY: all 4 | all: 5 | 6 | .PHONY: doc 7 | doc: man html 8 | 9 | .PHONY: man 10 | man: 11 | (cd doc && make man && mkdir -p man && cp _build/man/zkg.1 man) 12 | 13 | .PHONY: html 14 | html: 15 | (cd doc && make html) 16 | 17 | .PHONY: livehtml 18 | livehtml: 19 | (cd doc && make livehtml) 20 | 21 | .PHONY: test 22 | test: 23 | @( cd testing && make ) 24 | 25 | .PHONY: dist 26 | dist: 27 | python3 setup.py bdist_wheel 28 | 29 | .PHONY: upload 30 | upload: twine-check dist 31 | twine upload -u zeek dist/zkg-$(VERSION)-py2.py3-none-any.whl 32 | 33 | .PHONY: twine-check 34 | twine-check: 35 | @type twine > /dev/null 2>&1 || \ 36 | { \ 37 | echo "Uploading to PyPi requires 'twine' and it's not found in PATH."; \ 38 | echo "Install it and/or make sure it is in PATH."; \ 39 | echo "E.g. you could use the following command to install it:"; \ 40 | echo "\tpip3 install twine"; \ 41 | echo ; \ 42 | exit 1; \ 43 | } 44 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | repos: 4 | - repo: https://github.com/pre-commit/pre-commit-hooks 5 | rev: v6.0.0 6 | hooks: 7 | - id: trailing-whitespace 8 | exclude: testing/baselines 9 | - id: end-of-file-fixer 10 | exclude: testing/baselines 11 | - id: check-yaml 12 | - id: check-added-large-files 13 | - repo: https://github.com/astral-sh/ruff-pre-commit 14 | rev: v0.12.9 15 | hooks: 16 | - id: ruff 17 | args: [--fix] 18 | - id: ruff-format 19 | 20 | - repo: https://github.com/pre-commit/mirrors-mypy 21 | rev: v1.17.1 22 | hooks: 23 | - id: mypy 24 | args: [--strict] 25 | additional_dependencies: 26 | - "argcomplete>=3.6.2" 27 | - "GitPython>=3.1.43" 28 | - "semantic_version>=2.10.0" 29 | - "types-docutils>=0.21.0.20250809" 30 | - "types-setuptools>=80.9.0.20250809" 31 | exclude: "doc/.*" 32 | -------------------------------------------------------------------------------- /testing/tests/install-on-tty: -------------------------------------------------------------------------------- 1 | # This test installs a package with a "slow" pseudo build command, once using a 2 | # pretend TTY, and once normally. It then verifies that we see progress dots 3 | # only in the TTY. This requires the "script" command for TTY fakery. 4 | 5 | # @TEST-REQUIRES: script --version 6 | # @TEST-EXEC: bash %INPUT 7 | 8 | # https://stackoverflow.com/questions/32910661/pretend-to-be-a-tty-in-bash-for-any-command 9 | faketty () { 10 | script -qefc "$(printf "%q " "$@")" /dev/null 11 | } 12 | 13 | # Add a build command to the package that takes at least as long as it takes zkg 14 | # to produce progress dots. 15 | ( 16 | cd $(pwd)/packages/foo 17 | echo 'build_command = sleep 2' >>zkg.meta 18 | git add zkg.meta 19 | git commit -am 'build slowly' 20 | ) 21 | 22 | faketty zkg install foo >output.tty 23 | zkg uninstall --force foo 24 | zkg install foo >output.notty 25 | 26 | grep 'Installing' output.tty | grep -q '\.' 27 | grep 'Installing' output.notty | grep -v -q '\.' 28 | -------------------------------------------------------------------------------- /testing/tests/info-submodules: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Test that the info doesn't recursively clone repos. The tested repository has a broken submodule in it and will fail to clone otherwise. 2 | # 3 | # @TEST-EXEC: bash %INPUT 4 | # @TEST-EXEC: zkg info ./clonetest | grep -v "metadata file:" > clonetest.info 5 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff clonetest.info 6 | 7 | zkg create --packagedir clonetest --user-var name=clonetest.gitmodules 8 | cp zkg.meta clonetest/zkg.meta 9 | 10 | pushd clonetest 11 | 12 | git add zkg.meta && gitcommit -v -m "Update zkg.meta" 13 | 14 | git submodule add "../$(basename $(realpath .))" 15 | sed 's~url.*$~url = http://github.com/zeek/A-REPO-WHICH-SHOULD-NOT-EXIST~' .gitmodules > modules && mv modules .gitmodules 16 | git add .gitmodules && git commit -v -m 'Add submodule' 17 | 18 | # @TEST-START-FILE zkg.meta 19 | [package] 20 | build_command = ./configure && make 21 | description = Zeek package with a broken submodule for testing 'zkg info' 22 | # @TEST-END-FILE 23 | -------------------------------------------------------------------------------- /testing/tests/list: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg list all > all.out 2 | # @TEST-EXEC: btest-diff all.out 3 | 4 | # @TEST-EXEC: zkg install foo bar 5 | # @TEST-EXEC: zkg unload bar 6 | # @TEST-EXEC: zkg list installed > installed.out 7 | # @TEST-EXEC: btest-diff installed.out 8 | 9 | # @TEST-EXEC: zkg list > list.out 10 | # @TEST-EXEC: cmp list.out installed.out 11 | 12 | # @TEST-EXEC: zkg list loaded > loaded.out 13 | # @TEST-EXEC: btest-diff loaded.out 14 | 15 | # @TEST-EXEC: zkg list unloaded > unloaded.out 16 | # @TEST-EXEC: btest-diff unloaded.out 17 | 18 | # @TEST-EXEC: zkg list not_installed > not_installed.out 19 | # @TEST-EXEC: btest-diff not_installed.out 20 | 21 | # @TEST-EXEC: bash %INPUT 22 | # @TEST-EXEC: zkg refresh 23 | # @TEST-EXEC: zkg list outdated > outdated.out 24 | # @TEST-EXEC: btest-diff outdated.out 25 | 26 | # @TEST-EXEC: zkg upgrade 27 | # @TEST-EXEC: zkg list outdated > after_upgrade.out 28 | # @TEST-EXEC: btest-diff after_upgrade.out 29 | 30 | cd packages/foo 31 | echo 'print "hello";' >> __load__.zeek 32 | git commit -am 'new stuff' 33 | -------------------------------------------------------------------------------- /testing/baselines/tests.dependency-management/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | ** Install grault 3 | Installing "one/bob/corge" 4 | Installed "one/bob/corge" (1.0.0) 5 | Loaded "one/bob/corge" 6 | Installing "one/bob/grault" 7 | Installed "one/bob/grault" (1.0.0) 8 | Loaded "one/bob/grault" 9 | ** Unload grault 10 | Unloaded "one/bob/grault" 11 | ** Install foo 12 | Installing "one/alice/baz" 13 | Installed "one/alice/baz" (1.0.0) 14 | Loaded "one/alice/baz" 15 | Installing "one/alice/bar" 16 | Installed "one/alice/bar" (1.0.0) 17 | Loaded "one/alice/bar" 18 | Installing "one/alice/foo" 19 | Installed "one/alice/foo" (main) 20 | Loaded "one/alice/foo" 21 | The following installed packages were additionally loaded to satisfy runtime dependencies 22 | grault 23 | 24 | ** Unload foo 25 | Unloaded "one/alice/foo" 26 | ** Load foo 27 | Loaded "one/alice/foo" 28 | ** Unload bar 29 | Unloaded "one/alice/bar" 30 | Unloaded "one/alice/foo" 31 | ** Remove grault 32 | Unloaded "one/alice/baz" 33 | Removed "one/bob/grault" 34 | -------------------------------------------------------------------------------- /testing/baselines/tests.template-create/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | "foo" will use value of "name" (the name of the package, e.g. "FooBar") from command line: test1 3 | "foo" will use value of "name" (the name of the package, e.g. "FooBar") from environment: test2 4 | "foo" will use value of "name" (the name of the package, e.g. "FooBar") from command line: test3 5 | "foo" will use value of "name" (the name of the package, e.g. "FooBar") from command line: test4 6 | <...>/out1 (installed: master) - TODO: A more detailed description of test1. 7 | <...>/out2 (installed: master) - TODO: A more detailed description of test2. 8 | <...>/out3 (installed: master) - TODO: A more detailed description of test3. 9 | error: could not determine value of user variable "name", provide via environment or --user-var 10 | error: the following features are unknown: "doesntexist". Template "foo" offers "readme". 11 | "foo" will use value of "name" (the name of the package, e.g. "FooBar") from command line: 你こ안مγПनสXש😊©GBCDČM 12 | -------------------------------------------------------------------------------- /testing/tests/builtin-spicy-bundle: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Bundle foo which depends spicy-plugin (built-in) and check the created manifest.txt 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # @TEST-REQUIRES: tar --version 5 | # 6 | # @TEST-EXEC: bash %INPUT 7 | # @TEST-EXEC: zkg install foo > output 8 | # @TEST-EXEC: zkg bundle bundle.tar --manifest foo >> output 9 | # @TEST-EXEC: zkg unbundle bundle.tar >> output 10 | # @TEST-EXEC: mkdir bundle && tar -C bundle -xf bundle.tar 11 | # @TEST-EXEC: TEST_DIFF_CANONIFIER='sed -r "s/(.*)=[0-9]+\.[0-9]+\.[0-9]+/\1=X.X.X/g" | $SCRIPTS/diff-remove-abspath btest-diff' btest-diff bundle/manifest.txt 12 | # @TEST-EXEC: btest-diff output 13 | # @TEST-EXEC: btest-diff .stderr 14 | # @TEST-EXEC: btest-diff package.log 15 | # 16 | 17 | export LOG=$(pwd)/package.log 18 | 19 | ( 20 | cd packages/foo 21 | cat >>zkg.meta <> $LOG 23 | build_command = echo "Building foo" >> $LOG 24 | depends = 25 | spicy-plugin >=6.0.0 26 | EOF 27 | git commit -am 'foo: depends on spicy-plugin' 28 | ) 29 | -------------------------------------------------------------------------------- /testing/tests/search-extra: -------------------------------------------------------------------------------- 1 | # First search for corge in source one default branch (i.e. 'master' or 'main') 2 | # 3 | # @TEST-EXEC: zkg search corge > search.out 4 | # @TEST-EXEC: grep -q -m 1 'one/bob/corge' search.out 5 | 6 | # Now overwrite source one with the branch 7 | # @TEST-EXEC: zkg --extra-source one=`pwd`/sources/one@drop-corge search corge > search.out 8 | # @TEST-EXEC: grep -m 1 'no matches' search.out 9 | 10 | # Make sure grault is still there 11 | # @TEST-EXEC: zkg --extra-source one=`pwd`/sources/one@drop-corge search grault > search.out 12 | # @TEST-EXEC: grep -m 1 'one/bob/grault' search.out 13 | 14 | # Search for quux without source two 15 | # @TEST-EXEC: zkg search quux > search.out 16 | # @TEST-EXEC: grep -m 1 'no matches' search.out 17 | # 18 | # Now in source two with explicit branch (i.e. using the default of 'master' or 'main') 19 | # @TEST-EXEC: ( cd $(pwd)/sources/two && git rev-parse --abbrev-ref HEAD ) > default_branch_name 20 | # @TEST-EXEC: zkg --extra-source two=`pwd`/sources/two@$(cat default_branch_name) search quux > search.out 21 | # @TEST-EXEC: grep -m 1 'two/eve/quux' search.out 22 | -------------------------------------------------------------------------------- /doc/ext/sphinxarg/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Alex Rudakov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /testing/baselines/tests.user-mode/output: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | [sources] 3 | one = <...>/sources/one 4 | 5 | [paths] 6 | state_dir = <...>/zeekroot/var/lib/zkg 7 | script_dir = <...>/zeekroot/share/zeek/site 8 | plugin_dir = <...>/zeekroot/lib/zeek/plugins 9 | bin_dir = <...>/zeekroot/var/lib/zkg/bin 10 | zeek_dist = 11 | 12 | [templates] 13 | default = https://github.com/zeek/package-template 14 | 15 | 16 | Installing "one/alice/foo" 17 | Installed "one/alice/foo" (main) 18 | Loaded "one/alice/foo" 19 | one/alice/foo (installed: main) 20 | Installing "zeek/alice/bar" 21 | Installed "zeek/alice/bar" (master) 22 | Loaded "zeek/alice/bar" 23 | zeek/alice/bar (installed: master) 24 | Successfully wrote config file to <...>/home/testuser/.zkg/config 25 | [sources] 26 | 27 | [paths] 28 | state_dir = <...>/home/testuser/.zkg 29 | script_dir = <...>/home/testuser/.zkg/script_dir 30 | plugin_dir = <...>/home/testuser/.zkg/plugin_dir 31 | bin_dir = <...>/home/testuser/.zkg/bin 32 | zeek_dist = 33 | 34 | [templates] 35 | default = https://github.com/zeek/package-template 36 | 37 | 38 | -------------------------------------------------------------------------------- /testing/tests/install-invalid: -------------------------------------------------------------------------------- 1 | # Test invalid package names and paths 2 | # @TEST-EXEC-FAIL: bash %INPUT 2>output 3 | # @TEST-EXEC: btest-diff output 4 | 5 | CONFIG=$(pwd)/config 6 | mkdir -p invalid 7 | 8 | cp -R ./packages/bar ./invalid/\ fronting-whitespace 9 | (cd ./invalid/\ fronting-whitespace && zkg --config=$CONFIG install --force .) 10 | 11 | cp -R ./packages/bar './invalid/trailing-whitespace ' 12 | (cd './invalid/trailing-whitespace ' && zkg --config=$CONFIG install --force . ) 13 | 14 | zkg --config=$CONFIG install --force ./packages/doesntexist 15 | 16 | mkdir ./packages/notagitrepo 17 | zkg --config=$CONFIG install --force ./packages/notagitrepo 18 | 19 | mkdir ./packages/dirtyrepo 20 | ( 21 | cd ./packages/dirtyrepo && \ 22 | git init . && \ 23 | touch README && \ 24 | cat << EOF > zkg.meta 25 | [package] 26 | EOF 27 | git add README zkg.meta && \ 28 | git commit -m "Initial commit" 29 | ) 30 | echo README > ./packages/dirtyrepo/README 31 | zkg --config=$CONFIG install --force ./packages/dirtyrepo 32 | 33 | (cd ./packages && zkg --config=$CONFIG install dirtyrepo --force 1>&2) 34 | (cd ./packages && zkg --config=$CONFIG install ./dirtyrepo --force 1>&2) 35 | -------------------------------------------------------------------------------- /testing/tests/bundle-missing-dependency: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Create a bundle by hand with a package depending on "zkg-test-plugin" which does not exist, observe a warning during unbundling. 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # @TEST-REQUIRES: tar --version 5 | # 6 | # @TEST-EXEC: bash %INPUT 7 | # 8 | # @TEST-EXEC: zkg unbundle bundle.tar >> output 9 | # @TEST-EXEC: zkg list >> output 10 | # @TEST-EXEC: btest-diff output 11 | # @TEST-EXEC: TEST_DIFF_CANONIFIER='sed -r "s/[0-9]{2}/XX/g" | $SCRIPTS/diff-remove-abspath btest-diff' btest-diff .stderr 12 | # @TEST-EXEC: btest-diff package.log 13 | # 14 | 15 | export LOG=$(pwd)/package.log 16 | 17 | ( 18 | cd packages/foo 19 | cat >>zkg.meta <> $LOG 21 | build_command = echo "Building foo" >> $LOG 22 | depends = 23 | zkg-test-plugin >=6.0.0 24 | EOF 25 | git commit -am 'foo: depends on zkg-test-plugin' 26 | git checkout -b origin/main 27 | ) 28 | 29 | # Create a bundle 30 | mkdir the-bundle 31 | cp -R packages/foo ./the-bundle 32 | echo -e '[bundle]\n/one/alice/foo = main' >> the-bundle/manifest.txt 33 | tar -cf bundle.tar -C ./the-bundle . 34 | -------------------------------------------------------------------------------- /testing/tests/plugin: -------------------------------------------------------------------------------- 1 | # @TEST-REQUIRES: type zeek-config 2 | 3 | # @TEST-EXEC: bash %INPUT 4 | # @TEST-EXEC: zkg install rot13 5 | 6 | # @TEST-EXEC: test -f plugins/packages/rot13/__bro_plugin__ || test -f plugins/packages/rot13/__zeek_plugin__ 7 | # @TEST-EXEC: btest-diff scripts/packages/rot13/__load__.zeek 8 | 9 | # Unloading the package should also disable the plugin, which we 10 | # detect via the renamed __bro_plugin__ magic file. 11 | # @TEST-EXEC: zkg unload rot13 12 | 13 | # @TEST-EXEC: test ! -f plugins/packages/rot13/__bro_plugin__ && test ! -f plugins/packages/rot13/__zeek_plugin__ 14 | # @TEST-EXEC: test -f plugins/packages/rot13/__bro_plugin__.disabled || test -f plugins/packages/rot13/__zeek_plugin__.disabled 15 | 16 | # (Re-)loading the package should also (re-)enable the plugin. 17 | # @TEST-EXEC: zkg load rot13 18 | 19 | # @TEST-EXEC: test -f plugins/packages/rot13/__bro_plugin__ || test -f plugins/packages/rot13/__zeek_plugin__ 20 | # @TEST-EXEC: test ! -f plugins/packages/rot13/__bro_plugin__.disabled && test ! -f plugins/packages/rot13/__zeek_plugin__.disabled 21 | 22 | echo "$(pwd)/packages/rot13" >> sources/one/bob/zkg.index 23 | cd sources/one 24 | git commit -am 'add rot13 package' 25 | -------------------------------------------------------------------------------- /testing/tests/aliases-conflict: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Ensure alias conflicts are reported and cause package installation failures. 2 | # 3 | # @TEST-EXEC: bash %INPUT 4 | # @TEST-EXEC: zkg install foo >>out 2>&1 5 | # @TEST-EXEC-FAIL: zkg install bar >>out 2>&1 6 | # @TEST-EXEC-FAIL: zkg install baz >>out 2>&1 7 | # @TEST-EXEC-FAIL: zkg install corge >>out 2>&1 8 | # @TEST-EXEC: cp scripts/packages/packages.zeek packages.zeek.1 9 | # 10 | # Remove foo, then install baz and corge 11 | # Now, remove foo, install baz and corge and ensure foo cannot be installed thereafter. 12 | # @TEST-EXEC: zkg remove foo >>out 2>&1 13 | # @TEST-EXEC: zkg install baz >>out 2>&1 14 | # @TEST-EXEC: zkg install corge >>out 2>&1 15 | # @TEST-EXEC-FAIL: zkg install foo >>out 2>&1 16 | # @TEST-EXEC: cp scripts/packages/packages.zeek packages.zeek.2 17 | # @TEST-EXEC: btest-diff out 18 | # @TEST-EXEC: btest-diff packages.zeek.1 19 | # @TEST-EXEC: btest-diff packages.zeek.2 20 | 21 | (cd packages/foo && echo 'aliases = bar' >> zkg.meta && git commit -n -am 'new stuff') 22 | (cd packages/baz && echo 'aliases = foo' >> zkg.meta && git commit -n -am 'new stuff') 23 | (cd packages/corge && echo 'aliases = bar' >> zkg.meta && git commit -n -am 'new stuff') 24 | -------------------------------------------------------------------------------- /testing/tests/user_vars: -------------------------------------------------------------------------------- 1 | # This test involves package testing, for which zkg internally requires 2 | # zeek-config. So require a Zeek install: 3 | # @TEST-REQUIRES: type zeek-config 4 | 5 | # @TEST-EXEC: bash %INPUT 6 | 7 | # @TEST-EXEC: LAST_VAR=/home/jon/sandbox zkg install foo 8 | # @TEST-EXEC: cp state/logs/foo-build.log state/logs/foo-build.log1 9 | # @TEST-EXEC: btest-diff state/logs/foo-build.log1 10 | 11 | # @TEST-EXEC: zkg install --user-var TEST_VAR="Initial description is here" --user-var LAST_VAR=/home/jon/sandbox2 foo 12 | # @TEST-EXEC: cp state/logs/foo-build.log state/logs/foo-build.log2 13 | # @TEST-EXEC: btest-diff state/logs/foo-build.log2 14 | # @TEST-EXEC: btest-diff state/testing/foo/clones/test.log 15 | 16 | cd packages/foo 17 | echo 'user_vars =' >> zkg.meta 18 | echo ' TEST_VAR [/usr] "First description is here"' >> zkg.meta 19 | echo ' ANOTHER_VAR [/usr/local] "Second description is here"' >> zkg.meta 20 | echo ' LAST_VAR [/opt] "Last description is here"' >> zkg.meta 21 | echo 'build_command = echo "%(LAST_VAR)s" && echo "%(ANOTHER_VAR)s" && echo "%(TEST_VAR)s"' >> zkg.meta 22 | echo 'test_command = echo "%(TEST_VAR)s" > %(package_base)s/test.log' >> zkg.meta 23 | git commit -am 'new stuff' 24 | -------------------------------------------------------------------------------- /testing/tests/bundle-unsatisfied-dependency: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Create a bundle by hand with a package depending on "spicy-plugin<6.0.0" which isn't satisfiable. Observe a warning during unbundling. 2 | # 3 | # @TEST-REQUIRES: zeek -e 'exit(Version::at_least("6.0.0") ? 0 : 1)' 4 | # @TEST-REQUIRES: tar --version 5 | # 6 | # @TEST-EXEC: bash %INPUT 7 | # 8 | # @TEST-EXEC: zkg unbundle bundle.tar >> output 9 | # @TEST-EXEC: zkg list >> output 10 | # @TEST-EXEC: btest-diff output 11 | # @TEST-EXEC: TEST_DIFF_CANONIFIER='sed -r "s/[0-9]{2}/XX/g" | sed -r "s/\(.\..\..\)/(X.X.X)/g" | $SCRIPTS/diff-remove-abspath btest-diff' btest-diff .stderr 12 | # @TEST-EXEC: btest-diff package.log 13 | # 14 | 15 | export LOG=$(pwd)/package.log 16 | 17 | ( 18 | cd packages/foo 19 | cat >>zkg.meta <> $LOG 21 | build_command = echo "Building foo" >> $LOG 22 | depends = 23 | spicy-plugin <6.0.0 24 | EOF 25 | git commit -am 'foo: depends on spicy-plugin' 26 | git checkout -b origin/main 27 | ) 28 | 29 | # Create a bundle 30 | mkdir the-bundle 31 | cp -R packages/foo ./the-bundle 32 | echo -e '[bundle]\n/one/alice/foo = main' >> the-bundle/manifest.txt 33 | tar -cf bundle.tar -C ./the-bundle . 34 | -------------------------------------------------------------------------------- /testing/tests/upgrade-test-fail: -------------------------------------------------------------------------------- 1 | # @TEST-DOC: Upgrading fails when a test_comamnd fails, even with --force. 2 | # @TEST-REQUIRES: type zeek-config 3 | # @TEST-EXEC: (cd packages/foo && echo 'print "foo 1.0.2";' >> __load__.zeek && git tag -a 1.0.2 -m 1.0.2 ) 4 | 5 | # @TEST-EXEC: zkg install foo >>out 2>&1 6 | 7 | # @TEST-EXEC: bash improve-foo-tag-1.0.3 8 | 9 | # @TEST-EXEC: zkg refresh 10 | # 11 | # @TEST-EXEC: echo "=== upgrade without skiptests" >>out 12 | # @TEST-EXEC-FAIL: zkg upgrade --force >>out 2>&1 13 | 14 | # The upgrade failed, no 1.0.3 to be found in the __load__.zeek file 15 | # @TEST-EXEC-FAIL: grep -F '1.0.3' scripts/packages/foo/__load__.zeek >>out 16 | # 17 | # @TEST-EXEC: echo "=== upgrade with skiptest" >>out 18 | # @TEST-EXEC: zkg upgrade --force --skiptests >>out 2>&1 19 | # @TEST-EXEC: grep -F '1.0.3' scripts/packages/foo/__load__.zeek >>out 20 | # 21 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out 22 | 23 | @TEST-START-FILE improve-foo-tag-1.0.3 24 | set -e 25 | cd packages/foo 26 | echo 'test_command = exit 1' >> zkg.meta 27 | echo 'print "foo 1.0.3";' > __load__.zeek 28 | git add zkg.meta 29 | git commit -am 'add a test' 30 | git tag -a 1.0.3 -m 1.0.3 31 | @TEST-END-FILE 32 | -------------------------------------------------------------------------------- /doc/overview.rst: -------------------------------------------------------------------------------- 1 | .. _Zeek: https://www.zeek.org 2 | .. _Zeek package source: https://github.com/zeek/packages 3 | .. _documentation: https://docs.zeek.org/projects/package-manager 4 | 5 | Zeek Package Manager 6 | ==================== 7 | 8 | The Zeek Package Manager makes it easy for Zeek users to install and 9 | manage third party scripts as well as plugins for Zeek and ZeekControl. 10 | The command-line tool is preconfigured to download packages from the 11 | `Zeek package source`_ , a GitHub repository that has been set up such 12 | that any developer can request their Zeek package be included. See the 13 | ``README`` file of that repository for information regarding the package 14 | submission process. 15 | 16 | .. note:: 17 | 18 | It's left up to users to decide for themselves via code review, 19 | GitHub comments/stars, or other metrics whether any given package 20 | is trustworthy as there is no implied guarantees that it's secure 21 | just because it's been accepted into the default package source. 22 | 23 | See the package manager documentation_ for further usage information, 24 | how-to guides, and walkthroughs. For offline reading, it's also 25 | available in the ``doc/`` directory of the source code distribution. 26 | -------------------------------------------------------------------------------- /testing/tests/upgrade: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash setup_foo 2 | 3 | # @TEST-EXEC: zkg install foo bar 4 | 5 | # @TEST-EXEC: bash %INPUT 6 | 7 | # @TEST-EXEC: zkg refresh 8 | # @TEST-EXEC: zkg upgrade 9 | 10 | # @TEST-EXEC: btest-diff scripts/packages/foo/__load__.zeek 11 | # @TEST-EXEC: btest-diff scripts/packages/bar/__load__.zeek 12 | 13 | @TEST-START-FILE setup_foo 14 | cd packages/foo 15 | echo 'print "foo 1.0.0";' > __load__.zeek 16 | git commit -am 'new stuff' 17 | git tag -a 1.0.0 -m 1.0.0 18 | echo 'print "foo 1.0.1";' > __load__.zeek 19 | git commit -am 'new stuff' 20 | git tag -a 1.0.1 -m 1.0.1 21 | echo 'print "foo 1.0.2";' > __load__.zeek 22 | git commit -am 'new stuff' 23 | git tag -a 1.0.2 -m 1.0.2 24 | @TEST-END-FILE 25 | 26 | cd packages/foo 27 | echo 'print "foo 1.0.3";' > __load__.zeek 28 | git commit -am 'new stuff' 29 | git tag -a 1.0.3 -m 1.0.3 30 | echo 'print "foo 1.0.4";' > __load__.zeek 31 | git commit -am 'new stuff' 32 | git tag -a 1.0.4 -m 1.0.4 33 | echo 'print "foo master";' > __load__.zeek 34 | git commit -am 'new stuff' 35 | 36 | cd ../bar 37 | echo 'print "bar+ loaded";' > __load__.zeek 38 | git commit -am 'new stuff' 39 | echo 'print "bar 1.0.0 loaded";' > __load__.zeek 40 | git commit -am 'new stuff' 41 | git tag -a 1.0.0 -m 1.0.0 42 | echo 'print "bar++ loaded";' > __load__.zeek 43 | git commit -am 'new stuff' 44 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5 FATAL_ERROR) 2 | project(zkg) 3 | 4 | set(ZEEK_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin) 5 | set(orig_file ${CMAKE_CURRENT_SOURCE_DIR}/zkg) 6 | set(configed_file ${CMAKE_CURRENT_BINARY_DIR}/zkg) 7 | configure_file(${orig_file} ${configed_file} @ONLY) 8 | 9 | # Install zkg 10 | install(DIRECTORY DESTINATION bin) 11 | install(PROGRAMS ${configed_file} DESTINATION bin) 12 | 13 | if ( NOT PY_MOD_INSTALL_DIR ) 14 | # This is not a Zeek-bundled install. Default to "home"-style install. 15 | set(PY_MOD_INSTALL_DIR lib/python) 16 | endif () 17 | 18 | # Install the Python module tree 19 | install(DIRECTORY DESTINATION ${PY_MOD_INSTALL_DIR}) 20 | install(DIRECTORY zeekpkg DESTINATION ${PY_MOD_INSTALL_DIR}) 21 | 22 | if ( NOT ZEEK_MAN_INSTALL_PATH ) 23 | set(ZEEK_MAN_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/man) 24 | endif () 25 | 26 | install(FILES doc/man/zkg.1 DESTINATION ${ZEEK_MAN_INSTALL_PATH}/man1) 27 | 28 | message( 29 | "\n=====================| ZKG Build Summary |====================" 30 | "\n" 31 | "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" 32 | "\nPython module path: ${PY_MOD_INSTALL_DIR}" 33 | "\nConfig path: ${ZEEK_ZKG_CONFIG_DIR}" 34 | "\nState path: ${ZEEK_ZKG_STATE_DIR}" 35 | "\n" 36 | "\n================================================================\n" 37 | ) 38 | -------------------------------------------------------------------------------- /testing/baselines/tests.aliases-conflict/out: -------------------------------------------------------------------------------- 1 | ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. 2 | Installing "one/alice/foo" 3 | Installed "one/alice/foo" (main) 4 | Loaded "one/alice/foo" 5 | Installing "one/alice/bar" 6 | error: incomplete installation, the follow packages failed to be installed: 7 | one/alice/bar (master) 8 | Failed installing "one/alice/bar": name "bar" conflicts with alias from "one/alice/foo" 9 | Installing "one/alice/baz" 10 | error: incomplete installation, the follow packages failed to be installed: 11 | one/alice/baz (master) 12 | Failed installing "one/alice/baz": alias "foo" conflicts with name of installed package "one/alice/foo" 13 | Installing "one/bob/corge" 14 | error: incomplete installation, the follow packages failed to be installed: 15 | one/bob/corge (master) 16 | Failed installing "one/bob/corge": alias "bar" conflicts with alias of installed package "one/alice/foo" 17 | Removed "one/alice/foo" 18 | Installing "one/alice/baz" 19 | Installed "one/alice/baz" (master) 20 | Loaded "one/alice/baz" 21 | Installing "one/bob/corge" 22 | Installed "one/bob/corge" (master) 23 | Loaded "one/bob/corge" 24 | Installing "one/alice/foo" 25 | error: incomplete installation, the follow packages failed to be installed: 26 | one/alice/foo (main) 27 | Failed installing "one/alice/foo": name "foo" conflicts with alias from "one/alice/baz" 28 | -------------------------------------------------------------------------------- /testing/tests/info: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo 2 | # @TEST-EXEC: bash %INPUT 3 | # @TEST-EXEC: zkg refresh 4 | # @TEST-EXEC: zkg install bar 5 | 6 | # @TEST-EXEC: zkg info foo | grep -v 'url:' | grep -v 'current_hash' > foo.info 7 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff foo.info 8 | 9 | # @TEST-EXEC: zkg info bar | grep -v 'url:' | grep -v 'current_hash' > bar.info 10 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff bar.info 11 | 12 | # @TEST-EXEC: zkg remove bar 13 | # @TEST-EXEC: zkg info installed | grep -v 'url:' | grep -v 'current_hash' > installed.info 14 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff installed.info 15 | 16 | cd packages/foo 17 | echo 'print "foo 1.0.0";' > __load__.zeek 18 | git commit -am 'new stuff' 19 | git tag -a 1.0.0 -m 1.0.0 20 | echo 'print "foo 1.0.1";' > __load__.zeek 21 | git commit -am 'new stuff' 22 | git tag -a 1.0.1 -m 1.0.1 23 | echo 'print "foo 1.0.2";' > __load__.zeek 24 | git commit -am 'new stuff' 25 | git tag -a 1.0.2 -m 1.0.2 26 | 27 | cd ../bar 28 | echo 'print "bar+ loaded";' > __load__.zeek 29 | git commit -am 'new stuff' 30 | echo 'print "bar 1.0.0 loaded";' > __load__.zeek 31 | echo 'tags = sega sunset' >> zkg.meta 32 | echo 'description = bar bar bar' >> zkg.meta 33 | git commit -am 'new stuff' 34 | git tag -a 1.0.0 -m 1.0.0 35 | echo 'print "bar++ loaded";' > __load__.zeek 36 | git commit -am 'new stuff' 37 | -------------------------------------------------------------------------------- /testing/tests/metadata-config_files: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash setup 2 | 3 | # @TEST-EXEC: zkg install foo bar 4 | 5 | # @TEST-EXEC: bash %INPUT 6 | 7 | # @TEST-EXEC: zkg refresh 8 | # @TEST-EXEC: zkg upgrade foo 9 | 10 | # @TEST-EXEC: btest-diff scripts/foo/config.zeek 11 | # @TEST-EXEC: btest-diff scripts/bar/config.zeek 12 | # @TEST-EXEC: cp state/backups/one/alice/foo/config.zeek* foo_backup.zeek 13 | # @TEST-EXEC: btest-diff foo_backup.zeek 14 | 15 | # @TEST-EXEC: zkg install bar --version=2.0.0 16 | # @TEST-EXEC: cp scripts/bar/config.zeek barconfig2.zeek 17 | # @TEST-EXEC: btest-diff barconfig2.zeek 18 | # @TEST-EXEC: cp state/backups/one/alice/bar/config.zeek* bar_backup.zeek 19 | # @TEST-EXEC: btest-diff bar_backup.zeek 20 | 21 | @TEST-START-FILE setup 22 | cd packages/foo 23 | echo 'print "foo orig";' > config.zeek 24 | echo 'config_files = config.zeek' >> zkg.meta 25 | git add * 26 | git commit -am 'new stuff' 27 | 28 | cd ../bar 29 | echo 'print "bar 1.0.0";' > config.zeek 30 | echo 'config_files = config.zeek' >> zkg.meta 31 | git add * 32 | git commit -am 'new stuff' 33 | git tag -a 1.0.0 -m 1.0.0 34 | @TEST-END-FILE 35 | 36 | echo 'print "foo mod";' > scripts/foo/config.zeek 37 | echo 'print "bar mod";' > scripts/bar/config.zeek 38 | 39 | cd packages/foo 40 | echo 'print "foo new";' > config.zeek 41 | git commit -am 'new stuff' 42 | 43 | cd ../bar 44 | echo 'print "bar 2.0.0";' > config.zeek 45 | git commit -am 'new stuff' 46 | git tag -a 2.0.0 -m 2.0.0 47 | -------------------------------------------------------------------------------- /testing/tests/dependency-management: -------------------------------------------------------------------------------- 1 | # This test puts in place a dependency chain and then verifies zkg's behavior 2 | # when the state of individual packages in that chain changes. The chain: 3 | # 4 | # foo -> bar (*) -> baz (>=1.0.0) -> grault (==1.0.0) -> corge (==1.0.0) 5 | 6 | # @TEST-EXEC: bash %INPUT 7 | 8 | # @TEST-EXEC: echo '** Install grault' >out 9 | # @TEST-EXEC: zkg install grault >>out 10 | 11 | # @TEST-EXEC: echo '** Unload grault' >>out 12 | # @TEST-EXEC: zkg unload grault >>out 13 | 14 | # @TEST-EXEC: echo '** Install foo' >>out 15 | # @TEST-EXEC: zkg install foo >>out 16 | 17 | # @TEST-EXEC: echo '** Unload foo' >>out 18 | # @TEST-EXEC: zkg unload foo >>out 19 | 20 | # @TEST-EXEC: echo '** Load foo' >>out 21 | # @TEST-EXEC: zkg load foo >>out 22 | 23 | # @TEST-EXEC: echo '** Unload bar' >>out 24 | # @TEST-EXEC: zkg unload bar>>out 25 | 26 | # @TEST-EXEC: echo '** Remove grault' >>out 27 | # @TEST-EXEC: zkg remove grault >>out 28 | 29 | # @TEST-EXEC: btest-diff out 30 | 31 | cd packages/foo 32 | echo 'depends = bar *' >> zkg.meta 33 | git commit -am 'foo now depends on bar' 34 | 35 | cd ../bar 36 | echo 'depends = baz >=1.0.0' >> zkg.meta 37 | git commit -am 'bar now depends on baz >= 1.0.0' 38 | git tag -a 1.0.0 -m 1.0.0 39 | 40 | cd ../baz 41 | echo 'depends = grault ==1.0.0' >> zkg.meta 42 | git commit -am 'baz now depends on grault 1.0.0' 43 | git tag -a 1.0.0 -m 1.0.0 44 | 45 | cd ../grault 46 | echo 'depends = corge ==1.0.0' >> zkg.meta 47 | git commit -am 'grault now depends on corge 1.0.0' 48 | git tag -a 1.0.0 -m 1.0.0 49 | 50 | cd ../corge 51 | git tag -a 1.0.0 -m 1.0.0 52 | -------------------------------------------------------------------------------- /testing/tests/user-mode: -------------------------------------------------------------------------------- 1 | # Establish a skeletal Zeek installation layout and alternative home directory 2 | # @TEST-EXEC: setup-zeek-and-home 3 | 4 | # Pretending to be the Zeek-bundled zkg, install a package and show it 5 | # @TEST-EXEC: zkg-zeek config >>output 6 | # @TEST-EXEC: zkg-zeek install --force foo >>output 7 | # @TEST-EXEC: zkg-zeek list >>output 8 | 9 | # At this point, zkg should have crated manifest and package state in 10 | # the Zeek install tree. The home directory should still be left 11 | # alone. 12 | # @TEST-EXEC: test -f zeekroot/var/lib/zkg/manifest.json 13 | # @TEST-EXEC: test -f zeekroot/share/zeek/site/packages/foo/__load__.zeek 14 | # @TEST-EXEC: test ! -d home/testuser/.zkg 15 | 16 | # Switching to user mode, install a different package. 17 | # @TEST-EXEC: zkg-zeek --user --extra-source zeek=$(pwd)/sources/one install --force bar >>output 18 | # 19 | # Only that package should get listed, and zkg should have built up 20 | # state in the home directory. 21 | # @TEST-EXEC: zkg-zeek --user list >>output 22 | # @TEST-EXEC: test -f home/testuser/.zkg/manifest.json 23 | # @TEST-EXEC: test ! -f home/testuser/.zkg/script_dir/packages/foo/__load__.zeek 24 | # @TEST-EXEC: test -f home/testuser/.zkg/script_dir/packages/bar/__load__.zeek 25 | 26 | # So far this didn't need a config file, but we can produce one: 27 | # @TEST-EXEC: test ! -f home/testuser/.zkg/config 28 | # @TEST-EXEC: zkg-zeek --user autoconfig >>output 29 | # @TEST-EXEC: test -f home/testuser/.zkg/config 30 | # @TEST-EXEC: zkg-zeek --user config >>output 31 | 32 | # @TEST-EXEC: TEST_DIFF_CANONIFIER="$SCRIPTS/diff-remove-cwd" btest-diff output 33 | -------------------------------------------------------------------------------- /testing/tests/pin: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash setup_foo 2 | 3 | # @TEST-EXEC: zkg install foo bar 4 | # @TEST-EXEC: zkg pin foo bar 5 | 6 | # @TEST-EXEC: bash %INPUT 7 | 8 | # @TEST-EXEC: zkg refresh 9 | # @TEST-EXEC-FAIL: zkg upgrade 10 | 11 | # @TEST-EXEC: btest-diff scripts/packages/foo/__load__.zeek 12 | # @TEST-EXEC: btest-diff scripts/packages/bar/__load__.zeek 13 | 14 | # @TEST-EXEC: zkg unpin foo bar 15 | # @TEST-EXEC: zkg upgrade 16 | # @TEST-EXEC: cp scripts/packages/foo/__load__.zeek foo_after_unpin.out 17 | # @TEST-EXEC: cp scripts/packages/bar/__load__.zeek bar_after_unpin.out 18 | # @TEST-EXEC: btest-diff foo_after_unpin.out 19 | # @TEST-EXEC: btest-diff bar_after_unpin.out 20 | 21 | @TEST-START-FILE setup_foo 22 | cd packages/foo 23 | echo 'print "foo 1.0.0";' > __load__.zeek 24 | git commit -am 'new stuff' 25 | git tag -a 1.0.0 -m 1.0.0 26 | echo 'print "foo 1.0.1";' > __load__.zeek 27 | git commit -am 'new stuff' 28 | git tag -a 1.0.1 -m 1.0.1 29 | echo 'print "foo 1.0.2";' > __load__.zeek 30 | git commit -am 'new stuff' 31 | git tag -a 1.0.2 -m 1.0.2 32 | @TEST-END-FILE 33 | 34 | cd packages/foo 35 | echo 'print "foo 1.0.3";' > __load__.zeek 36 | git commit -am 'new stuff' 37 | git tag -a 1.0.3 -m 1.0.3 38 | echo 'print "foo 1.0.4";' > __load__.zeek 39 | git commit -am 'new stuff' 40 | git tag -a 1.0.4 -m 1.0.4 41 | echo 'print "foo master";' > __load__.zeek 42 | git commit -am 'new stuff' 43 | 44 | cd ../bar 45 | echo 'print "bar+ loaded";' > __load__.zeek 46 | git commit -am 'new stuff' 47 | echo 'print "bar 1.0.0 loaded";' > __load__.zeek 48 | git commit -am 'new stuff' 49 | git tag -a 1.0.0 -m 1.0.0 50 | echo 'print "bar++ loaded";' > __load__.zeek 51 | git commit -am 'new stuff' 52 | -------------------------------------------------------------------------------- /testing/tests/metadata-depends: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo 2 | # @TEST-EXEC: zkg list installed > no_depends.out 3 | # @TEST-EXEC: btest-diff no_depends.out 4 | 5 | # @TEST-EXEC: bash %INPUT 6 | 7 | # @TEST-EXEC: zkg refresh 8 | # @TEST-EXEC: zkg upgrade foo 9 | # @TEST-EXEC: zkg list installed > upgrade_depends.out 10 | # @TEST-EXEC: btest-diff upgrade_depends.out 11 | 12 | # @TEST-EXEC: zkg purge 13 | # @TEST-EXEC: zkg install foo 14 | # @TEST-EXEC: zkg list installed > install_depends.out 15 | # @TEST-EXEC: btest-diff install_depends.out 16 | 17 | # @TEST-EXEC: zkg purge 18 | # @TEST-EXEC: zkg bundle test.bundle --manifest foo 19 | # @TEST-EXEC: zkg unbundle test.bundle 20 | # @TEST-EXEC: zkg list installed > bundle_depends.out 21 | # @TEST-EXEC: btest-diff bundle_depends.out 22 | 23 | cd packages/foo 24 | echo 'depends = bar *' >> zkg.meta 25 | git commit -am 'new stuff' 26 | 27 | cd ../bar 28 | echo 'depends = baz >=1.0.0' >> zkg.meta 29 | git commit -am 'new stuff' 30 | git tag -a 1.0.0 -m 1.0.0 31 | 32 | default_branch_name=$( cd ../grault && git rev-parse --abbrev-ref HEAD ) 33 | 34 | cd ../baz 35 | echo "depends = grault branch=${default_branch_name}" >> zkg.meta 36 | git commit -am 'new stuff' 37 | git tag -a 1.0.0 -m 1.0.0 38 | echo 'print "2.0.0";' > __load__.zeek 39 | git commit -am 'new stuff' 40 | git tag -a 2.0.0 -m 2.0.0 41 | 42 | cd ../grault 43 | echo 'depends = corge ==1.0.1' >> zkg.meta 44 | git commit -am 'new stuff' 45 | git tag -a 1.0.0 -m 1.0.0 46 | 47 | cd ../corge 48 | git tag -a 1.0.0 -m 1.0.0 49 | echo 'depends = foo * bar *' >> zkg.meta 50 | git commit -am 'new stuff' 51 | git tag -a 1.0.1 -m 1.0.1 52 | echo 'print "2.0.0";' > __load__.zeek 53 | git commit -am 'new stuff' 54 | git tag -a 2.0.0 -m 2.0.0 55 | -------------------------------------------------------------------------------- /testing/tests/bundle: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: bash %INPUT 2 | # @TEST-EXEC: zkg install foo baz 3 | # @TEST-EXEC: zkg install bar --version 1.0.0 4 | # @TEST-EXEC: zkg bundle test.bundle 5 | # @TEST-EXEC: zkg purge 6 | # @TEST-EXEC: zkg unbundle test.bundle 7 | # @TEST-EXEC: zkg list installed > snapshot.out 8 | # @TEST-EXEC: btest-diff snapshot.out 9 | 10 | # @TEST-EXEC: zkg purge 11 | # @TEST-EXEC: zkg bundle test.bundle --manifest foo bar baz 12 | # @TEST-EXEC: zkg unbundle test.bundle 13 | # @TEST-EXEC: zkg list installed > args.out 14 | # @TEST-EXEC: btest-diff args.out 15 | 16 | # @TEST-EXEC: zkg purge 17 | # @TEST-EXEC: zkg bundle test.bundle --manifest manifest.txt 18 | # @TEST-EXEC: zkg unbundle test.bundle 19 | # @TEST-EXEC: zkg list installed > manifest.out 20 | # @TEST-EXEC: btest-diff manifest.out 21 | 22 | default_branch_name=$( cd packages/baz && git rev-parse --abbrev-ref HEAD ) 23 | echo "[bundle]" > manifest.txt 24 | echo "foo = 1.0.0" >> manifest.txt 25 | echo "bar = 1.0.1" >> manifest.txt 26 | echo "baz = ${default_branch_name}" >> manifest.txt 27 | 28 | cd packages/foo 29 | echo 'print "foo 1.0.0";' > __load__.zeek 30 | git commit -am 'new stuff' 31 | git tag -a 1.0.0 -m 1.0.0 32 | echo 'print "foo 1.0.1";' > __load__.zeek 33 | git commit -am 'new stuff' 34 | git tag -a 1.0.1 -m 1.0.1 35 | echo 'print "foo 1.0.2";' > __load__.zeek 36 | git commit -am 'new stuff' 37 | git tag -a 1.0.2 -m 1.0.2 38 | 39 | cd ../bar 40 | echo 'print "bar 1.0.0";' > __load__.zeek 41 | git commit -am 'new stuff' 42 | git tag -a 1.0.0 -m 1.0.0 43 | echo 'print "bar 1.0.1";' > __load__.zeek 44 | git commit -am 'new stuff' 45 | git tag -a 1.0.1 -m 1.0.1 46 | echo 'print "bar 1.0.2";' > __load__.zeek 47 | git commit -am 'new stuff' 48 | git tag -a 1.0.2 -m 1.0.2 49 | -------------------------------------------------------------------------------- /testing/tests/metadata-suggests: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo 2 | # @TEST-EXEC: zkg list installed > no_suggests.out 3 | # @TEST-EXEC: btest-diff no_suggests.out 4 | 5 | # @TEST-EXEC: bash %INPUT 6 | 7 | # @TEST-EXEC: zkg refresh 8 | # @TEST-EXEC: zkg upgrade foo 9 | # @TEST-EXEC: zkg list installed > upgrade_suggests.out 10 | # @TEST-EXEC: btest-diff upgrade_suggests.out 11 | 12 | # @TEST-EXEC: zkg purge 13 | # @TEST-EXEC: zkg install foo 14 | # @TEST-EXEC: zkg list installed > install_suggests.out 15 | # @TEST-EXEC: btest-diff install_suggests.out 16 | 17 | # @TEST-EXEC: zkg purge 18 | # @TEST-EXEC: zkg bundle test.bundle --manifest foo 19 | # @TEST-EXEC: zkg unbundle test.bundle 20 | # @TEST-EXEC: zkg list installed > bundle_suggests.out 21 | # @TEST-EXEC: btest-diff bundle_suggests.out 22 | 23 | cd packages/foo 24 | echo 'suggests = bar *' >> zkg.meta 25 | git commit -am 'new stuff' 26 | 27 | cd ../bar 28 | echo 'suggests = baz >=1.0.0' >> zkg.meta 29 | git commit -am 'new stuff' 30 | git tag -a 1.0.0 -m 1.0.0 31 | 32 | default_branch_name=$( cd ../grault && git rev-parse --abbrev-ref HEAD ) 33 | 34 | cd ../baz 35 | echo "suggests = grault branch=${default_branch_name}" >> zkg.meta 36 | git commit -am 'new stuff' 37 | git tag -a 1.0.0 -m 1.0.0 38 | echo 'print "2.0.0";' > __load__.zeek 39 | git commit -am 'new stuff' 40 | git tag -a 2.0.0 -m 2.0.0 41 | 42 | cd ../grault 43 | echo 'suggests = corge ==1.0.1' >> zkg.meta 44 | git commit -am 'new stuff' 45 | git tag -a 1.0.0 -m 1.0.0 46 | 47 | cd ../corge 48 | git tag -a 1.0.0 -m 1.0.0 49 | echo 'suggests = foo * bar *' >> zkg.meta 50 | git commit -am 'new stuff' 51 | git tag -a 1.0.1 -m 1.0.1 52 | echo 'print "2.0.0";' > __load__.zeek 53 | git commit -am 'new stuff' 54 | git tag -a 2.0.0 -m 2.0.0 55 | -------------------------------------------------------------------------------- /testing/packages/rot13/COPYING.edit-me: -------------------------------------------------------------------------------- 1 | ### 2 | ### This is a BSD-style license. If you're happy with it, just edit 3 | ### the XXX parts below and remove this comment. Otherwise, put in 4 | ### your own license instead. 5 | ### 6 | 7 | Copyright (c) 2015 by 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | (1) Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | (2) Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in 17 | the documentation and/or other materials provided with the 18 | distribution. 19 | 20 | (3) Neither the name of , nor 21 | the names of contributors may be used to endorse or promote 22 | products derived from this software without specific prior written 23 | permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /testing/scripts/initializer: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # 3 | # This initializer runs prior to every test. It creates a fresh copy of our 4 | # test packages and package sources. Individual tests may tweak these further as 5 | # needed, prior to running tests with them. The initializer also creates a zkg 6 | # config that all tests automatically run with, via the "zkg" wrapper script in 7 | # this directory. 8 | 9 | cp -R $PACKAGES . 10 | 11 | for p in packages/*; do 12 | if [ $p = 'packages/foo' ]; then 13 | # Use a different default branch than 'master' for testing purposes 14 | ( cd $p && git init && git checkout -b main && git add * && git commit -m 'init' ) 15 | else 16 | ( cd $p && git init && git add * && git commit -m 'init' ) 17 | fi 18 | done 19 | 20 | cp -R $SOURCES . 21 | 22 | find sources -name 'zkg.index' -exec sed -i -e "s#^#$(pwd)/packages/#" {} \; 23 | 24 | for s in sources/*; do 25 | ( cd $s && git init && git add * && git commit -m 'init' ) 26 | done 27 | 28 | # Create a branch drop-corge in source "one" to drop corge from index 29 | ( cd sources/one && 30 | default_branch=$(git rev-parse --abbrev-ref HEAD) && 31 | git checkout -b drop-corge && 32 | sed -i -e '/corge/d' bob/zkg.index && 33 | git add ./bob/zkg.index && 34 | git commit -m 'Remove corge' && 35 | git checkout ${default_branch} ) 36 | 37 | cp -R $TEMPLATES . 38 | 39 | for t in templates/*; do 40 | ( 41 | cd $t && git init && git add * && git commit -m 'init' 42 | git remote add origin https://example.com/zeek/package-template 43 | ) 44 | done 45 | 46 | echo "\ 47 | [sources] 48 | one = $(pwd)/sources/one 49 | [paths] 50 | state_dir = $(pwd)/state 51 | script_dir = $(pwd)/scripts 52 | plugin_dir = $(pwd)/plugins 53 | bin_dir = $(pwd)/bin 54 | " >> config 55 | 56 | type zeek-config > /dev/null 2>&1 && echo "zeek_dist = $(zeek-config --zeek_dist)" >> config || true 57 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools", 4 | ] 5 | 6 | [project] 7 | name = "zkg" 8 | dynamic = ["version"] 9 | description = "The Zeek Package Manager" 10 | readme = "README" 11 | 12 | requires-python = ">= 3.10" 13 | 14 | keywords = [ 15 | "zeek", 16 | "zeekctl", 17 | "zeekcontrol", 18 | "package", 19 | "manager", 20 | "scripts", 21 | "plugins", 22 | "security", 23 | ] 24 | 25 | classifiers = [ 26 | "Development Status :: 5 - Production/Stable", 27 | "Environment :: Console", 28 | "License :: OSI Approved :: University of Illinois/NCSA Open Source License", 29 | "Operating System :: POSIX :: Linux", 30 | "Operating System :: MacOS :: MacOS X", 31 | "Programming Language :: Python :: 3", 32 | "Topic :: System :: Networking :: Monitoring", 33 | "Topic :: Utilities", 34 | ] 35 | 36 | # NOTE: Keep `requirements.txt` in sync which we currently use e.g., for RTD. 37 | dependencies = [ 38 | "GitPython>=3.1.43", 39 | "semantic_version>=2.10.0", 40 | # Technically not a zkg dependency, but typically expected by users to be present. 41 | "btest>=1.1", 42 | ] 43 | 44 | [project.optional-dependencies] 45 | dev = [ 46 | "Sphinx>=7.2.6", 47 | "sphinx_rtd_theme>=2.0.0", 48 | ] 49 | 50 | [project.license] 51 | file = "COPYING" 52 | 53 | [project.urls] 54 | Homepage = "https://docs.zeek.org/projects/package-manager" 55 | Repository = "https://github.com/zeek/package-manager" 56 | 57 | [[project.maintainers]] 58 | name = "The Zeek Project" 59 | email = "info@zeek.org" 60 | 61 | [tool.setuptools] 62 | packages = ["zeekpkg"] 63 | script-files = ["zkg"] 64 | 65 | [tool.distutils.bdist_wheel] 66 | universal = true 67 | 68 | [[tool.mypy.overrides]] 69 | module = ["zeekpkg", "semantic_version"] 70 | ignore_missing_imports = true 71 | 72 | [tool.ruff.lint] 73 | select = ["A", "B", "C4", "COM", "F", "I", "ISC", "N", "PL", "RUF", "RET", "UP"] 74 | ignore = ["PLR0912", "PLR0915", "PLR0911", "PLR0913", "PLR2004", "PLW2901"] 75 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The Board of Trustees of the University of Illinois. 2 | All rights reserved. 3 | 4 | Developed by: 5 | 6 | Cybersecurity Directorate 7 | National Center for Supercomputing Applications 8 | University of Illinois 9 | http://illinois.edu 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a 12 | copy of this software and associated documentation files (the 13 | "Software"), to deal with the Software without restriction, including 14 | without limitation the rights to use, copy, modify, merge, publish, 15 | distribute, sublicense, and/or sell copies of the Software, and to 16 | permit persons to whom the Software is furnished to do so, subject to 17 | the following conditions: 18 | 19 | * Redistributions of source code must retain the above copyright 20 | notice, this list of conditions and the following disclaimers. 21 | 22 | * Redistributions in binary form must reproduce the above copyright 23 | notice, this list of conditions and the following disclaimers in 24 | the documentation and/or other materials provided with the 25 | distribution. 26 | 27 | * Neither the names of the National Center for Supercomputing 28 | Applications, the University of Illinois, nor the names of its 29 | contributors may be used to endorse or promote products derived 30 | from this Software without specific prior written permission. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 33 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 34 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 35 | IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR 36 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 37 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 38 | SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. 39 | 40 | Note that some files in the distribution may carry their own copyright 41 | notices. 42 | -------------------------------------------------------------------------------- /testing/templates/foo/__init__.py: -------------------------------------------------------------------------------- 1 | import zeekpkg.template 2 | import zeekpkg.uservar 3 | 4 | TEMPLATE_API_VERSION = "1.0.0" 5 | 6 | 7 | class Package(zeekpkg.template.Package): 8 | def contentdir(self) -> str: 9 | return "package" 10 | 11 | def needed_user_vars(self) -> list[str]: 12 | return ["name"] 13 | 14 | def validate(self, tmpl: zeekpkg.template.Template) -> None: 15 | if not tmpl.lookup_param("name"): 16 | raise zeekpkg.template.InputError("package requires a name") 17 | 18 | 19 | class Readme(zeekpkg.template.Feature): 20 | def contentdir(self) -> str: 21 | return "readme" 22 | 23 | def needed_user_vars(self) -> list[str]: 24 | return ["readme"] 25 | 26 | def validate(self, tmpl: zeekpkg.template.Template) -> None: 27 | pass 28 | 29 | 30 | class Template(zeekpkg.template.Template): 31 | def define_user_vars(self) -> list[zeekpkg.uservar.UserVar]: 32 | return [ 33 | zeekpkg.uservar.UserVar( 34 | "name", 35 | desc='the name of the package, e.g. "FooBar"', 36 | ), 37 | zeekpkg.uservar.UserVar( 38 | "readme", 39 | desc="Content of the README file", 40 | val="This is a README.", 41 | ), 42 | ] 43 | 44 | def apply_user_vars(self, user_vars: list[zeekpkg.uservar.UserVar]) -> None: 45 | for uvar in user_vars: 46 | val = uvar.val() 47 | assert val 48 | 49 | if uvar.name() == "name": 50 | self.define_param("name", val) 51 | self.define_param("module", val.upper()) 52 | if uvar.name() == "readme": 53 | self.define_param("readme", val) 54 | 55 | def package(self) -> Package: 56 | return Package() 57 | 58 | def features(self) -> list[zeekpkg.template.Feature]: 59 | return [Readme()] 60 | 61 | def validate(self, tmpl: zeekpkg.template.Template) -> None: 62 | pass 63 | -------------------------------------------------------------------------------- /testing/tests/template-create: -------------------------------------------------------------------------------- 1 | # This test verifies template instantiation. 2 | 3 | # Provide variable via --user-var and ensure resulting package installs 4 | # @TEST-EXEC: zkg create --packagedir out1 --template $TEMPLATES/foo --user-var name=test1 >output 5 | # @TEST-EXEC: zkg install ./out1 6 | 7 | # Provide variable via environment and ensure resulting package installs. 8 | # @TEST-EXEC: name=test2 zkg create --packagedir out2 --template $TEMPLATES/foo >>output 9 | # @TEST-EXEC: zkg install ./out2 10 | # 11 | # Verify the README does not exist -- it's provided by a template feature 12 | # @TEST-EXEC: test ! -f out2/README 13 | 14 | # Same as first test, but now request the readme feature. This uses 15 | # --force to suppress user input, making user var resolution fall back 16 | # to the default for the readme parameter. 17 | # @TEST-EXEC: zkg create --force --packagedir out3 --template $TEMPLATES/foo --feature readme --user-var name=test3 >>output 18 | # @TEST-EXEC: zkg install ./out3 19 | # @TEST-EXEC: btest-diff out3/README 20 | # @TEST-EXEC: btest-diff out3/scripts/main.zeek 21 | # 22 | # Verify the zkg.meta content. 23 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-zkg-version btest-diff out3/zkg.meta 24 | 25 | # Create a package from a git-versioned template repo -- this has different 26 | # information in zkg.meta: 27 | # @TEST-EXEC: zkg create --packagedir out4 --template templates/foo --user-var name=test4 >>output 28 | # @TEST-EXEC: TEST_DIFF_CANONIFIER="$SCRIPTS/diff-remove-zkg-version | $SCRIPTS/diff-remove-zkg-meta-commit" btest-diff out4/zkg.meta 29 | 30 | # zkg should now have the first three packages installed. 31 | # @TEST-EXEC: zkg list >>output 32 | 33 | # Fail to provide a user variable when using --force (thus suppressing input). This should fail. 34 | # @TEST-EXEC-FAIL: zkg create --force --packagedir out4 --template $TEMPLATES/foo >>output 2>&1 35 | 36 | # Request an unknown feature. This should fail. 37 | # @TEST-EXEC-FAIL: zkg create --packagedir out5 --template $TEMPLATES/foo --feature doesntexist >>output 2>&1 38 | 39 | # Provide non-ASCII characters variable via --user-var and ensure resulting package installs 40 | # @TEST-EXEC: zkg create --packagedir out6 --template $TEMPLATES/foo --user-var name=你こ안مγПनสXש😊©GBCDČM >>output 41 | # @TEST-EXEC: zkg install ./out6 42 | 43 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output 44 | -------------------------------------------------------------------------------- /testing/tests/install: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo 2 | # @TEST-EXEC: btest-diff scripts/packages/foo/__load__.zeek 3 | 4 | # @TEST-EXEC: zkg install alice/bar 5 | # @TEST-EXEC: btest-diff scripts/packages/bar/__load__.zeek 6 | 7 | # @TEST-EXEC: zkg install one/alice/baz 8 | # @TEST-EXEC: btest-diff scripts/packages/baz/__load__.zeek 9 | 10 | # @TEST-EXEC: zkg install $(pwd)/packages/qux 11 | # @TEST-EXEC: btest-diff scripts/packages/qux/__load__.zeek 12 | 13 | # @TEST-EXEC: bash %INPUT 14 | 15 | # @TEST-EXEC: zkg install corge 16 | # @TEST-EXEC: btest-diff scripts/packages/corge/__load__.zeek 17 | 18 | # @TEST-EXEC: zkg remove corge 19 | # @TEST-EXEC: ( cd $(pwd)/packages/corge && git rev-parse --abbrev-ref HEAD ) > default_branch_name 20 | # @TEST-EXEC: zkg install corge --version=$(cat default_branch_name) 21 | # @TEST-EXEC: cp scripts/packages/corge/__load__.zeek corge.master 22 | # @TEST-EXEC: btest-diff corge.master 23 | 24 | cd packages/corge 25 | git tag -a 1.0.0 -m 1.0.0 26 | echo 'print "hello";' >> __load__.zeek 27 | git commit -am 'new stuff' 28 | 29 | cd ../grault 30 | echo 'print "grault 1.0.0";' > __load__.zeek 31 | git commit -am 'new stuff' 32 | git tag -a 1.0.0 -m 1.0.0 33 | echo 'print "grault 1.0.1";' > __load__.zeek 34 | git commit -am 'new stuff' 35 | git tag -a v1.0.1 -m 1.0.1 36 | echo 'print "grault 1.0.2";' > __load__.zeek 37 | git commit -am 'new stuff' 38 | git tag -a 1.0.2 -m 1.0.2 39 | 40 | # @TEST-EXEC: zkg install grault 41 | # @TEST-EXEC: btest-diff scripts/packages/grault/__load__.zeek 42 | 43 | # @TEST-EXEC: zkg remove grault 44 | # @TEST-EXEC: zkg install grault --version=v1.0.1 45 | # @TEST-EXEC: cp scripts/packages/grault/__load__.zeek grault.1.0.1 46 | # @TEST-EXEC: btest-diff grault.1.0.1 47 | # 48 | # @TEST-EXEC: zkg remove grault 49 | # @TEST-EXEC: (cd packages/grault && git checkout --detach) 50 | # @TEST-EXEC: zkg install $(pwd)/packages/grault 51 | # @TEST-EXEC: cp scripts/packages/grault/__load__.zeek grault.detached 52 | # @TEST-EXEC: btest-diff grault.detached 53 | # @TEST-EXEC: zkg info grault | grep tracking_method > grault.info 54 | # @TEST-EXEC: btest-diff grault.info 55 | # 56 | # @TEST-EXEC: zkg remove grault 57 | # @TEST-EXEC: (cd packages/grault && git checkout 1.0.0) 58 | # @TEST-EXEC: (cd packages/grault && git rev-parse HEAD) > grault.head.hash 59 | # @TEST-EXEC: zkg install grault --version=$(cat grault.head.hash) 60 | # @TEST-EXEC: cp scripts/packages/grault/__load__.zeek grault.detached.head 61 | # @TEST-EXEC: btest-diff grault.detached.head 62 | # @TEST-EXEC: zkg info grault | grep tracking_method > grault.info 63 | # @TEST-EXEC: btest-diff grault.info 64 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test and upload Python package 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: [master] 7 | tags: 8 | - 'v*' 9 | - '!v*-dev' 10 | 11 | env: 12 | ZEEKROOT: /usr/local/zeek 13 | 14 | jobs: 15 | test: 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | # Test Zeek LTS, latest, and nightly, and 20 | # don't fail for the nightly one. 21 | include: 22 | - repo: zeek 23 | version: latest 24 | continue_on_error: false 25 | - repo: zeek 26 | version: lts 27 | continue_on_error: false 28 | - repo: zeek-dev 29 | version: latest 30 | continue_on_error: true 31 | 32 | runs-on: ubuntu-latest 33 | continue-on-error: ${{ matrix.continue_on_error }} 34 | container: 35 | image: zeek/${{ matrix.repo }}:${{ matrix.version }} 36 | 37 | steps: 38 | - name: Install build environment 39 | run: | 40 | apt-get update 41 | apt-get install -y --no-install-recommends cmake g++ libssl-dev libpcap-dev make 42 | - name: Remove zkg installation 43 | # Rule out confusion between test environment and pre-existing zkg: 44 | run: | 45 | rm $ZEEKROOT/bin/zkg $ZEEKROOT/share/man/man1/zkg.1 46 | rm -r $ZEEKROOT/etc/zkg 47 | rm -r $ZEEKROOT/lib/zeek/python/zeekpkg 48 | rm -r $ZEEKROOT/var/lib/zkg 49 | - uses: actions/checkout@v4 50 | - name: Run unit tests 51 | run: btest -j -A -d -c testing/btest.cfg 52 | - uses: actions/upload-artifact@v4 53 | if: failure() 54 | with: 55 | name: btest-${{ matrix.repo }}-${{ matrix.version }} 56 | path: testing/.tmp/ 57 | 58 | upload: 59 | runs-on: ubuntu-latest 60 | needs: [test] 61 | if: github.repository == 'zeek/package-manager' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') 62 | steps: 63 | - uses: actions/checkout@v4 64 | - name: Check release version 65 | # This fails e.g. if VERSION contains a dev commits suffix, 66 | # since we don't want to push these to PyPI. Accepts two- 67 | # and three-component version numbers (e.g. 1.0 and 1.0.1). 68 | run: | 69 | grep -E -x '[0-9]+\.[0-9]+(\.[0-9]+)?' VERSION 70 | - name: Build wheel 71 | run: | 72 | make dist 73 | - name: Upload to PyPI 74 | uses: pypa/gh-action-pypi-publish@release/v1 75 | with: 76 | user: __token__ 77 | password: ${{ secrets.PYPI_API_TOKEN }} 78 | -------------------------------------------------------------------------------- /testing/tests/refresh: -------------------------------------------------------------------------------- 1 | # @TEST-EXEC: zkg install foo 2 | 3 | # @TEST-EXEC: bash %INPUT 4 | # @TEST-EXEC: zkg refresh 5 | # @TEST-EXEC: zkg list outdated > outdated.out 6 | # @TEST-EXEC: btest-diff outdated.out 7 | 8 | # @TEST-EXEC: zkg list all > list.out 9 | # @TEST-EXEC: btest-diff list.out 10 | 11 | # With --fail-on-aggregate problems, the following should fail since 12 | # there are metadata problems in the package set. 13 | # @TEST-EXEC-FAIL: zkg -vvv refresh --aggregate --fail-on-aggregate-problems >agg.fail.out 2>agg.fail.errout.orig 14 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff agg.fail.out 15 | # @TEST-EXEC: grep -v 'built-in package' < agg.fail.errout.orig > agg.fail.errout 16 | # @TEST-EXEC: TEST_DIFF_CANONIFIER='$SCRIPTS/diff-canonifier' btest-diff agg.fail.errout 17 | 18 | # Remove the aggregated metadata so the next invocation has a clean slate 19 | # @TEST-EXEC: rm -f state/clones/source/one/aggregate.meta 20 | 21 | # This time we trigger only warnings for offending packages, commit, and push. 22 | # @TEST-EXEC: zkg -vvv refresh --aggregate --push >agg.out 2>agg.errout.orig 23 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff agg.out 24 | # @TEST-EXEC: grep -v 'built-in package' < agg.errout.orig > agg.errout 25 | # @TEST-EXEC: TEST_DIFF_CANONIFIER='$SCRIPTS/diff-canonifier' btest-diff agg.fail.errout 26 | # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-canonifier btest-diff agg.errout 27 | 28 | # @TEST-EXEC: zkg search lucky > search.out 29 | # @TEST-EXEC: btest-diff search.out 30 | 31 | # @TEST-EXEC: zkg list all > list_after_agg.out 32 | # @TEST-EXEC: btest-diff list_after_agg.out 33 | # note: foo's description isn't in the list output since the installed 34 | # version's metadata has no 'description' field 35 | 36 | cd packages/foo 37 | echo 'tags = esoteric lucky land' >> zkg.meta 38 | echo 'description = This is the foo package description' >> zkg.meta 39 | git commit -am 'new stuff' 40 | 41 | cd .. 42 | mkdir new_pkg 43 | cd new_pkg 44 | git init 45 | echo '[package]' > zkg.meta 46 | echo 'tags = esoteric lucky land' >> zkg.meta 47 | echo 'description = This is the new_pkg package description' >> zkg.meta 48 | echo 'print "hello";' >> __load__.zeek 49 | git add * 50 | git commit -m 'init' 51 | 52 | cd .. 53 | mkdir bad_pkg 54 | cd bad_pkg 55 | git init 56 | echo '[package]' > bad.meta 57 | git add * 58 | git commit -m 'init' 59 | 60 | cd ../.. 61 | echo "$(pwd)/packages/new_pkg" >> sources/one/alice/zkg.index 62 | echo "$(pwd)/packages/bad_pkg" >> sources/one/alice/zkg.index 63 | cd sources 64 | 65 | ( cd one && git commit -am 'add packages' ) 66 | 67 | # Make it a bare repo so we can push to it 68 | mv one one.tmp 69 | git clone --bare one.tmp one 70 | rm -rf one.tmp 71 | -------------------------------------------------------------------------------- /testing/tests/dependency-ordering: -------------------------------------------------------------------------------- 1 | # This test puts in place a dependecy tree, installs the tree's root package, 2 | # and verifies that package builds and testing honors the dependency ordering: 3 | # depended-upon packages need to be built and available prior to dependers. 4 | # The package tree: 5 | 6 | # foo ---> bar ----> grault 7 | # \ / 8 | # baz -> corge 9 | # 10 | # To verify the ordering we use package executables that dependers require both 11 | # in test_command and build_command. This leverages the fact that executables 12 | # transparently appear in a bin/ directory in the test staging area. foo's build 13 | # & test call executables that bar and baz install; baz's build & test call 14 | # corge's executable, bar and corge call grault's executable. 15 | 16 | # We trigger package tests in the below, for which zkg internally looks 17 | # for zeek-config. So require a Zeek install: 18 | # @TEST-REQUIRES: type zeek-config 19 | 20 | # @TEST-EXEC: BUILDLOG=$(pwd)/build.log bash %INPUT 21 | 22 | # After testing, the packages get installed up the dependency chain, installing 23 | # their executables into the bin folder at the test's toplevel. That directory 24 | # isn't automatically in the path, so add it. 25 | # @TEST-EXEC: PATH=$(pwd)/bin:$PATH zkg install foo 26 | 27 | # Verify the order and number of times the packages got built. 28 | # @TEST-EXEC: btest-diff build.log 29 | 30 | add_executable() { 31 | echo "echo from $1" >$1 32 | chmod +x $1 33 | git add $1 34 | } 35 | 36 | ( 37 | cd packages/foo 38 | cat >>zkg.meta <>$BUILDLOG 40 | test_command = bar && baz 41 | depends = 42 | bar * 43 | baz * 44 | EOF 45 | git commit -am 'foo: depend on bar and baz, add commands' 46 | ) 47 | 48 | ( 49 | cd packages/bar 50 | cat >>zkg.meta <>$BUILDLOG 52 | test_command = grault 53 | executables = bar 54 | depends = grault * 55 | EOF 56 | add_executable bar 57 | git commit -am 'bar: depend on grault, add executable and commands' 58 | ) 59 | 60 | ( 61 | cd packages/baz 62 | cat >>zkg.meta <>$BUILDLOG 64 | test_command = corge 65 | executables = baz 66 | depends = corge * 67 | EOF 68 | add_executable baz 69 | git commit -am 'baz: depend on corge, add executable and commands' 70 | ) 71 | 72 | ( 73 | cd packages/corge 74 | cat >>zkg.meta <>$BUILDLOG 76 | test_command = grault 77 | executables = corge 78 | depends = grault * 79 | EOF 80 | add_executable corge 81 | git commit -am 'corge: depend on grault, add executable and commands' 82 | ) 83 | 84 | ( 85 | cd packages/grault 86 | cat >>zkg.meta <>$BUILDLOG 88 | executables = grault 89 | EOF 90 | add_executable grault 91 | git commit -am 'grault: add executable and build command' 92 | ) 93 | -------------------------------------------------------------------------------- /zkg.config: -------------------------------------------------------------------------------- 1 | # This is an example config file for zkg to explain what 2 | # settings are possible as well as their default values. 3 | # The order of precedence for how zkg finds/reads config files: 4 | # 5 | # (1) zkg --configfile=/path/to/custom/config 6 | # (2) the ZKG_CONFIG_FILE environment variable 7 | # (3) a config file located at $HOME/.zkg/config 8 | # (4) if none of the above exist, then zkg uses builtin/default 9 | # values for all settings shown below 10 | 11 | [sources] 12 | 13 | # The default package source repository from which zkg fetches 14 | # packages. The default source may be removed, changed, or 15 | # additional sources may be added as long as they use a unique key 16 | # and a value that is a valid git URL. The git URL may also use a 17 | # suffix like "@branch-name" where "branch-name" is the name of a real 18 | # branch to checkout (as opposed to the default branch, which is typically 19 | # "main" or "master"). You can override the package source zkg puts 20 | # in new config files (e.g. "zkg autoconfig") by setting the 21 | # ZKG_DEFAULT_SOURCE environment variable. 22 | zeek = https://github.com/zeek/packages 23 | 24 | [paths] 25 | 26 | # Directory where source repositories are cloned, packages are 27 | # installed, and other package manager state information is 28 | # maintained. If left blank or with --user this defaults to 29 | # $HOME/.zkg. In Zeek-bundled installations, it defaults to 30 | # /var/lib/zkg/. 31 | state_dir = 32 | 33 | # The directory where package scripts are copied upon installation. 34 | # A subdirectory named "packages" is always created within the 35 | # specified path and the package manager will copy the directory 36 | # specified by the "script_dir" option of each package's zkg.meta 37 | # (or legacy bro-pkg.meta) file there. 38 | # If left blank or with --user this defaults to /script_dir. 39 | # In Zeek-bundled installations, it defaults to 40 | # /share/zeek/site. 41 | # If you decide to change this location after having already 42 | # installed packages, zkg will automatically relocate them 43 | # the next time you run any zkg command. 44 | script_dir = 45 | 46 | # The directory where package plugins are copied upon installation. 47 | # A subdirectory named "packages" is always created within the 48 | # specified path and the package manager will copy the directory 49 | # specified by the "plugin_dir" option of each package's zkg.meta 50 | # (or legacy bro-pkg.meta) file there. 51 | # If left blank or with --user this defaults to /plugin_dir. 52 | # In Zeek-bundled installations, it defaults to 53 | # /lib/zeek/plugins. 54 | # If you decide to change this location after having already 55 | # installed packages, zkg will automatically relocate them 56 | # the next time you run any zkg command. 57 | plugin_dir = 58 | 59 | # The directory where executables from packages are linked into upon 60 | # installation. If left blank or with --user this defaults to /bin. 61 | # In Zeek-bundled installations, it defaults to /bin. 62 | # If you decide to change this location after having already 63 | # installed packages, zkg will automatically relocate them 64 | # the next time you run any zkg command. 65 | bin_dir = 66 | 67 | # The directory containing Zeek distribution source code. This is only 68 | # needed when installing packages that contain Zeek plugins that are 69 | # not pre-built. This value is generally not needed by most users other 70 | # than plugin developers anymore. 71 | zeek_dist = 72 | 73 | [templates] 74 | 75 | # The URL of the package template repository that the "zkg create" command 76 | # will instantiate by default. 77 | default = https://github.com/zeek/package-template 78 | 79 | [user_vars] 80 | 81 | # For any key in this section that is matched for value interpolation 82 | # in a package's zkg.meta (or legacy bro-pkg.meta) file, the corresponding 83 | # value is substituted during execution of the package's `build_command`. 84 | # This section is typically automatically populated with the 85 | # the answers supplied during package installation prompts 86 | # and, as a convenience feature, used to recall the last-used settings 87 | # during subsequent operations (e.g. upgrades) on the same package. 88 | -------------------------------------------------------------------------------- /doc/zkg.rst: -------------------------------------------------------------------------------- 1 | .. _zkg: 2 | 3 | zkg Command-Line Tool 4 | ===================== 5 | 6 | .. argparse:: 7 | :module: zkg 8 | :func: argparser 9 | :prog: zkg 10 | :nosubcommands: 11 | 12 | --configfile : @after 13 | See :ref:`zkg-config-file`. 14 | 15 | Commands 16 | -------- 17 | 18 | .. _test-command: 19 | 20 | test 21 | ~~~~ 22 | .. argparse:: 23 | :module: zkg 24 | :func: argparser 25 | :prog: zkg 26 | :path: test 27 | 28 | .. _install-command: 29 | 30 | install 31 | ~~~~~~~ 32 | .. argparse:: 33 | :module: zkg 34 | :func: argparser 35 | :prog: zkg 36 | :path: install 37 | 38 | .. _remove-command: 39 | 40 | remove 41 | ~~~~~~ 42 | .. argparse:: 43 | :module: zkg 44 | :func: argparser 45 | :prog: zkg 46 | :path: remove 47 | 48 | .. note:: 49 | 50 | You may also say ``uninstall``. 51 | 52 | .. _purge-command: 53 | 54 | purge 55 | ~~~~~ 56 | .. argparse:: 57 | :module: zkg 58 | :func: argparser 59 | :prog: zkg 60 | :path: purge 61 | 62 | .. _bundle-command: 63 | 64 | bundle 65 | ~~~~~~ 66 | .. argparse:: 67 | :module: zkg 68 | :func: argparser 69 | :prog: zkg 70 | :path: bundle 71 | 72 | .. _unbundle-command: 73 | 74 | unbundle 75 | ~~~~~~~~ 76 | .. argparse:: 77 | :module: zkg 78 | :func: argparser 79 | :prog: zkg 80 | :path: unbundle 81 | 82 | .. _refresh-command: 83 | 84 | refresh 85 | ~~~~~~~ 86 | .. argparse:: 87 | :module: zkg 88 | :func: argparser 89 | :prog: zkg 90 | :path: refresh 91 | 92 | .. _upgrade-command: 93 | 94 | upgrade 95 | ~~~~~~~ 96 | .. argparse:: 97 | :module: zkg 98 | :func: argparser 99 | :prog: zkg 100 | :path: upgrade 101 | 102 | .. _load-command: 103 | 104 | load 105 | ~~~~ 106 | .. argparse:: 107 | :module: zkg 108 | :func: argparser 109 | :prog: zkg 110 | :path: load 111 | 112 | .. _unload-command: 113 | 114 | unload 115 | ~~~~~~ 116 | .. argparse:: 117 | :module: zkg 118 | :func: argparser 119 | :prog: zkg 120 | :path: unload 121 | 122 | .. _pin-command: 123 | 124 | pin 125 | ~~~ 126 | .. argparse:: 127 | :module: zkg 128 | :func: argparser 129 | :prog: zkg 130 | :path: pin 131 | 132 | .. _unpin-command: 133 | 134 | unpin 135 | ~~~~~ 136 | .. argparse:: 137 | :module: zkg 138 | :func: argparser 139 | :prog: zkg 140 | :path: unpin 141 | 142 | .. _list-command: 143 | 144 | list 145 | ~~~~ 146 | .. argparse:: 147 | :module: zkg 148 | :func: argparser 149 | :prog: zkg 150 | :path: list 151 | 152 | .. _search-command: 153 | 154 | search 155 | ~~~~~~ 156 | .. argparse:: 157 | :module: zkg 158 | :func: argparser 159 | :prog: zkg 160 | :path: search 161 | 162 | .. _info-command: 163 | 164 | info 165 | ~~~~ 166 | .. argparse:: 167 | :module: zkg 168 | :func: argparser 169 | :prog: zkg 170 | :path: info 171 | 172 | .. _config-command: 173 | 174 | config 175 | ~~~~~~ 176 | .. argparse:: 177 | :module: zkg 178 | :func: argparser 179 | :prog: zkg 180 | :path: config 181 | 182 | .. _autoconfig-command: 183 | 184 | autoconfig 185 | ~~~~~~~~~~ 186 | .. argparse:: 187 | :module: zkg 188 | :func: argparser 189 | :prog: zkg 190 | :path: autoconfig 191 | 192 | .. _env-command: 193 | 194 | env 195 | ~~~ 196 | .. argparse:: 197 | :module: zkg 198 | :func: argparser 199 | :prog: zkg 200 | :path: env 201 | 202 | create 203 | ~~~~~~ 204 | .. argparse:: 205 | :module: zkg 206 | :func: argparser 207 | :prog: zkg 208 | :path: create 209 | 210 | template info 211 | ~~~~~~~~~~~~~ 212 | .. argparse:: 213 | :module: zkg 214 | :func: argparser 215 | :prog: zkg 216 | :path: template info 217 | 218 | .. _zkg-config-file: 219 | 220 | Config File 221 | ----------- 222 | 223 | The :program:`zkg` command-line tool uses an INI-format config file to allow 224 | users to customize their :doc:`Package Sources `, :doc:`Package 225 | ` installation paths, Zeek executable/source paths, and other 226 | :program:`zkg` options. 227 | 228 | See the default/example config file below for explanations of the 229 | available options and how to customize them: 230 | 231 | .. literalinclude:: ../zkg.config 232 | -------------------------------------------------------------------------------- /doc/source.rst: -------------------------------------------------------------------------------- 1 | .. _Zeek Packages Git Repository: https://github.com/zeek/packages 2 | 3 | How-To: Create a Package Source 4 | =============================== 5 | 6 | :ref:`zkg `, by default, is configured to obtain packages from a 7 | single "package source", the `Zeek Packages Git Repository`_, which is hosted by 8 | and loosely curated by the Zeek Team. However, users may :ref:`configure zkg 9 | ` to use other package sources: either ones they've set up 10 | themselves for organization purposes or those hosted by other third parties. 11 | 12 | Package Source Setup 13 | -------------------- 14 | 15 | In order to set up such a package source, one simply has to create a git 16 | repository and then add :ref:`Package Index Files ` to it. 17 | These files may be created at any path in the package source's git repository. 18 | E.g. the `Zeek Packages Git Repository`_ organizes package index files 19 | hierarchically based on package author names such as :file:`alice/zkg.index` 20 | or :file:`bob/zkg.index` where ``alice`` and ``bob`` are usually GitHub 21 | usernames or some unique way of identifying the organization/person that 22 | maintains Zeek packages. However, a source is free to use a flat organization 23 | with a single, top-level :file:`zkg.index`. 24 | 25 | .. note:: 26 | 27 | The magic index file name of :file:`zkg.index` is available :program:`since 28 | zkg v2.0`. For compatibility purposes, the old index file name of 29 | :file:`bro-pkg.index` is also still supported. 30 | 31 | After creating a git repo for the package source and adding package index files 32 | to it, it's ready to be used by :ref:`zkg `. 33 | 34 | .. _package-index-file: 35 | 36 | Package Index Files 37 | ------------------- 38 | 39 | Files named :file:`zkg.index` (or the legacy :file:`bro-pkg.index`) are used to 40 | describe the :doc:`Zeek Packages ` found within the package source. 41 | They are simply a list of git URLs pointing to the git repositories of 42 | packages. For example:: 43 | 44 | https://github.com/zeek/foo 45 | https://github.com/zeek/bar 46 | https://github.com/zeek/baz 47 | 48 | Local filesystem paths are also valid if the package source is only meant for 49 | your own private usage or testing. 50 | 51 | Adding Packages 52 | --------------- 53 | 54 | Adding packages is as simple as adding new :ref:`Package Index Files 55 | ` or extending existing ones with new URLs and then 56 | commiting/pushing those changes to the package source git repository. 57 | 58 | :ref:`zkg ` will see new packages listed the next time it uses 59 | the :ref:`refresh command `. 60 | 61 | Removing Packages 62 | ----------------- 63 | 64 | Just remove the package's URL from the :ref:`Package Index File 65 | ` that it's contained within. 66 | 67 | After the next time :program:`zkg` uses the :ref:`refresh command 68 | `, it will no longer see the now-removed package 69 | when viewing package listings via by the :ref:`list command `. 70 | 71 | Users that had previously installed the now-removed package may continue to 72 | use it and receive updates for it. 73 | 74 | Aggregating Metadata 75 | -------------------- 76 | 77 | The maintainer/operator of a package source may choose to periodically aggregate 78 | the metadata contained in its packages' :file:`zkg.meta` (and legacy 79 | :file:`bro-pkg.meta`) files. The :ref:`zkg refresh ` 80 | is used to perform the task. For example: 81 | 82 | .. code-block:: console 83 | 84 | $ zkg refresh --aggregate --push --sources my_source 85 | 86 | The optional ``--push`` flag is helpful for setting up cron jobs to 87 | automatically perform this task periodically, assuming you've set up your 88 | git configuration to push changesets without interactive prompts. E.g. 89 | to set up pushing to remote servers you could set up SSH public key 90 | authentication. 91 | 92 | Aggregated metadata gets written to a file named :file:`aggregate.meta` 93 | at the top-level of a package source and the :ref:`list `, 94 | :ref:`search `, and :ref:`info ` all may access 95 | this file. Having access to the aggregated metadata in this way 96 | is beneficial to all :program:`zkg` users because they then will not have 97 | to crawl the set of packages listed in a source in order to obtain this metadata 98 | as it will have already been pre-aggregated by the operator of the package 99 | source. 100 | -------------------------------------------------------------------------------- /doc/ext/sphinxarg/parser.py: -------------------------------------------------------------------------------- 1 | import re 2 | from argparse import _HelpAction, _SubParsersAction 3 | 4 | 5 | class NavigationError(Exception): 6 | pass 7 | 8 | 9 | def parser_navigate(parser_result, path, current_path=None): 10 | if isinstance(path, str): 11 | if path == "": 12 | return parser_result 13 | path = re.split(r"\s+", path) 14 | current_path = current_path or [] 15 | if len(path) == 0: 16 | return parser_result 17 | if "children" not in parser_result: 18 | raise NavigationError( 19 | "Current parser have no children elements. (path: {})".format( 20 | " ".join(current_path), 21 | ), 22 | ) 23 | next_hop = path.pop(0) 24 | for child in parser_result["children"]: 25 | # identifer is only used for aliased subcommands 26 | identifier = child["identifier"] if "identifier" in child else child["name"] 27 | if identifier == next_hop: 28 | current_path.append(next_hop) 29 | return parser_navigate(child, path, current_path) 30 | raise NavigationError( 31 | f"Current parser have no children element with name: {next_hop} (path: %s)" 32 | % " ".join(current_path), 33 | ) 34 | 35 | 36 | def _try_add_parser_attribute(data, parser, attribname): 37 | attribval = getattr(parser, attribname, None) 38 | if attribval is None: 39 | return 40 | if not isinstance(attribval, str): 41 | return 42 | if len(attribval) > 0: 43 | data[attribname] = attribval 44 | 45 | 46 | def _format_usage_without_prefix(parser): 47 | """ 48 | Use private argparse APIs to get the usage string without 49 | the 'usage: ' prefix. 50 | """ 51 | fmt = parser._get_formatter() 52 | fmt.add_usage( 53 | parser.usage, 54 | parser._actions, 55 | parser._mutually_exclusive_groups, 56 | prefix="", 57 | ) 58 | return fmt.format_help().strip() 59 | 60 | 61 | def parse_parser(parser, data=None, **kwargs): 62 | if data is None: 63 | data = { 64 | "name": "", 65 | "usage": parser.format_usage().strip(), 66 | "bare_usage": _format_usage_without_prefix(parser), 67 | "prog": parser.prog, 68 | } 69 | _try_add_parser_attribute(data, parser, "description") 70 | _try_add_parser_attribute(data, parser, "epilog") 71 | for action in parser._get_positional_actions(): 72 | if isinstance(action, _HelpAction): 73 | continue 74 | if isinstance(action, _SubParsersAction): 75 | helps = {} 76 | for item in action._choices_actions: 77 | helps[item.dest] = item.help 78 | 79 | # commands which share an existing parser are an alias, 80 | # don't duplicate docs 81 | subsection_alias = {} 82 | subsection_alias_names = set() 83 | for name, subaction in action._name_parser_map.items(): 84 | if subaction not in subsection_alias: 85 | subsection_alias[subaction] = [] 86 | else: 87 | subsection_alias[subaction].append(name) 88 | subsection_alias_names.add(name) 89 | 90 | for name, subaction in action._name_parser_map.items(): 91 | if name in subsection_alias_names: 92 | continue 93 | subalias = subsection_alias[subaction] 94 | subaction.prog = f"{parser.prog} {name}" 95 | subdata = { 96 | "name": name 97 | if not subalias 98 | else "{} ({})".format(name, ", ".join(subalias)), 99 | "help": helps.get(name, ""), 100 | "usage": subaction.format_usage().strip(), 101 | "bare_usage": _format_usage_without_prefix(subaction), 102 | } 103 | if subalias: 104 | subdata["identifier"] = name 105 | parse_parser(subaction, subdata, **kwargs) 106 | data.setdefault("children", []).append(subdata) 107 | continue 108 | if "args" not in data: 109 | data["args"] = [] 110 | arg = { 111 | "name": action.dest, 112 | "help": action.help or "", 113 | "metavar": action.metavar, 114 | } 115 | if action.choices: 116 | arg["choices"] = action.choices 117 | data["args"].append(arg) 118 | show_defaults = ("skip_default_values" not in kwargs) or ( 119 | kwargs["skip_default_values"] is False 120 | ) 121 | for action in parser._get_optional_actions(): 122 | if isinstance(action, _HelpAction): 123 | continue 124 | if "options" not in data: 125 | data["options"] = [] 126 | option = { 127 | "name": action.option_strings, 128 | "default": action.default if show_defaults else "==SUPPRESS==", 129 | "help": action.help or "", 130 | } 131 | if action.choices: 132 | option["choices"] = action.choices 133 | if "==SUPPRESS==" not in option["help"]: 134 | data["options"].append(option) 135 | return data 136 | -------------------------------------------------------------------------------- /zeekpkg/source.py: -------------------------------------------------------------------------------- 1 | """ 2 | A module containing the definition of a "package source": a git repository 3 | containing a collection of :file:`zkg.index` (or legacy :file:`bro-pkg.index`) 4 | files. These are simple INI files that can describe many Zeek packages. Each 5 | section of the file names a Zeek package along with the git URL where it is 6 | located and metadata tags that help classify/describe it. 7 | """ 8 | 9 | import configparser 10 | import os 11 | import shutil 12 | 13 | import git 14 | 15 | from . import LOG 16 | from ._util import git_checkout, git_clone, git_default_branch 17 | from .package import Package, name_from_path 18 | 19 | #: The name of package index files. 20 | INDEX_FILENAME = "zkg.index" 21 | LEGACY_INDEX_FILENAME = "bro-pkg.index" 22 | #: The name of the package source file where package metadata gets aggregated. 23 | AGGREGATE_DATA_FILE = "aggregate.meta" 24 | 25 | 26 | class Source: 27 | """A Zeek package source. 28 | 29 | This class contains properties of a package source like its name, remote git 30 | URL, and local git clone. 31 | 32 | Attributes: 33 | name (str): The name of the source as given by a config file key 34 | in it's ``[sources]`` section. 35 | 36 | git_url (str): The git URL of the package source. 37 | 38 | clone (git.Repo): The local git clone of the package source. 39 | """ 40 | 41 | def __init__( 42 | self, 43 | name: str, 44 | clone_path: str, 45 | git_url: str, 46 | version: str | None = None, 47 | ) -> None: 48 | """Create a package source. 49 | 50 | Raises: 51 | git.GitCommandError: if the git repo is invalid 52 | OSError: if the git repo is invalid and can't be re-initialized 53 | """ 54 | git_url = os.path.expanduser(git_url) 55 | self.name = name 56 | self.git_url = git_url 57 | self.clone: git.Repo 58 | 59 | try: 60 | self.clone = git.Repo(clone_path) 61 | except git.NoSuchPathError: 62 | LOG.debug('creating source clone of "%s" at %s', name, clone_path) 63 | self.clone = git_clone(git_url, clone_path, shallow=True) 64 | except git.InvalidGitRepositoryError: 65 | LOG.debug('deleting invalid source clone of "%s" at %s', name, clone_path) 66 | shutil.rmtree(clone_path) 67 | self.clone = git_clone(git_url, clone_path, shallow=True) 68 | else: 69 | LOG.debug('found source clone of "%s" at %s', name, clone_path) 70 | old_url = self.clone.git.config("--local", "--get", "remote.origin.url") 71 | 72 | if git_url != old_url: 73 | LOG.debug( 74 | 'url of source "%s" changed from %s to %s, reclone at %s', 75 | name, 76 | old_url, 77 | git_url, 78 | clone_path, 79 | ) 80 | shutil.rmtree(clone_path) 81 | self.clone = git_clone(git_url, clone_path, shallow=True) 82 | 83 | git_checkout(self.clone, version or git_default_branch(self.clone)) 84 | 85 | def __str__(self) -> str: 86 | return self.git_url 87 | 88 | def __repr__(self) -> str: 89 | return self.git_url 90 | 91 | def package_index_files(self) -> list[str]: 92 | """Return a list of paths to package index files in the source.""" 93 | rval = [] 94 | visited_dirs = set() 95 | 96 | for root, dirs, files in os.walk(self.clone.working_dir, followlinks=True): 97 | stat = os.stat(root) 98 | visited_dirs.add((stat.st_dev, stat.st_ino)) 99 | dirs_to_visit_next = [] 100 | 101 | for d in dirs: 102 | stat = os.stat(os.path.join(root, d)) 103 | 104 | if (stat.st_dev, stat.st_ino) not in visited_dirs: 105 | dirs_to_visit_next.append(d) 106 | 107 | dirs[:] = dirs_to_visit_next 108 | 109 | try: 110 | dirs.remove(".git") 111 | except ValueError: 112 | pass 113 | 114 | for filename in files: 115 | if filename in {INDEX_FILENAME, LEGACY_INDEX_FILENAME}: 116 | rval.append(os.path.join(root, filename)) 117 | 118 | return sorted(rval) 119 | 120 | def packages(self) -> list[Package]: 121 | """Return a list of :class:`.package.Package` in the source.""" 122 | rval = [] 123 | # Use raw parser so no value interpolation takes place. 124 | parser = configparser.RawConfigParser() 125 | aggregate_file = os.path.join(self.clone.working_dir, AGGREGATE_DATA_FILE) 126 | parser.read(aggregate_file) 127 | 128 | for index_file in self.package_index_files(): 129 | relative_path = index_file[len(str(self.clone.working_dir)) + 1 :] 130 | directory = os.path.dirname(relative_path) 131 | lines = [] 132 | 133 | with open(index_file) as f: 134 | lines = [line.rstrip("\n") for line in f] 135 | 136 | for url in lines: 137 | pkg_name = name_from_path(url) 138 | agg_key = os.path.join(directory, pkg_name) 139 | metadata = {} 140 | 141 | if parser.has_section(agg_key): 142 | metadata = dict(parser.items(agg_key)) 143 | 144 | package = Package( 145 | git_url=url, 146 | source=self.name, 147 | directory=directory, 148 | metadata=metadata, 149 | ) 150 | rval.append(package) 151 | 152 | return rval 153 | -------------------------------------------------------------------------------- /testing/packages/rot13/configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Wrapper for viewing/setting options that the plugin's CMake 4 | # scripts will recognize. 5 | # 6 | # This file is maintained by zkg. Do not edit. 7 | # Modify configure.plugin to add plugin-specific options. 8 | # 9 | 10 | set -e 11 | command="$0 $*" 12 | 13 | if [ -e `dirname $0`/configure.plugin ]; then 14 | # Include custom additions. 15 | . `dirname $0`/configure.plugin 16 | fi 17 | 18 | usage() { 19 | 20 | cat 1>&2 </dev/null 2>&1; then 35 | plugin_usage 1>&2 36 | fi 37 | 38 | echo 39 | 40 | exit 1 41 | } 42 | 43 | # Function to append a CMake cache entry definition to the 44 | # CMakeCacheEntries variable 45 | # $1 is the cache entry variable name 46 | # $2 is the cache entry variable type 47 | # $3 is the cache entry variable value 48 | append_cache_entry () { 49 | CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3" 50 | } 51 | 52 | # set defaults 53 | builddir=build 54 | zeekdist="" 55 | installroot="default" 56 | CMakeCacheEntries="" 57 | 58 | while [ $# -ne 0 ]; do 59 | case "$1" in 60 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 61 | *) optarg= ;; 62 | esac 63 | 64 | case "$1" in 65 | --help|-h) 66 | usage 67 | ;; 68 | 69 | --cmake=*) 70 | CMakeCommand=$optarg 71 | ;; 72 | 73 | --zeek-dist=*) 74 | zeekdist=`cd $optarg && pwd` 75 | ;; 76 | 77 | --install-root=*) 78 | installroot=$optarg 79 | ;; 80 | 81 | --with-binpac=*) 82 | append_cache_entry BinPAC_ROOT_DIR PATH $optarg 83 | binpac_root=$optarg 84 | ;; 85 | 86 | --with-broker=*) 87 | append_cache_entry BROKER_ROOT_DIR PATH $optarg 88 | broker_root=$optarg 89 | ;; 90 | 91 | --with-caf=*) 92 | append_cache_entry CAF_ROOT_DIR PATH $optarg 93 | caf_root=$optarg 94 | ;; 95 | 96 | --with-bifcl=*) 97 | append_cache_entry BifCl_EXE PATH $optarg 98 | ;; 99 | 100 | --enable-debug) 101 | append_cache_entry BRO_PLUGIN_ENABLE_DEBUG BOOL true 102 | ;; 103 | 104 | *) 105 | if type plugin_option >/dev/null 2>&1; then 106 | plugin_option $1 && shift && continue; 107 | fi 108 | 109 | echo "Invalid option '$1'. Try $0 --help to see available options." 110 | exit 1 111 | ;; 112 | esac 113 | shift 114 | done 115 | 116 | if [ -z "$CMakeCommand" ]; then 117 | # prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL) 118 | if command -v cmake3 >/dev/null 2>&1 ; then 119 | CMakeCommand="cmake3" 120 | elif command -v cmake >/dev/null 2>&1 ; then 121 | CMakeCommand="cmake" 122 | else 123 | echo "This package requires CMake, please install it first." 124 | echo "Then you may use this script to configure the CMake build." 125 | echo "Note: pass --cmake=PATH to use cmake in non-standard locations." 126 | exit 1; 127 | fi 128 | fi 129 | 130 | if [ -z "$zeekdist" ]; then 131 | if type zeek-config >/dev/null 2>&1; then 132 | zeek_config="zeek-config" 133 | else 134 | echo "Either 'zeek-config' must be in PATH or '--zeek-dist=' used" 135 | exit 1 136 | fi 137 | 138 | append_cache_entry BRO_CONFIG_PREFIX PATH `${zeek_config} --prefix` 139 | append_cache_entry BRO_CONFIG_INCLUDE_DIR PATH `${zeek_config} --include_dir` 140 | append_cache_entry BRO_CONFIG_PLUGIN_DIR PATH `${zeek_config} --plugin_dir` 141 | append_cache_entry BRO_CONFIG_LIB_DIR PATH `${zeek_config} --lib_dir` 142 | append_cache_entry BRO_CONFIG_CMAKE_DIR PATH `${zeek_config} --cmake_dir` 143 | append_cache_entry CMAKE_MODULE_PATH PATH `${zeek_config} --cmake_dir` 144 | 145 | build_type=`${zeek_config} --build_type` 146 | 147 | if [ "$build_type" = "debug" ]; then 148 | append_cache_entry BRO_PLUGIN_ENABLE_DEBUG BOOL true 149 | fi 150 | 151 | if [ -z "$binpac_root" ]; then 152 | append_cache_entry BinPAC_ROOT_DIR PATH `${zeek_config} --binpac_root` 153 | fi 154 | 155 | if [ -z "$broker_root" ]; then 156 | append_cache_entry BROKER_ROOT_DIR PATH `${zeek_config} --broker_root` 157 | fi 158 | 159 | if [ -z "$caf_root" ]; then 160 | append_cache_entry CAF_ROOT_DIR PATH `${zeek_config} --caf_root` 161 | fi 162 | else 163 | if [ ! -e "$zeekdist/zeek-path-dev.in" ]; then 164 | echo "$zeekdist does not appear to be a valid Zeek source tree." 165 | exit 1 166 | fi 167 | 168 | # BRO_DIST is the canonical/historical name used by plugin CMake scripts 169 | # ZEEK_DIST doesn't serve a function at the moment, but set/provided anyway 170 | append_cache_entry BRO_DIST PATH $zeekdist 171 | append_cache_entry ZEEK_DIST PATH $zeekdist 172 | append_cache_entry CMAKE_MODULE_PATH PATH $zeekdist/cmake 173 | fi 174 | 175 | if [ "$installroot" != "default" ]; then 176 | mkdir -p $installroot 177 | append_cache_entry BRO_PLUGIN_INSTALL_ROOT PATH $installroot 178 | fi 179 | 180 | if type plugin_addl >/dev/null 2>&1; then 181 | plugin_addl 182 | fi 183 | 184 | echo "Build Directory : $builddir" 185 | echo "Zeek Source Directory : $zeekdist" 186 | 187 | mkdir -p $builddir 188 | cd $builddir 189 | 190 | "$CMakeCommand" $CMakeCacheEntries .. 191 | 192 | echo "# This is the command used to configure this build" > config.status 193 | echo $command >> config.status 194 | chmod u+x config.status 195 | -------------------------------------------------------------------------------- /zeekpkg/uservar.py: -------------------------------------------------------------------------------- 1 | """ 2 | A module for zkg's notion of "user variables": named values required 3 | by packages that the user can provide in a variety of ways, including 4 | responses to zkg's input prompting. 5 | """ 6 | 7 | import configparser 8 | import os 9 | import re 10 | import readline 11 | 12 | 13 | def slugify(string: str) -> str: 14 | """Returns file-system-safe, lower-case version of the input string. 15 | 16 | Any character sequence outside of ``[a-zA-Z0-9_]+`` gets replaced by a 17 | single underscore. If the variable has no value or the value is an 18 | empty string, returns the given default. 19 | """ 20 | return re.sub(r"[^\w]+", "_", string, flags=re.ASCII).lower() 21 | 22 | 23 | def _rlinput(prompt: str, prefill: str = "") -> str: 24 | """Variation of input() that supports pre-filling a value.""" 25 | readline.set_startup_hook(lambda: readline.insert_text(prefill)) 26 | try: 27 | return input(prompt) 28 | finally: 29 | readline.set_startup_hook() 30 | 31 | 32 | class UserVar: 33 | """A class representing a single user variable. 34 | 35 | User variables have a name and an optional description. They 36 | resolve to a value using a cascade of mechanisms, including 37 | command-line arguments (via --user-var), environment variables, 38 | cached previous values, and user input. They may come with a 39 | default value. 40 | """ 41 | 42 | def __init__( 43 | self, 44 | name: str, 45 | val: str | None = None, 46 | default: str | None = None, 47 | desc: str | None = None, 48 | ) -> None: 49 | self._name = name 50 | self._desc = desc or "" 51 | self._val = val 52 | self._default = default if default is not None else val 53 | 54 | def name(self) -> str: 55 | return self._name 56 | 57 | def desc(self) -> str: 58 | return self._desc 59 | 60 | def set(self, val: str) -> None: 61 | self._val = val 62 | 63 | def val(self, fallback: str | None = None) -> str | None: 64 | return self._val if self._val is not None else fallback 65 | 66 | def default(self) -> str | None: 67 | return self._default 68 | 69 | def resolve( 70 | self, 71 | name: str, 72 | config: configparser.ConfigParser, 73 | user_var_args: list["UserVar"] | None = None, 74 | force: bool = False, 75 | ) -> str: 76 | """Populates user variables with updated values and returns them. 77 | 78 | This function resolves the variable in the following order: 79 | 80 | (1) Use any value provided on the command line via --user-var 81 | (2) If force is not used, prompt the user for input 82 | (3) use an environment variables of the same name, 83 | (4) retrieve from the provided config parser's "user_vars" section, 84 | (5) use the default value of the user variable. 85 | 86 | The resolved value is stored with the instance (to be 87 | retrieved via .val() in the future) and also returned. 88 | 89 | Args: 90 | name (str): the requesting entity, e.g. a package name 91 | 92 | config (configparser.ConfigParser): the zkg configuration 93 | 94 | user_var_args (list of UserVar): user-var instances 95 | provided via command line 96 | 97 | force (bool): whether to skip prompting for input 98 | 99 | Returns: 100 | str: the resulting variable value 101 | 102 | Raises: 103 | ValueError: when we couldn't produce a value for the variable 104 | """ 105 | val: str | None = None 106 | source = None 107 | 108 | if user_var_args: 109 | for uvar in user_var_args: 110 | if uvar.name() == self._name: 111 | val = uvar.val() 112 | source = "command line" 113 | break 114 | 115 | if val is None: 116 | val = os.environ.get(self._name) 117 | if val: 118 | source = "environment" 119 | 120 | if source: 121 | print( 122 | f'"{name}" will use value of "{self._name}" ({self._desc}) from {source}: {val}', 123 | ) 124 | self._val = val 125 | assert val 126 | return val 127 | 128 | if val is None: 129 | # Try to re-use a cached value in the subsequent prompt 130 | val = config.get("user_vars", self._name, fallback=self._default) 131 | 132 | if force: 133 | if val is None: 134 | raise ValueError(self._name) 135 | self._val = val 136 | return val 137 | 138 | desc = " (" + self._desc + ")" if self._desc else "" 139 | print(f'"{name}" requires a "{self._name}" value{desc}: ') 140 | self._val = _rlinput(self._name + ": ", val if val else "") 141 | 142 | return self._val 143 | 144 | @staticmethod 145 | def parse_arg(arg: str) -> "UserVar": 146 | """Parser for NAME=VAL format string used in command-line args.""" 147 | try: 148 | name, val = arg.split("=", 1) 149 | return UserVar(name, val=val) 150 | except ValueError as error: 151 | raise ValueError( 152 | f'invalid user var argument "{arg}", must be NAME=VAR', 153 | ) from error 154 | 155 | @staticmethod 156 | def parse_dict(metadata_dict: dict[str, str]) -> list["UserVar"] | None: 157 | """Returns list of UserVars from the metadata's 'user_vars' field. 158 | 159 | Args: 160 | metadata_dict (dict of str->str): the input metadata, e.g. from 161 | a configparser entry value. 162 | 163 | Returns: 164 | list of UserVar. If the 'user_vars' field is not present, 165 | an empty list is returned. If malformed, returns None. 166 | """ 167 | text = metadata_dict.get("user_vars") 168 | 169 | if not text: 170 | return [] 171 | 172 | rval = [] 173 | 174 | text = text.strip() 175 | # Example: LIBRDKAFKA_ROOT [/usr] "Path to librdkafka installation" 176 | 177 | entries = re.split(r'(\w+\s+\[.*\]\s+".*")\s+', text) 178 | entries = list(filter(None, entries)) 179 | 180 | for entry in entries: 181 | mob = re.match(r'(\w+)\s+\[(.*)\]\s+"(.*)"', entry) 182 | 183 | if not mob: 184 | return None 185 | 186 | groups = mob.groups() 187 | 188 | if len(groups) != 3: 189 | return None 190 | 191 | rval.append(UserVar(groups[0], val=groups[1], desc=groups[2])) 192 | 193 | return rval 194 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help 18 | help: 19 | @echo "Please use \`make ' where is one of" 20 | @echo " html to make standalone HTML files" 21 | @echo " dirhtml to make HTML files named index.html in directories" 22 | @echo " singlehtml to make a single large HTML file" 23 | @echo " pickle to make pickle files" 24 | @echo " json to make JSON files" 25 | @echo " htmlhelp to make HTML files and a HTML help project" 26 | @echo " qthelp to make HTML files and a qthelp project" 27 | @echo " applehelp to make an Apple Help Book" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " epub3 to make an epub3" 31 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 32 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 33 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 34 | @echo " text to make text files" 35 | @echo " man to make manual pages" 36 | @echo " texinfo to make Texinfo files" 37 | @echo " info to make Texinfo files and run them through makeinfo" 38 | @echo " gettext to make PO message catalogs" 39 | @echo " changes to make an overview of all changed/added/deprecated items" 40 | @echo " xml to make Docutils-native XML files" 41 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 42 | @echo " linkcheck to check all external links for integrity" 43 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 44 | @echo " coverage to run coverage check of the documentation (if enabled)" 45 | @echo " dummy to check syntax errors of document sources" 46 | 47 | .PHONY: clean 48 | clean: 49 | rm -rf $(BUILDDIR)/* 50 | 51 | .PHONY: html 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | touch $(BUILDDIR)/html/.nojekyll 55 | @echo 56 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 57 | 58 | .PHONY: livehtml 59 | livehtml: 60 | sphinx-autobuild --ignore "../testing/*" --ignore "*.git/*" --ignore "*.lock" --ignore "*.pyc" --ignore "*.swp" --ignore "*.swpx" --ignore "*.swx" --watch .. --watch ../zeekpkg -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 61 | 62 | .PHONY: dirhtml 63 | dirhtml: 64 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 65 | @echo 66 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 67 | 68 | .PHONY: singlehtml 69 | singlehtml: 70 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 71 | @echo 72 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 73 | 74 | .PHONY: pickle 75 | pickle: 76 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 77 | @echo 78 | @echo "Build finished; now you can process the pickle files." 79 | 80 | .PHONY: json 81 | json: 82 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 83 | @echo 84 | @echo "Build finished; now you can process the JSON files." 85 | 86 | .PHONY: htmlhelp 87 | htmlhelp: 88 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 89 | @echo 90 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 91 | ".hhp project file in $(BUILDDIR)/htmlhelp." 92 | 93 | .PHONY: qthelp 94 | qthelp: 95 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 96 | @echo 97 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 98 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 99 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ZeekPackageManager.qhcp" 100 | @echo "To view the help file:" 101 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ZeekPackageManager.qhc" 102 | 103 | .PHONY: applehelp 104 | applehelp: 105 | $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp 106 | @echo 107 | @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." 108 | @echo "N.B. You won't be able to view it unless you put it in" \ 109 | "~/Library/Documentation/Help or install it in your application" \ 110 | "bundle." 111 | 112 | .PHONY: devhelp 113 | devhelp: 114 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 115 | @echo 116 | @echo "Build finished." 117 | @echo "To view the help file:" 118 | @echo "# mkdir -p $$HOME/.local/share/devhelp/ZeekPackageManager" 119 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ZeekPackageManager" 120 | @echo "# devhelp" 121 | 122 | .PHONY: epub 123 | epub: 124 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 125 | @echo 126 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 127 | 128 | .PHONY: epub3 129 | epub3: 130 | $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 131 | @echo 132 | @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." 133 | 134 | .PHONY: latex 135 | latex: 136 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 137 | @echo 138 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 139 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 140 | "(use \`make latexpdf' here to do that automatically)." 141 | 142 | .PHONY: latexpdf 143 | latexpdf: 144 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 145 | @echo "Running LaTeX files through pdflatex..." 146 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 147 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 148 | 149 | .PHONY: latexpdfja 150 | latexpdfja: 151 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 152 | @echo "Running LaTeX files through platex and dvipdfmx..." 153 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 154 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 155 | 156 | .PHONY: text 157 | text: 158 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 159 | @echo 160 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 161 | 162 | .PHONY: man 163 | man: 164 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 165 | @echo 166 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 167 | 168 | .PHONY: texinfo 169 | texinfo: 170 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 171 | @echo 172 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 173 | @echo "Run \`make' in that directory to run these through makeinfo" \ 174 | "(use \`make info' here to do that automatically)." 175 | 176 | .PHONY: info 177 | info: 178 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 179 | @echo "Running Texinfo files through makeinfo..." 180 | make -C $(BUILDDIR)/texinfo info 181 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 182 | 183 | .PHONY: gettext 184 | gettext: 185 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 186 | @echo 187 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 188 | 189 | .PHONY: changes 190 | changes: 191 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 192 | @echo 193 | @echo "The overview file is in $(BUILDDIR)/changes." 194 | 195 | .PHONY: linkcheck 196 | linkcheck: 197 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 198 | @echo 199 | @echo "Link check complete; look for any errors in the above output " \ 200 | "or in $(BUILDDIR)/linkcheck/output.txt." 201 | 202 | .PHONY: doctest 203 | doctest: 204 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 205 | @echo "Testing of doctests in the sources finished, look at the " \ 206 | "results in $(BUILDDIR)/doctest/output.txt." 207 | 208 | .PHONY: coverage 209 | coverage: 210 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 211 | @echo "Testing of coverage in the sources finished, look at the " \ 212 | "results in $(BUILDDIR)/coverage/python.txt." 213 | 214 | .PHONY: xml 215 | xml: 216 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 217 | @echo 218 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 219 | 220 | .PHONY: pseudoxml 221 | pseudoxml: 222 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 223 | @echo 224 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 225 | 226 | .PHONY: dummy 227 | dummy: 228 | $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy 229 | @echo 230 | @echo "Build finished. Dummy builder generates no files." 231 | --------------------------------------------------------------------------------