8000 请问fedora、openEuler、centos这类系统如何liblol · Issue #26 · AOSC-Dev/liblol · GitHub
[go: up one dir, main page]

Skip to content
8000

请问fedora、openEuler、centos这类系统如何liblol #26

Open

Description

@sterling-teng

我执行打包命令时报错:

./build: 行 395: abinfo: 未找到命令
./build: 行 396: dpkg-query: 未找到命令
./build: 行 398: abdie: 未找到命令
./build: 行 400: abinfo: 未找到命令
./build: 行 409: abinfo: 未找到命令
./build: 行 410: dpkg-query: 未找到命令
./build: 行 412: abdie: 未找到命令
./build: 行 414: abinfo: 未找到命令

请问如何打包?
或者有没有编译部署指南?

Activity

  1. xen0n commented on Mar 24, 2026

    @xen0n
    Member

    https://liblol.aosc.io/docs/dev/packaging/

    简而言之:每个发行版都要单独研究打包方式

  2. sterling-teng commented on Mar 25, 2026

    @sterling-teng
    Author

    打包确实有难度,我试用了aosc,解决不了我的需求所以放弃了liblol。我最终使用了新世界host + 旧世界guest的方案解决了我的需求。以下是我的搞了一半的spec:

    %global debug_package %{nil}
    
    %define pkgname liblol
    %define version 0.1.4
    %define glibc_ver 2.38
    %define libxcrypt_ver 4.4.36
    %define patchelf_ver 0.18.0
    
    Name:           %{pkgname}
    Version:        %{version}
    Release:        1%{?dist}
    Summary:        LoongArch Old-World ABI Compatibility Runtime
    License:        GPLv2 and LGPLv2.1+
    URL:            https://github.com/AOSC-Dev/liblol
    
    Source0:        liblol-%{version}.tar.gz
    Source1:        glibc-%{glibc_ver}.tar.xz
    Source2:        patchelf-%{patchelf_ver}.tar.gz
    Source3:        libxcrypt-%{libxcrypt_ver}.tar.xz
    
    BuildRequires:  gcc gcc-c++ make python3 bison gawk texinfo sed gettext diffutils
    BuildRequires:  kernel-headers >= 5.19
    
    %description
    liblol provided by AOSC, base on glibc 2.42 and libxcrypt 4.5.2.
    
    %prep
    # 1. 解压 liblol 源码
    %setup -q -n liblol-%{version}
    
    # 2. 解压辅助源码
    tar -xf %{SOURCE1}
    tar -xf %{SOURCE2}
    tar -xf %{SOURCE3}
    
    # 3. 应用补丁
    # --- 给 Patchelf 打补丁 ---
    cd patchelf-%{patchelf_ver}
    # 使用你 ls 出来的确切文件名
    patch -p1 < ../autobuild/patches/patchelf/0001-add-remap-symvers.patch
    cd ..
    
    # --- 给 Glibc 打补丁 ---
    cd glibc-%{glibc_ver}
    # 按照 series 文件定义的顺序打补丁是更稳妥的做法
    # 如果没有 quilt 工具,我们可以解析 series 文件
    if [ -f ../autobuild/patches/glibc/series ]; then
        while read -r p; do
            [ -z "$p" ] && continue
            echo "Applying glibc patch: $p"
            patch -p1 < "../autobuild/patches/glibc/$p"
        done < ../autobuild/patches/glibc/series
    else
        # 如果没有 series,回退到 for 循环
        for p in ../autobuild/patches/glibc/*.patch; do
            echo "Applying glibc patch: $p"
            patch -p1 < "$p"
        done
    fi
    cd ..
    
    %build
    # 1. 编译本地 patchelf
    mkdir -p tools-bin
    cd patchelf-%{patchelf_ver}
    ./bootstrap.sh || true
    ./configure --prefix=$(pwd)/../tools-bin
    make -j$(nproc)
    make install
    cd ..
    export PATH=$(pwd)/tools-bin/bin:$PATH
    
    # 2. 编译 Glibc 2.42
    mkdir -p build-glibc
    cd build-glibc
    export CFLAGS_COMMON="-O2 -g -ffile-prefix-map=%{_sourcedir}=."
    export LDFLAGS_COMMON="-Wl,-O1,--sort-common,--as-needed -Wl,-build-id=sha1"
    cat > configparms <<EOF
    slibdir = /usr/lib
    rtlddir = /usr/lib
    sbindir = /usr/bin
    rootsbindir = /usr/bin
    complocaledir = /usr/lib/locale
    localtime-file = /etc/localtime
    sysconfdir = %{LOL_PREFIX}/etc
    user-defined-trusted-dirs-pre = %{LOL_PREFIX}/local/preload-lib %{LOL_PREFIX}/support/lib/loongarch-lp64d
    user-defined-trusted-dirs = %{LOL_PREFIX}/local/lib %{LOL_PREFIX}/lib/loongarch-lp64d %{LOL_PREFIX}/lib
    build-programs=no
    
    CFLAGS = -pipe $CFLAGS_COMMON
    ASFLAGS = -pipe $CFLAGS_COMMON
    BUILD_CFLAGS = $CFLAGS_COMMON
    LDFLAGS = $LDFLAGS_COMMON
    EOF
    
    ../glibc-%{glibc_ver}/configure \
    --prefix=/usr \
    --with-headers=/usr/include \
    --with-bugurl=https://github.com/loongarchlinux/core/issues \
    --enable-bind-now \
    --enable-fortify-source \
    --enable-kernel=4.4 \
    --enable-multi-arch \
    --enable-stack-protector=strong \
    --disable-nscd \
    --disable-profile \
    --enable-obsolete-api=no \
    --enable-obsolete-rpc \
    --disable-werror \
    --libdir=/usr/lib \
    --libexecdir=/usr/lib \
    --enable-cet \
    --without-gd \
    --enable-crypt
    make -O -j$(nproc)
    gcc -shared \
        -x c /dev/null \
        -o ld-linux-loongarch-lp64d.so.1 \
        -Wl,--version-script -Wl,./ld.map \
        -nostdlib \
        $CFLAGS_COMMON \
        $LDFLAGS_COMMON
    cd ..
    
    # 3. 编译 libxcrypt (这是为了提供 libcrypt.so.1)
    export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong"
    unset PERL5LIB
    mkdir -p build-libxcrypt
    cd build-libxcrypt
    ../libxcrypt-%{libxcrypt_ver}/configure \
        --prefix=/opt/lol \
        --host=loongarch64-unknown-linux-gnu \
        --build=loongarch64-unknown-linux-gnu \
        --enable-hashes=all \
        --enable-obsolete-api=glibc \
        --disable-static
    make -j$(nproc)
    cd ..
    
    %install
    export PATH=$(pwd)/tools-bin/bin:$PATH
    
    # 安装 Glibc
    cd build-glibc
    make install install_root=%{buildroot}
    cd ..
    
    # 安装 libxcrypt
    cd build-libxcrypt
    make install DESTDIR=%{buildroot}
    cd ..
    
    # 清理无用文件
    rm -rf %{buildroot}/opt/lol/{share,include,bin,sbin,libexec}
    find %{buildroot}/opt/lol/lib -name "*.a" -delete
    find %{buildroot}/opt/lol/lib -name "*.la" -delete
    
    # 魔改符号 (Fixup)
    LOL_LIB_DEST=%{buildroot}/opt/lol/lib
    LD_SO_NAME=$(ls $LOL_LIB_DEST | grep 'ld-linux-loongarch' | head -n 1)
    LD_SO_PATH=$LOL_LIB_DEST/$LD_SO_NAME
    
    # 处理所有库文件
    patchelf --force-adjust-file-offset --set-rpath /opt/lol/lib $LD_SO_PATH
    
    for f in $LOL_LIB_DEST/*.so*; do
        if [ -L "$f" ] || [ "$f" == "$LD_SO_PATH" ]; then continue; fi
        patchelf --force-adjust-file-offset --add-needed $LD_SO_NAME --set-rpath /opt/lol/lib $f
    done
    
    # 环境变量
    mkdir -p %{buildroot}/etc/profile.d
    echo 'export LD_LIBRARY_PATH=/opt/lol/lib:$LD_LIBRARY_PATH' > %{buildroot}/etc/profile.d/liblol.sh
    
    %files
    /opt/lol/lib/*.so*
    /etc/profile.d/liblol.sh
    
    %changelog
    * Fri Jan 09 2026 fuck - 0.1.10-1
    - Update to glibc 2.42 and libxcrypt 4.5.2
    

    希望有人能继续下去。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0