[ Technical exchange] 打包玲珑应用如何设置依赖项?
Tofloor
poster avatar
chise
deepin
2025-08-05 09:25
Author

我的程序需要有依赖项,还有就是deepin25用的qt6但是这个程序用的qt5,请问这个怎么设置?

我现在的yaml如下(主要就是build那块的 apt install和设置qt版本不知道怎么配置):

version: "1"

package:
  id: com.github.Chise1.qdirstat    # 软件包 appid,类似 deb 格式软件包包名,区分不同玲珑格式软件包
  name: qdirstat    # 应用名称
  kind: app
  version: 1.9.0.0    # 软件包版本
  description: |
    QDirStat - Qt-based directory statistics (KDirStat without any KDE - from the original KDirStat author)

command:
  - /opt/apps/com.github.Chise1.qdirstat/files/src/qdirstat

base: org.deepin.base/23.1.0
runtime: org.deepin.runtime.dtk/23.1.0

build: |
  apt-get install qttools5-dev-tools qtbase5-doc qtbase5-doc-html qtbase5-examples
  apt-get install qtchooser
  export QT_SELECT="qt5"
  qmake
  make
  make install


Reply Favorite View the author
All Replies
chise
deepin
2025-08-05 09:29
#1

另外吐个槽,版本号你们教程里面没说必须1.0.0.0这种格式,我用1.9的时候老是报错,查了半天才发现是这个的问题

Reply View the author
会飞的鱼11
deepin
Community Developer
2025-08-05 09:48
#2
chise

另外吐个槽,版本号你们教程里面没说必须1.0.0.0这种格式,我用1.9的时候老是报错,查了半天才发现是这个的问题

配置文件一章(https://linyaps.org.cn/guide/ll-builder/manifests.html)有提到推荐的版本写法,可能不太明显。

Reply View the author
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2025-08-05 09:59
#3

文档的确有不少需要完善的地方。

Reply View the author
会飞的鱼11
deepin
Community Developer
2025-08-05 10:05
#4

打包依赖的写法可以参考(https://linyaps.org.cn/guide/ll-builder/manifests.html#%E6%9E%84%E5%BB%BA%E6%89%A9%E5%B1%95-buildext)一章配置, 其中runtime里面已经带了qt的环境,不需要额外安装。

Reply View the author
chise
deepin
2025-08-05 10:09
#5
会飞的鱼11

配置文件一章(https://linyaps.org.cn/guide/ll-builder/manifests.html)有提到推荐的版本写法,可能不太明显。

这种不能叫推荐,应该说清楚是强制。。

Reply View the author
chise
deepin
2025-08-05 10:32
#6
会飞的鱼11

打包依赖的写法可以参考(https://linyaps.org.cn/guide/ll-builder/manifests.html#%E6%9E%84%E5%BB%BA%E6%89%A9%E5%B1%95-buildext)一章配置, 其中runtime里面已经带了qt的环境,不需要额外安装。

我设置了构建依赖,但是构建的时候提示没有qmake?这是啥情况。。

version: "1"

package:
  id: com.github.Chise1.qdirstat    # 软件包 appid,类似 deb 格式软件包包名,区分不同玲珑格式软件包
  name: qdirstat    # 应用名称
  kind: app
  version: 1.9.0.0    # 软件包版本
  description: |
    QDirStat - Qt-based directory statistics (KDirStat without any KDE - from the original KDirStat author)

command:
  - /opt/apps/com.github.Chise1.qdirstat/files/src/qdirstat

base: org.deepin.base/23.1.0
runtime: org.deepin.runtime.dtk/23.1.0

build: |
  qmake INSTALL_PREFIX=$PREFIX
  make
  make install

buildext:
  apt:
    build_depends: # 构建时依赖,仅在构建环境中安装
      - qmake
      - cmake
      - build-essential
      - zlib1g-dev
      - qtbase5-dev
      # - make
      # - qttools5-dev-tools
#     depends: # 运行时依赖,会包含在最终的应用或运行时中
#       - libqt6widgets6
#       - libglib2.0-0

运行ll-build build的时候报错:

E: 无法定位软件包 qmake
(163188) ./apps/ll-builder/src/main.cpp:279 Build failed: [code -1 ] message:
./libs/linglong/src/linglong/builder/linglong_builder.cpp:1509 build project /home/yuxf/Downloads/qdirstat-1.9/qdirstat-1.9/linglong.yaml: stage build error
./libs/linglong/src/linglong/builder/linglong_builder.cpp:860 build stage build: stage pre build failed
./libs/linglong/src/linglong/builder/linglong_builder.cpp:844 build stage pre build: failed to process buildext
./libs/linglong/src/linglong/builder/linglong_builder.cpp:791 process build depends: failed to process buildext.apt.buildDepends
./libs/linglong/src/linglong/runtime/container.cpp:272 run container ea5bbd1a61ed942f5dbf77362548eb6896fdf7f73ce5323702e860e09e7eb2ed: cli run: run command failed: /usr/bin/ll-box --cgroup-manager=disabled run -b /run/user/1000/linglong/ea5bbd1a61ed942f5dbf77362548eb6896fdf7f73ce5323702e860e09e7eb2ed ea5bbd1a61ed942f5dbf77362548eb6896fdf7f73ce5323702e860e09e7eb2ed retval=25600

Reply View the author
会飞的鱼11
deepin
Community Developer
2025-08-05 10:38
#7
chise

我设置了构建依赖,但是构建的时候提示没有qmake?这是啥情况。。

version: "1"

package:
  id: com.github.Chise1.qdirstat    # 软件包 appid,类似 deb 格式软件包包名,区分不同玲珑格式软件包
  name: qdirstat    # 应用名称
  kind: app
  version: 1.9.0.0    # 软件包版本
  description: |
    QDirStat - Qt-based directory statistics (KDirStat without any KDE - from the original KDirStat author)

command:
  - /opt/apps/com.github.Chise1.qdirstat/files/src/qdirstat

base: org.deepin.base/23.1.0
runtime: org.deepin.runtime.dtk/23.1.0

build: |
  qmake INSTALL_PREFIX=$PREFIX
  make
  make install

buildext:
  apt:
    build_depends: # 构建时依赖,仅在构建环境中安装
      - qmake
      - cmake
      - build-essential
      - zlib1g-dev
      - qtbase5-dev
      # - make
      # - qttools5-dev-tools
#     depends: # 运行时依赖,会包含在最终的应用或运行时中
#       - libqt6widgets6
#       - libglib2.0-0

运行ll-build build的时候报错:

E: 无法定位软件包 qmake
(163188) ./apps/ll-builder/src/main.cpp:279 Build failed: [code -1 ] message:
./libs/linglong/src/linglong/builder/linglong_builder.cpp:1509 build project /home/yuxf/Downloads/qdirstat-1.9/qdirstat-1.9/linglong.yaml: stage build error
./libs/linglong/src/linglong/builder/linglong_builder.cpp:860 build stage build: stage pre build failed
./libs/linglong/src/linglong/builder/linglong_builder.cpp:844 build stage pre build: failed to process buildext
./libs/linglong/src/linglong/builder/linglong_builder.cpp:791 process build depends: failed to process buildext.apt.buildDepends
./libs/linglong/src/linglong/runtime/container.cpp:272 run container ea5bbd1a61ed942f5dbf77362548eb6896fdf7f73ce5323702e860e09e7eb2ed: cli run: run command failed: /usr/bin/ll-box --cgroup-manager=disabled run -b /run/user/1000/linglong/ea5bbd1a61ed942f5dbf77362548eb6896fdf7f73ce5323702e860e09e7eb2ed ea5bbd1a61ed942f5dbf77362548eb6896fdf7f73ce5323702e860e09e7eb2ed retval=25600

build_depends 中应该只用写一个 zlib1g-dev

Reply View the author
chise
deepin
2025-08-05 10:42
#8
会飞的鱼11

build_depends 中应该只用写一个 zlib1g-dev

依然报没有qmake。。

W: chown to root:adm of file /var/log/apt/term.log failed - OpenLog (22: 无效的参数)
[Start Build]
cd src/ && ( test -e Makefile || /runtime/bin/qmake -o Makefile /project/src/src.pro INSTALL_PREFIX=/opt/apps/com.github.Chise1.qdirstat/files ) && make -f Makefile 
make[1]: 进入目录“/project/src”
/usr/lib/qt5/bin/qmake -o Makefile src.pro
make[1]: /usr/lib/qt5/bin/qmake: 没有那个文件或目录
make[1]: *** [Makefile:764:Makefile] 错误 127
make[1]: 离开目录“/project/src”
make: *** [Makefile:51:sub-src-make_first-ordered] 错误 2
(165650) ./apps/ll-builder/src/main.cpp:279 Build failed:  [code -1 ] message:
        ./libs/linglong/src/linglong/builder/linglong_builder.cpp:1509 build project /home/yuxf/Downloads/qdirstat-1.9/qdirstat-1.9/linglong.yaml: stage build error
        ./libs/linglong/src/linglong/builder/linglong_builder.cpp:974 build stage build
        ./libs/linglong/src/linglong/runtime/container.cpp:272 run container a765977a92f6fba70d59cbac2e02b3f8e6ac26761710ef9856c0b24716874f1d: cli run: run command failed: /usr/bin/ll-box --cgroup-manager=disabled run -b /run/user/1000/linglong/a765977a92f6fba70d59cbac2e02b3f8e6ac26761710ef9856c0b24716874f1d a765977a92f6fba70d59cbac2e02b3f8e6ac26761710ef9856c0b24716874f1d retval=512
Reply View the author
chise
deepin
2025-08-05 10:48
#9
It has been deleted!
chise
deepin
2025-08-05 10:59
#10
会飞的鱼11

打包依赖的写法可以参考(https://linyaps.org.cn/guide/ll-builder/manifests.html#%E6%9E%84%E5%BB%BA%E6%89%A9%E5%B1%95-buildext)一章配置, 其中runtime里面已经带了qt的环境,不需要额外安装。

我看到构建的时候自动执行了这句:

cd src/ && ( test -e Makefile || /runtime/bin/qmake -o Makefile /project/src/src.pro INSTALL_PREFIX=/opt/apps/com.github.Chise1.qdirstat/files ) && make -f Makefile

这个怎么取消啊

Reply View the author
MeGusta
deepin
2025-08-05 12:08
#11

个人觉得,设置依赖项目前是个比较麻烦的事情,但是可以通过其他的方法变通,我这几天研究出来的简要方法如下:

1.把你的依赖写成一个空包,只有DEBIAN/control,制作成deb,例如:dummypkg-0.0.1.zip

2.安装好ll-killer-go,制作一个ll-killer-go工程,在配置文件里面把需要的base,runtime写好,在deps.list和sources.list把需要安装的依赖和软件源填写好,例如:ll-killer-project.zip

3.由于ll-killer-go目前在deepin25下无法正常构建,你需要安装ubuntu 24.04子系统,进入子系统之后,进入ll-killer-go工程目录,执行make,来获取你的依赖。

4.获取好的依赖deb包在:
l-killer-project/linglong/apt/cache/apt/archives
释放的文件在:
ll-killer-project/linglong/filesystem/diff

5.你可以直接解压deb来用,或者把diff中的.wh..opq和*.dpkg-tmp清理干净之后,直接用。

6.处理so库和二进制的环境变量

7.如果需要精简依赖deb,你可以比较这个清单,去掉base和runtime中已有的包:

baseruntime23-all.txt

Reply View the author
chise
deepin
2025-08-05 12:25
#12
MeGusta

个人觉得,设置依赖项目前是个比较麻烦的事情,但是可以通过其他的方法变通,我这几天研究出来的简要方法如下:

1.把你的依赖写成一个空包,只有DEBIAN/control,制作成deb,例如:dummypkg-0.0.1.zip

2.安装好ll-killer-go,制作一个ll-killer-go工程,在配置文件里面把需要的base,runtime写好,在deps.list和sources.list把需要安装的依赖和软件源填写好,例如:ll-killer-project.zip

3.由于ll-killer-go目前在deepin25下无法正常构建,你需要安装ubuntu 24.04子系统,进入子系统之后,进入ll-killer-go工程目录,执行make,来获取你的依赖。

4.获取好的依赖deb包在:
l-killer-project/linglong/apt/cache/apt/archives
释放的文件在:
ll-killer-project/linglong/filesystem/diff

5.你可以直接解压deb来用,或者把diff中的.wh..opq和*.dpkg-tmp清理干净之后,直接用。

6.处理so库和二进制的环境变量

7.如果需要精简依赖deb,你可以比较这个清单,去掉base和runtime中已有的包:

baseruntime23-all.txt

如何去掉base中带的包?我现在能run了,但是export的时候有个包和base里面的libpng16-16冲突了,能不能把这个干掉

Reply View the author
MeGusta
deepin
2025-08-05 12:33
#13
chise

如何去掉base中带的包?我现在能run了,但是export的时候有个包和base里面的libpng16-16冲突了,能不能把这个干掉

ll-killer-go会获取所有依赖,包括更新包。去除和base runtime里面重复的包,可以减小打包体积。

base 和runtime里面是只读的,无法去除。

部分包导出uab会报错libpng错误,这是bug,用ll-builder export --layer

Reply View the author
myml
Super Moderator
Developer
2025-08-05 16:31
#14

不要安装 qtchooser 这个包,这个包硬编码了qt的路径。

runtime: org.deepin.runtime.dtk/23.1.0 这个runtime就是qt5+dtk5, 不需要安装qt5。

下面这个试过可用。

version: "1"

package:
  id: com.github.Chise1.qdirstat # 软件包 appid,类似 deb 格式软件包包名,区分不同玲珑格式软件包
  name: qdirstat # 应用名称
  kind: app
  version: 1.9.0.0 # 软件包版本
  description: |
    QDirStat - Qt-based directory statistics (KDirStat without any KDE - from the original KDirStat author)

command:
  - /opt/apps/com.github.Chise1.qdirstat/files/bin/qdirstat

base: org.deepin.base/23.1.0
runtime: org.deepin.runtime.dtk/23.1.0

build: |
  qmake INSTALL_PREFIX=$PREFIX
  make -j8
  make install

buildext:
  apt:
    build_depends:
      - zlib1g-dev

有两个需要注意的点:
一:command应该写xxx//bin/qdirstat 而不是你之前写的xxx/src/qdirstat。这个是看二进制安装在哪里就写什么

二:qmake是有缓存的,如果你先执行过qmake,再执行qmake INSTALL_PREFIX=$PREFIX是不会生效的,要先清理缓存。

一般推荐是创建一个build目录,在目录里面执行qmake ..
比如 https://github.com/linuxdeepin/linglong-builder-demo 就是这么做的。这样删除build目录就可以清缓存了。

但是这个项目的install写的有问题,在build目录里面执行install会报错,因为使用了项目根目录下的man目录。所以需要手动清理缓存:

make distclean
rm -f .qmake.stash
Reply View the author