Skip to content

Commit

Permalink
refactor: remove unused field 'bind' and 'innerBind'
Browse files Browse the repository at this point in the history
Signed-off-by: ComixHe <[email protected]>
  • Loading branch information
ComixHe committed Jan 7, 2025
1 parent 54330be commit f29bb88
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 355 deletions.
45 changes: 0 additions & 45 deletions api/schema/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,51 +47,6 @@
"properties": {
"xdgDirectories": {
"$ref": "#/$defs/XDGDirectoryPermissions"
},
"binds": {
"type": "array",
"items": {
"type": "object",
"title": "ApplicationConfigurationPermissionsBind",
"description": "items of container",
"required": [
"source",
"destination"
],
"properties": {
"source": {
"type": "string",
"description": "source file of host"
},
"destination": {
"type": "string",
"description": "mount source file to the container"
}
}
}
},
"innerBinds": {
"type": "array",
"description": "inner binds of container",
"items": {
"type": "object",
"title": "ApplicationConfigurationPermissionsInnerBind",
"description": "items of inner binds of container",
"required": [
"source",
"destination"
],
"properties": {
"source": {
"type": "string",
"description": "source file of container"
},
"destination": {
"type": "string",
"description": "mount source file to the another position of container"
}
}
}
}
}
},
Expand Down
33 changes: 0 additions & 33 deletions api/schema/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,39 +55,6 @@ $defs:
properties:
xdgDirectories:
$ref: '#/$defs/XDGDirectoryPermissions'
binds:
type: array
items:
type: object
title: ApplicationConfigurationPermissionsBind
description: items of container
required:
- source
- destination
properties:
source:
type: string
description: source file of host
destination:
type: string
description: mount source file to the container
innerBinds:
type: array
description: inner binds of container
items:
type: object
title: ApplicationConfigurationPermissionsInnerBind
description: items of inner binds of container
required:
- source
- destination
properties:
source:
type: string
description: source file of container
destination:
type: string
description: mount source file to the another position of container
ContainerProcessStateInfo:
description: |
information about process which in container that start by ll-cli, all content
Expand Down
2 changes: 0 additions & 2 deletions libs/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ pfl_add_library(
src/linglong/api/types/helper.cpp
src/linglong/api/types/helper.h
src/linglong/api/types/v1/ApplicationConfiguration.hpp
src/linglong/api/types/v1/ApplicationConfigurationPermissionsBind.hpp
src/linglong/api/types/v1/ApplicationConfigurationPermissions.hpp
src/linglong/api/types/v1/ApplicationConfigurationPermissionsInnerBind.hpp
src/linglong/api/types/v1/ApplicationPermissionsRequest.hpp
src/linglong/api/types/v1/BuilderConfig.hpp
src/linglong/api/types/v1/BuilderProject.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include <nlohmann/json.hpp>
#include "linglong/api/types/v1/helper.hpp"

#include "linglong/api/types/v1/ApplicationConfigurationPermissionsBind.hpp"
#include "linglong/api/types/v1/ApplicationConfigurationPermissionsInnerBind.hpp"
#include "linglong/api/types/v1/XdgDirectoryPermission.hpp"

namespace linglong {
Expand All @@ -35,11 +33,6 @@ using nlohmann::json;
* application configuration permissions
*/
struct ApplicationConfigurationPermissions {
std::optional<std::vector<ApplicationConfigurationPermissionsBind>> binds;
/**
* inner binds of container
*/
std::optional<std::vector<ApplicationConfigurationPermissionsInnerBind>> innerBinds;
std::optional<std::vector<XdgDirectoryPermission>> xdgDirectories;
};
}
Expand Down

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions libs/api/src/linglong/api/types/v1/Generators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,11 @@
#include "linglong/api/types/v1/ApplicationConfiguration.hpp"
#include "linglong/api/types/v1/ApplicationConfigurationPermissions.hpp"
#include "linglong/api/types/v1/XdgDirectoryPermission.hpp"
#include "linglong/api/types/v1/ApplicationConfigurationPermissionsInnerBind.hpp"
#include "linglong/api/types/v1/ApplicationConfigurationPermissionsBind.hpp"

namespace linglong {
namespace api {
namespace types {
namespace v1 {
void from_json(const json & j, ApplicationConfigurationPermissionsBind & x);
void to_json(json & j, const ApplicationConfigurationPermissionsBind & x);

void from_json(const json & j, ApplicationConfigurationPermissionsInnerBind & x);
void to_json(json & j, const ApplicationConfigurationPermissionsInnerBind & x);

void from_json(const json & j, XdgDirectoryPermission & x);
void to_json(json & j, const XdgDirectoryPermission & x);

Expand Down Expand Up @@ -218,28 +210,6 @@ void to_json(json & j, const SubState & x);
void from_json(const json & j, Version & x);
void to_json(json & j, const Version & x);

inline void from_json(const json & j, ApplicationConfigurationPermissionsBind& x) {
x.destination = j.at("destination").get<std::string>();
x.source = j.at("source").get<std::string>();
}

inline void to_json(json & j, const ApplicationConfigurationPermissionsBind & x) {
j = json::object();
j["destination"] = x.destination;
j["source"] = x.source;
}

inline void from_json(const json & j, ApplicationConfigurationPermissionsInnerBind& x) {
x.destination = j.at("destination").get<std::string>();
x.source = j.at("source").get<std::string>();
}

inline void to_json(json & j, const ApplicationConfigurationPermissionsInnerBind & x) {
j = json::object();
j["destination"] = x.destination;
j["source"] = x.source;
}

inline void from_json(const json & j, XdgDirectoryPermission& x) {
x.allowed = j.at("allowed").get<bool>();
x.dirType = j.at("dirType").get<std::string>();
Expand All @@ -252,19 +222,11 @@ j["dirType"] = x.dirType;
}

inline void from_json(const json & j, ApplicationConfigurationPermissions& x) {
x.binds = get_stack_optional<std::vector<ApplicationConfigurationPermissionsBind>>(j, "binds");
x.innerBinds = get_stack_optional<std::vector<ApplicationConfigurationPermissionsInnerBind>>(j, "innerBinds");
x.xdgDirectories = get_stack_optional<std::vector<XdgDirectoryPermission>>(j, "xdgDirectories");
}

inline void to_json(json & j, const ApplicationConfigurationPermissions & x) {
j = json::object();
if (x.binds) {
j["binds"] = x.binds;
}
if (x.innerBinds) {
j["innerBinds"] = x.innerBinds;
}
if (x.xdgDirectories) {
j["xdgDirectories"] = x.xdgDirectories;
}
Expand Down
38 changes: 0 additions & 38 deletions libs/linglong/src/linglong/builder/linglong_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,44 +1468,6 @@ utils::error::Result<void> Builder::run(const QStringList &modules,
}

std::vector<ocppi::runtime::config::types::Mount> applicationMounts{};
auto bindMount =
[&applicationMounts](const api::types::v1::ApplicationConfigurationPermissionsBind &bind) {
applicationMounts.push_back(ocppi::runtime::config::types::Mount{
.destination = bind.destination,
.gidMappings = {},
.options = { { "rbind" } },
.source = bind.source,
.type = "bind",
.uidMappings = {},
});
};
auto bindInnerMount =
[&applicationMounts](
const api::types::v1::ApplicationConfigurationPermissionsInnerBind &bind) {
applicationMounts.push_back(ocppi::runtime::config::types::Mount{
.destination = bind.destination,
.gidMappings = {},
.options = { { "rbind" } },
.source = "rootfs" + bind.source,
.type = "bind",
.uidMappings = {},
});
};

if (info->permissions) {
auto &perm = info->permissions;
if (perm->binds) {
const auto &binds = perm->binds;
std::for_each(binds->cbegin(), binds->cend(), bindMount);
}

if (perm->innerBinds) {
const auto &innerBinds = perm->innerBinds;
const auto &hostSourceDir =
std::filesystem::path{ curDir->absolutePath().toStdString() };
std::for_each(innerBinds->cbegin(), innerBinds->cend(), bindInnerMount);
}
}
if (debug) {
std::filesystem::path workdir = this->workingDir.absolutePath().toStdString();
// 生成 host_gdbinit 可使用 gdb --init-command=linglong/host_gdbinit 从宿主机调试
Expand Down
42 changes: 1 addition & 41 deletions libs/linglong/src/linglong/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,46 +617,6 @@ int Cli::run()
}

std::vector<ocppi::runtime::config::types::Mount> applicationMounts{};
auto bindMount =
[&applicationMounts](const api::types::v1::ApplicationConfigurationPermissionsBind &bind) {
applicationMounts.push_back(ocppi::runtime::config::types::Mount{
.destination = bind.destination,
.gidMappings = {},
.options = { { "rbind" } },
.source = bind.source,
.type = "bind",
.uidMappings = {},
});
};

auto bindInnerMount =
[&applicationMounts](
const api::types::v1::ApplicationConfigurationPermissionsInnerBind &bind) {
applicationMounts.push_back(ocppi::runtime::config::types::Mount{
.destination = bind.destination,
.gidMappings = {},
.options = { { "rbind" } },
.source = "rootfs" + bind.source,
.type = "bind",
.uidMappings = {},
});
};

if (info.permissions) {
const auto &perm = info.permissions;
if (perm->binds) {
const auto &binds = perm->binds;
std::for_each(binds->cbegin(), binds->cend(), bindMount);
}

if (perm->innerBinds) {
const auto &innerBinds = perm->innerBinds;
const auto &hostSourceDir =
std::filesystem::path{ appLayerDir->absolutePath().toStdString() };
std::for_each(innerBinds->cbegin(), innerBinds->cend(), bindInnerMount);
}
}

applicationMounts.push_back(ocppi::runtime::config::types::Mount{
.destination = "/run/linglong/cache",
.options = nlohmann::json::array({ "rbind", "ro" }),
Expand Down Expand Up @@ -2420,7 +2380,7 @@ Cli::ensureCache(const package::Reference &ref,

void Cli::updateAM() noexcept
{
// NOTE: make sure AM refresh the cache of desktop
// NOTE: make sure AM refresh the cache of desktop
if ((QSysInfo::productType() == "Deepin" || QSysInfo::productType() == "deepin")
&& this->lastState == linglong::api::types::v1::State::Succeed) {
QDBusConnection conn = QDBusConnection::systemBus();
Expand Down
Loading

0 comments on commit f29bb88

Please sign in to comment.