From 55c25299da90027e3ebe81f384ef04e7a8c07fe0 Mon Sep 17 00:00:00 2001 From: luc Date: Sat, 8 Nov 2025 11:58:41 +0100 Subject: [PATCH 1/2] src/zlevis*: rename and add versioning Renamed zlevis binaries for versioning capability with meson. --- src/{zlevis-decrypt => zlevis-decrypt.in} | 13 +++++++++++-- src/{zlevis-encrypt => zlevis-encrypt.in} | 11 ++++++++++- src/{zlevis => zlevis.in} | 13 +++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) rename src/{zlevis-decrypt => zlevis-decrypt.in} (94%) rename src/{zlevis-encrypt => zlevis-encrypt.in} (97%) rename src/{zlevis => zlevis.in} (89%) diff --git a/src/zlevis-decrypt b/src/zlevis-decrypt.in similarity index 94% rename from src/zlevis-decrypt rename to src/zlevis-decrypt.in index 7cac845..c5a4211 100755 --- a/src/zlevis-decrypt +++ b/src/zlevis-decrypt.in @@ -3,10 +3,13 @@ # Exit immediately if a command exits with a non-zero status set -e -# Summary of the script's functionality +# Summary of the functionality of zlevis-decrypt summary="Decrypts a JWE using a TPM2.0 chip" -# TPM2.0 owner hierarchy to be used by the Operating System +# Version of zlevis +version="@VERSION@" + +# TPM2.0 owner hierarchy to be used by the operating system auth="o" # Display summary if requested @@ -15,6 +18,12 @@ if [ "$1" = "--summary" ]; then exit 0 fi +# Display version if requested +if [ "$1" = "--version" ]; then + echo "$version" + exit 0 +fi + # Display usage information if input is from a terminal if [ -t 0 ]; then exec >&2 diff --git a/src/zlevis-encrypt b/src/zlevis-encrypt.in similarity index 97% rename from src/zlevis-encrypt rename to src/zlevis-encrypt.in index 6700bbe..fc8503e 100755 --- a/src/zlevis-encrypt +++ b/src/zlevis-encrypt.in @@ -3,9 +3,12 @@ # Exit immediately if a command exits with a non-zero status set -e -# Summary of the script's functionality +# Summary of the functionality of zlevis-encrypt summary="Encrypts using a TPM2.0 chip binding policy" +# Version of zlevis +version="@VERSION@" + # TPM2.0 owner hierarchy to be used by the Operating System auth="o" @@ -18,6 +21,12 @@ if [ "$1" = "--summary" ]; then exit 0 fi +# Display version if requested +if [ "$1" = "--version" ]; then + echo "$version" + exit 0 +fi + # Display usage information if input is from a terminal if [ -t 0 ]; then exec >&2 diff --git a/src/zlevis b/src/zlevis.in similarity index 89% rename from src/zlevis rename to src/zlevis.in index 34acddc..33ccb49 100755 --- a/src/zlevis +++ b/src/zlevis.in @@ -3,15 +3,24 @@ # Exit immediately if a command exits with a non-zero status set -e -# Summary of the script's functionality +# Summary of the functionality of zlevis summary="A tool that enables automatic decryption of ZFS rpools with TPM2" +# Version of zlevis +version="@VERSION@" + # Display summary if requested if [ "$1" = "--summary" ]; then echo "$summary" exit 0 fi +# Display version if requested +if [ "$1" = "--version" ]; then + echo "$version" + exit 0 +fi + # Function to display usage information of zlevis info() { exec >&2 @@ -48,4 +57,4 @@ else fi # Exit with the status of the last command -exit $? \ No newline at end of file +exit $? From a6de269de53b2ae4f65af7465b8742916bd42d42 Mon Sep 17 00:00:00 2001 From: luc Date: Sat, 8 Nov 2025 12:00:03 +0100 Subject: [PATCH 2/2] meson.build: add versioning Added versioning to the binaries with configuration file in meson. --- meson.build | 12 +++--------- src/meson.build | 18 +++++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/meson.build b/meson.build index e8969cc..4974d28 100644 --- a/meson.build +++ b/meson.build @@ -1,14 +1,8 @@ # Project definition -project('zlevis', license: 'GPL3') +project('zlevis', license: 'GPL3', version: '2.3') -# Define bindir -bindir = join_paths(get_option('prefix'), get_option('bindir')) - -# Define bins list -bins = [] +# Define bin dir +bin_dir = join_paths(get_option('prefix'), get_option('bindir')) # Define subdir with bins subdir('src') - -# Install bins in bindir -install_data(bins, install_dir: bindir) diff --git a/src/meson.build b/src/meson.build index 09c3d2c..a7fbadc 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,14 +1,14 @@ -# Find scripts -main = find_program('zlevis') -encrypt = find_program('zlevis-encrypt') -decrypt = find_program('zlevis-decrypt') +# Find the scripts +frontend = find_program('zlevis.in') +encrypt = find_program('zlevis-encrypt.in') +decrypt = find_program('zlevis-decrypt.in') # Test the scripts -test('zlevis', main, args: '--summary') +test('zlevis', frontend, args: '--summary') test('zlevis-encrypt', encrypt, args: '--summary') test('zlevis-decrypt', decrypt, args: '--summary') -# Add paths of scripts to bins -bins += join_paths(meson.current_source_dir(), 'zlevis') -bins += join_paths(meson.current_source_dir(), 'zlevis-encrypt') -bins += join_paths(meson.current_source_dir(), 'zlevis-decrypt') \ No newline at end of file +# Configure the scripts +configure_file(input: 'zlevis.in', output: 'zlevis', configuration: {'VERSION': meson.project_version()}, install: true, install_dir: bin_dir) +configure_file(input: 'zlevis-encrypt.in', output: 'zlevis-encrypt', configuration: {'VERSION': meson.project_version()}, install: true, install_dir: bin_dir) +configure_file(input: 'zlevis-decrypt.in', output: 'zlevis-decrypt', configuration: {'VERSION': meson.project_version()}, install: true, install_dir: bin_dir)