summaryrefslogtreecommitdiff
path: root/src/ukify/ukify.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-11-16 15:52:47 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-12-07 15:32:13 +0100
commit30ec2eaef5f1e3c6639304316a12bf01a5cd7150 (patch)
treeb80207195995556afe7c4ee3394f178b75d94d0d /src/ukify/ukify.py
parentf4780cbe303c266c3b25a107eb0eb0296c6156da (diff)
downloadsystemd-30ec2eaef5f1e3c6639304316a12bf01a5cd7150.tar.gz
meson,ukify: hook up ukify, add --version option
The option is added because we have a similar one for kernel-install. This program requires python, and some people might want to skip it because of this. The tool is installed in /usr/lib/systemd for now, since the interface might change. A template file is used, but there is no .in suffix. The problem is that we'll later want to import the file as a module for tests, but recent Python versions make it annoyingly hard to import a module from a file without a .py suffix. imp.load_sources() works, but it is deprecated and throws warnings. importlib.machinery.SourceFileLoader().load_module() works, but is also deprecated. And the documented replacements are a maze of twisted little callbacks that result in an empty module. So let's take the easy way out, and skip the suffix which makes it easy to import the template as a module after adding the directory to sys.path.
Diffstat (limited to 'src/ukify/ukify.py')
-rwxr-xr-xsrc/ukify/ukify.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py
index 4041cefc9d..d4afd88290 100755
--- a/src/ukify/ukify.py
+++ b/src/ukify/ukify.py
@@ -22,6 +22,8 @@ import typing
import pefile
+__version__ = '{{GIT_VERSION}}'
+
EFI_ARCH_MAP = {
# host_arch glob : [efi_arch, 32_bit_efi_arch if mixed mode is supported]
'x86_64' : ['x64', 'ia32'],
@@ -519,6 +521,10 @@ usage: ukify [options…] linux initrd
action=argparse.BooleanOptionalAction,
help='print systemd-measure output for the UKI')
+ p.add_argument('--version',
+ action='version',
+ version=f'ukify {__version__}')
+
opts = p.parse_args(args)
if opts.cmdline and opts.cmdline.startswith('@'):