Skip to content

archbuild 使用参考

Avimitin edited this page May 18, 2022 · 7 revisions

archbuild 使用参考

使用流程

  1. archbuild 的使用大多是由软链接链接过来执行的,比如

    $ ls /usr/bin/*-x86_64-build  -l
    lrwxrwxrwx 1 root root 9 Jul 14 12:27 /usr/bin/extra-x86_64-build -> archbuild
    lrwxrwxrwx 1 root root 9 Jul 14 12:27 /usr/bin/gnome-unstable-x86_64-build -> archbuild
    lrwxrwxrwx 1 root root 9 Jul 14 12:27 /usr/bin/kde-unstable-x86_64-build -> archbuild
    lrwxrwxrwx 1 root root 9 Jul 14 12:27 /usr/bin/staging-x86_64-build -> archbuild
    lrwxrwxrwx 1 root root 9 Jul 14 12:27 /usr/bin/testing-x86_64-build -> archbuild
  2. 默认大家都安装了默认开发工具集 base-devel 的软件包,如果开发者未安装该工具集,则会在运行上一节中的 _-_-build 相关命令时报错,报错信息如下:

    ==> ERROR: Cannot find the strip binary required for object file stripping.
    ==> ERROR: Could not download sources.
    

    如果出现以上报错,需要安装 base-devel 工具集,命令如下:

    $ sudo pacman -S base-devel
  3. 在包含 PKGBUILD 文件的路径下运行extra-x86_64-build,首先会调用 root 权限,然后检查 base-devel 工具集,之后检查源码的 GPG 公钥

    devtools-20210202.tar.gz ... FAILED (unknown public key FC1B547C8D8172C8)
    
  4. 导入缺失的公钥

    $ gpg --recv-keys FC1B547C8D8172C8
    gpg: /home/tsuibin/.gnupg/trustdb.gpg: trustdb created
    gpg: key FC1B547C8D8172C8: public key "Levente Polyak (anthraxx) <[email protected]>" imported
    gpg: Total number processed: 1
    gpg:               imported: 1
  5. 完成后,再来重新运行 extra-x86_64-build

  6. 运行结果(此处以 devtools,降级过的 ruby-bundler 举例)

    • devtools

      ==> ERROR: The built package (devtools) is the one in the repo right now!
      

      说明该软件包已经打包完成,只不过,软件包于仓库中的版本一样

    • 降级后的 ruby-bundler

      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/templ | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/templ
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/templ | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/templ
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/ui.rb | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/ui.rb
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/ui/   | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/ui/
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/ui/rg | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/ui/rg
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/ui/sh | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/ui/sh
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/ui/si | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/ui/si
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/uri_c | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/uri_c
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/vendo | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/vendo
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/vendo | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/vendo
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/vendo | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/vendo
      ...
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/vlad. | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/vlad.
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/worke | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/worke
      usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/lib/bundler/yaml_ | usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.20/lib/bundler/yaml_
      usr/lib/ruby/gems/3.0.0/specifications/bundler-2.2.24.gemspec | usr/lib/ruby/gems/3.0.0/specifications/bundler-2.2.20.gemspec
      ==> No soname differences for ruby-bundler.
      

      说明该软件包打包完成。

跨平台打包

比如我们目前正在做的 riscv64 移植工作,需要在 x86_64 环境下编译 riscv64 的程序,我们可以这样做:

过时内容
  1. 首先创建软连接将文件 extra-riscv64-build 链接到 archbuild (/usr/bin/extra-riscv64-build -> archbuild )

    $ cd /usr/bin/
    
    $ sudo ln -s archbuild extra-riscv64-build
    
  1. 导入 Arch Linux CN 源,安装 devtools-riscv64

  2. 进入到你要打包的软件目录,目录下需要由 PKGBUILD 文件,执行如下命令

    # extra-riscv64-build -- -d "/tmp/cache:/var/cache/pacman/pkg"
    

    参数说明:

    • -- 将参数传递到 extra-riscv64-build 程序的下一层(实际上是给了 makechrootpkg 这个程序)
    • -d 以读写的方式绑定目录到打包 build chroot (将/tmp/cache 用来保存下载的软件包,使用前需要先创建这个目录,不然会报错)

Tips: 如果遇到如 /var/lib/archbuild/extra-riscv64/root does not appear to be an Arch chroot, 或者 invalid or corrupted package 的错误, 你可以给 archbuild 带上 -c 参数: extra-riscv64-build -c -- -d .....

  • -c 参数会检查当前是否有其他用户正在运行 archbuild,如果没有会清理掉 /var/lib/archbuild/extra-riscv64/ 目录下的 所有目录和 *.lock 文件。

待补充

当用户执行extra-x86_64-build,系统做了哪些工作。

Clone this wiki locally