File tree Expand file tree Collapse file tree 9 files changed +50
-6
lines changed
services/host-service/src/worker Expand file tree Collapse file tree 9 files changed +50
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ all: clippy
99 cargo build --target=x86_64-unknown-linux-musl --all
1010
1111release : clippy
12- cargo build --release --target=x86_64-unknown-linux-musl --all
12+ cargo build --release --features git-version -- target=x86_64-unknown-linux-musl --all
1313
1414run : all
1515 sudo ./target/debug/feos --ipam $(IPAM )
Original file line number Diff line number Diff line change @@ -56,4 +56,7 @@ prost = { workspace = true }
5656hyper-util = { workspace = true }
5757once_cell = { workspace = true }
5858tower = { workspace = true }
59- tempfile = { workspace = true }
59+ tempfile = { workspace = true }
60+
61+ [features ]
62+ git-version = [" feos-utils/git-version" ]
Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ pub async fn handle_get_version_info(
325325 let result = fs:: read_to_string ( path)
326326 . await
327327 . map ( |kernel_version| {
328- let feos_version = env ! ( "CARGO_PKG_VERSION" ) . to_string ( ) ;
328+ let feos_version = feos_utils :: version :: full_version_string ( ) ;
329329 GetVersionInfoResponse {
330330 kernel_version : kernel_version. trim ( ) . to_string ( ) ,
331331 feos_version,
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ use image_service::IMAGE_SERVICE_SOCKET;
99use log:: { error, info, warn} ;
1010use nix:: unistd:: Uid ;
1111use setup:: * ;
12- use std:: env;
1312use tokio:: { fs, net:: UnixListener , sync:: mpsc} ;
1413use tokio_stream:: wrappers:: UnixListenerStream ;
1514use tonic:: transport:: Server ;
@@ -25,7 +24,7 @@ pub async fn run_server(restarted_after_upgrade: bool) -> Result<()> {
2524 ╚═╝ ╚══════╝ ╚═════╝ ╚══════╝
2625 v{}
2726 " ,
28- env! ( "CARGO_PKG_VERSION" )
27+ feos_utils :: version :: full_version_string ( )
2928 ) ;
3029
3130 let log_handle = feos_utils:: feos_logger:: Builder :: new ( )
Original file line number Diff line number Diff line change @@ -15,4 +15,11 @@ netlink-packet-route = { workspace = true }
1515pnet = { workspace = true }
1616rtnetlink = { workspace = true }
1717socket2 = { workspace = true }
18- libc = { workspace = true }
18+ libc = { workspace = true }
19+
20+ [build-dependencies ]
21+ cc = " 1.0"
22+
23+ [features ]
24+ default = []
25+ git-version = []
Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ use std:: process:: Command ;
5+
6+ fn main ( ) {
7+ println ! ( "cargo:rerun-if-changed=.git/HEAD" ) ;
8+
9+ let output = Command :: new ( "git" )
10+ . args ( [ "rev-parse" , "--short" , "HEAD" ] )
11+ . output ( ) ;
12+
13+ if let Ok ( output) = output {
14+ if output. status . success ( ) {
15+ let commit_hash = String :: from_utf8_lossy ( & output. stdout ) . trim ( ) . to_string ( ) ;
16+ println ! ( "cargo:rustc-env=GIT_COMMIT_HASH={commit_hash}" ) ;
17+ }
18+ }
19+ }
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ pub mod feos_logger;
55pub mod filesystem;
66pub mod host;
77pub mod network;
8+ pub mod version;
Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ #[ cfg( not( feature = "git-version" ) ) ]
5+ pub fn full_version_string ( ) -> String {
6+ env ! ( "CARGO_PKG_VERSION" ) . to_string ( )
7+ }
8+
9+ #[ cfg( feature = "git-version" ) ]
10+ pub fn full_version_string ( ) -> String {
11+ let version = env ! ( "CARGO_PKG_VERSION" ) ;
12+ let commit_hash = option_env ! ( "GIT_COMMIT_HASH" ) . unwrap_or ( "???????" ) ;
13+ format ! ( "{} ({})" , version, commit_hash)
14+ }
You can’t perform that action at this time.
0 commit comments