Skip to content

Commit

Permalink
Merge pull request #231 from ks734/add_pluginData
Browse files Browse the repository at this point in the history
RDK-41482 : make localtime symlink path configurable
  • Loading branch information
goruklu committed May 5, 2023
2 parents caf554b + 4fc97b9 commit 86d9822
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
env:
# For CI, build all optional plugins. Newly developed plugins should be added to this list
optional_plugins: "-DPLUGIN_TESTPLUGIN=ON -DPLUGIN_GPU=ON -DPLUGIN_LOCALTIME=ON -DPLUGIN_RTSCHEDULING=ON -DPLUGIN_HTTPPROXY=ON -DPLUGIN_APPSERVICES=ON -DPLUGIN_IONMEMORY=ON -DPLUGIN_DEVICEMAPPER=ON -DPLUGIN_OOMCRASH=ON"
Expand All @@ -18,12 +18,12 @@ jobs:
name: Build in ${{ matrix.build_type }} Mode (${{ matrix.extra_flags }})
steps:
- name: checkout
uses: actions/checkout@v2.1.0
uses: actions/checkout@v3

- name: install-dependencies
run: |
sudo apt-get update -y -q
sudo apt-get install -q -y automake libtool autotools-dev software-properties-common build-essential cmake libsystemd-dev libctemplate-dev libjsoncpp-dev libjsoncpp1 libdbus-1-dev libnl-3-dev libnl-route-3-dev libsystemd-dev libyajl-dev libcap-dev libboost-dev
sudo apt-get install -q -y automake libtool autotools-dev software-properties-common build-essential cmake libsystemd-dev libctemplate-dev libjsoncpp-dev libdbus-1-dev libnl-3-dev libnl-route-3-dev libsystemd-dev libyajl-dev libcap-dev libboost-dev
- name: build dobby
run: |
Expand Down
1 change: 1 addition & 0 deletions bundle/lib/include/DobbySpecConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class DobbySpecConfig : public DobbyConfig
const std::shared_ptr<const IDobbySettings::HardwareAccessSettings> mGpuSettings;
const std::shared_ptr<const IDobbySettings::HardwareAccessSettings> mVpuSettings;
const std::vector<std::string> mDefaultPlugins;
const Json::Value mRdkPluginsData;

private:
bool mValid;
Expand Down
7 changes: 4 additions & 3 deletions bundle/lib/source/DobbySpecConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <array>
#include <atomic>
#include <algorithm>
#include <grp.h>
#include <fcntl.h>
#include <limits.h>
Expand Down Expand Up @@ -206,6 +207,7 @@ DobbySpecConfig::DobbySpecConfig(const std::shared_ptr<IDobbyUtils> &utils,
, mGpuSettings(settings->gpuAccessSettings())
, mVpuSettings(settings->vpuAccessSettings())
, mDefaultPlugins(settings->defaultPlugins())
, mRdkPluginsData(settings->rdkPluginsData())
, mDictionary(nullptr)
, mConf(nullptr)
, mSpecVersion(SpecVersion::Unknown)
Expand Down Expand Up @@ -618,11 +620,10 @@ bool DobbySpecConfig::parseSpec(ctemplate::TemplateDictionary* dictionary,
dictionary->ShowSection(ENABLE_RDK_PLUGINS);

// step 6.5 - add any default plugins in the settings file
// TODO:: Allow defining plugin data in the settings file
Json::Value rdkPluginData = Json::objectValue;
Json::Value rdkPluginData = mRdkPluginsData;
for (const auto& pluginName : mDefaultPlugins)
{
mRdkPluginsJson[pluginName]["data"] = rdkPluginData;
mRdkPluginsJson[pluginName]["data"] = rdkPluginData[pluginName];
mRdkPluginsJson[pluginName]["required"] = false;
}

Expand Down
22 changes: 15 additions & 7 deletions rdkPlugins/LocalTime/source/LocalTimePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,31 @@ bool LocalTimePlugin::postInstallation()
{
AI_LOG_FN_ENTRY();

const char* path = mContainerConfig->rdk_plugins->localtime->data->path;
if (path)
std::string path;

if (mContainerConfig->rdk_plugins->localtime->data->path)
{
AI_LOG_INFO("Set localtime path %s",path);
path = mContainerConfig->rdk_plugins->localtime->data->path;
std::size_t found = path.find_last_of("/");
std::string dirPath = path.substr(0, found);

if (mUtils->mkdirRecursive(mRootfsPath + dirPath, 0755) || (errno == EEXIST))
AI_LOG_INFO("Set localtime path %s", path.c_str());
else
AI_LOG_SYS_ERROR(errno, "failed to create dir. %s", path.c_str());
}
else
{
path = "/etc/localtime";
AI_LOG_INFO("Set default path %s", path);
AI_LOG_INFO("Set default path %s", path.c_str());
}

// get the real path to the correct local time zone
char pathBuf[PATH_MAX];
ssize_t len = readlink(path, pathBuf, sizeof(pathBuf));
ssize_t len = readlink(path.c_str(), pathBuf, sizeof(pathBuf));
if (len <= 0)
{
AI_LOG_SYS_ERROR_EXIT(errno, "readlink failed on %s", path);
AI_LOG_SYS_ERROR_EXIT(errno, "readlink failed on %s", path.c_str());
return false;
}

Expand All @@ -88,7 +96,7 @@ bool LocalTimePlugin::postInstallation()
}
else if (symlink(localtimeInHost.c_str(), localtimeInContainer.c_str()) < 0)
{
AI_LOG_SYS_ERROR_EXIT(errno, "failed to create %s symlink", path);
AI_LOG_SYS_ERROR_EXIT(errno, "failed to create %s symlink", path.c_str());
return false;
}

Expand Down
7 changes: 7 additions & 0 deletions settings/include/IDobbySettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
#include <set>
#include <netinet/in.h>

#if defined(RDK)
# include <json/json.h>
#else
# include <jsoncpp/json.h>
#endif

// -----------------------------------------------------------------------------
/**
* @class IDobbySettings
Expand Down Expand Up @@ -189,6 +195,7 @@ class IDobbySettings
*/
virtual std::vector<std::string> defaultPlugins() const = 0;

virtual Json::Value rdkPluginsData() const = 0;

struct LogRelaySettings
{
Expand Down
4 changes: 4 additions & 0 deletions settings/include/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class Settings final : public IDobbySettings
in_addr_t addressRange() const override;
std::vector<std::string> defaultPlugins() const override;

Json::Value rdkPluginsData() const override;

LogRelaySettings logRelaySettings() const override;

void dump(int aiLogLevel = -1) const;
Expand Down Expand Up @@ -122,6 +124,8 @@ class Settings final : public IDobbySettings
std::pair<std::string, in_addr_t> mAddressRange;
std::vector<std::string> mDefaultPlugins;

Json::Value mRdkPluginsData;

LogRelaySettings mLogRelaySettings;
};

Expand Down
23 changes: 22 additions & 1 deletion settings/source/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,18 @@ Settings::Settings(const Json::Value& settings)
for (const Json::Value &pluginName : defaultPluginNames)
{
if (pluginName.isString())
{
mDefaultPlugins.push_back(pluginName.asString());
mRdkPluginsData[pluginName.asString()] = Json::Value::null;
}
else if(pluginName.isObject())
{
for (const auto& value : pluginName.getMemberNames())
{
mDefaultPlugins.push_back(value);
mRdkPluginsData[value] = pluginName[value];
}
}
else
AI_LOG_ERROR("invalid entry in defaultPlugins array in JSON settings file");
}
Expand Down Expand Up @@ -401,6 +412,16 @@ std::vector<std::string> Settings::defaultPlugins() const
return mDefaultPlugins;
}

// -----------------------------------------------------------------------------
/**
* @brief
*
*/
Json::Value Settings::rdkPluginsData() const
{
return mRdkPluginsData;
}

// -----------------------------------------------------------------------------
/**
* @brief
Expand Down Expand Up @@ -973,4 +994,4 @@ std::shared_ptr<IDobbySettings::HardwareAccessSettings> Settings::getHardwareAcc
accessSettings->extraEnvVariables = getEnvVarsFromJson(hw, Json::Path(".extraEnvVariables"));

return accessSettings;
}
}

0 comments on commit 86d9822

Please sign in to comment.