Commit Graph

130 Commits

Author SHA1 Message Date
dengbo bd80b77f50 fix: Refactors logging system initialization to use explicit backend
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.
2025-11-07 14:20:57 +08:00
reddevillg 8748a64e1e refactor: Rework repository client and search logic
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>
2025-10-30 13:30:06 +08:00
guanzi008 857948b3c3 feat: Support manual extension loading via command line
Introduces the `--extensions` command-line flag for both cli and
builder, enabling users to manually specify and load extensions at
runtime.
2025-10-14 20:25:37 +08:00
wrj97 75b70e80af refactor: simplify error handling and improve testing
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. 检查错误处理在不同错误类型间的一致性
2025-10-14 17:08:52 +08:00
wrj97 e6cfbf420d refactor: use std::string for error tracing
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. 验证在错误传播过程中不会发生字符串转换错误
2025-10-13 15:02:21 +08:00
ComixHe ecef330edb refactor: migrate from Qt to std library and fix warnings
- Replace Qt's QString with std::string throughout codebase
- Replace QDebug with custom Log
- Replace QString::arg with fmt::format
- Remove Qt dependencies in core modules (builder, package, cli, utils)
- Add [[nodiscard]] attributes for better warnings
- Create common string utilities in libs/common/strings
- Optimize enum storage from quint32 to uint8_t
- Improve compatibility and performance

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-10-11 10:04:04 +08:00
reddevillg d0d33320a3 refactor: using std::filesystem for file operations
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>
2025-10-09 18:21:33 +08:00
wrj97 cc43c5dc3a refactor: migrate architecture string handling to std::string
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. 测试字符串转换的性能影响
2025-09-23 14:00:54 +08:00
reddevillg 103eeacd29 refactor: Use std::filesystem::path instead of QDir
Key changes include:
- The `Builder` and `OverlayFS` classes now store and operate on
  `std::filesystem::path` objects.
- A new utility function `utils::copyDirectory` is introduced to handle
  recursive directory copying with filtering.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-09-22 10:26:54 +08:00
reddevillg 502ae5553a feat: Refactor namespace handling for rootless builds
Previously, a simple `unshare` call was made deep within the builder
logic. This approach was brittle and has been replaced by a re-execution
execution pattern at the application entry point.

The new implementation consists of:
- A check (`needRunInNamespace`) at startup to determine if the process
  has sufficient capabilities (`CAP_SYS_ADMIN`).
- If not, the application re-launches itself in a new user and mount
  namespace using `clone(CLONE_NEWNS | CLONE_NEWUSER)`.
- The parent process configures UID and GID mappings for the child using
  the external `newuidmap` and `newgidmap` tools. This maps the current
  user to root inside the new namespace and includes any subordinate
  UIDs/GIDs.
- The container configuration for build stages is updated to run within
  this parent namespace. It no longer creates a nested user namespace
  but instead operates with a specific, limited set of capabilities.

This change introduces a runtime dependency on the `newuidmap` and
`newgidmap` utilities, which are typically provided by the `uidmap`
package.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-09-19 10:41:36 +08:00
wrj97 d3c51b9efd feat: add no-clean-objects option for remove command
1. Add new flag --no-clean-objects to remove command options
2. Modify cmdRemoveApp function signature to accept prune parameter
3. Conditionally execute repo.prune() based on prune flag
4. Maintain repo.mergeModules() execution regardless of prune flag
5. Update command line interface to expose the new flag

This change allows users to control whether object files should be
cleaned during app removal. By default, objects are cleaned (previous
behavior), but users can now skip this step using --no-clean-objects
flag for faster removal operations or when they want to preserve objects
for other purposes.

Log: Added --no-clean-objects flag to ll-builder remove command

Influence:
1. Test default remove behavior (should clean objects)
2. Test remove with --no-clean-objects flag (should not clean objects)
3. Verify repo.mergeModules() is always called
4. Test removal of single and multiple apps with both options
5. Verify error handling for invalid app references
6. Test edge cases with empty app list

feat: 为 remove 命令添加 no-clean-objects 选项

1. 为 remove 命令选项添加新的 --no-clean-objects 标志
2. 修改 cmdRemoveApp 函数签名以接受 prune 参数
3. 根据 prune 标志有条件地执行 repo.prune()
4. 无论 prune 标志如何都执行 repo.mergeModules()
5. 更新命令行界面以暴露新标志

此更改允许用户控制在删除应用程序期间是否应清理对象文件。默认情况下,对象
会被清理(之前的行为),但用户现在可以使用 --no-clean-objects 标志跳过此
步骤,以实现更快的删除操作或在他们希望为其他目的保留对象时使用。

Log: 为 ll-builder remove 命令添加 --no-clean-objects 标志

Influence:
1. 测试默认删除行为(应清理对象)
2. 测试使用 --no-clean-objects 标志的删除(不应清理对象)
3. 验证 repo.mergeModules() 是否始终被调用
4. 测试单个和多个应用程序的删除(两种选项)
5. 验证无效应用程序引用的错误处理
6. 测试空应用程序列表的边界情况
2025-09-12 17:14:54 +08:00
ComixHe 4f90d76911 feat: add '--ref' export option for exporting package
Add ability to export specific package references from repository using
--ref and --modules parameters, without requiring complete project setup.

This mode is only for distributing.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-08-25 10:24:04 +08:00
reddevillg ccdc5dd9df feat: add new fmt based logging system
Introduces a new fmt based logging system to replace the previous
Qt-based logging mechanism.

Key features:
- Logging macros (LogD, LogI, LogW, LogE, LogF) for different levels.
- Configurable log levels and backends (Console, Journal).
- Configuration via environment variables (LINYAPS_LOG_LEVEL,
  LINYAPS_LOG_BACKEND) for flexible control.
- Integration with systemd-journal for structured logging, including
  code location (file, line, function).
- Custom `fmt` formatters for `QString`, `QStringList`, and
  `linglong::utils::error::Error`.
- New string utility functions (`stringEqual`, `splitString`) are added.

The `qdebug_helper.h` is removed as part of this transition.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-08-05 16:28:53 +08:00
deepsource-autofix[bot] f4277e2b74 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 941b502 according to the output
from ClangFormat and Prettier.

Details: None
2025-07-18 15:13:19 +08:00
myml bdf2cde3c9 feat: add mirror enable/disable functionality for repos
1. Added new CLI commands `enable-mirror` and `disable-mirror` for
repository management
2. Implemented handler functions for mirror enable/disable operations in
both ll-builder and ll-cli
3. Modified repo config handling to support mirrorEnabled flag as
optional boolean
4. Updated test cases to include mirrorEnabled field in test data
5. Improved repo alias handling by using value_or to fallback to
repoName when alias is not provided

These changes allow users to control mirror functionality for
repositories through CLI commands, providing more flexibility in
repository configuration. The mirrorEnabled flag is now properly handled
in the OSTree repo configuration.

feat: 为仓库添加镜像启用/禁用功能

1. 新增了用于仓库管理的`enable-mirror`和`disable-mirror` CLI命令
2. 在ll-builder和ll-cli中实现了镜像启用/禁用操作的处理函数
3. 修改了仓库配置处理以支持可选的mirrorEnabled标志
4. 更新了测试用例,在测试数据中包含mirrorEnabled字段
5. 通过使用value_or在别名未提供时回退到repoName,改进了仓库别名处理

这些变更允许用户通过CLI命令控制仓库的镜像功能,为仓库配置提供更多灵活
性。现在在OSTree仓库配置中正确处理了mirrorEnabled标志。
2025-07-10 19:28:36 +08:00
reddevillg c6386bdfe5 feat: modify the way container patches work
1. provide application level patches
2. application level patches will apply after global patches

move configure.h.in to src root, becasue lib utils depends on QT,
we don't want to introduce QT in certain scenarios.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-06-04 14:45:07 +08:00
ComixHe 881f0d5b1e refactor: move gvfs envs to OstreeRepo ctor
ensure that gvfs module wouldn't be loaded

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-04 10:14:31 +08:00
reddevillg 01455c39f2 feat: support architecture specfied linglong.yaml
1. ll-builder use current directory as project directory.
2. Project yaml file(aka linglong.yaml) must reside within project
   directory or its subdirectories.
3. User can use -f option to specfy a project yaml file.
4. ll-builder will attempt to load project yaml file in the following
   order from the project root directory:
     - linglong.<arch>.yaml (architecture-specific)
     - linglong.yaml (generic)

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-05-29 11:19:54 +08:00
dengbo fa65a7be3c fix: layer file can not install in uos v20
Do not support lzma compressor in uos v20.
2025-05-15 19:05:28 +08:00
ComixHe dbe988add5 style: format whole project
based on clang-format 19.1.7

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-05-14 11:35:50 +08:00
ice909 f7415b9341 fix: improve base and runtime version validation
The code now parses base and runtime fields using FuzzyReference::parse
before validating their versions, adding proper error handling for
parsing failures. This ensures that complex reference formats are
correctly handled before version validation is performed, making
the validation process more robust.
2025-05-08 16:11:03 +08:00
ice909 a9c83dbef8 refactor: implement semantic version matching
1. Added semanticMatch functionality to VersionV1, VersionV2, and
FallbackVersion classes
2. Added semanticMatching flag to clearReferenceOption struct
3. Updated clearReference implementations to use semantic version
matching
4. Modified package filtering to support semantic versioning
5. Replaced version tweak handling with more robust semantic matching
6. Enabled semantic matching in Builder, PackageManager and CLI
components

refactor: 实现语义化版本匹配

1. 为 VersionV1、VersionV2 和 FallbackVersion 类添加 semanticMatch 功能
2. 在 clearReferenceOption 结构体中添加 semanticMatching 标志
3. 更新 clearReference 实现以使用语义化版本匹配
4. 修改包过滤功能以支持语义化版本控制
5. 用更健壮的语义匹配替代版本补丁处理
6. 在 Builder、PackageManager 和 CLI 组件中启用语义化匹配
2025-05-08 15:05:32 +08:00
ice909 71a8e8041d feat: support semver sepc
Supports semver specification version numbers.
2025-05-08 15:05:32 +08:00
ComixHe 1840243f59 refactor: fix compiling warnings
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-24 13:53:45 +08:00
ice909 b70df3c967 fix: builder build crash when parsing version number
When writing a version number incorrectly, it should return an error and exit instead of crashing directly.

Signed-off-by: ice909 <gaochang1@uniontech.com>
2025-04-22 16:42:47 +08:00
reddevillg 06cdb32115 refactor: refactor ll-builder main function
Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-04-21 16:00:57 +08:00
reddevillg b8705353a6 feat: Add output file option and improve compressor handling
Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-04-15 10:14:35 +08:00
reddevillg 71fb063e1c fix: clear project working directory
Set the directory containing the YAML file as the project working
directory

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-04-14 15:21:07 +08:00
ice 5821e5c4ef
chore: update translate (#1114)
add ca、fi、pl、pt_BR、uk translates.
fix some typo.

Signed-off-by: ice909 <gaochang1@uniontech.com>
2025-04-14 14:44:09 +08:00
reddevillg b67fc5c348 feat: add isolate network option for build
use --isolate-network to build in an isolated network environment
2025-04-08 10:08:43 +08:00
reddevillg 761d44f5ad refactor: make builder and pm use ContainerCfgBuiler
Make builder and pm use ContainerCfgBuiler
2025-04-08 10:08:43 +08:00
reddevillg eb1da48ae6 fix: avoid gio start thread before unshare
set GVFS_REMOTE_VOLUME_MONITOR_IGNORE to 1
2025-04-07 17:13:46 +08:00
ice909 337e42022f feat: support don't export the develop module
When exporting layer, add --no-develop to avoid exporting the develop module.

Signed-off-by: ice909 <gaochang1@uniontech.com>
2025-04-02 14:28:22 +08:00
reddevillg d6a36355a3 fix: fix unshare error
tryMigrate may use ostree repo, put GIO_USE_VFS=local before it
2025-03-26 13:32:39 +08:00
myml 0450a2726c feat: supports selecting compression algorithm
在导出时传递参数自选压缩算法
layer默认使用lzma有更高压缩率
uab默认使用lz4可以更快解压速度,避免影响应用自运行
2025-03-18 15:16:36 +08:00
reddevillg 60c5ba8740 feat: Introduce export UAB option --loader
Option --loader=<app_loader> can be used to run app without container
involved. With custom loader, only app's layer will be exported. When
custom loader get started, environment variable LINGLONG_UAB_APPROOT
is the app directory.
2025-02-27 14:28:19 +08:00
reddevillg f26e6e5046 feat: ll-builder support install package via apt
Provide "build depends" and "depends" for apt build extension, build
phase seperate into build phase and prepare phase. "build depends"
to be installed in build environment before build phase starting, and
preserve in overlayfs. "depends" to be installed in prepare phase, and
will be merged to apps output.
2025-02-24 20:28:37 +08:00
ComixHe f2610f9f9c refactor: use onlyapp to export uab by default
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-02-18 21:12:20 +08:00
ice909 1148261f8c fix: can't search after adding repo using alias
OSTree still uses defaultRepo, but defaultRepo has now become an alias.
2025-02-18 11:42:53 +08:00
ice909 4b3fed1f00 feat: add --alias option for repo add
Add the --alias option to set aliases for the 'll-cli repo add' and 'll-builder repo add' commands.

So update, remove, and set-default also need to pass alias instead of name.
2025-02-13 20:29:24 +08:00
ComixHe 3c475dea5f fix: add runtimeCheck method for builder
all checkers should execute at the container which
based on binary layer

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-01-09 14:50:27 +08:00
dengbo c7c3c6bb92 feat: add some translation
1. ll-dialog need to load translation file when running.
2. add some notification message translation.
2025-01-09 14:07:59 +08:00
ComixHe 137fe30110 feat(builder): support exporting uab in 'onlyApp' mode
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-01-07 11:54:08 +08:00
myml 6abd470586 feat: ll-builder supports import directory
ll-builder import命令支持传递目录, 这便于制作base和手动修改app
2024-12-24 09:37:44 +08:00
myml 572d384e89 feat: add list and remove commands to builder
builder添加应用列表和删除应用的命令, 便于开发者清理构建缓存
2024-11-29 17:17:03 +08:00
dengbo11 f533e6690e fix(build): ll-builder push can not working fine
Option --repo-name should use correct variable.
2024-11-23 15:25:17 +08:00
dengbo11 c6b0bdcc0d fix(build): ll-builder build compatible with '-f' option
Some packaging build platforms use the '-f' option, we must
provide for compatibility.
2024-11-23 15:05:54 +08:00
ComixHe 7a45551fd9 refactor(migrate): try to migrate builder repo
Signed-off-by: ComixHe <heyuming@deepin.org>
2024-11-21 17:34:58 +08:00
dengbo11 5e39b2ad8e refactor(ll-build): use build optios to replace variable
Use BuilderBuildOptions to replace variable directly.
2024-11-21 09:29:07 +08:00
ComixHe ca4f8bc7c7 refactor: re-implement migrate
Signed-off-by: ComixHe <heyuming@deepin.org>
2024-11-19 17:46:22 +08:00