-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
virtme-ng: provide a man page for vng
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
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ dist | |
.mypy_cache | ||
virtme-ng-prompt | ||
vng-prompt | ||
vng.1 | ||
virtme_ng.egg-info/ | ||
.pybuild/ | ||
debian/virtme-ng/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
argcomplete | ||
argparse-manpage | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}") | ||
|
@@ -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"): | ||
|
@@ -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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}" | ||
|
98b1a49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ker- nel/kernel/
98b1a49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed thanks!