diff --git a/configure.h.in b/configure.h.in index e8b42a617..18d7b60d9 100644 --- a/configure.h.in +++ b/configure.h.in @@ -25,7 +25,7 @@ // The directory where the package install hooks reside. #define LINGLONG_INSTALL_HOOKS_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/linglong/config.d" -#define LINGLONG_EXPORT_VERSION "1.0.0.2" +#define LINGLONG_EXPORT_VERSION "1.0.0.1" // The package's locale domain. #define PACKAGE_LOCALE_DOMAIN "@GETTEXT_DOMAIN_NAME@" diff --git a/libs/linglong/src/linglong/builder/linglong_builder.cpp b/libs/linglong/src/linglong/builder/linglong_builder.cpp index 6e209befc..7672a5d9f 100644 --- a/libs/linglong/src/linglong/builder/linglong_builder.cpp +++ b/libs/linglong/src/linglong/builder/linglong_builder.cpp @@ -1371,7 +1371,7 @@ utils::error::Result Builder::commitToLocalRepo() noexcept if (!ret) { return LINGLONG_ERR(ret); } - info.size = static_cast(*ret); + info.size = static_cast(*ret); QFile infoFile{ moduleOutput.filePath("info.json") }; if (!infoFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { diff --git a/libs/linglong/src/linglong/package/uab_packager.cpp b/libs/linglong/src/linglong/package/uab_packager.cpp index 6cadb6ba5..195c78cc0 100644 --- a/libs/linglong/src/linglong/package/uab_packager.cpp +++ b/libs/linglong/src/linglong/package/uab_packager.cpp @@ -702,7 +702,7 @@ utils::error::Result UABPackager::prepareBundle(const QDir &bundleDir, boo if (!newSize) { return LINGLONG_ERR(newSize); } - info.size = static_cast(*newSize); + info.size = static_cast(*newSize); stream << nlohmann::json(info).dump(); layerInfoRef.info = info; diff --git a/libs/linglong/src/linglong/repo/ostree_repo.cpp b/libs/linglong/src/linglong/repo/ostree_repo.cpp index f107f5aba..e16b51c61 100644 --- a/libs/linglong/src/linglong/repo/ostree_repo.cpp +++ b/libs/linglong/src/linglong/repo/ostree_repo.cpp @@ -2102,16 +2102,6 @@ OSTreeRepo::exportEntries(const std::filesystem::path &rootEntriesDir, destination = rootEntriesDir / "lib/systemd/user"; } - auto desktopExportPath = std::string{ LINGLONG_EXPORT_PATH } + "/applications"; - - if (path == "share/applications") { - if (desktopExportPath != "share/applications") { - qInfo() << "destination update from " << destination.c_str() << " to " - << QString::fromStdString(rootEntriesDir / desktopExportPath); - } - destination = rootEntriesDir / desktopExportPath; - } - if (path == "share/deepin-elf-verify") { destination = rootEntriesDir / "share/deepin-elf-verify" / item.commit; } @@ -2128,6 +2118,23 @@ OSTreeRepo::exportEntries(const std::filesystem::path &rootEntriesDir, if (!ret.has_value()) { return ret; } + + if (path == "share/applications") { + auto desktopExportPath = std::string{ LINGLONG_EXPORT_PATH } + "/applications"; + + // 如果存在自定义的desktop安装路径,则也需要将desktop文件导出到指定目录 + if (desktopExportPath != "share/applications") { + qInfo() << "destination update from " << destination.c_str() << " to " + << QString::fromStdString(rootEntriesDir / desktopExportPath); + + destination = rootEntriesDir / desktopExportPath; + + auto ret = this->exportDir(item.info.id, source, destination, 10); + if (!ret.has_value()) { + return ret; + } + } + } } return LINGLONG_OK; } diff --git a/misc/lib/linglong/generate-xdg-data-dirs.sh b/misc/lib/linglong/generate-xdg-data-dirs.sh index 485bfe0d2..837942ba0 100644 --- a/misc/lib/linglong/generate-xdg-data-dirs.sh +++ b/misc/lib/linglong/generate-xdg-data-dirs.sh @@ -14,9 +14,7 @@ LINGLONG_ROOT="@LINGLONG_ROOT@" LINGLONG_EXPORT_PATH="@LINGLONG_EXPORT_PATH@" -# 规范化 LINGLONG_DATA_DIR:移除末尾可能存在的斜杠 LINGLONG_DATA_DIR="${LINGLONG_ROOT}/entries/share" -LINGLONG_DATA_DIR=${LINGLONG_DATA_DIR%/} # --- 辅助函数:安全地添加路径到 XDG_DATA_DIRS --- # 这个函数会检查路径是否已存在,如果不存在则添加。 @@ -26,9 +24,6 @@ _add_path_to_xdg_data_dirs() { local path_to_add="${1%/}" # 确保要添加的路径没有末尾斜杠 local position="${2:-start}" # 默认添加到开头 - # 确保 XDG_DATA_DIRS 变量已定义,如果未定义则初始化为空字符串 - : "${XDG_DATA_DIRS:=}" - # 检查路径是否已存在于 XDG_DATA_DIRS 中 # 在 XDG_DATA_DIRS 两端加上冒号,以确保精确匹配(无论路径在开头、中间还是结尾) if [[ ":${XDG_DATA_DIRS}:" == *":${path_to_add}:"* ]]; then @@ -36,11 +31,7 @@ _add_path_to_xdg_data_dirs() { return 0 fi - # 如果路径不存在,则根据指定位置添加 - if [[ -z "$XDG_DATA_DIRS" ]]; then - # 如果 XDG_DATA_DIRS 当前为空,直接赋值 - XDG_DATA_DIRS="$path_to_add" - elif [[ "$position" == "start" ]]; then + if [[ "$position" == "start" ]]; then # 添加到开头 XDG_DATA_DIRS="$path_to_add:$XDG_DATA_DIRS" elif [[ "$position" == "end" ]]; then @@ -49,21 +40,19 @@ _add_path_to_xdg_data_dirs() { fi } +# 如果 XDG_DATA_DIRS 为空,则先设置为 /usr/local/share:/usr/share +# 参考: https://specifications.freedesktop.org/basedir-spec/latest +_add_path_to_xdg_data_dirs "/usr/local/share" "end" +_add_path_to_xdg_data_dirs "/usr/share" "end" + +# 将 LINGLONG_DATA_DIR 添加到 XDG_DATA_DIRS 的末尾(如果不存在) +_add_path_to_xdg_data_dirs "$LINGLONG_DATA_DIR" "end" + # 如果有自定义 LINGLONG_EXPORT_PATH(默认为 "share"),将自定义路径添加到 XDG_DATA_DIRS if [ "$LINGLONG_EXPORT_PATH" != "share" ]; then - # 规范化 CUSTOM_DATA_DIR:移除末尾可能存在的斜杠 CUSTOM_DATA_DIR="${LINGLONG_ROOT}/entries/${LINGLONG_EXPORT_PATH}" - CUSTOM_DATA_DIR=${CUSTOM_DATA_DIR%/} _add_path_to_xdg_data_dirs "$CUSTOM_DATA_DIR" "start" fi -# 2. 处理 LINGLONG_DATA_DIR 的添加逻辑 -# 如果 XDG_DATA_DIRS 为空,则先设置为 /usr/local/share:/usr/share, -# 然后再将 LINGLONG_DATA_DIR 添加到末尾。 -: "${XDG_DATA_DIRS:=/usr/local/share:/usr/share}" - -# 然后,将 LINGLONG_DATA_DIR 添加到 XDG_DATA_DIRS 的末尾(如果不存在) -_add_path_to_xdg_data_dirs "$LINGLONG_DATA_DIR" "end" - # --- 清理辅助函数 --- unset -f _add_path_to_xdg_data_dirs