Skip to content

Commit

Permalink
feat: adjust systemd/user priority
Browse files Browse the repository at this point in the history
XDG_DATA_DIRS下面的systemd优先级很高, 会影响系统systemd服务
将应用的systemd导出到其他地方, 再使用user-generator复制到优先级最低的generator.late目录
  • Loading branch information
myml committed Dec 25, 2024
1 parent 3d3d948 commit 8544c5a
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 137 deletions.
1 change: 1 addition & 0 deletions debian/linglong-bin.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ usr/bin/ll-cli
usr/bin/llpkg
usr/lib/linglong/*
usr/lib/systemd/system-environment-generators/61-linglong
usr/lib/systemd/user-generators/linglong-user-systemd-generator
usr/lib/systemd/system/org.deepin.linglong.PackageManager.service lib/systemd/system/
usr/lib/systemd/user/linglong-session-helper.service
usr/lib/sysusers.d/linglong.conf
Expand Down
301 changes: 185 additions & 116 deletions libs/linglong/src/linglong/repo/ostree_repo.cpp

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions libs/linglong/src/linglong/repo/ostree_repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,16 @@ class OSTreeRepo : public QObject
[[nodiscard]] utils::error::Result<package::LayerDir>
getMergedModuleDir(const api::types::v1::RepositoryCacheLayersItem &layer,
bool fallbackLayerDir = true) const noexcept;
utils::error::Result<void> exportEntries(
const QDir &entriesDir, const api::types::v1::RepositoryCacheLayersItem &item) noexcept;
utils::error::Result<void>
exportEntries(const std::filesystem::path &rootEntriesDir,
const api::types::v1::RepositoryCacheLayersItem &item) noexcept;
static utils::error::Result<void> IniLikeFileRewrite(const QFileInfo &info,
const QString &id) noexcept;

utils::error::Result<void> exportDir(const std::string &appID,
const std::filesystem::path &source,
const std::filesystem::path &destination,
const int &max_depth);
};

} // namespace linglong::repo
51 changes: 32 additions & 19 deletions libs/utils/src/linglong/utils/error/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <QStringBuilder>

#include <memory>
#include <string>
#include <utility>

namespace linglong::utils::error {
Expand All @@ -38,11 +39,9 @@ class Error

[[nodiscard]] auto message() const { return pImpl->message(); }

static auto Err(const char *file,
int line,
const QString &trace_msg,
const QString &msg,
int code = -1) -> Error
static auto
Err(const char *file, int line, const QString &trace_msg, const QString &msg, int code = -1)
-> Error
{
return Error(std::make_unique<details::ErrorImpl>(file,
line,
Expand All @@ -67,8 +66,8 @@ class Error
nullptr));
}

static auto
Err(const char *file, int line, const QString &trace_msg, const QFile &qfile) -> Error
static auto Err(const char *file, int line, const QString &trace_msg, const QFile &qfile)
-> Error
{
return Error(std::make_unique<details::ErrorImpl>(file,
line,
Expand All @@ -79,11 +78,9 @@ class Error
nullptr));
}

static auto Err(const char *file,
int line,
const QString &trace_msg,
std::exception_ptr err,
int code = -1) -> Error
static auto
Err(const char *file, int line, const QString &trace_msg, std::exception_ptr err, int code = -1)
-> Error
{
QString what = trace_msg + ": ";
try {
Expand Down Expand Up @@ -118,8 +115,8 @@ class Error
std::make_unique<details::ErrorImpl>(file, line, "default", code, what, nullptr));
}

static auto
Err(const char *file, int line, const QString &trace_msg, const std::exception &e) -> Error
static auto Err(const char *file, int line, const QString &trace_msg, const std::exception &e)
-> Error
{
return Error(std::make_unique<details::ErrorImpl>(file,
line,
Expand Down Expand Up @@ -156,6 +153,15 @@ class Error
return Err(file, line, trace_msg, new_msg);
}

static auto Err(const char *file,
int line,
const QString &trace_msg,
const char *msg,
const std::system_error &e) -> Error
{
return Err(file, line, trace_msg, msg, e, e.code().value());
}

static auto Err(const char *file,
int line,
const QString &trace_msg,
Expand All @@ -165,6 +171,15 @@ class Error
return Err(file, line, trace_msg, msg, e, e.code().value());
}

static auto Err(const char *file,
int line,
const QString &trace_msg,
const std::string &msg,
const std::system_error &e) -> Error
{
return Err(file, line, trace_msg, msg.c_str(), e, e.code().value());
}

template<typename Value>
static auto Err(const char *file,
int line,
Expand Down Expand Up @@ -198,11 +213,9 @@ class Error
std::move(cause.error().pImpl)));
}

static auto Err(const char *file,
int line,
const QString &trace_msg,
const QString &msg,
Error &&cause) -> Error
static auto
Err(const char *file, int line, const QString &trace_msg, const QString &msg, Error &&cause)
-> Error
{
return Error(std::make_unique<details::ErrorImpl>(file,
line,
Expand Down
6 changes: 6 additions & 0 deletions misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ configure_files(
lib/linglong/container/README.md
lib/linglong/generate-xdg-data-dirs.sh
lib/systemd/system-environment-generators/61-linglong
lib/systemd/user-generators/linglong-user-systemd-generator
lib/systemd/system/org.deepin.linglong.PackageManager.service
lib/systemd/system-preset/91-linglong.preset
lib/systemd/user/linglong-session-helper.service
Expand Down Expand Up @@ -149,6 +150,11 @@ install(
${CMAKE_CURRENT_BINARY_DIR}/lib/systemd/system-environment-generators/61-linglong
DESTINATION ${SYSTEMD_SYSTEM_GENERATOR_PATH})

install(
PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/lib/systemd/user-generators/linglong-user-systemd-generator
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/user-generators)

# sysuser

set(SYSTEMD_SYSUSERSDIR ${CMAKE_INSTALL_PREFIX}/lib/sysusers.d)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env sh

# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: LGPL-3.0-or-later

# https://www.freedesktop.org/software/systemd/man/latest/systemd.generator.html
late="$3"
cp -rs @LINGLONG_ROOT@/entries/lib/systemd/user/* "$late/"
1 change: 1 addition & 0 deletions rpm/linglong.spec
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ cd build
%{_prefix}/lib/systemd/system-preset/*.preset
%{_prefix}/lib/systemd/user/*
%{_prefix}/lib/systemd/system-environment-generators/*
%{_prefix}/lib/systemd/user-generators/*
%{_libexecdir}/%{name}/ll-package-manager
%{_libexecdir}/%{name}/ll-session-helper
%{_libexecdir}/%{name}/ld-cache-generator
Expand Down

0 comments on commit 8544c5a

Please sign in to comment.