Skip to content

Commit

Permalink
virtme-ng: provide a man page for vng
Browse files Browse the repository at this point in the history
Automatically generate a manpage via argparse-manpage.

We can improve the content of the man page later in the future, but for
now it has all the basic information about the command line options and
their description, that can be useful when it's not possible to access
the main README.md on the github page.

This closes issue #89.

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
Andrea Righi committed Jun 5, 2024
1 parent 45ce650 commit 98b1a49
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
.mypy_cache
virtme-ng-prompt
vng-prompt
vng.1
virtme_ng.egg-info/
.pybuild/
debian/virtme-ng/
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
argcomplete
argparse-manpage
requests
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ def run(self):
sys.exit(1)


man_command = f"""
argparse-manpage \
--pyfile ./virtme_ng/run.py --function make_parser \
--prog vng --version v{VERSION} \
--author "virtme-ng is written by Andrea Righi <[email protected]>" \
--author "Based on virtme by Andy Lutomirski <[email protected]>" \
--project-name virtme-ng --manual-title virtme-ng \
--description "Quickly run kernels inside a virtualized snapshot of your live system" \
--url https://github.com/arighi/virtme-ng > vng.1
"""


class BuildPy(build_py):
def run(self):
print(f"BUILD_VIRTME_NG_INIT: {build_virtme_ng_init}")
Expand All @@ -73,6 +85,12 @@ def run(self):
["strip", "-s", "../virtme/guest/bin/virtme-ng-init"],
cwd="virtme_ng_init",
)
# Generate manpage
if which('argparse-manpage'):
env = os.environ.copy()
env["PYTHONPATH"] = os.path.dirname(os.path.abspath(__file__))
check_call(man_command, shell=True, env=env)

# Generate bash autocompletion scripts
completion_command = ''
if which("register-python-argcomplete"):
Expand Down Expand Up @@ -157,6 +175,7 @@ def run(self):
("/etc", ["cfg/virtme-ng.conf"]),
("/usr/share/bash-completion/completions", ["virtme-ng-prompt"]),
("/usr/share/bash-completion/completions", ["vng-prompt"]),
("/usr/share/man/man1", ["vng.1"]),
],
scripts=[
"bin/virtme-prep-kdir-mods",
Expand Down
23 changes: 23 additions & 0 deletions virtme_ng/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,30 @@ def make_parser():
"""Main virtme-ng command line parser."""

parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description="Build and run kernels inside a virtualized snapshot of your live system",
epilog="""\
virtme-ng is a tool that allows to easily and quickly recompile and test a
Linux kernel, starting from the source code. It allows to re‐ compile the
kernel in a few minutes (rather than hours), then the kernel is automatically
started in a virtualized environment that is an exact copy-on-write copy of
your live system, which means that any changes made to the virtualized
environment do not affect the host system.
In order to do this, a minimal config is produced (with the bare minimum
support to test the kernel inside qemu), then the selected ker‐ nel is
automatically built and started inside qemu, using the filesystem of the host
as a copy-on-write snapshot.
This means that you can safely destroy the entire filesystem, crash the kernel,
etc. without affecting the host.
NOTE: kernels produced with virtme-ng are lacking lots of features, in order to
reduce the build time to the minimum and still provide you a usable kernel
capable of running your tests and experiments.
virtme-ng is based on virtme, written by Andy Lutomirski <[email protected]>.
""",
)
parser.add_argument(
"--version", "-V", action="version", version=f"virtme-ng {VERSION}"
Expand Down

2 comments on commit 98b1a49

@jimc
Copy link
Contributor

@jimc jimc commented on 98b1a49 Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ker- nel/kernel/

@arighi
Copy link
Owner

@arighi arighi commented on 98b1a49 Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ker- nel/kernel/

Fixed thanks!

Please sign in to comment.