Commit Graph

649 Commits

Author SHA1 Message Date
reddevillg 1c638ac591 fix: fix env is cleared by `env -i`
Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-09-19 15:57:13 +08:00
dengbo e6737735dd refactor: simplify container entrypoint generation
1. Introduce `BashCommandHelper` to centralize bash command generation.
2. Refactor container entrypoint script generation for better
readability and maintainability.
3.  Remove masking of `~/.bashrc` as it's no longer necessary with the
new entrypoint setup.

The previous method of generating the entrypoint script and default
bash command was scattered and not easily maintainable. This commit
introduces `BashCommandHelper` to encapsulate the logic for generating
default bash commands, exec commands, and the entrypoint script. This
improves code readability and makes it easier to modify these commands
in the future.  Also removed the `~/.bashrc` masking, the new entrypoint
creation mechanism has already solved the problem.

Influence:
1.  Test container execution with different commands and entrypoints.
2.  Verify that environment variables are correctly set up within the
container.
3.  Ensure that the default bash shell is correctly initialized when
entering the container without specific commands.

重构: 简化容器入口点生成

1. 引入 `BashCommandHelper` 来集中化 bash 命令的生成。
2. 重构容器入口点脚本的生成,以提高可读性和可维护性。
3. 移除 `~/.bashrc` 的屏蔽,因为使用新的入口点设置后不再需要它。

之前的入口点脚本和默认 bash 命令的生成方法分散且不易于维护。 此提交引入
`BashCommandHelper` 来封装生成默认 bash 命令、exec 命令和入口点脚本的逻
辑。 这提高了代码的可读性,并且更容易在将来修改这些命令。 此外,删除了
`~/.bashrc` 屏蔽,新的入口点创建机制已经解决了该问题。

Influence:
1. 使用不同的命令和入口点测试容器执行。
2. 验证容器内是否正确设置了环境变量。
3. 确保在没有特定命令的情况下进入容器时,正确初始化默认的 bash shell。
2025-09-19 15:57:13 +08:00
wrj97 378d6c3e60 feat: enable git submodule fetching with environment variable control
1. Add environment variable support to Cmd class for process execution
2. Set GIT_SUBMODULES=true when executing source fetch scripts
3. Conditionally execute git submodule commands based on GIT_SUBMODULES
env var
4. Fix member variable naming in Cmd class (command -> m_command)
5. Pass environment variables to command existence checking process

This change allows git submodules to be fetched only when explicitly
enabled through the GIT_SUBMODULES environment variable, providing
better control over the source fetching process. The environment
variable mechanism was added to the Cmd utility class to support this
feature, and existing command execution logic was updated to use proper
member variable naming conventions.

Log: Added conditional git submodule fetching support in source fetcher

Influence:
1. Test git repository fetching with submodules enabled
2. Verify git repository fetching without submodules (default behavior)
3. Test environment variable passing in command execution
4. Verify command existence checking with environment variables
5. Test source fetching for projects with and without submodules
6. Validate that existing git fetch functionality remains unchanged

feat: 通过环境变量控制启用 git 子模块获取

1. 为 Cmd 类添加环境变量支持以执行进程
2. 在执行源码获取脚本时设置 GIT_SUBMODULES=true
3. 基于 GIT_SUBMODULES 环境变量条件性执行 git 子模块命令
4. 修正 Cmd 类中的成员变量命名(command -> m_command)
5. 将环境变量传递给命令存在性检查进程

此变更允许仅在通过 GIT_SUBMODULES 环境变量明确启用时才获取 git 子模块,
从而更好地控制源码获取过程。为支持此功能,向 Cmd 工具类添加了环境变量机
制,并更新了现有命令执行逻辑以使用正确的成员变量命名约定。

Log: 在源码获取器中添加条件性 git 子模块获取支持

Influence:
1. 测试启用子模块的 git 仓库获取
2. 验证不带子模块的 git 仓库获取(默认行为)
3. 测试命令执行中的环境变量传递
4. 验证带环境变量的命令存在性检查
5. 测试带和不带子模块的项目源码获取
6. 验证现有 git 获取功能保持不变
2025-09-19 15:57:13 +08:00
wrj97 3759dfc849 feat: add mirror enable/disable functionality for repositories
1. Rename lambda function from 'argsParseFunc' to 'argsParsed' for
better clarity
2. Add new subcommands 'enable-mirror' and 'disable-mirror' to control
repository mirror status
3. Implement mirror enable/disable logic that updates the repository
configuration
4. Maintain existing repository management functionality (add, remove,
update, set-default, set-priority)
5. Add validation to ensure URL is provided when enabling/disabling
mirrors

Log: Added repository mirror enable/disable commands

Influence:
1. Test enabling mirror with valid and invalid URLs
2. Test disabling mirror with valid and invalid URLs
3. Verify mirror status is properly updated in repository configuration
4. Test existing repository commands (add, remove, update, set-default,
set-priority) still work
5. Verify error handling for empty URLs in mirror operations
6. Test repository configuration persistence after mirror operations

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

1. 将 lambda 函数从 'argsParseFunc' 重命名为 'argsParsed' 以提高清晰度
2. 添加新的子命令 'enable-mirror' 和 'disable-mirror' 来控制仓库镜像状态
3. 实现镜像启用/禁用逻辑,更新仓库配置
4. 保持现有的仓库管理功能(添加、删除、更新、设为默认、设置优先级)
5. 添加验证确保在启用/禁用镜像时提供 URL

Log: 新增仓库镜像启用/禁用命令

Influence:
1. 测试使用有效和无效 URL 启用镜像
2. 测试使用有效和无效 URL 禁用镜像
3. 验证镜像状态在仓库配置中正确更新
4. 测试现有的仓库命令(添加、删除、更新、设为默认、设置优先级)仍然正常
工作
5. 验证镜像操作中空 URL 的错误处理
6. 测试镜像操作后仓库配置的持久化
2025-09-19 15:57:13 +08:00
wrj97 f83e78523a 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-19 15:57:13 +08:00
deepsource-autofix[bot] a46c1c701a style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 0f5586d according to the output
from ClangFormat and Prettier.

Details: None
2025-09-11 20:06:25 +08:00
wrj97 71f4a716f8 fix: correct list command logic and logging
1. Fixed inverted logic in list command for showing upgrade list vs
regular package list
2. Added sorting by package ID for both regular list and upgrade list
outputs
3. Replaced Qt logging with linglong's custom logging in ostree
repository
4. Maintained existing filtering functionality by package type

Log: Fixed package list display logic and improved sorting

Influence:
1. Test ll-cli list command without parameters to show installed
packages
2. Test ll-cli list --upgradable to show available upgrades
3. Verify package sorting by ID in both list modes
4. Test package type filtering with --type parameter
5. Verify installation time display in package list
6. Confirm error handling for repository access issues

fix: 修复列表命令逻辑和日志记录

1. 修复了显示升级列表与常规包列表的反向逻辑
2. 为常规列表和升级列表输出添加了按包ID排序功能
3. 在ostree仓库中将Qt日志替换为linglong自定义日志
4. 保持了按包类型过滤的现有功能

Log: 修复包列表显示逻辑并改进排序功能

Influence:
1. 测试不带参数的 ll-cli list 命令以显示已安装的包
2. 测试 ll-cli list --upgradable 以显示可用升级
3. 验证两种列表模式下的包ID排序
4. 测试使用 --type 参数的包类型过滤功能
5. 验证包列表中的安装时间显示
6. 确认仓库访问错误的处理机制
2025-09-11 20:06:25 +08:00
wrj97 6d1b5e3a06 feat: add base and runtime options
1. Add `--base` option to specify the base layer.
2. Add `--runtime` option to specify the runtime.
3. Modify `RunContext::resolve` to utilize the `--base` and `--runtime`
options.
4. Update builder resolution to pass base and runtime references.
5. Add logging for base and runtime resolution

Log: Added command-line options to specify the base and runtime for
application execution.

Influence:
1. Test application execution with different base layers.
2. Verify that specifying a runtime overrides the default runtime.
3. Ensure that the `--base` and `--runtime` options are respected during
application resolution.
4. Check that the logging accurately reflects the used base and runtime.

feat: 为 ll-cli 添加 base 和 runtime 选项

1. 添加 --base 选项来指定基础层
2. 添加 --runtime 选项来指定运行时环境
3. 修改 RunContext::resolve 以使用 --base 和 --runtime 选项
4. 更新构建器解析以传递基础和运行时引用
5. 添加基础和运行时解析的日志记录

Log: 增加了 ll-cli 的命令行选项,用于指定应用程序执行的基础层和运行时
环境。

Influence:
1. 使用不同的基础层测试应用程序执行
2. 验证指定运行时是否会覆盖默认运行时
3. 确保在应用程序解析期间尊重 --base 和 --runtime 选项
4. 检查日志是否准确地反映所使用的基础和运行时
2025-09-11 20:06:25 +08:00
dengbo d4d155b940 fix: clear removableStorageMounts before binding
Clear the `removableStorageMounts` vector before binding removable
storage mounts. This ensures that stale mount points from previous
configurations are not included, preventing potential issues with
incorrect mount configurations. This is crucial for scenarios where the
removable storage setup changes between container runs.

Influence:
1. Test with removable storage devices connected and disconnected
before/after container startup.
2. Verify that only the currently available removable storage devices
are mounted inside the container.
3. Check that stale mount points are correctly removed when a removable
device is disconnected.

fix: 在绑定之前清除 removableStorageMounts

在绑定可移动存储挂载点之前,清除 `removableStorageMounts` 向量。 这样可
以确保不包含来自先前配置的陈旧挂载点,从而避免潜在的错误挂载配置问题。这
对于可移动存储设置在容器运行之间发生变化的场景至关重要。

Influence:
1. 测试在容器启动之前/之后连接和断开可移动存储设备的情况。
2. 验证只有当前可用的可移动存储设备才会在容器内挂载。
3. 检查当可移动设备断开连接时,陈旧的挂载点是否已正确删除。
2025-09-11 20:06:25 +08:00
deepsource-autofix[bot] 6db6feecb0 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 6f7ca1c according to the output
from ClangFormat and Prettier.

Details: None
2025-09-11 20:06:25 +08:00
deepsource-autofix[bot] 623967089b style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 0246d9d according to the output
from ClangFormat and Prettier.

Details: None
2025-09-11 20:06:25 +08:00
dengbo f61ee6e1f7 fix: fix removable storage bind mount
Refactored the logic for binding removable storage mounts to improve
readability and reduce unnecessary complexity. Previously, the code
used a `do...while(false)` loop that wasn't actually serving a purpose.
The code now directly processes each propagation path (/media, /mnt)
without the unnecessary loop construct. This simplifies the control
flow and makes the code easier to understand and maintain. Also
changed how symlinks are handled in removable storage mounts, adding
the target directory to the mounts vector, so that applications inside
the container can access the target directory, instead of breaking the
symlink.

Influence:
1. Verify removable storage mounts function correctly after the changes.
2. Ensure applications inside the container can access removable storage
devices without errors.
3. Specifically test applications that rely on symbolic links within /
media or /mnt.

fix: 修复可移动存储绑定挂载

简化了绑定可移动存储挂载点的逻辑,以提高可读性并减少不必要的复杂性。 之
前,代码使用了一个 `do...while(false)` 循环,但实际上并没有起到任何作
用。 现在,代码直接处理每个传播路径(/media、/mnt),而无需不必要的循环
结构。 这简化了控制流程,使代码更易于理解和维护。 此外,更改了可移动存储
挂载中符号链接的处理方式,将目标目录添加到挂载向量,以便容器内的应用程序
可以访问目标目录,而不是破坏符号链接。

Influence:
1. 验证更改后可移动存储挂载功能是否正常。
2. 确保容器内的应用程序可以访问可移动存储设备而不会出错。
3. 专门测试依赖于 /media 或 /mnt 中符号链接的应用程序。
2025-09-09 21:19:59 +08:00
wrj97 4cdcfb1559 refactor: refactor CLI command options structure for better maintainability
- 为每个子命令创建专门的选项:RunOptions、EnterOptions、KillOptions等
- 添加GlobalOptions用于处理全局选项如verbose
- 重构main.cpp中的命令解析逻辑,使用新的选项结构体
- 改进代码组织,使每个子命令的选项更加清晰和独立
2025-09-09 21:19:59 +08:00
dengbo 36a0564e8b fix: can not find QUuid::Id128 in qt5
Add QUuid head include.
2025-09-09 21:19:59 +08:00
deepsource-autofix[bot] c340fba3a3 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 6992340 according to the output
from ClangFormat and Prettier.

Details: None
2025-09-09 21:19:59 +08:00
dengbo 461de97735 refactor: use RAII for env vars in hooks
1. Replaces the custom `EnvVarGuard` class with the
`command::EnvironmentVariableGuard` class, which is a RAII wrapper for
setting and unsetting environment variables.
2. Changes the `envVarGuards` vector from holding
instances of `EnvVarGuard` to holding `unique_ptr`s to
`command::EnvironmentVariableGuard`. This ensures that the environment
variables are properly cleaned up when the vector goes out of scope,
even if exceptions are thrown.
3. Marks the `stringEqual` and `splitString` functions as inline to
potentially improve performance by allowing the compiler to inline these
functions.

Influence:
1. Verify hook scripts that rely on environment variables are still
functioning correctly after the change.
2. Confirm that environment variables set by hook scripts are properly
cleaned up after the script execution, even in cases where the script
throws an exception.

重构: 在hooks中使用RAII管理环境变量

1. 将自定义的 `EnvVarGuard` 类替换为 `command::EnvironmentVariableGuard`
类,后者是一个 RAII 包装器,用于设置和取消设置环境变量。
2. 将 `envVarGuards` 向量从保存 `EnvVarGuard` 的实例更改为保存指向
`command::EnvironmentVariableGuard` 的 `unique_ptr`。 这确保了即使抛出异
常,环境变量在向量超出范围时也能正确清理。
3. 将 `stringEqual` 和 `splitString` 函数标记为内联,以通过允许编译器内
联这些函数来潜在地提高性能。

Influence:
1. 验证在更改后,依赖环境变量的 hook 脚本仍然可以正常运行。
2. 确认 hook 脚本设置的环境变量在脚本执行后能够正确清理,即使在脚本抛出
异常的情况下。
2025-09-09 21:19:59 +08:00
reddevillg 2505dd2806 refactor: Move uninstall logic to package manager service
This refactoring moves the core uninstall logic from the cli to PM.

Key changes:
- Support uninstall extension
- Added robust error handling for uninstalling:
  - Returns an error if multiple versions are installed and the user
    input is ambiguous.
  - Prevents uninstalling 'base' or 'runtime' packages directly.
  - Checks if an application or its dependencies are running before
    proceeding.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-09-09 21:19:59 +08:00
ComixHe 8bca53490d refactor: remove symlink target validation and force overwrite existing files
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-09-05 10:24:25 +08:00
ComixHe b63f2a0c5e chore: fix typo
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-09-05 10:24:25 +08:00
dengbo 2ed1814032 refactor: remove develop module check
This commit removes the check that prevented installation of packages
with `packageInfoV2Module` set to anything other than "binary" or
"runtime". This restriction was unnecessary and blocked the installation
of development modules. Removing it allows for greater flexibility in
package definitions and enables the installation of a wider range of
packages.

Influence:
1. Test installation of packages with `packageInfoV2Module` set to
"binary", "runtime", and other valid values.
2. Verify that development modules can now be installed successfully.
3. Ensure no regressions in the installation process of binary and
runtime modules.

重构: 移除开发模块检查

此提交移除了对 `packageInfoV2Module` 设置为 "binary" 或 "runtime" 之外的
值的软件包安装的检查。 此限制是不必要的,并且阻止了开发模块的安装。 删除
它允许软件包定义中更大的灵活性,并支持安装更广泛的软件包。

Influence:
1. 测试将 `packageInfoV2Module` 设置为 "binary"、"runtime" 和其他有效值
的软件包的安装。
2. 验证现在可以成功安装开发模块。
3. 确保二进制和运行时模块的安装过程中没有发生回归。
2025-09-05 10:24:25 +08:00
ComixHe 73395ea2d8 fix: improve UAB loader and packager with better mount handling
- Add processProfile function for triplet configuration
- Fix mount options from rbind to bind
- Optimize custom loader handling in packager

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-09-05 10:24:25 +08:00
deepsource-autofix[bot] 81794729a3 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in d25bb09 according to the output
from ClangFormat and Prettier.

Details: None
2025-09-05 10:24:25 +08:00
dengbo b8dd2e98ba refactor: rename bindMedia to bindRemovableStorageMounts
1. Renamed the `bindMedia` function to `bindRemovableStorageMounts` in
`ContainerCfgBuilder`.
2. Updated the function's implementation to include both `/media` and `/
mnt` mount points. This ensures that removable storage devices mounted
in either location are correctly bound within the container. The logic
now iterates through a vector of propagation paths including `/media`
and `/mnt`, binding them to their respective destinations.
3. This change was made to better reflect the function's purpose, which
is to handle removable storage mounts and also aligns with common Linux
conventions where `/mnt` is also used for mounting removable devices.
The previous name only covered the `/media` mount point.

Influence:
1. Test applications that rely on accessing files on removable storage
devices (USB drives, external hard drives) mounted under both /media
and /mnt.
2. Verify that the correct files and directories are accessible inside
the container when removable storage devices are mounted under /media
and /mnt.
3. Check that the read-only mount option is correctly applied to the /
media and /mnt mounts inside the container, preventing accidental writes
from the container to the host's removable storage.

重构: 将 bindMedia 重命名为 bindRemovableStorageMounts

1. 在 `ContainerCfgBuilder` 中,将 `bindMedia` 函数重命名为
`bindRemovableStorageMounts`。
2. 更新了函数的实现,使其包含 `/media` 和 `/mnt` 挂载点。这确保了在这两
个位置挂载的可移动存储设备都可以在容器内正确绑定。 现在的逻辑是遍历包含
`/media` 和 `/mnt` 的传播路径的向量,并将它们绑定到各自的目标。
3. 做出此更改是为了更好地反映该函数的目标,该目标是处理可移动存储挂载,
并且与常见的 Linux 约定(其中 `/mnt` 也用于挂载可移动设备)保持一致。 之
前的名称仅涵盖 `/media` 挂载点。

Influence:
1. 测试依赖于访问可移动存储设备(U盘、外部硬盘)上的文件的应用程序,这些
设备挂载在 /media 和 /mnt 下。
2. 验证当可移动存储设备挂载在 /media 和 /mnt 下时,容器内可以访问正确的
文件和目录。
3. 检查只读挂载选项是否已正确应用于容器内的 /media 和 /mnt 挂载,从而防
止容器意外写入主机可移动存储。
2025-09-05 10:24:25 +08:00
wrj97 aa3c79a9bb fix: null pointer exception when building runtime
在构建runtime时会出现空指针异常的问题
2025-09-05 10:24:25 +08:00
ComixHe 2ed4a92739 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-09-05 10:24:25 +08:00
dengbo 413726bab1 fix: fix duplicate runtime dependencies
This change addresses an issue where runtime dependencies were not
being correctly deduplicated, leading to multiple instances of the
same runtime being included in the application environment. This was
happening because the `reference` field of `runtime` and `base` was
directly assigned with `*localRuntime` or `*localBase`, which did not
include repo information. The fix involves wrapping `localRuntime` and
`localBase` with `ReferenceWithRepo` and adding repo information. This
ensures that the package manager can accurately identify and reuse
existing runtimes. The `semanticMatching = true` option is added to
`getSatisfiedPackage` to ensure the version matching works.

Influence:
1. Test installing an application with shared runtime dependencies.
2. Verify that only one instance of each runtime is present in the
environment.
3. Check that the application functions correctly with the deduplicated
runtimes.
4. Ensure semantic version matching works as expected.

fix: 修复重复的运行时依赖

此更改解决了运行时依赖项未被正确去重的问题,导致应用程序环境中包含同一
运行时的多个实例。发生这种情况是因为 `runtime` 和 `base` 的 `reference`
字段直接使用 `*localRuntime` 或 `*localBase` 进行赋值,未包含仓库信息。
此修复包括使用 `ReferenceWithRepo` 包装 `localRuntime` 和 `localBase`
并添加仓库信息。这确保了包管理器可以准确地识别和重用现有的运行时。
`semanticMatching = true` 选项已添加到 `getSatisfiedPackage`,以确保版本
匹配正常工作。

Influence:
1. 测试安装具有共享运行时依赖项的应用程序。
2. 验证环境中仅存在每个运行时的单个实例。
3. 检查应用程序在使用去重后的运行时时是否正常运行。
4. 确保语义版本匹配按预期工作。
2025-08-21 21:00:30 +08:00
dengbo 3eb9537489 fix: fix pull dependency in offline scenarios
This commit addresses a critical issue where dependency pulling would
fail in offline or unreliable network conditions. The `pullDependency`
function in `PackageManager` was solely relying on remote repositories
to fetch runtime and base dependencies. This change introduces a
fallback mechanism: if fetching from the remote repository fails, the
function now attempts to locate the dependency in the local repository
before failing. This ensures that if the required dependency is already
present locally (e.g., from a previous successful pull), it can be used
even when offline or experiencing network issues.

Influence:
1. Test dependency pulling in offline mode after successfully pulling
dependencies online.
2. Simulate network issues during dependency pulling to verify the
fallback mechanism.
3. Test cases where dependencies are only available locally.

fix: 修复离线场景下依赖拉取失败的问题

此提交修复了一个在离线或网络不可靠的情况下依赖拉取会失败的关键问题。
`PackageManager` 中的 `pullDependency` 函数之前仅依赖于远程仓库来获取
runtime 和 base 依赖。此更改引入了一个回退机制:如果从远程仓库获取失败,
该函数现在会尝试在本地仓库中查找依赖项,然后再失败。这确保了如果所需的依
赖项已在本地存在(例如,从先前成功的拉取中获得),即使在离线或遇到网络问
题时也可以使用。

Influence:
1. 在成功在线拉取依赖后,测试离线模式下的依赖拉取。
2. 在依赖拉取期间模拟网络问题,以验证回退机制。
3. 测试仅在本地可用的依赖项的情况。
2025-08-21 16:55:11 +08:00
wrj97 61f0a31b34 feat: clean up temporary ref after getting commit size
在获取commit size后清理ref, 避免重新生成缓存时出问题
2025-08-21 13:14:39 +08:00
deepsource-autofix[bot] aa42090ee8 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in b6cff37 according to the output
from ClangFormat and Prettier.

Details: None
2025-08-21 13:13:42 +08:00
wrj97 b6cff37c65 feat: optimize layer search logic
优化layer查找的逻辑, 优先从默认仓库搜索, 再从多仓库搜索, 最后再回退runtime搜索
补充部分代码的错误信息传递
2025-08-21 10:39:36 +08:00
wrj97 36e41e887a refactor: improve code organization in layer packager
1. Remove unused qcontainerfwd.h header to eliminate dead code
2. Split UUID generation and string conversion for better readability
3. Reformat mkfs.erofs command arguments for improved code style
4. Add missing filesystem header include to fix potential compilation issues

refactor: 改进层打包器代码组织

1. 移除未使用的 qcontainerfwd.h 头文件以消除死代码
2. 分离 UUID 生成和字符串转换以提高可读性
3. 重新格式化 mkfs.erofs 命令参数以改善代码风格
4. 添加缺失的 filesystem 头文件包含以修复潜在编译问题
2025-08-14 09:43:33 +08:00
deepsource-autofix[bot] e133ed3269 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 31e8d75 according to the output
from ClangFormat and Prettier.

Details: None
2025-08-13 10:01:33 +08:00
myml 31e8d75b01 refactor: improve UAB file handling and cleanup
1. Changed LayerPackager to use std::filesystem::path instead of QDir
for workDir
2. Added defensive programming in initWorkDir to handle multiple calls
3. Implemented proper cleanup in UABFile destructor for mount points and
unpacked files
4. Added support for both erofsfuse and fsck.erofs unpack methods
5. Improved error handling and added new utility methods in UABFile
6. Added comprehensive unit tests for UAB file operations

refactor: 改进UAB文件处理和清理

1. 将LayerPackager中的workDir从QDir改为std::filesystem::path
2. 在initWorkDir中添加防御性编程以处理多次调用
3. 在UABFile析构函数中实现挂载点和解压文件的正确清理
4. 添加对erofsfuse和fsck.erofs两种解压方法的支持
5. 改进错误处理并在UABFile中添加新的实用方法
6. 为UAB文件操作添加全面的单元测试
2025-08-12 17:00:55 +08:00
dengbo f9929a2664 test: refine command execution tests
Refines the command execution tests to improve accuracy and reliability.
Specifically, the test for the "id" command now includes the "-u"
flag to directly retrieve the user ID, and the assertion checks if
the returned user ID matches the current user's UID obtained from
`getuid()`. This change eliminates the dependency on the "USER"
environment variable, which may not always be reliable, and provides
a more deterministic and accurate test. The previous test relied on
pattern matching to find the username within the output of `id`, which
was fragile.

Influence:
1. Execute the tests to verify that the `command::Cmd` class correctly
executes commands and returns their output.
2. Ensure that the updated test using `id -u` correctly retrieves and
validates the user ID.
3. Verify that the test case for non-existent commands still behaves as
expected, returning an empty `std::optional`.

test: 优化命令执行测试

优化命令执行测试,以提高准确性和可靠性。 具体来说,"id" 命令的测试
现在包含 "-u" 标志以直接检索用户ID,并且断言检查返回的用户ID是否与从
`getuid()` 获取的当前用户的UID匹配。 此更改消除了对 "USER" 环境变量的依
赖,该变量可能并不总是可靠的,并提供了更具确定性和准确性的测试。 之前的
测试依赖于模式匹配以在 `id` 的输出中查找用户名,这很不稳定。

Influence:
1. 执行测试以验证 `command::Cmd` 类是否正确执行命令并返回其输出。
2. 确保使用 `id -u` 的更新测试正确检索并验证用户 ID。
3. 验证不存在命令的测试用例是否仍然按预期运行,返回一个空的
`std::optional`。
2025-08-11 16:34:43 +08:00
reddevillg b8eb70c4ac fix: add missing header
Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-08-05 16:58:29 +08:00
ComixHe daf7e29fed refactor(oci-cfg): simplify media mount options
Remove "rshared" option from media mount configuration,
keeping only "rbind" for better compatibility and simpler mount behavior.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-08-05 16:34:42 +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] c255e247b1 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 59123f5 according to the output
from ClangFormat and Prettier.

Details: None
2025-08-05 10:26:14 +08:00
myml 59123f56c1 refactor: improve layer packager reliability and testing
1. Refactor LayerPackager to handle work directory creation more
robustly with fallback to /var/tmp or system temp dir
2. Add proper cleanup in destructor including unmounting if mounted
3. Implement file permission checking and manual file copying for cases
where direct FD access fails
4. Support both erofsfuse and fsck.erofs for unpacking with appropriate
fallback logic
5. Add comprehensive unit tests covering various unpack scenarios and
work dir initialization
6. Replace utils::command::Exec with utils::command::Cmd for better
command execution handling
7. Add proper error handling and logging throughout the implementation

The changes improve reliability when dealing with file permissions and
different system configurations, while making the code more testable
through mockable interfaces. The new unit tests verify behavior under
various conditions including:
- Normal fuse mounting
- Fuse mounting with offset
- Fallback to fsck.erofs when fuse isn't available
- Work directory initialization failures

refactor: 提升layer packager的可靠性和测试覆盖率

1. 重构 LayerPackager 以更健壮地处理工作目录创建,支持回退到/var/tmp或系
统临时目录
2. 在析构函数中添加适当的清理逻辑,包括卸载已挂载的文件系统
3. 实现文件权限检查和手动文件复制,处理直接文件描述符访问失败的情况
4. 支持使用erofsfuse和fsck.erofs两种方式进行解包,并实现适当的回退逻辑
5. 添加全面的单元测试,覆盖各种解包场景和工作目录初始化
6. 使用utils::command::Cmd替换utils::command::Exec以获得更好的命令执行
处理
7. 在整个实现中添加适当的错误处理和日志记录

这些改动提高了处理文件权限和不同系统配置时的可靠性,同时通过可模拟接口使
代码更易于测试。新的单元测试验证了各种条件下的行为,包括:
- 正常的fuse挂载
- 带偏移量的fuse挂载
- 当fuse不可用时回退到fsck.erofs
- 工作目录初始化失败的情况
2025-08-04 15:12:30 +08:00
dengbo 98a3b177dd feat: add graphics card environment variables
Adds environment variables to forward NVIDIA rendering
support.
2025-07-31 20:44:23 +08:00
dengbo 2d2c5d041a chore: clean code
Removes the `envList` variable as it is no longer used.
2025-07-31 20:44:23 +08:00
dengbo bf1899d328 chore: update external dependency libraries used
1. Update external tl-expected and cli11 to new version.
2. tl-expected and cli11 only import header files.
2025-07-31 14:56:56 +08:00
reddevillg e6394ed758 fix: Don't bind host statics in build stage
1. Don't bind host statics in build statics, because build script may
   write to those directories.
2. add /sbin to merge list.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-07-28 16:03:32 +08:00
ComixHe f7cf75b867 feat(run): add option '--env'
Adding a '--env' option to the ll-cli run command,
allowing users to set environment variables when running applications.
This feature supports multiple environment variables in KEY=VALUE format with
input validation to ensure proper formatting.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-28 15:29:16 +08:00
reddevillg 33eeea7559 fix: Always use copy-symlink on /etc/resolv.conf
Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-07-25 12:02:36 +08:00
reddevillg 7292e1b428 fix: share /tmp directory with host
Share /tmp directory with host for maximize compability

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-07-23 18:14:31 +08:00
reddevillg c728fab048 feat: set ns_last_pid annotation
Use this annotation with ll-box to configure ns_last_pid in new pid
namespace to avoid pid collisions.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-07-23 15:00:31 +08:00
deepsource-autofix[bot] 995a71e85a style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 2614170 according to the output
from ClangFormat and Prettier.

Details: None
2025-07-22 16:44:16 +08:00
myml b7c6a7d47d chore: remove desktop entry utility and tests
1. Removed DesktopEntry class implementation and its header file
2. Removed corresponding test cases from ll-tests
3. Updated CMakeLists.txt to reflect these removals
4. The functionality appears to be unused in the project
5. Cleanup helps reduce maintenance burden and code complexity

chore: 移除桌面入口工具类和测试

1. 移除了 DesktopEntry 类的实现和头文件
2. 从 ll-tests 中移除了对应的测试用例
3. 更新了 CMakeLists.txt 以反映这些移除
4. 该功能在项目中似乎未被使用
5. 清理有助于减少维护负担和代码复杂度
2025-07-22 16:38:18 +08:00
myml 261417050f refactor: extract OSTree pull options initialization
Extracted the common OSTree pull options initialization code into a
separate method initOStreePullOptions to avoid code duplication. The
method handles:
1. Creating GVariantBuilder with common options
2. Setting refs and user agent
3. Disabling static deltas by default
This change makes the pull operation code cleaner and more maintainable
by centralizing the options configuration logic.

refactor: 提取 OSTree 拉取选项初始化代码

将 OSTree 拉取选项的初始化代码提取到单独的 initOStreePullOptions 方法中
以避免重复代码。该方法处理:
1. 创建带有通用选项的 GVariantBuilder
2. 设置refs和user-agent
3. 默认禁用静态增量
通过集中管理选项配置逻辑,使拉取操作代码更清晰且更易于维护。
2025-07-22 16:36:40 +08:00