Skip to content
Open
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
10 changes: 8 additions & 2 deletions src/sm/launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ set(SOURCES instanceidprovider.cpp runtimes.cpp)
# Libraries
# ######################################################################################################################

set(LIBRARIES Poco::JSON aos::core::common::tools aos::sm::runtimes::container aos::sm::runtimes::boot
aos::sm::runtimes::rootfs aos::sm::utils
set(LIBRARIES
Poco::JSON
aos::core::common::tools
aos::sm::runtimes::container
aos::sm::runtimes::filecopy
aos::sm::runtimes::boot
aos::sm::runtimes::rootfs
aos::sm::utils
)

# ######################################################################################################################
Expand Down
11 changes: 11 additions & 0 deletions src/sm/launcher/runtimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "runtimes.hpp"
#include "runtimes/boot/boot.hpp"
#include "runtimes/filecopy/filecopy.hpp"
#include "runtimes/rootfs/rootfs.hpp"

namespace aos::sm::launcher {
Expand Down Expand Up @@ -58,6 +59,16 @@ Error Runtimes::Init(const Config& config, iamclient::CurrentNodeInfoProviderItf
return AOS_ERROR_WRAP(err);
}

mRuntimes.emplace_back(std::move(runtime));
} else if (runtimeConfig.mPlugin == cRuntimeFileCopy) {
auto runtime = std::make_unique<FileCopyRuntime>();

if (auto err = runtime->Init(
runtimeConfig, currentNodeInfoProvider, itemInfoProvider, ociSpec, statusReceiver, systemdConn);
!err.IsNone()) {
return AOS_ERROR_WRAP(err);
}

mRuntimes.emplace_back(std::move(runtime));
} else {
return AOS_ERROR_WRAP(Error(ErrorEnum::eNotSupported, "runtime is not supported"));
Expand Down
1 change: 1 addition & 0 deletions src/sm/launcher/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ set(TARGET_PREFIX ${TARGET_PREFIX}_runtimes)

add_subdirectory(boot)
add_subdirectory(container)
add_subdirectory(filecopy)
add_subdirectory(rootfs)
add_subdirectory(utils)
51 changes: 51 additions & 0 deletions src/sm/launcher/runtimes/filecopy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright (C) 2026 EPAM Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#

# ######################################################################################################################
# Target name
# ######################################################################################################################

set(TARGET_NAME filecopy)

# ######################################################################################################################
# Sources
# ######################################################################################################################

set(SOURCES config.cpp filecopy.cpp)

# ######################################################################################################################
# Libraries
# ######################################################################################################################

set(LIBRARIES Poco::JSON aos::common::utils aos::core::common::tools aos::sm::config aos::sm::utils
aos::sm::runtimes::utils
)

# ######################################################################################################################
# Target
# ######################################################################################################################

add_module(
TARGET_NAME
${TARGET_NAME}
LOG_MODULE
STACK_USAGE
${AOS_STACK_USAGE}
SOURCES
${SOURCES}
HEADERS
${HEADERS}
LIBRARIES
${LIBRARIES}
)

# ######################################################################################################################
# Tests
# ######################################################################################################################

if(WITH_TEST)
add_subdirectory(tests)
endif()
37 changes: 37 additions & 0 deletions src/sm/launcher/runtimes/filecopy/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2026 EPAM Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <common/utils/exception.hpp>
#include <common/utils/filesystem.hpp>

#include "config.hpp"

namespace aos::sm::launcher {

namespace {

constexpr auto cDefaultTargetBaseDir = "/var/aos/components";
constexpr auto cDefaultRuntimeSubDir = "runtimes";

} // namespace

Error ParseConfig(const RuntimeConfig& config, FileCopyConfig& fileCopyConfig)
{
try {
const auto object = common::utils::CaseInsensitiveObjectWrapper(config.mConfig);

fileCopyConfig.mTargetPath
= object.GetValue<std::string>("targetPath", common::utils::JoinPath(cDefaultTargetBaseDir, config.mType));
fileCopyConfig.mRuntimeDir = object.GetValue<std::string>(
"runtimeDir", common::utils::JoinPath(config.mWorkingDir, cDefaultRuntimeSubDir, config.mType));
} catch (const std::exception& e) {
return common::utils::ToAosError(e);
}

return ErrorEnum::eNone;
}

} // namespace aos::sm::launcher
37 changes: 37 additions & 0 deletions src/sm/launcher/runtimes/filecopy/config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2026 EPAM Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef AOS_SM_LAUNCHER_RUNTIMES_FILECOPY_CONFIG_HPP_
#define AOS_SM_LAUNCHER_RUNTIMES_FILECOPY_CONFIG_HPP_

#include <string>

#include <sm/config/config.hpp>

#include <sm/launcher/runtimes/config.hpp>

namespace aos::sm::launcher {

/**
* File copy runtime config.
*/
struct FileCopyConfig {
std::string mTargetPath;
std::string mRuntimeDir;
};

/**
* Parses file copy runtime config.
*
* @param config runtime config.
* @param[out] fileCopyConfig file copy runtime config.
* @return Error.
*/
Error ParseConfig(const RuntimeConfig& config, FileCopyConfig& fileCopyConfig);

} // namespace aos::sm::launcher

#endif
Loading
Loading