Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ all: clippy
cargo build --target=x86_64-unknown-linux-musl --all

release: clippy
cargo build --release --target=x86_64-unknown-linux-musl --all
cargo build --release --features git-version --target=x86_64-unknown-linux-musl --all

run: all
sudo ./target/debug/feos --ipam $(IPAM)
Expand Down
5 changes: 4 additions & 1 deletion feos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ prost = { workspace = true }
hyper-util = { workspace = true }
once_cell = { workspace = true }
tower = { workspace = true }
tempfile = { workspace = true }
tempfile = { workspace = true }

[features]
git-version = ["feos-utils/git-version"]
2 changes: 1 addition & 1 deletion feos/services/host-service/src/worker/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ pub async fn handle_get_version_info(
let result = fs::read_to_string(path)
.await
.map(|kernel_version| {
let feos_version = env!("CARGO_PKG_VERSION").to_string();
let feos_version = feos_utils::version::full_version_string();
GetVersionInfoResponse {
kernel_version: kernel_version.trim().to_string(),
feos_version,
Expand Down
3 changes: 1 addition & 2 deletions feos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use image_service::IMAGE_SERVICE_SOCKET;
use log::{error, info, warn};
use nix::unistd::Uid;
use setup::*;
use std::env;
use tokio::{fs, net::UnixListener, sync::mpsc};
use tokio_stream::wrappers::UnixListenerStream;
use tonic::transport::Server;
Expand All @@ -25,7 +24,7 @@ pub async fn run_server(restarted_after_upgrade: bool) -> Result<()> {
╚═╝ ╚══════╝ ╚═════╝ ╚══════╝
v{}
",
env!("CARGO_PKG_VERSION")
feos_utils::version::full_version_string()
);

let log_handle = feos_utils::feos_logger::Builder::new()
Expand Down
9 changes: 8 additions & 1 deletion feos/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ netlink-packet-route = { workspace = true }
pnet = { workspace = true }
rtnetlink = { workspace = true }
socket2 = { workspace = true }
libc = { workspace = true }
libc = { workspace = true }

[build-dependencies]
cc = "1.0"

[features]
default = []
git-version = []
19 changes: 19 additions & 0 deletions feos/utils/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

use std::process::Command;

fn main() {
println!("cargo:rerun-if-changed=.git/HEAD");

let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output();

if let Ok(output) = output {
if output.status.success() {
let commit_hash = String::from_utf8_lossy(&output.stdout).trim().to_string();
println!("cargo:rustc-env=GIT_COMMIT_HASH={commit_hash}");
}
}
}
1 change: 1 addition & 0 deletions feos/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pub mod feos_logger;
pub mod filesystem;
pub mod host;
pub mod network;
pub mod version;
14 changes: 14 additions & 0 deletions feos/utils/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

#[cfg(not(feature = "git-version"))]
pub fn full_version_string() -> String {
env!("CARGO_PKG_VERSION").to_string()
}

#[cfg(feature = "git-version")]
pub fn full_version_string() -> String {
let version = env!("CARGO_PKG_VERSION");
let commit_hash = option_env!("GIT_COMMIT_HASH").unwrap_or("???????");
format!("{} ({})", version, commit_hash)
}
Loading