Building on the previous chapter, we now explore how to adapt linglong.yaml for automated builds. Having established functional build rules in the previous session, this chapter focuses on implementing automated operations using git:

  1. Automatically clone open-source Git repositories.
  2. Automatically apply custom patches.

Modifying linglong.yaml

We will enhance the existing linglong.yaml from the previous successful local compilation.

sources Module

Following the [Linyaps Packaging linglong.yaml Specifications], set kind to git for Git-based sources. Required information:

  1. url: Git repository URL (mirrors acceptable).
  2. version: Specific tag (e.g., release-4.6.7).
  3. commit: Specific commit hash (overrides version).

For qBittorrent.git and libtorrent.git, we use mirror URLs:


sources:  
  - kind: git  
    url: https://githubfast.com/qbittorrent/qBittorrent.git  
    version: release-4.6.7  
    commit: 839bc696d066aca34ebd994ee1673c4b2d5afd7b  
​
  - kind: git  
    url: https://githubfast.com/arvidn/libtorrent.git  
    version: v2.0.9  
    commit: 4b4003d0fdc09a257a0841ad965b22533ed87a0d  

build Module

Update paths according to [Linyaps Packaging Specifications]. Final build rules:

build: |  
mkdir -p ${PREFIX}/bin/ ${PREFIX}/share/  
##Build 3rd libs  
mkdir /project/linglong/sources/libtorrent.git/build  
cd /project/linglong/sources/libtorrent.git/build  
cmake -DCMAKE_BUILD_TYPE=Release \  
      -DCMAKE_INSTALL_PREFIX=$PREFIX ..  
make -j$(nproc)  
make install  

##Build main  
mkdir /project/linglong/sources/qBittorrent.git/build  
cd /project/linglong/sources/qBittorrent.git/build  
cmake -DCMAKE_BUILD_TYPE=Release \  
      -DCMAKE_INSTALL_PREFIX=$PREFIX ..  
make -j$(nproc)  
make install  

##Extract common res  
cp -rf /project/template_app/* ${PREFIX}/share/  

Custom Patch Application

This case introduces patch management via git diff and git apply to fix vulnerabilities.

Steps:

  1. Clone the repository locally.
  2. Modify source code and generate a patch:
git diff > /project/patches/linyaps-qBittorrent-4.6.7-szbt2.patch  
  1. Integrate patch application into build rules:
build: |  
mkdir -p ${PREFIX}/bin/ ${PREFIX}/share/  
##Apply patch for qBittorrent  
cd /project/linglong/sources/qBittorrent.git  
git apply -v /project/patches/linyaps-qBittorrent-4.6.7-szbt2.patch  

##Build 3rd libs  
mkdir /project/linglong/sources/libtorrent.git/build  
cd /project/linglong/sources/libtorrent.git/build  
cmake -DCMAKE_BUILD_TYPE=Release \  
      -DCMAKE_INSTALL_PREFIX=$PREFIX ..  
make -j$(nproc)  
make install  

##Build main  
mkdir /project/linglong/sources/qBittorrent.git/build  
cd /project/linglong/sources/qBittorrent.git/build  
cmake -DCMAKE_BUILD_TYPE=Release \  
      -DCMAKE_INSTALL_PREFIX=$PREFIX ..  
make -j$(nproc)  
make install  

##Extract common res  
cp -rf /project/template_app/* ${PREFIX}/share/  
  1. Build and export the package:
ll-builder build -v  
ll-builder export --layer  

Cross-Distribution Testing

Test the generated binary.layer on supported distributions:

deepin 23

openKylin 2.0

Ubuntu 2404

OpenEuler 2403

Conclusion: The patched qBittorrent application built via Linyaps runs seamlessly across multiple distributions!