diff --git a/Cargo.lock b/Cargo.lock index 0aefc6e..dd15d44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -158,6 +158,67 @@ version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" +[[package]] +name = "build-info" +version = "0.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6183075b0f5008e1bec830f436cc13fbf4a95b777c451fb601b6530a77895da2" +dependencies = [ + "build-info-proc", +] + +[[package]] +name = "build-info-build" +version = "0.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "838512144e4af79c9846a5e1292daca0d4f8111b33dfd81a1ca1c4cfc2eeb00d" +dependencies = [ + "anyhow", + "build-info-common", + "cargo_metadata", + "chrono", + "ciborium", + "git2", + "glob", + "pretty_assertions", + "rustc_version", + "serde_json", + "z85", + "zstd", +] + +[[package]] +name = "build-info-common" +version = "0.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f49ba4d478c1ad6ba848ef096bbe2f77902f8630383fd213a5174b86f3c2f9" +dependencies = [ + "chrono", + "derive_more", + "semver", + "serde", +] + +[[package]] +name = "build-info-proc" +version = "0.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d69e45bef27c9fe98d5b1c33f77062d7c23ddc0fa106d78e2f558e5540df6983" +dependencies = [ + "build-info-common", + "chrono", + "ciborium", + "manyhow", + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.119", + "z85", + "zstd", +] + [[package]] name = "bumpalo" version = "3.20.3" @@ -170,6 +231,15 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +[[package]] +name = "camino" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1307f12aa967b5a58416e87b3653360e0fd614a016b6e970db08fecbb1b80d" +dependencies = [ + "serde_core", +] + [[package]] name = "caps" version = "0.5.6" @@ -179,6 +249,30 @@ dependencies = [ "libc", ] +[[package]] +name = "cargo-platform" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0061da739915fae12ea00e16397555ed4371a6bb285431aab930f61b0aa4ba" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "cargo_metadata" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef987d17b0a113becdd19d3d0022d04d7ef41f9efe4f3fb63ac44ba61df3ade9" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" version = "1.3.0" @@ -186,6 +280,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -225,6 +321,33 @@ dependencies = [ "phf", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "clap" version = "4.6.3" @@ -290,6 +413,36 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const_format" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4481a617ad9a412be3b97c5d403fef8ed023103368908b9c50af598ff467cc1e" +dependencies = [ + "const_format_proc_macros", + "konst", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -302,6 +455,12 @@ version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + [[package]] name = "defmt" version = "1.1.1" @@ -339,6 +498,35 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.119", + "unicode-xid", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "displaydoc" version = "0.2.6" @@ -601,12 +789,35 @@ dependencies = [ "r-efi", ] +[[package]] +name = "git2" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddddbf932745a6be37109b6112d3ee09696106f848449069d3a57bba937ab82e" +dependencies = [ + "bitflags 2.13.1", + "libc", + "libgit2-sys", + "log", +] + [[package]] name = "glob" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + [[package]] name = "hashbrown" version = "0.17.1" @@ -767,6 +978,16 @@ dependencies = [ "jiff-tzdb", ] +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom", + "libc", +] + [[package]] name = "js-sys" version = "0.3.103" @@ -778,6 +999,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "konst" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128133ed7824fcd73d6e7b17957c5eb7bacb885649bd8c69708b2331a10bcefb" +dependencies = [ + "konst_macro_rules", +] + +[[package]] +name = "konst_macro_rules" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" + [[package]] name = "lazy_static" version = "1.5.0" @@ -790,6 +1026,30 @@ version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +[[package]] +name = "libgit2-sys" +version = "0.18.7+1.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23c7391e4b9f4ffab1a624223cc1d7385ff9a678f490768add717de7ea2f4d89" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bc9657773828b90eeb625adff10eeac83cc21bbfd8e23a03eaa8a33c9e28d9" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -802,6 +1062,29 @@ version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" +[[package]] +name = "manyhow" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b33efb3ca6d3b07393750d4030418d594ab1139cee518f0dc88db70fec873587" +dependencies = [ + "manyhow-macros", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "manyhow-macros" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fce34d199b78b6e6073abf984c9cf5fd3e9330145a93ee0738a7443e371495" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", +] + [[package]] name = "matchers" version = "0.2.0" @@ -907,12 +1190,31 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "num-bigint" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93e7820bc0a80a0238e650327316f929ba18d5be054b647490a3a6a339f3e7c0" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "num-conv" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -998,6 +1300,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + [[package]] name = "polling" version = "3.11.0" @@ -1033,6 +1341,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -1042,6 +1360,17 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-utils" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaf08a13de400bc215877b5bdc088f241b12eb42f0a548d3390dc1c56bb7071" +dependencies = [ + "proc-macro2", + "quote", + "smallvec", +] + [[package]] name = "proc-macro2" version = "1.0.107" @@ -1088,13 +1417,17 @@ name = "roowho2" version = "0.1.0" dependencies = [ "anyhow", + "build-info", + "build-info-build", "bytes", "caps", "chrono", "chrono-tz", "clap", "clap_complete", + "const_format", "futures-util", + "git2", "indoc", "itertools", "netlink-packet-audit", @@ -1124,6 +1457,15 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "1.1.4" @@ -1164,6 +1506,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + [[package]] name = "serde" version = "1.0.229" @@ -1623,12 +1975,24 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + [[package]] name = "unicode-width" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "users" version = "0.11.0" @@ -1694,6 +2058,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -1911,6 +2281,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] +name = "z85" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e61e59a957b7ccee15d2049f86e8bfd6f66968fcd88f018950662d9b86e675" + [[package]] name = "zbus" version = "5.18.0" @@ -1967,6 +2349,26 @@ dependencies = [ "zvariant", ] +[[package]] +name = "zerocopy" +version = "0.8.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a105cd7b140f6eeec8acff2ea38135d3cab283ada58540f629fe51e46696eb" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fe976fb70c78cd64cccfe3a6fc142244e8a77b70959b30faf9d0ac37ee228eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "zerofrom" version = "0.1.8" @@ -2068,6 +2470,34 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.16+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "zvariant" version = "5.13.1" diff --git a/Cargo.toml b/Cargo.toml index 81d7dbe..0ae8911 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,13 @@ netlink-sys = { version = "0.8.8", features = ["tokio_socket"] } netlink-packet-audit = "0.6.1" thiserror = "2.0.19" zbus = { version = "5.18.0", default-features = false, features = ["tokio"] } +build-info = { version = "0.0.45", default-features = false } +const_format = "0.2.36" + +[build-dependencies] +anyhow = "1.0.104" +build-info-build = "0.0.45" +git2 = "0.21.0" [dev-dependencies] indoc = "2.0.7" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..91593da --- /dev/null +++ b/build.rs @@ -0,0 +1,40 @@ +fn get_git_commit() -> Option { + let repo = git2::Repository::discover(".").ok()?; + let head = repo.head().ok()?; + let commit = head.peel_to_commit().ok()?; + Some(commit.id().to_string()) +} + +fn embed_build_time_info() { + let commit = option_env!("GIT_COMMIT") + .map(|s| s.to_string()) + .or_else(get_git_commit) + .unwrap_or_else(|| "unknown".to_string()); + + let build_profile = std::env::var("OUT_DIR") + .unwrap_or_else(|_| "unknown".to_string()) + .split(std::path::MAIN_SEPARATOR) + .nth_back(3) + .unwrap_or("unknown") + .to_string(); + + let dependencies = build_info_build::build_script() + .collect_runtime_dependencies(build_info_build::DependencyDepth::Depth(1)) + .build() + .crate_info + .dependencies + .into_iter() + .map(|dep| format!("{}: {}", dep.name, dep.version)) + .collect::>() + .join(";"); + + println!("cargo:rustc-env=GIT_COMMIT={}", commit); + println!("cargo:rustc-env=BUILD_PROFILE={}", build_profile); + println!("cargo:rustc-env=DEPENDENCY_LIST={}", dependencies); +} + +fn main() -> anyhow::Result<()> { + embed_build_time_info(); + + Ok(()) +} diff --git a/src/bin/finger.rs b/src/bin/finger.rs index a245b70..c7e1fd6 100644 --- a/src/bin/finger.rs +++ b/src/bin/finger.rs @@ -9,6 +9,7 @@ use roowho2_lib::{ DEFAULT_CLIENT_SERVER_SOCKET_PATH, VarlinkFingerClientError, VarlinkFingerClientProxy, }, }, + version, }; /// User information lookup program @@ -30,7 +31,11 @@ use roowho2_lib::{ /// If standard output is a socket, finger will emit a carriage return (^M) before every linefeed (^J). /// This is for processing remote finger requests when invoked by the daemon. #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = version::LONG_VERSION +)] pub struct Args { /// Forces finger to use IPv4 addresses only. #[arg(long, short = '4', conflicts_with = "ipv6")] diff --git a/src/bin/roowhod.rs b/src/bin/roowhod.rs index 16dba3e..3642ce7 100644 --- a/src/bin/roowhod.rs +++ b/src/bin/roowhod.rs @@ -13,20 +13,25 @@ use tokio_util::sync::CancellationToken; use tracing::level_filters::LevelFilter; use tracing_subscriber::layer::SubscriberExt; -use roowho2_lib::server::{ - config::{DEFAULT_CONFIG_PATH, LogLevel}, - ignore_list::IgnoreList, - rwhod::{ - RwhodStatusRegistry, RwhodStatusStore, rwhod_packet_receiver_task, rwhod_packet_sender_task, +use roowho2_lib::{ + server::{ + config::{DEFAULT_CONFIG_PATH, LogLevel}, + ignore_list::IgnoreList, + rwhod::{ + RwhodStatusRegistry, RwhodStatusStore, rwhod_packet_receiver_task, + rwhod_packet_sender_task, + }, + varlink_api::varlink_client_server_task, }, - varlink_api::varlink_client_server_task, + version, }; #[derive(Parser)] #[command( - author = "Programvareverkstedet ", - about, - version + author = "Programvareverkstedet ", + about, + version, + long_version = version::LONG_VERSION )] struct Args { /// Path to configuration file diff --git a/src/bin/rup.rs b/src/bin/rup.rs index b6967a9..c238ce5 100644 --- a/src/bin/rup.rs +++ b/src/bin/rup.rs @@ -6,7 +6,11 @@ use clap::Parser; /// The output shows the current time of day, how long the system has been up, and the load averages. /// The load average numbers give the number of jobs in the run queue averaged over 1, 5 and 15 minutes. #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = crate::version::LONG_VERSION +)] pub struct Args { /// The hosts to query. hosts: Vec, diff --git a/src/bin/ruptime.rs b/src/bin/ruptime.rs index de9645f..0c97a54 100644 --- a/src/bin/ruptime.rs +++ b/src/bin/ruptime.rs @@ -8,6 +8,7 @@ use roowho2_lib::{ server::varlink_api::{ DEFAULT_CLIENT_SERVER_SOCKET_PATH, VarlinkRwhodClientError, VarlinkRwhodClientProxy, }, + version, }; /// Show host status of local machines. @@ -18,7 +19,11 @@ use roowho2_lib::{ /// Machines for which no status report has been received for a while (11 minutes by default, /// see `--uptime-timeout`) are shown as being down. #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = version::LONG_VERSION +)] pub struct Args { /// Users idle an hour or more are not counted unless the `-a` flag is given. #[arg(long, short, conflicts_with = "idle_timeout")] diff --git a/src/bin/rusers.rs b/src/bin/rusers.rs index 419f547..c566fc1 100644 --- a/src/bin/rusers.rs +++ b/src/bin/rusers.rs @@ -1,4 +1,5 @@ use clap::Parser; +use roowho2_lib::version; /// Check who is logged in to machines on local network. /// @@ -8,7 +9,11 @@ use clap::Parser; /// the host-name with the names of the users currently logged on is printed on each line. /// The `rusers` command will wait for one minute to catch late responders. #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = version::LONG_VERSION +)] pub struct Args { /// Print all machines responding even if no one is currently logged in #[arg(long, short)] diff --git a/src/bin/rwall.rs b/src/bin/rwall.rs index 121281a..1cfce08 100644 --- a/src/bin/rwall.rs +++ b/src/bin/rwall.rs @@ -1,11 +1,16 @@ use clap::Parser; +use roowho2_lib::version; /// Send a message to users logged on a host. /// /// The `rwall` command sends a message to the users logged into the specified host. /// The message to be sent can be typed in and terminated with EOF or it can be in a file #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = version::LONG_VERSION +)] pub struct Args { /// The host to send the message to host: String, diff --git a/src/bin/rwho.rs b/src/bin/rwho.rs index 8a7ec0d..cf84d6c 100644 --- a/src/bin/rwho.rs +++ b/src/bin/rwho.rs @@ -8,6 +8,7 @@ use roowho2_lib::{ server::varlink_api::{ DEFAULT_CLIENT_SERVER_SOCKET_PATH, VarlinkRwhodClientError, VarlinkRwhodClientProxy, }, + version, }; /// Check who is logged in on local machines. @@ -20,7 +21,11 @@ use roowho2_lib::{ /// If a user hasn't typed to the system for an hour or more, /// then the user will be omitted from the output of `rwho` unless the `-a` flag is given. #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = version::LONG_VERSION +)] pub struct Args { /// Print all machines responding even if no one is currently logged in #[arg(long, short, conflicts_with = "idle_timeout")] diff --git a/src/bin/wall.rs b/src/bin/wall.rs index 5f0cebf..4bfc85d 100644 --- a/src/bin/wall.rs +++ b/src/bin/wall.rs @@ -7,13 +7,20 @@ use anyhow::Context; use clap::{CommandFactory, Parser}; use clap_complete::{Shell, generate}; use nix::unistd; -use roowho2_lib::server::varlink_api::{ - DEFAULT_CLIENT_SERVER_SOCKET_PATH, VarlinkWalldClientProxy, VarlinkWalldClientResponse, +use roowho2_lib::{ + server::varlink_api::{ + DEFAULT_CLIENT_SERVER_SOCKET_PATH, VarlinkWalldClientProxy, VarlinkWalldClientResponse, + }, + version, }; /// Write a message to all users #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = version::LONG_VERSION +)] pub struct Args { /// Only send message to group #[arg(long, short, value_name = "GROUP")] diff --git a/src/bin/write.rs b/src/bin/write.rs index 164af6e..c5c0fe3 100644 --- a/src/bin/write.rs +++ b/src/bin/write.rs @@ -8,13 +8,20 @@ use clap::{CommandFactory, Parser}; use clap_complete::{Shell, generate}; use nix::unistd; -use roowho2_lib::server::varlink_api::{ - DEFAULT_CLIENT_SERVER_SOCKET_PATH, VarlinkWalldClientProxy, VarlinkWalldClientResponse, +use roowho2_lib::{ + server::varlink_api::{ + DEFAULT_CLIENT_SERVER_SOCKET_PATH, VarlinkWalldClientProxy, VarlinkWalldClientResponse, + }, + version, }; /// Send a message to another user #[derive(Debug, Parser)] -#[command(author = "Programvareverkstedet ", version)] +#[command( + author = "Programvareverkstedet ", + version, + long_version = version::LONG_VERSION +)] pub struct Args { /// User to send the message to #[arg(value_name = "USER", required_unless_present = "completions")] diff --git a/src/lib.rs b/src/lib.rs index dae6a9e..b309646 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,3 +5,4 @@ pub mod proto; pub mod server; pub mod util; +pub mod version; diff --git a/src/version.rs b/src/version.rs new file mode 100644 index 0000000..fb4effc --- /dev/null +++ b/src/version.rs @@ -0,0 +1,31 @@ +use clap::crate_version; + +const fn long_version() -> &'static str { + // macro_rules! feature { + // ($title:expr, $flag:expr) => { + // if cfg!(feature = $flag) { + // concat!($title, ": enabled") + // } else { + // concat!($title, ": disabled") + // } + // }; + // } + + const_format::concatcp!( + crate_version!(), + "\n", + "build profile: ", + env!("BUILD_PROFILE"), + "\n", + "commit: ", + env!("GIT_COMMIT"), + "\n\n", + // "[features]\n", + // "\n", + // "\n", + "[dependencies]\n", + const_format::str_replace!(env!("DEPENDENCY_LIST"), ";", "\n") + ) +} + +pub const LONG_VERSION: &str = long_version();