Commit Graph

125 Commits

Author SHA1 Message Date
reddevillg bb4ed7b3e8 feat: Add --force option to uninstall command
build / ubuntu_24.04 (push) Has been cancelled Details
build / ubuntu_22.04 (push) Has been cancelled Details
coverage / codecov (push) Has been cancelled Details
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>
2025-11-11 16:28:50 +08:00
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
dengbo d94d9b8b76 feat: enhance inspect command with dir type
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 和选项进行测试,以确保正确的错误处理和消息。
2025-10-22 09:42:40 +08:00
reddevillg 76fcc5b201 feat: Add --privileged and --caps-add options to 'run' command
- 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>
2025-10-15 13:42:41 +08:00
deepsource-autofix[bot] 7551f68448 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 857948b according to the output
from ClangFormat and Prettier.

Details: None
2025-10-15 09:49:43 +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
dengbo de078d0981 fix: correct no-dbus flag logic
The logic for handling the `--no-dbus` flag was inverted.  It was
checking `!noDBusFlag` which meant the sudo block was executed when
`--no-dbus` was *not* set. This meant that the application attempted
to use the package manager connection even when the user explicitly
requested to not use dbus (and likely intended to run as root).  This
commit corrects the logic by checking `*noDBusFlag`. Now the sudo block
will only execute when `--no-dbus` is actually set.

Influence:
1. Test ll-cli commands with and without the `--no-dbus` flag as a
normal user.  Verify that without `--no-dbus`, the commands fail due to
insufficient permissions.
2. Test ll-cli commands with the `--no-dbus` flag as root. Verify that
the commands succeed.
3. Test ll-cli commands without the `--no-dbus` flag as root. Verify
that the commands succeed as they will connect via DBus.

fix: 修正 no-dbus 标志逻辑

`--no-dbus` 标志的处理逻辑被反转了。 它检查的是 `!noDBusFlag`,这意味着
当 *没有* 设置 `--no-dbus` 时,sudo 代码块会被执行。 这意味着即使当用户
明确要求不使用 dbus (并且可能打算以 root 身份运行) 时,应用程序也会尝试
使用包管理器连接。 此提交通过检查 `*noDBusFlag` 来更正逻辑。 现在,只有
在实际设置 `--no-dbus` 时,sudo 代码块才会执行。

Influence:
1. 作为普通用户,使用和不使用 `--no-dbus` 标志测试 ll-cli 命令。 验证在
没有 `--no-dbus` 的情况下,由于权限不足,命令会失败。
2. 作为 root 用户,使用 `--no-dbus` 标志测试 ll-cli 命令。 验证命令是否
成功。
3. 作为 root 用户,在没有 `--no-dbus` 标志的情况下测试 ll-cli 命令。 验
证命令是否成功,因为它们将通过 DBus 连接。
2025-09-19 10:50:41 +08:00
reddevillg a1f559e851 refactor: Centralize XDG and display configuration logic
Key changes:
- `bindXDGRuntime` signature is simplified. The host path is now
  resolved internally during the build phase.
- `buildDisplaySystem` now handles creating a predictable graphics
  environment inside the container.
- X11 is configured with a stable socket path (`/tmp/.X11-unix/X0`)
  and `DISPLAY=:0`.
- Wayland socket path is now `XDG_RUNTIME_DIR/wayland-0` if xdg runtime
  dir mounted, otherwise is '/run/linglong/wayland-0'.

Signed-off-by: reddevillg <reddevillg@gmail.com>
2025-09-18 15:50:21 +08:00
deepsource-autofix[bot] efcb2f7634 style: format code with ClangFormat and Prettier
This commit fixes the style issues introduced in 9466067 according to the output
from ClangFormat and Prettier.

Details: None
2025-09-10 13:59:26 +08:00
wrj97 0f5586d57a 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-10 13:59:01 +08:00
wrj97 9466067893 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-10 13:55:10 +08:00
wrj97 6f7ca1c69d refactor: refactor CLI command options structure for better maintainability
- 为每个子命令创建专门的选项:RunOptions、EnterOptions、KillOptions等
- 添加GlobalOptions用于处理全局选项如verbose
- 重构main.cpp中的命令解析逻辑,使用新的选项结构体
- 改进代码组织,使每个子命令的选项更加清晰和独立
2025-09-09 17:09:18 +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
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
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
dengbo 466faea895 refactor: extends ll-cli dir command with module support
Adds support for specifying a module when using the `ll-cli dir`
command. This allows users to retrieve the layer directory for a
specific module within an application.
2025-07-16 15:06: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
ice909 ca321628aa feat: add support for installing packages from specific repositories
1. Added a new --repo option to the install command to specify a
repository for installation
2. Enhanced repository management with priority-based package resolution
3. Implemented methods to get, promote and recover repository priorities
4. Updated package installation logic to respect repository selection
5. Improved error handling for module not found cases
6. Added ReferenceWithRepo struct to track package references with their
source repositories
2025-05-15 12:23:25 +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
dengbo 8b2d49a6f1 refactor: adjust the default display type
The default display type is changed from app to all.
2025-05-12 10:27:23 +08:00
ice909 bb3624da8e feat: enhance package search with multi-repository support
1. Added repository field to search parameters requiring specifying
repos to search
2. Modified search implementation to support searching in multiple
repositories
3. Restructured search results to group packages by repository source
4. Added --repo option to the CLI search command
5. Updated display format to show repository information in search
results
6. Improved filtering logic to work with the repository-grouped package
structure
7. Added PackageManager1PruneResult type to separate it from search
results
2025-05-09 17:05:28 +08:00
ice909 fb09ada313 feat: optimization error message
Define error codes to identify different errors.
The cli displays error information to users based on error codes.
Add -v,--verbose option to display detailed error information.

Signed-off-by: ice909 <gaochang1@uniontech.com>
2025-04-16 10:56:11 +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
dengbo11 4c66ed5a85 feat(cli): ll-cli add dir sub command
ll-cli add dir sub command to support get layer director by appid.
2025-03-04 09:59:10 +08:00
ComixHe d7cea3443a refactor: optimize starting container
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-02-27 19:42:27 +08:00
ice909 c8d3330c9c feat: add priority to the repo config
The default priority for the stable repository is 0.
When adding a new repository, its priority will be set to the current minimum priority minus 100.
If the new repository is set as the default repository, its priority will be set to the current maximum priority plus 100.
Added the set-priority subcommand to allow manual specification of priorities (duplicates are not allowed).
2025-02-25 14:23:22 +08:00
ice909 0283ea34f4 fix: ll-cli outputs --help info instead of --help-all
This commit ensures that `ll-cli` now outputs the standard `--help` information when no arguments are provided, aligning with common CLI conventions.
The `--help-all` option remains available for users who need expanded details.
2025-02-20 14:09:12 +08:00
ice909 fa51411213 feat: add translations for all titles
ll-cli list and search remove arch field.
2025-02-19 16:51:54 +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 ae7beb907f feat: filter search results to show only latest versions by default
Added a new `--all` flag to the search command to display all versions of packages.
By default, search results will only show the latest version of each package.
2025-02-13 20:56:31 +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 a233980823 feat: support kill container by specific signal
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-02-12 16:23:05 +08:00
ComixHe d393cf3ed5 fix: make option accepts empty container
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-02-07 18:14:50 +08:00
ComixHe bef4a49985 feat(ll-cli): add subcommand 'inspect'
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-01-20 05:41:29 +00:00
Comix 27ea143990
refactor: only create runtime directory before container running (#965)
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-01-16 16:12:01 +08:00
ComixHe e1c9652009 fix: Correcting file mappings when there is no file path passing
Signed-off-by: ComixHe <heyuming@deepin.org>
2024-12-24 17:47:57 +08:00
myml 0b7d27fc0b fix: getRemoteModuleList for incompatibility with runtime modules
获取远程模块列表时, 应该考虑兼容旧版本的runtime modules
优化安装和升级流程, 只安装单个模块时, 不需要提前获取远程模块列表
2024-12-20 10:39:18 +08:00
ComixHe 851e178d3f refactor: move migrating process to ll-package-manager
Signed-off-by: ComixHe <heyuming@deepin.org>
2024-11-26 14:27:39 +08:00
dengbo11 db54a5f645 fix(cli): ll-cli kill can not stop app by reference
1. Compatible with old versions to stop running app container using fuzz reference.
2. Only support enter running app container by fuzz reference.
2024-11-23 17:24:25 +08:00
dengbo11 e6aea9d998 feat(cli): support kill or enter container by appid
Support kill or enter application by appid.
2024-11-22 17:20:22 +08:00
ComixHe 57ea9cb404 feat: filepathMapping supports multiple files or urls
Signed-off-by: ComixHe <heyuming@deepin.org>
2024-11-22 15:15:50 +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
myml 4bea611f7b feat: re-export all application entries after migrate
在迁移后重新导出所有应用的entries, 避免数据残留影响功能
2024-11-21 16:55:36 +08:00
dengbo11 ce9545dd78 fix(ll-cli): cli sub command will error when use --json flag
Use fallthrough to allow list,search,info,content sub command to support --json flags.
2024-11-21 14:52:18 +08:00
dengbo11 124bc72721 fix(cli): add some options back for compatibility
--prune and --all options should be provided for compatibility with older command line parsing.

Bug: https://pms.uniontech.com/bug-view-288097.html
2024-11-20 17:16:00 +08:00
ComixHe ca4f8bc7c7 refactor: re-implement migrate
Signed-off-by: ComixHe <heyuming@deepin.org>
2024-11-19 17:46:22 +08:00
kamiyadm c9d59d653d fix: adjust error output level
-

Log:
2024-11-14 17:17:33 +08:00
dengbo11 2d561fcab3 fix: subcommand help information display error
Subcommand should add usage, or will inherited the parent command.
2024-11-13 11:30:23 +08:00