mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-16 08:26:16 +00:00
Merge pull request #742 from c3d/2.0-dev-bug740-generate-version
Generate version file with more information in it.
This commit is contained in:
commit
54aa6ede96
@ -57,12 +57,27 @@ INIT := no
|
||||
# Path to systemd unit directory if installed as not init.
|
||||
UNIT_DIR := /usr/lib/systemd/system
|
||||
|
||||
GENERATED_CODE = src/version.rs
|
||||
|
||||
AGENT_NAME=$(TARGET)
|
||||
API_VERSION=0.0.1
|
||||
AGENT_VERSION=$(VERSION)
|
||||
|
||||
GENERATED_REPLACEMENTS= \
|
||||
AGENT_NAME \
|
||||
AGENT_VERSION \
|
||||
API_VERSION \
|
||||
BINDIR \
|
||||
COMMIT \
|
||||
VERSION_COMMIT
|
||||
GENERATED_FILES :=
|
||||
|
||||
GENERATED_FILES += $(GENERATED_CODE)
|
||||
|
||||
ifeq ($(INIT),no)
|
||||
# Unit file to start kata agent in systemd systems
|
||||
UNIT_FILES = kata-agent.service
|
||||
GENERATED_FILES := $(UNIT_FILES)
|
||||
GENERATED_FILES += $(UNIT_FILES)
|
||||
# Target to be reached in systemd services
|
||||
UNIT_FILES += kata-containers.target
|
||||
endif
|
||||
@ -86,7 +101,7 @@ endef
|
||||
|
||||
default: $(TARGET) show-header
|
||||
|
||||
$(TARGET): $(TARGET_PATH)
|
||||
$(TARGET): $(GENERATED_CODE) $(TARGET_PATH)
|
||||
|
||||
$(TARGET_PATH): $(SOURCES) | show-summary
|
||||
@cargo build --target $(TRIPLE) --$(BUILD_TYPE)
|
||||
@ -98,16 +113,14 @@ show-header:
|
||||
@printf "%s - version %s (commit %s)\n\n" "$(TARGET)" "$(VERSION)" "$(COMMIT_MSG)"
|
||||
|
||||
$(GENERATED_FILES): %: %.in
|
||||
@sed \
|
||||
-e 's|[@]bindir[@]|$(BINDIR)|g' \
|
||||
-e 's|[@]kata-agent[@]|$(TARGET)|g' \
|
||||
"$<" > "$@"
|
||||
@sed $(foreach r,$(GENERATED_REPLACEMENTS),-e 's|@$r@|$($r)|g') "$<" > "$@"
|
||||
|
||||
install: build-service
|
||||
@install -D $(TARGET_PATH) $(DESTDIR)/$(BINDIR)/$(TARGET)
|
||||
|
||||
clean:
|
||||
@cargo clean
|
||||
@rm -f $(GENERATED_FILES)
|
||||
|
||||
test:
|
||||
@cargo test --all --target $(TRIPLE)
|
||||
|
@ -14,7 +14,7 @@ Wants=kata-containers.target
|
||||
# from a VM vsock port
|
||||
StandardOutput=tty
|
||||
Type=simple
|
||||
ExecStart=@bindir@/@kata-agent@
|
||||
ExecStart=@BINDIR@/@AGENT_NAME@
|
||||
LimitNOFILE=infinity
|
||||
# ExecStop is required for static agent tracing; in all other scenarios
|
||||
# the runtime handles shutting down the VM.
|
||||
|
@ -83,13 +83,8 @@ lazy_static! {
|
||||
}
|
||||
|
||||
fn announce(logger: &Logger, config: &agentConfig) {
|
||||
let commit = match env::var("VERSION_COMMIT") {
|
||||
Ok(s) => s,
|
||||
Err(_) => String::from(""),
|
||||
};
|
||||
|
||||
info!(logger, "announce";
|
||||
"agent-commit" => commit.as_str(),
|
||||
"agent-commit" => version::VERSION_COMMIT,
|
||||
|
||||
// Avoid any possibility of confusion with the old agent
|
||||
"agent-type" => "rust",
|
||||
@ -109,7 +104,7 @@ fn main() -> Result<()> {
|
||||
NAME,
|
||||
version::AGENT_VERSION,
|
||||
version::API_VERSION,
|
||||
env::var("VERSION_COMMIT").unwrap_or("unknown".to_string())
|
||||
version::VERSION_COMMIT,
|
||||
);
|
||||
|
||||
exit(0);
|
||||
|
@ -1,7 +0,0 @@
|
||||
// Copyright (c) 2019 Ant Financial
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
pub const AGENT_VERSION: &str = "1.4.5";
|
||||
pub const API_VERSION: &str = "0.0.1";
|
16
src/agent/src/version.rs.in
Normal file
16
src/agent/src/version.rs.in
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2020 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
//
|
||||
// WARNING: This file is auto-generated - DO NOT EDIT!
|
||||
//
|
||||
|
||||
pub const AGENT_VERSION: &str = "@AGENT_VERSION@";
|
||||
pub const API_VERSION: &str = "@API_VERSION@";
|
||||
pub const VERSION_COMMIT: &str = "@VERSION_COMMIT@";
|
||||
pub const GIT_COMMIT: &str = "@COMMIT@";
|
||||
pub const AGENT_NAME: &str = "@AGENT_NAME@";
|
||||
pub const AGENT_DIR: &str = "@BINDIR@";
|
||||
pub const AGENT_PATH: &str = "@BINDIR@/@AGENT_NAME@";
|
Loading…
Reference in New Issue
Block a user