The LINYAPS_BACKTRACE environment variable now controls the verbosity of
error messages, including file paths, line numbers, and backtrace details.
Signed-off-by: reddevillg <reddevillg@gmail.com>
1. Hook scripts should be executed before exporting and generating caches; otherwise, execution failures may result in the application being removed.
2. Enhances logging for better visibility into hook execution
failures and aligns hook handling across installation, upgrade,
and dependency management workflows.
build / ubuntu_24.04 (push) Has been cancelledDetails
build / ubuntu_22.04 (push) Has been cancelledDetails
coverage / codecov (push) Has been cancelledDetails
Introduces a `--force` flag to the `ll-cli uninstall` command, allowing
users to forcefully uninstall packages that are typically protected,
such as base and runtime dependencies.
This commit also includes significant refactoring:
- The dependency pulling logic in `PackageManager::pullDependency` has
been refactored to prioritize newer remote packages over existing local
ones, ensuring dependencies are kept up-to-date.
Signed-off-by: reddevillg <reddevillg@gmail.com>
Repetitive code for D-Bus calls, task state management, and error
handling was extracted into helper functions.
Signed-off-by: reddevillg <reddevillg@gmail.com>
Encapsulates the complex package installation process into a set of
Action classes to improve clarity, maintainability, and testability.
This change introduces an abstract `Action` base class and a concrete
`RefInstallationAction` and `UabInstallationAction` for handling
installations from a repository or UAB file.
The core logic, including remote package discovery, version comparison,
user interaction, and transaction management, has been moved from
PackageManager into concrete installation action.
Key changes:
- A new `RefInstallationAction` class now manages the entire lifecycle
of a reference-based installation task.
- `UabInstallationAction` class now is derived from `Action`.
- A `RemotePackages` helper class is introduced to manage and query
package search results from multiple repositories.
- `OSTreeRepo` is extended with a `matchRemoteByPriority` method to
find packages according to repository priorities.
- The `PackageManager::Install` method is simplified to be a factory
for creating and queuing installation tasks.
- Added extensive unit tests for the new remote package matching logic.
Signed-off-by: reddevillg <reddevillg@gmail.com>
Replaces command-based initialization of the logging system with
an explicit backend parameter, simplifying configuration logic
and improving maintainability.
Removes redundant code that inferred the log backend from
command names. Updates all affected components to pass the
appropriate backend directly when initializing the log system.
Refactors the icon packaging process by removing the intermediate
step of creating an "icon.a" archive and directly passing the
icon value to the `addNewSection` method. Improves code
clarity and reduces unnecessary operations.
Refactors the interaction with remote repositories to clarify the code's
intent.
Key changes include:
- Introduce `ClientAPIWrapper` to encapsulate the generated C-style API
client.
- The remote package searching function is renamed from `listRemote` to
`searchRemote` to better reflect its purpose.
- The `pull` method now requires an explicit repo argument.
- add `getPrioritySortedRepos` and `getPriorityGroupedRepos` helpers.
Co-authored-by: reddevillg <reddevillg@gmail.com>
Signed-off-by: reddevillg <reddevillg@gmail.com>
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
- Replaced Qt logging calls with linyaps log system.
- Centralized log system initialization for tests.
- Remove the unused `isChildProcess` helper function.
- Remove permission notify, it's not used for a while.
- move `ensureDirectory` to file utils.
Signed-off-by: reddevillg <reddevillg@gmail.com>
The `PackageManager::installFromUAB` method was overly complex and
handled multiple responsibilities, including validation, user
interaction, and the core installation logic. This made the method
difficult to maintain, test, and understand.
This commit refactors the UAB installation process by extracting the
entire logic into a new `UabInstallationAction` class. This class
encapsulates all steps required for a UAB installation, from preparation
and validation to execution and cleanup.
We will continue refactoring and abstracting the Task and Action related
code in subsequent phases to improve maintainability and testability.
Signed-off-by: reddevillg <reddevillg@gmail.com>
Fixed the equality operator for Repo struct to include the newly added
mirrorEnabled field, preventing incorrect comparison results when this
field differs between configurations. Added static assertions to ensure
future structural changes to Repo-related types will trigger compilation
errors if equality operators are not updated accordingly.
Enhanced configuration setting logic with comprehensive debug logging
to improve troubleshooting capabilities. Added logging for configuration
changes, comparison results, and key operations during config updates to
help diagnose issues with repository configuration management.
Log: Improved repository configuration change detection and logging
Influence:
1. Test repository configuration changes with different mirrorEnabled
settings
2. Verify configuration comparison works correctly when only
mirrorEnabled differs
3. Check debug logs appear during configuration updates
4. Test configuration persistence and cache rebuilding after changes
5. Verify no regression in existing configuration management
functionality
fix: 修复仓库配置比较并添加调试日志
修复了 Repo 结构的相等运算符,包含新增的 mirrorEnabled 字段,防止在该字
段不同时产生错误的比较结果。添加了静态断言,确保未来对 Repo 相关类型的结
构更改如果未更新相等运算符实现将触发编译错误。
增强了配置设置逻辑,添加了全面的调试日志以改进故障排除能力。增加了配置变
更、比较结果和配置更新期间关键操作的日志记录,帮助诊断仓库配置管理问题。
Log: 改进仓库配置变更检测和日志记录
Influence:
1. 测试使用不同 mirrorEnabled 设置的仓库配置变更
2. 验证当仅 mirrorEnabled 不同时配置比较正常工作
3. 检查配置更新期间调试日志是否正确出现
4. 测试配置变更后的配置持久化和缓存重建
5. 验证现有配置管理功能无回归问题
Added comprehensive unit tests for three utility modules:
1. GKeyFileWrapper tests - validate INI file parsing and manipulation
functionality including file loading, value setting/getting, group/key
operations, and file saving
2. PackageInfoHandler tests - test package information conversion
between V1 and V2 formats, JSON parsing from files/GFile objects, and
handling of optional fields
3. XDG directory tests - verify application data directory resolution
based on HOME environment variable with various app ID scenarios
These tests ensure the reliability of core utility functions used
throughout the Linglong system, covering edge cases, error handling, and
proper data conversion between different package information formats.
Influence:
1. Run test suite to verify all new unit tests pass
2. Test GKeyFileWrapper with various INI file formats and invalid inputs
3. Verify PackageInfoHandler handles both V1 and V2 package info formats
correctly
4. Test XDG directory resolution with different HOME environment
settings
5. Confirm error handling works as expected for invalid inputs
feat: 为工具组件添加单元测试
新增了三个工具模块的全面单元测试:
1. GKeyFileWrapper测试 - 验证INI文件解析和操作功能,包括文件加载、值设
置/获取、组/键操作和文件保存
2. PackageInfoHandler测试 - 测试V1和V2格式之间的包信息转换、从文件/GFile
对象解析JSON以及可选字段处理
3. XDG目录测试 - 基于HOME环境变量验证应用程序数据目录解析,涵盖各种应用
ID场景
这些测试确保了Linglong系统中使用的核心工具函数的可靠性,涵盖了边界情况、
错误处理以及不同包信息格式之间的正确数据转换。
Influence:
1. 运行测试套件验证所有新单元测试通过
2. 使用各种INI文件格式和无效输入测试GKeyFileWrapper
3. 验证PackageInfoHandler正确处理V1和V2包信息格式
4. 使用不同的HOME环境设置测试XDG目录解析
5. 确认错误处理对无效输入按预期工作
1. Refactored the `inspect` command to support the `dir` subcommand for
displaying application directories.
2. Added options to specify the directory type (`layer` or `bundle`)
and module type (`binary` or `develop`) when using the `dir` subcommand.
3. Introduced a version option to retrieve directories for specific
application versions.
4. Implemented `getLayerDir` and `getBundleDir` methods to fetch and
print the respective directory paths.
5. The original `inspect` command that used pid is currently removed
because it is not commonly used and requires more discussion if needed.
Log: Added inspect command's dir subcommand to get the layer or bundle
directory of the installed(running) application.
Influence:
1. Test the `ll-cli inspect dir APP` command to verify it displays the
correct layer directory by default.
2. Test the `ll-cli inspect dir APP --type bundle` command to verify it
displays the correct bundle directory.
3. Test the `ll-cli inspect dir APP --type layer --module binary`
command to verify it displays the correct directory for the binary
module.
4. Test the `ll-cli inspect dir APP --version VERSION` command to
verify it displays the correct directory for the specified version of
the application.
5. Test with invalid application IDs and options to ensure proper error
handling and messages.
feat: 增强 inspect 命令,支持目录类型
1. 重构了 `inspect` 命令,以支持 `dir` 子命令来显示应用程序目录。
2. 添加了选项,用于在使用 `dir` 子命令时指定目录类型(`layer` 或
`bundle`)和模块类型(`binary` 或 `develop`)。
3. 引入了版本选项,以检索特定应用程序版本的目录。
4. 实现了 `getLayerDir` 和 `getBundleDir` 方法来获取和打印相应的目录
路径。
5. 原先使用 pid 的 `inspect` 命令已被移除,因为使用场景较少,并且如果需
要可能需要进行更多讨论。
Log: 增加了 inspect 命令的 dir 子命令,用于获取已安装(正在运行)应用程
序的 layer 或 bundle 目录。
Influence:
1. 测试 `ll-cli inspect dir APP` 命令,验证它默认显示正确的 layer 目录。
2. 测试 `ll-cli inspect dir APP --type bundle` 命令,验证它显示正确的
bundle 目录。
3. 测试 `ll-cli inspect dir APP --type layer --module binary` 命令,验证
它显示 binary 模块的正确目录。
4. 测试 `ll-cli inspect dir APP --version VERSION` 命令,验证它显示指定
版本应用程序的正确目录。
5. 使用无效的应用程序 ID 和选项进行测试,以确保正确的错误处理和消息。
- `fmt::println(stderr, message)` could crash if the message contained
format specifiers like `{}`.
- fix the `mergeOutput` logic and extract it from the `Builder` class
into a free function within the `detail` namespace. This refactoring
allows for easier unit testing.
- Unit tests have been added for both `mergeOutput` function and the
logging format fix.
Adds a new `--mount` command-line option to the UAB helper. This allows
mounting the UAB's bundle filesystem to a specified directory and
keeping it mounted, which is useful for debugging and inspection.
The UAB loader is enhanced to forward all its command-line arguments
to the application running inside the container.
Signed-off-by: reddevillg <reddevillg@gmail.com>
- The `--privileged` flag allows running a container with an elevated
set of capabilities and share user namespace with host. This is useful
for applications that require broader access to host system resources,
such as network management tools or debugging tools.
- The `--caps-add` option allows for adding specific Linux capabilities
to the container, offering fine-grained privilege control.
Signed-off-by: reddevillg <reddevillg@gmail.com>
Add unit tests for the strings utility functions
Key changes include:
- Enhance `trim` to support trimming with a custom set of characters
- `join` function can handle empty vector now
- Rename `hasPrefix` and `hasSuffix` to `starts_with` and `ends_with`
respectively.
Signed-off-by: reddevillg <reddevillg@gmail.com>
The error handling implementation has been simplified by removing Qt
dependencies from the core error module. The ErrorImpl class now uses
std::string instead of QString for message storage and formatting. This
makes the error module more portable and reduces dependencies on Qt.
The error message output in main.cpp has been updated to directly use
the std::string message without unnecessary conversion to std::string
via toStdString() since the message() method now returns std::string
directly.
Additionally, the test files have been reorganized - the result_test.cpp
has been removed and its content merged into a new error_test.cpp file
with expanded test coverage. The new tests cover more error scenarios
including standard error codes and Qt file errors.
Log: Improved error handling and testing infrastructure
Influence:
1. Test repository operations (add/remove/update/set-default/enable-
mirror/disable-mirror) to verify error messages are displayed correctly
2. Run the updated error tests to ensure all error scenarios are
properly handled
3. Verify error messages contain relevant context information when
operations fail
4. Check that error handling works consistently across different error
types
重构:简化错误处理并改进测试
错误处理实现已通过从核心错误模块中移除 Qt 依赖项得到简化。ErrorImpl 类
现在使用 std::string 而不是 QString 进行消息存储和格式化。这使得错误模
块更具可移植性并减少了对 Qt 的依赖。main.cpp 中的错误消息输出已更新为直
接使用 std::string 消息,无需通过 toStdString() 进行不必要的转换,因为
message() 方法现在直接返回 std::string。
此外,测试文件已重新组织 - result_test.cpp 已被删除,其内容已合并到新的
error_test.cpp 文件中,并扩展了测试覆盖范围。新测试涵盖了更多错误场景,
包括标准错误代码和 Qt 文件错误。
Log: 改进错误处理和测试基础设施
影响:
1. 测试仓库操作(添加/删除/更新/设置默认/启用镜像/禁用镜像)以验证错误消
息是否正确显示
2. 运行更新后的错误测试以确保所有错误场景得到正确处理
3. 验证操作失败时错误消息包含相关上下文信息
4. 检查错误处理在不同错误类型间的一致性
Changed error handling system to use std::string instead of QString
for trace messages to improve performance and reduce unnecessary string
conversions. The LINGLONG_TRACE macro now directly stores the message
as std::string without complex type detection logic. All error creation
methods have been updated to accept std::string for trace messages and
handle string concatenation more efficiently.
This refactoring eliminates the need for QString conversions when
working with standard C++ strings, reducing overhead in error handling
paths. The changes maintain backward compatibility while improving type
consistency throughout the error system.
Influence:
1. Verify error messages are correctly formatted and displayed
2. Test error handling with various string types (QString, std::string,
const char*)
3. Confirm trace functionality works correctly in different scenarios
4. Check that existing error reporting mechanisms continue to function
properly
5. Validate that no string conversion errors occur during error
propagation
refactor: 使用 std::string 进行错误追踪
将错误处理系统中的跟踪消息从 QString 改为 std::string,以提高性能并减少
不必要的字符串转换。LINGLONG_TRACE 宏现在直接以 std::string 存储消息,无
需复杂的类型检测逻辑。所有错误创建方法都已更新为接受 std::string 类型的
跟踪消息,并更高效地处理字符串连接。
此次重构消除了在处理标准 C++ 字符串时进行 QString 转换的需求,减少了错误
处理路径的开销。这些更改在提高类型一致性的同时保持了向后兼容性。
Influence:
1. 验证错误消息格式正确且显示正常
2. 测试使用各种字符串类型(QString、std::string、const char*)的错误处理
3. 确认跟踪功能在不同场景下正常工作
4. 检查现有的错误报告机制是否继续正常运行
5. 验证在错误传播过程中不会发生字符串转换错误
Introduce `common::dir` to provide a single source for all runtime
directory paths, and adds unit tests for the XDG runtime directory
retrieval.
Signed-off-by: reddevillg <reddevillg@gmail.com>
Extracted filename generation logic into separate functions
uabExportFilename and layerExportFilename to eliminate code duplication
and improve maintainability. The original inline string formatting was
replaced with function calls that use fmt::format for better consistency
and readability. Added comprehensive unit tests to verify the filename
generation behavior.
Influence:
1. Verify UAB file export functionality works correctly
2. Test layer file export with different modules
3. Confirm filename format follows expected pattern
4. Validate that existing export workflows remain functional
重构:提取导出文件名生成函数
将文件名生成逻辑提取为独立的 uabExportFilename 和 layerExportFilename
函数,以消除代码重复并提高可维护性。原有的内联字符串格式化被替换为使用
fmt::format 的函数调用,以提高一致性和可读性。添加了全面的单元测试来验证
文件名生成行为。
Influence:
1. 验证 UAB 文件导出功能正常工作
2. 使用不同模块测试层文件导出
3. 确认文件名格式符合预期模式
4. 验证现有导出工作流程保持正常
Refactors file and directory handling within the builder, replacing
Qt-based implementations with the modern C++ standard library.
Key changes include:
- Removed support for the deprecated `$appid.install` file. Its presence
now causes a build error to enforce the `modules` definition in the
project configuration.
- Introduced `utils::moveFiles`, a new utility function that centralizes
the logic for moving directory contents based on a flexible matcher
predicate.
- Simplified the handling of the default `binary` and `develop` modules.
The `binary` module now defaults to a "catch-all" rule (`/`) if not
explicitly defined by the user.
- Added unit tests for the new `utils::moveFiles` function and the
refactored `installModule` logic.
Signed-off-by: reddevillg <reddevillg@gmail.com>
The change improves portability by finding the localtime directory
via the TZDIR environment variable. TZDIR is used by glibc, and on
distos like nixos, they set TZDIR to `/etc/zoneinfo`.
Changed SetUpTestSuite/TearDownTestSuite to SetUpTestCase/
TearDownTestCase in test files to maintain compatibility with older
versions of Google Test framework. The newer naming convention
(SetUpTestSuite) was introduced in more recent versions of gtest, while
older versions only support SetUpTestCase.
This change ensures the test suite can run on systems with older gtest
installations without requiring framework upgrades. The functionality
remains exactly the same, only the method names are updated to match the
older API convention.
Influence:
1. Verify all tests still run correctly after the change
2. Check test setup and teardown operations still work as expected
3. Confirm no regression in test coverage or functionality
fix: 将SetUpTestSuite替换为SetUpTestCase以提高gtest兼容性
将测试文件中的SetUpTestSuite/TearDownTestSuite改为SetUpTestCase/
TearDownTestCase,以保持与旧版Google Test框架的兼容性。较新版本的gtest引
入了新的命名约定(SetUpTestSuite),而旧版本仅支持SetUpTestCase。
此更改确保测试套件可以在装有旧版gtest的系统上运行,而无需升级框架。功能
完全保持不变,只是更新了方法名称以匹配旧版API约定。
Influence:
1. 验证更改后所有测试仍能正确运行
2. 检查测试设置和清理操作是否仍按预期工作
3. 确认测试覆盖率和功能没有退化
1. Added conditional compilation to support both GTEST_SKIP and simple
return for test skipping
2. This change makes the tests compatible with older versions of Google
Test that don't support GTEST_SKIP
3. The modification ensures tests can be properly skipped when erofsfuse
is not available, regardless of gtest version
Influence:
1. Verify tests can run on systems with older gtest versions
2. Check test skipping behavior when erofsfuse is not available
3. Ensure no test failures occur due to missing GTEST_SKIP macro
fix: 改进测试对旧版gtest的兼容性
1. 添加条件编译以同时支持GTEST_SKIP和简单返回的测试跳过方式
2. 此更改使测试兼容不支持GTEST_SKIP的旧版Google Test
3. 修改确保无论gtest版本如何,当erofsfuse不可用时都能正确跳过测试
Influence:
1. 验证测试能在使用旧版gtest的系统上运行
2. 检查当erofsfuse不可用时的测试跳过行为
3. 确保不会因缺少GTEST_SKIP宏导致测试失败
1. Added check for erofsfuse command existence in LayerPackagerTest
and UabFileTest
2. Skip tests if erofsfuse is not available
3. Updated command name from "erofs-fuse" to "erofsfuse" in
UabFileTest::UnpackFsck
4. Added necessary header include for command utilities
These changes ensure tests requiring erofsfuse are only run when the
command is actually available on the system, preventing test failures
in environments without erofsfuse installed. The command name was also
corrected to match the actual executable name.
Influence:
1. Verify tests are skipped when erofsfuse is not installed
2. Check tests run normally when erofsfuse is available
3. Confirm all fuse-related functionality works as expected when tests
run
test: 在fuse相关测试中添加erofsfuse检查
1. 在LayerPackagerTest和UabFileTest中添加对erofsfuse命令存在的检查
2. 如果erofsfuse不可用则跳过测试
3. 在UabFileTest::UnpackFsck中将命令名称从"erofs-fuse"更新为"erofsfuse"
4. 添加了命令工具的必要头文件包含
这些更改确保需要erofsfuse的测试仅在系统上实际可用该命令时运行,防止在
没有安装erofsfuse的环境中测试失败。同时修正了命令名称以匹配实际可执行文
件名。
Influence:
1. 验证当erofsfuse未安装时测试是否被跳过
2. 检查当erofsfuse可用时测试是否正常运行
3. 确认当测试运行时所有fuse相关功能是否按预期工作
1. Deprecated QString-based toString() method in favor of toStdString()
2. Changed getTriplet() return type from QString to std::string
3. Added comprehensive unit tests for architecture handling
4. Improved error handling with std::optional and exceptions
5. Added test coverage for all supported architectures and edge cases
The changes were made to:
1. Reduce Qt dependencies in core functionality
2. Improve performance by avoiding QString conversions
3. Provide better type safety with std::string
4. Enhance testability with comprehensive unit tests
5. Prepare for future cross-platform compatibility
Log: Architecture string handling now uses std::string instead of
QString
Influence:
1. Test all architecture-related functionality with various inputs
2. Verify backward compatibility with existing code using toString()
3. Check error handling with invalid architecture strings
4. Validate cross-platform behavior on different CPU architectures
5. Test performance impact of string conversions
refactor: 将架构字符串处理迁移到 std::string
1. 弃用基于 QString 的 toString() 方法,改用 toStdString()
2. 将 getTriplet() 返回类型从 QString 改为 std::string
3. 添加了全面的架构处理单元测试
4. 使用 std::optional 和异常改进了错误处理
5. 增加了对所有支持架构和边界情况的测试覆盖
这些修改是为了:
1. 减少核心功能对 Qt 的依赖
2. 通过避免 QString 转换提高性能
3. 使用 std::string 提供更好的类型安全
4. 通过全面的单元测试增强可测试性
5. 为未来的跨平台兼容性做准备
Log: 架构字符串处理现在使用 std::string 替代 QString
Influence:
1. 使用各种输入测试所有架构相关功能
2. 验证与现有使用 toString() 代码的向后兼容性
3. 检查无效架构字符串的错误处理
4. 在不同 CPU 架构上验证跨平台行为
5. 测试字符串转换的性能影响
1. Replaced GMock-based mocks with custom mock classes for LayerPackager
and UABFile
2. Added new mock header files layer_packager_mock.h and uab_file_mock.h
3. Updated test files to use new mock implementations
4. Changed CMakeLists.txt to use GTest instead of GMock
5. Removed unused mock_package_manager.h
6. Improved test reliability by using function wrappers instead of
EXPECT_CALL
The change was made to:
1. Reduce dependency on GMock which was causing build issues
2. Provide more flexible and maintainable mock implementations
3. Improve test stability by avoiding complex GMock expectations
4. Make tests more explicit about their behavior through function
wrappers
Influence:
1. All tests using the modified mock classes should be re-run
2. Verify layer unpacking functionality still works as expected
3. Check UAB file handling remains correct
4. Confirm command execution tests pass with new mock implementation
重构: 在测试中用自定义mock类替换GMock
1. 为LayerPackager和UABFile替换了基于GMock的mock实现
2. 新增了layer_packager_mock.h和uab_file_mock.h头文件
3. 更新测试文件使用新的mock实现
4. 修改CMakeLists.txt使用GTest替代GMock
5. 移除了未使用的mock_package_manager.h
6. 通过使用函数包装器替代EXPECT_CALL提高了测试可靠性
这些修改是为了:
1. 减少导致构建问题的GMock依赖
2. 提供更灵活和可维护的mock实现
3. 通过避免复杂的GMock预期提高测试稳定性
4. 通过函数包装器使测试行为更加明确
影响:
1. 应重新运行所有使用修改后mock类的测试
2. 验证层解包功能仍按预期工作
3. 检查UAB文件处理保持正确
4. 确认命令执行测试在新的mock实现下通过