diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce9a284 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/glibc/ +/patchelf/ diff --git a/README.md b/README.md deleted file mode 100644 index 7cd63ad..0000000 --- a/README.md +++ /dev/null @@ -1,47 +0,0 @@ -libLoL -====== - -简体中文自述文档请见[此处](README.zh.md) - -libLoL (LoongArch on LoongArch) is a compatibility runtime for applications -designed for LoongArch's old-world ABI. By and large, these are applications -built for Loongson's Loongnix reference Linux distribution and UnionTech's -UOS, consisting mostly commercial applications designed for the mainland -Chinese market, such as: - -- Tencent's QQ for Linux -- Kingsoft's WPS for Linux -- Loongson Browser (based on Chromium) - -As these applications have not yet been ported to the new-world ABI, this -runtime is meant to provide help users of new-world Linux distributions use -the aforementioned applications. - -For a brief introduction on old-world and new-world incompatibility, please -refer to [this essay](https://areweloongyet.com/docs/old-and-new-worlds/) (in -Chinese) from the Loongson Open Source Community's *Are We Loong Yet?* site. - -Components ----------- - -libLoL consists of two components, one in the kernel-space and the other in -the user-space. - -- Kernel: The [la_ow_syscall](https://github.com/AOSC-Dev/la_ow_syscall) - modules provides support for old-world system call support in the Linux - Kernel, making it possible to run old-world applications on new-world - (upstream) kernels. -- User-space: A [patched Glibc](https://github.com/AOSC-Dev/glibc-loongarch-oldworld) - provides symbol support for old-world applications - see the Autobuild - building procedure in this repository. Additional runtime may be provided - by the distribution or in binary form from [Loongnix](https://www.loongson.cn/system/loongnix). - -Reporting Issues ----------------- - -Please use the [Issues](https://github.com/AOSC-Dev/liblol/issues) function -for reporting any developer or user issues (feel free to use English or -Chinese). - -You are also welcome to report issues at AOSC's various -[chat groups](https://aosc.io/contact/). diff --git a/README.zh.md b/README.zh.md deleted file mode 100644 index 11305e7..0000000 --- a/README.zh.md +++ /dev/null @@ -1,23 +0,0 @@ -libLoL -====== - -libLoL (LoongArch on LoongArch) 是一款用于提供旧世界 ABI 兼容性的运行时。旧世界 ABI 常用于为龙芯官方的 Loongnix 参考发行和统信 UOS 设计的商业软件,如: - -- 腾讯 QQ Linux 版 -- 金山 WPS for Linux -- 龙芯浏览器(基于 Chromium) - -由于这些应用程序尚未移植到新世界 ABI 上,本运行时旨在为新世界发行版用户提供运行上述应用程序的便利。欲知有关新旧世界应用不兼容来由的相关信息,请见龙芯开源社区《咱龙了吗?》站点的[《新世界与旧世界》](https://areweloongyet.com/docs/old-and-new-worlds/)一文。 - -组件 ----- - -libLoL 由内核空间和用户空间两个组件组成: - -- 内核部分:通过 [la_ow_syscall](https://github.com/AOSC-Dev/la_ow_syscall) 模块,给 Linux 内核新增旧世界系统调用支持,进而使得新世界内核得以兼容旧世界运行时和应用程序 -- 用户空间部分:给 [Glibc 打补丁](https://github.com/AOSC-Dev/glibc-loongarch-oldworld)以提供旧世界应用程序所需符号的兼容性。其余运行时库由发行版软件包或 [Loongnix](https://www.loongson.cn/system/loongnix) 的二进制软件包提供。 - -报告问题 --------- - -请使用本仓库的[工单系统](https://github.com/AOSC-Dev/liblol/issues) 报告有关开发和使用方面的问题。您也可以通过我社的[聊天群组](https://aosc.io/zh-cn/contact/)报告问题。 diff --git a/autobuild/additional-files/hooks/postinst.in b/autobuild/additional-files/hooks/postinst.in deleted file mode 100644 index 13a7db0..0000000 --- a/autobuild/additional-files/hooks/postinst.in +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e -o pipefail - -if ! systemd-detect-virt --container >/dev/null ; then - echo "Loading the la_ow_syscall (old-world syscall compatibility) kernel module ..." - modprobe la_ow_syscall || \ - echo " -Warning: The la_ow_syscall kernel module does not appear to be available. -Old-world applications may not run. -" -fi diff --git a/autobuild/build b/autobuild/build deleted file mode 100644 index 118c895..0000000 --- a/autobuild/build +++ /dev/null @@ -1,421 +0,0 @@ -abinfo "Setting up build environment ..." -OWTARGET="loongarch64-aosc-linux-gnuow" -LOLPREFIX="/opt/lol" - -abinfo "Appending -O2 to CPPFLAGS to fix build ..." -export CPPFLAGS="${CPPFLAGS} -O2" - -apply_source_patch_series() { - local patch_path=$1 - local src_path=$2 - local package=$3 - local patch - - abinfo "Applying $package patches ..." - while IFS= read -r patch; do - abinfo " Applying $patch ..." - patch -p 1 --ignore-whitespace -d "$src_path" \ - < "$patch_path/$patch" - done <"$patch_path/series" -} - -glibc_source() { - abinfo "Extracting Glibc sources ..." - - abinfo "Setting up Glibc source tree ..." - abinfo "Unpacking Glibc source tar ..." - mkdir -pv "$BLDDIR/src/glibc" - tar \ - -C "$BLDDIR/src/glibc" \ - -xvJ \ - --strip-components=1 \ - -f "$SRCDIR/glibc.tar.xz" - apply_source_patch_series \ - "$SRCDIR/autobuild/patches/glibc" \ - "$BLDDIR/src/glibc" \ - "Glibc" -} - -libxcrypt_source() { - abinfo "Extracting Libxcrypt sources ..." - - abinfo "Setting up Libxcrypt source tree ..." - abinfo "Unpacking Libxcrypt source tar ..." - mkdir -pv "$BLDDIR/src/libxcrypt" - tar \ - -C "$BLDDIR/src/libxcrypt" \ - -xvJ \ - --strip-components=1 \ - -f "$SRCDIR/libxcrypt.tar.xz" -} - -cflags_common="-O2 -g -ffile-prefix-map=$BLDDIR=." -ldflags_common="-Wl,-O1,--sort-common,--as-needed -Wl,-build-id=sha1" -libc_map="GLIBC_2.36=GLIBC_2.27,GLIBC_2.28" - -gen_abi_list() { - local lib=$1 - LC_ALL=C objdump --dynamic-syms "$lib" | \ - LC_ALL=C awk -f "$BLDDIR/src/glibc/scripts/abilist.awk" -} - -glibc_build() { - mkdir -pv "$BLDDIR/build/glibc" - - pushd "$BLDDIR/build/glibc" - - local debver=$PKGVER - if [ "$PKGREL" != 0 ]; then - debver+="-$PKGREL" - fi - - cat > configparms < "$BLDDIR/build/abiversions/actual/$lib.abilist" - done - - chmod -v +x \ - "$PKGDIR$LOLPREFIX/support/lib/$OWTARGET/ld.so.1" \ - "$PKGDIR$LOLPREFIX/support/lib/$OWTARGET/libc.so.6" - - mkdir -pv "$PKGDIR/usr/lib" #/lib64 is /usr/lib on AOSC - ln -sfvr "$PKGDIR$LOLPREFIX/support/lib/$OWTARGET/ld.so.1" \ - "$PKGDIR/usr/lib/ld.so.1" - popd -} - -libxcrypt_build_core() { - abinfo "Configuring Libxcrypt ..." - env -i "TERM=$TERM" "PATH=$PATH" \ - "$BLDDIR/src/libxcrypt/configure" \ - --prefix="/usr" \ - --host="$OWTARGET" \ - --disable-werror \ - --enable-shared \ - --disable-xcrypt-compat-files \ - --enable-obsolete-api=glibc \ - CFLAGS="$cflags_common" \ - LDFLAGS="$ldflags_common" - - abinfo "Building Libxcrypt ..." - rm -f crypt-symbol-vers.h crypt-symbol-vers.h.stamp - env -i "MAKEFLAGS=$MAKEFLAGS" "TERM=$TERM" "PATH=$PATH" \ - make "libcrypt.la" "$@" - - if [ ! -f .libs/libcrypt.so.1 ]; then - abdie "libcrypt.so.1 not generated" - fi -} - - -libxcrypt_build() { - mkdir -pv "$BLDDIR/build/libxcrypt" - pushd "$BLDDIR/build/libxcrypt" - - - autoreconf -fvs --install "$BLDDIR/src/libxcrypt" - - libxcrypt_build_core "SYMVER_FLOOR=GLIBC_2.27" - - abinfo "Patching Libxcrypt ..." - - "$BLDDIR/build/patchelf/src/patchelf" \ - --page-size "$(( 16 * 1024 ))" \ - --remap-symvers "$libc_map" \ - ".libs/libcrypt.so.1" - - "$BLDDIR/build/patchelf/src/patchelf" \ - --page-size "$(( 16 * 1024 ))" \ - --replace-needed "ld-linux-loongarch-lp64d.so.1" "ld.so.1" \ - ".libs/libcrypt.so.1" - - abinfo "Installing Libxcrypt ..." - install -Dvm644 ".libs/libcrypt.so.1" \ - -t "$PKGDIR$LOLPREFIX/support/lib/$OWTARGET/" - - abinfo "Generating abi info ..." - mkdir -pv "$BLDDIR/build/abiversions/actual" - - gen_abi_list ".libs/libcrypt.so.1" \ - > "$BLDDIR/build/abiversions/actual/libcrypt.abilist" - popd - - abinfo "Rebuilding Libxcrypt with proper ABI ..." - mkdir -pv "$BLDDIR/build/libxcrypt-normal" - pushd "$BLDDIR/build/libxcrypt-normal" - - libxcrypt_build_core - - abinfo "Generating expected abi info ..." - gen_abi_list ".libs/libcrypt.so.1" \ - > "$BLDDIR/build/libxcrypt-normal/libcrypt.abilist" - popd - -} - -patchelf_build() { - abinfo "Unpacking patchelf ..." - mkdir -pv "$BLDDIR/src/patchelf" - tar \ - -C "$BLDDIR/src/patchelf" \ - -xvz \ - --strip-components=1 \ - -f "$SRCDIR/patchelf.tar.gz" - - apply_source_patch_series \ - "$SRCDIR/autobuild/patches/patchelf" \ - "$BLDDIR/src/patchelf" \ - "patchelf" - - abinfo "Building patchelf ..." - mkdir -pv "$BLDDIR/build/patchelf" - pushd "$BLDDIR/build/patchelf" - "$BLDDIR/src/patchelf/configure" - make - popd -} - -install_hooks() { - for i in postinst; do - sed 's#@prefix@#'"$LOLPREFIX"'#g; s#@target@#'"$OWTARGET"'#g' \ - "$SRCDIR/autobuild/additional-files/hooks/$i.in" \ - > "$SRCDIR/autobuild/$i" - chmod +x "$SRCDIR/autobuild/$i" - done -} - -check_abiversion() { - abinfo "Generating expected ABI version ..." - mkdir -pv "$BLDDIR/build/abiversions/ow" - mkdir -pv "$BLDDIR/build/abiversions/exp" - local merged_libs=(libanl libdl libpthread librt libutil) - for i in "${merged_libs[@]}"; do - cut -d" " -f 1 "$SRCDIR/autobuild/abiversions/$i.abilist" | uniq | sed 's/$/ __'$i'_version_placeholder F/' >"$BLDDIR/build/abiversions/ow/$i.abilist" - cat "$SRCDIR/autobuild/abiversions/$i.abilist" >> "$BLDDIR/build/abiversions/ow/libc.abilist" - done - cat "$SRCDIR/autobuild/abiversions/libc.abilist" >> "$BLDDIR/build/abiversions/ow/libc.abilist" - for i in "$SRCDIR/autobuild/abiversions/"*".abilist"; do - local name=$(basename "$i") - local filename="$BLDDIR/build/abiversions/ow/$name" - if [ ! -f "$filename" ]; then - cp "$i" "$filename" - fi - done - for i in \ - "$BLDDIR/src/glibc/sysdeps/unix/sysv/linux/loongarch/lp64/"*".abilist" \ - "$BLDDIR/build/libxcrypt-normal/libcrypt.abilist" \ - ; do - local name=$(basename "$i") - local filename="$BLDDIR/build/abiversions/ow/$name" - if [ ! -f "$filename" ]; then - filename="/dev/null" - fi - cat "$i" "$filename" | sort | uniq >"$BLDDIR/build/abiversions/exp/$name" - done - for i in "$BLDDIR/build/abiversions/ow/"*".abilist"; do - local name=$(basename "$i") - local filename="$BLDDIR/build/abiversions/exp/$name" - if [ ! -f "$filename" ]; then - cp "$i" "$filename" - fi - done - abinfo "Comparing ABI versions ..." - local abi_error="" - local abi_warn="" - for i in "$BLDDIR/build/abiversions/exp/"*".abilist"; do - local name=$(basename "$i") - local lib=$(echo "$name" | cut -d. -f1) - if [ ! -f "$BLDDIR/build/abiversions/actual/$name" ]; then - abi_error+="Missing expected library: $lib"$'\n' - continue - fi - local missing=$(comm -23 "$i" <(cat "$BLDDIR/build/abiversions/actual/$name" "$BLDDIR/build/abiversions/actual/libc.abilist" | sort | uniq)) - local extra=$(comm -13 "$i" "$BLDDIR/build/abiversions/actual/$name") - if [ "" != "$missing" ]; then - abi_error+="Missing symbols in $lib:"$'\n' - abi_error+="$missing"$'\n' - fi - if [ "" != "$extra" ]; then - abi_warn+="Extra symbols in $lib:"$'\n' - abi_warn+="$extra"$'\n' - fi - done - if [ -n "$abi_error" ]; then - abdie "ABI check failed"$'\n'"$abi_error" - else - abinfo "ABI check passed" - if [ -n "$abi_warn" ]; then - abinfo "Warnings:"$'\n'"$abi_warn" - fi - fi -} - -abinfo "Building patchelf..." -patchelf_build - -abinfo "Building Glibc ..." -glibc_source -glibc_build - -abinfo "Building Libxcrypt ..." -libxcrypt_source -libxcrypt_build - -check_abiversion - -abinfo "Making symlinks for system provided libs ..." -system_libs_prio=("/usr/lib/libstdc++.so.6") -for i in "${system_libs_prio[@]}"; do - ln -sfv "$i" "$PKGDIR$LOLPREFIX/support/lib/$OWTARGET/" -done - -abinfo "Installing package hooks ..." -install_hooks - -abinfo "Adding glibc dependency ..." -cur_glibc_version=$(dpkg-query -W --showformat='${Version}' glibc) -if [ -z "$cur_glibc_version" ]; then - abdie "Cannot find glibc version" -fi -abinfo "Current glibc version: $cur_glibc_version" -cur_glibc_epoch="" -if [[ "$cur_glibc_version" == *":"* ]]; then - cur_glibc_epoch="$(echo "$cur_glibc_version" | cut -d: -f1)" - abinfo "Current glibc epoch: $cur_glibc_epoch" - cur_glibc_epoch+=":" -fi -PKGDEP+=" glibc>=${cur_glibc_epoch}2.36 glibc<<${cur_glibc_epoch}${__GLIBC_VER}.1~" - -abinfo "Adding libxcrypt dependency ..." -cur_libxcrypt_version=$(dpkg-query -W --showformat='${Version}' libxcrypt) -if [ -z "$cur_libxcrypt_version" ]; then - abdie "Cannot find libxcrypt version" -fi -abinfo "Current libxcrypt version: $cur_libxcrypt_version" -cur_libxcrypt_epoch="" -if [[ "$cur_libxcrypt_version" == *":"* ]]; then - cur_libxcrypt_epoch="$(echo "$cur_libxcrypt_version" | cut -d: -f1)" - abinfo "Current libxcrypt epoch: $cur_libxcrypt_epoch" - cur_libxcrypt_epoch+=":" -fi -PKGBREAK+=" libxcrypt>=${cur_libxcrypt_epoch}${__LIBXCRYPT_VER}.1~" diff --git a/autobuild/defines b/autobuild/defines deleted file mode 100644 index c4986f3..0000000 --- a/autobuild/defines +++ /dev/null @@ -1,8 +0,0 @@ -PKGNAME=liblol -PKGSEC=utils -PKGDES="Compatibility layer for running applications designed for \"Old World\" LoongArch systems" - -NOLTO=1 - -FAIL_ARCH="!(loongarch64)" -BUILDDEP="" diff --git a/autobuild/overrides/usr/lib/modules-load.d/liblol.conf b/autobuild/overrides/usr/lib/modules-load.d/liblol.conf deleted file mode 100644 index 889d09d..0000000 --- a/autobuild/overrides/usr/lib/modules-load.d/liblol.conf +++ /dev/null @@ -1,2 +0,0 @@ -# Load the la_ow_syscall kernel module for old-world compatibility. -la_ow_syscall diff --git a/autobuild/patch b/autobuild/patch deleted file mode 100644 index b9d207b..0000000 --- a/autobuild/patch +++ /dev/null @@ -1 +0,0 @@ -: "Do nothing" diff --git a/autobuild/abiversions/ld.abilist b/debian/abiversions/ld.abilist similarity index 100% rename from autobuild/abiversions/ld.abilist rename to debian/abiversions/ld.abilist diff --git a/autobuild/abiversions/libBrokenLocale.abilist b/debian/abiversions/libBrokenLocale.abilist similarity index 100% rename from autobuild/abiversions/libBrokenLocale.abilist rename to debian/abiversions/libBrokenLocale.abilist diff --git a/autobuild/abiversions/libanl.abilist b/debian/abiversions/libanl.abilist similarity index 100% rename from autobuild/abiversions/libanl.abilist rename to debian/abiversions/libanl.abilist diff --git a/autobuild/abiversions/libc.abilist b/debian/abiversions/libc.abilist similarity index 100% rename from autobuild/abiversions/libc.abilist rename to debian/abiversions/libc.abilist diff --git a/autobuild/abiversions/libcrypt.abilist b/debian/abiversions/libcrypt.abilist similarity index 100% rename from autobuild/abiversions/libcrypt.abilist rename to debian/abiversions/libcrypt.abilist diff --git a/autobuild/abiversions/libdl.abilist b/debian/abiversions/libdl.abilist similarity index 100% rename from autobuild/abiversions/libdl.abilist rename to debian/abiversions/libdl.abilist diff --git a/autobuild/abiversions/libm.abilist b/debian/abiversions/libm.abilist similarity index 100% rename from autobuild/abiversions/libm.abilist rename to debian/abiversions/libm.abilist diff --git a/autobuild/abiversions/libnsl.abilist b/debian/abiversions/libnsl.abilist similarity index 100% rename from autobuild/abiversions/libnsl.abilist rename to debian/abiversions/libnsl.abilist diff --git a/autobuild/abiversions/libpthread.abilist b/debian/abiversions/libpthread.abilist similarity index 100% rename from autobuild/abiversions/libpthread.abilist rename to debian/abiversions/libpthread.abilist diff --git a/autobuild/abiversions/libresolv.abilist b/debian/abiversions/libresolv.abilist similarity index 100% rename from autobuild/abiversions/libresolv.abilist rename to debian/abiversions/libresolv.abilist diff --git a/autobuild/abiversions/librt.abilist b/debian/abiversions/librt.abilist similarity index 100% rename from autobuild/abiversions/librt.abilist rename to debian/abiversions/librt.abilist diff --git a/autobuild/abiversions/libthread_db.abilist b/debian/abiversions/libthread_db.abilist similarity index 100% rename from autobuild/abiversions/libthread_db.abilist rename to debian/abiversions/libthread_db.abilist diff --git a/autobuild/abiversions/libutil.abilist b/debian/abiversions/libutil.abilist similarity index 100% rename from autobuild/abiversions/libutil.abilist rename to debian/abiversions/libutil.abilist diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..6c7c58d --- /dev/null +++ b/debian/changelog @@ -0,0 +1,52 @@ +liblol (0.1.6~pre2-1) unstable; urgency=medium + + * Release 0.1.6~pre2-1 + * fix implementation of lxstat64 + + -- Miao Wang Sat, 31 Aug 2024 23:36:00 +0800 + +liblol (0.1.5-1) unstable; urgency=medium + + * Release 0.1.5-1 + + -- Miao Wang Tue, 30 Apr 2024 22:55:00 +0800 + +liblol (0.1.5~pre6-1) unstable; urgency=medium + + * add ABI checking + * not promoting symbol versions of libnsl.so + * use libxcrypt for libcrypto.so.1 + * fix wrong version mapping for libpthread symbols + * upgrade glibc to 2.39 + + -- Miao Wang Mon, 18 Mar 2024 10:43:00 +0800 + +liblol (0.1.4-1) unstable; urgency=medium + + * Release 0.1.4-1 + + -- Miao Wang Fri, 01 Mar 2024 23:31:00 +0800 + +liblol (0.1.4~pre4-1) unstable; urgency=medium + + * glibc: also add syscall fallback for fstatat + + -- Miao Wang Tue, 20 Feb 2024 15:22:00 +0800 + +liblol (0.1.4~pre3-1) unstable; urgency=medium + + * make libc.so.6 executable + + -- Miao Wang Thu, 08 Feb 2024 16:09:00 +0800 + +liblol (0.1.4~pre2-1) unstable; urgency=medium + + * new upstream version + + -- Miao Wang Sun, 28 Jan 2024 08:07:00 +0800 + +liblol (0.1.3-1) unstable; urgency=medium + + * Initial upload + + -- Miao Wang Sat, 27 Jan 2024 18:09:00 +0800 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..0402ef1 --- /dev/null +++ b/debian/control @@ -0,0 +1,28 @@ +Source: liblol +Section: otherosfs +Priority: optional +Maintainer: Miao Wang +Build-Depends: debhelper-compat (= 13), + libstdc++6, + libltdl-dev, + quilt, + bison, + gawk, + python3, +Standards-Version: 4.6.2 +Homepage: https://github.com/AOSC-Dev/liblol + +Package: liblol +Architecture: loong64 +Multi-Arch: foreign +Depends: ${misc:Depends}, + ${shlibs:Depends}, + libstdc++6, + libc6 (>= 2.36), + libc6 (<< ${glibcVer}.1~), +Breaks: libcrypt1 (>= 1:${libxcryptVer}.1~) +Conflicts: glibc, +Recommends: liblol-dkms, +Description: Compatibility layer for old world applications + This package contains a Compatibility layer for old world + applications on new world loongarch64 platform. diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..3cf73aa --- /dev/null +++ b/debian/install @@ -0,0 +1,2 @@ +/lib64/ +/usr/lib/loongarch64-debian-linux-gnuow diff --git a/autobuild/patches/glibc/0001-add-old-world-abi-compatibility.patch b/debian/patches/glibc/0001-add-old-world-abi-compatibility.patch similarity index 100% rename from autobuild/patches/glibc/0001-add-old-world-abi-compatibility.patch rename to debian/patches/glibc/0001-add-old-world-abi-compatibility.patch diff --git a/autobuild/patches/glibc/0002-add-sigset-ops.patch b/debian/patches/glibc/0002-add-sigset-ops.patch similarity index 100% rename from autobuild/patches/glibc/0002-add-sigset-ops.patch rename to debian/patches/glibc/0002-add-sigset-ops.patch diff --git a/autobuild/patches/glibc/0003-add-signal-functions.patch b/debian/patches/glibc/0003-add-signal-functions.patch similarity index 100% rename from autobuild/patches/glibc/0003-add-signal-functions.patch rename to debian/patches/glibc/0003-add-signal-functions.patch diff --git a/autobuild/patches/glibc/0004-add-sigaction-ucontext-compat.patch b/debian/patches/glibc/0004-add-sigaction-ucontext-compat.patch similarity index 100% rename from autobuild/patches/glibc/0004-add-sigaction-ucontext-compat.patch rename to debian/patches/glibc/0004-add-sigaction-ucontext-compat.patch diff --git a/autobuild/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch b/debian/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch similarity index 100% rename from autobuild/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch rename to debian/patches/glibc/0005-add-stubs-for-signal-related-io-funcs.patch diff --git a/autobuild/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch b/debian/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch similarity index 100% rename from autobuild/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch rename to debian/patches/glibc/0006-add-syscall-fallback-for-stat-at.patch diff --git a/autobuild/patches/glibc/0007-add-more-pthread-symbols.patch b/debian/patches/glibc/0007-add-more-pthread-symbols.patch similarity index 100% rename from autobuild/patches/glibc/0007-add-more-pthread-symbols.patch rename to debian/patches/glibc/0007-add-more-pthread-symbols.patch diff --git a/autobuild/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch b/debian/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch similarity index 100% rename from autobuild/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch rename to debian/patches/glibc/0008-remove-clone3-for-compatibility-with-qq.patch diff --git a/autobuild/patches/glibc/0009-prepend-trusted-dirs.patch b/debian/patches/glibc/0009-prepend-trusted-dirs.patch similarity index 100% rename from autobuild/patches/glibc/0009-prepend-trusted-dirs.patch rename to debian/patches/glibc/0009-prepend-trusted-dirs.patch diff --git a/autobuild/patches/glibc/0010-Add-___brk_addr-symbol.patch b/debian/patches/glibc/0010-Add-___brk_addr-symbol.patch similarity index 100% rename from autobuild/patches/glibc/0010-Add-___brk_addr-symbol.patch rename to debian/patches/glibc/0010-Add-___brk_addr-symbol.patch diff --git a/autobuild/patches/glibc/0011-siglist-errlist-add-compact-statements.patch b/debian/patches/glibc/0011-siglist-errlist-add-compact-statements.patch similarity index 100% rename from autobuild/patches/glibc/0011-siglist-errlist-add-compact-statements.patch rename to debian/patches/glibc/0011-siglist-errlist-add-compact-statements.patch diff --git a/debian/patches/glibc/local-ld-multiarch.diff b/debian/patches/glibc/local-ld-multiarch.diff new file mode 100644 index 0000000..0bf5db6 --- /dev/null +++ b/debian/patches/glibc/local-ld-multiarch.diff @@ -0,0 +1,51 @@ +2012-05-01 Aurelien Jarno + + * elf/Makefile(trusted-dirs.st): Fix DL_DST_LIB computation with + two level slibdir directories. + +2009-09-08 Aurelien Jarno + + * Makeconfig: add support for multiarch compat directories. + +--- + Makeconfig | 9 +++++++++ + elf/Makefile | 2 +- + 2 files changed, 10 insertions(+), 1 deletion(-) + +--- a/Makeconfig ++++ b/Makeconfig +@@ -136,6 +136,11 @@ + endif + inst_libdir = $(install_root)$(libdir) + ++# Compat places to look for libraries ++ifndef extra_libdir ++extra_libdir = /lib:$(exec_prefix)/lib ++endif ++ + # Where to install the shared library. + ifndef slibdir + slibdir = $(exec_prefix)/lib +@@ -589,6 +594,10 @@ + default-rpath = $(libdir) + endif + ++ifdef extra_libdir ++default-rpath += :$(extra_libdir) ++endif ++ + ifndef link-extra-libs + link-extra-libs = $(LDLIBS-$(@F)) + link-extra-libs-static = $(link-extra-libs) +--- a/elf/Makefile ++++ b/elf/Makefile +@@ -507,7 +507,7 @@ + $(make-target-directory) + echo "$(subst :, ,$(user-defined-trusted-dirs-pre) $(default-rpath) $(user-defined-trusted-dirs))" \ + | $(AWK) -f gen-trusted-dirs.awk > ${@:st=T}; +- echo '#define DL_DST_LIB "$(notdir $(slibdir))"' >> ${@:st=T} ++ echo '#define DL_DST_LIB "$(shell echo $(slibdir) | sed 's,/,,')"' >> ${@:st=T} + echo '#define SYSTEM_DIRS_PRE_COUNT $(words $(subst :, ,$(user-defined-trusted-dirs-pre)))' >> ${@:st=T} + $(move-if-change) ${@:st=T} ${@:st=h} + touch $@ + CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx). diff --git a/debian/patches/glibc/local-remove-manual.diff b/debian/patches/glibc/local-remove-manual.diff new file mode 100644 index 0000000..e9ac85d --- /dev/null +++ b/debian/patches/glibc/local-remove-manual.diff @@ -0,0 +1,218 @@ +The GNU Libc Reference manual has to be removed for licensing reasons. +But some files have a dependency on manual/errno.texi; the easiest +solution is to drop those dependencies and make sure that MAKEINFO=: +so that no target depends on manual/*.texi files. + +--- + manual/Makefile | 182 +++++++++++++++++++++++++++++++++++++++++++++ + stdio-common/Makefile | 2 + sysdeps/mach/hurd/Makefile | 2 + 3 files changed, 184 insertions(+), 2 deletions(-) + +--- /dev/null ++++ b/manual/Makefile +@@ -0,0 +1,182 @@ ++# Copyright (C) 1992-2012 ++# Free Software Foundation, Inc. ++# This file is part of the GNU C Library. ++ ++# The GNU C Library is free software; you can redistribute it and/or ++# modify it under the terms of the GNU Lesser General Public ++# License as published by the Free Software Foundation; either ++# version 2.1 of the License, or (at your option) any later version. ++ ++# The GNU C Library is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# Lesser General Public License for more details. ++ ++# You should have received a copy of the GNU Lesser General Public ++# License along with the GNU C Library; if not, see ++# . ++ ++# Makefile for the GNU C Library manual. ++ ++subdir := manual ++ ++# Allow override ++INSTALL_INFO = install-info ++ ++.PHONY: dvi pdf info html ++ ++# Get glibc's configuration info. ++include ../Makeconfig ++ ++dvi: $(objpfx)libc.dvi ++pdf: $(objpfx)libc.pdf ++ ++TEXI2DVI = texi2dvi ++TEXI2PDF = texi2dvi --pdf ++ ++ifneq ($(strip $(MAKEINFO)),:) ++info: $(objpfx)libc.info ++endif ++ ++chapters = $(addsuffix .texi, \ ++ intro errno memory ctype string charset locale \ ++ message search pattern io stdio llio filesys \ ++ pipe socket terminal syslog math arith time \ ++ resource setjmp signal startup process job nss \ ++ users sysinfo conf crypt debug) ++add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi)) ++appendices = lang.texi header.texi install.texi maint.texi platform.texi \ ++ contrib.texi ++licenses = freemanuals.texi lgpl-2.1.texi fdl-1.3.texi ++ ++-include $(objpfx)texis ++$(objpfx)texis: texis.awk $(chapters) $(add-chapters) $(appendices) $(licenses) ++ $(make-target-directory) ++ $(AWK) -f $^ > $@.T ++ mv -f $@.T $@ ++ ++nonexamples = $(filter-out $(add-chapters) %.c.texi, $(texis)) ++examples = $(filter-out $(foreach d, $(add-ons), ../$d/%.c.texi), \ ++ $(filter %.c.texi, $(texis))) ++ ++# Generated files directly included from libc.texinfo. ++libc-texi-generated = chapters.texi top-menu.texi dir-add.texi \ ++ libm-err.texi version.texi ++ ++# Add path to build dir for generated files ++texis-path := $(filter-out $(libc-texi-generated) summary.texi $(examples), \ ++ $(texis)) \ ++ $(addprefix $(objpfx),$(filter $(libc-texi-generated) summary.texi \ ++ $(examples), $(texis))) ++ ++# Kludge: implicit rule so Make knows the one command does it all. ++chapters.% top-menu.%: libc-texinfo.sh $(texis-path) Makefile ++ AWK=$(AWK) $(SHELL) $< $(objpfx) \ ++ '$(chapters)' \ ++ '$(add-chapters)' \ ++ '$(appendices) $(licenses)' ++ ++ ++$(objpfx)libc.dvi $(objpfx)libc.pdf $(objpfx)libc.info: \ ++ $(addprefix $(objpfx),$(libc-texi-generated)) ++$(objpfx)libc.dvi $(objpfx)libc.pdf: texinfo.tex ++ ++html: $(objpfx)libc/index.html ++$(objpfx)libc/index.html: $(addprefix $(objpfx),$(libc-texi-generated)) ++ $(MAKEINFO) -P $(objpfx) -o $(objpfx)libc --html libc.texinfo ++ ++# Generate the summary from the Texinfo source files for each chapter. ++$(objpfx)summary.texi: $(objpfx)stamp-summary ; ++$(objpfx)stamp-summary: summary.awk $(filter-out $(objpfx)summary.texi, \ ++ $(texis-path)) ++ $(AWK) -f $^ | sort -t' ' -df -k 1,1 | tr '\014' '\012' \ ++ > $(objpfx)summary-tmp ++ $(move-if-change) $(objpfx)summary-tmp $(objpfx)summary.texi ++ touch $@ ++ ++# Generate a file which can be added to the `dir' content to provide direct ++# access to the documentation of the function, variables, and other ++# definitions. ++$(objpfx)dir-add.texi: xtract-typefun.awk $(texis-path) ++ (echo "@dircategory GNU C library functions and macros"; \ ++ echo "@direntry"; \ ++ $(AWK) -f $^ | sort; \ ++ echo "@end direntry") > $@.new ++ mv -f $@.new $@ ++ ++# The table with the math errors is generated. ++$(objpfx)libm-err.texi: $(objpfx)stamp-libm-err ++$(objpfx)stamp-libm-err: libm-err-tab.pl $(wildcard $(foreach dir,$(sysdirs),\ ++ $(dir)/libm-test-ulps)) ++ pwd=`pwd`; \ ++ $(PERL) $< $$pwd/.. > $(objpfx)libm-err-tmp ++ $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi ++ touch $@ ++ ++# Generate a file with the version number. ++$(objpfx)version.texi: $(objpfx)stamp-version ; ++$(objpfx)stamp-version: $(common-objpfx)config.make ++ echo "@set VERSION $(version)" > $(objpfx)version-tmp ++ $(move-if-change) $(objpfx)version-tmp $(objpfx)version.texi ++ touch $@ ++ ++# Generate Texinfo files from the C source for the example programs. ++$(objpfx)%.c.texi: examples/%.c ++ sed -e '1,/^\*\/$$/d' \ ++ -e 's,[{}],@&,g' \ ++ -e 's,/\*\(@.*\)\*/,\1,g' \ ++ -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \ ++ -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\ ++ $< | expand > $@.new ++ mv -f $@.new $@ ++ ++$(objpfx)%.info: %.texinfo ++ LANGUAGE=C LC_ALL=C $(MAKEINFO) -P $(objpfx) --output=$@ $< ++ ++$(objpfx)%.dvi: %.texinfo ++ cd $(objpfx);$(TEXI2DVI) -I $(shell cd $(/dev/null 2>&1; then \ ++ test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\ ++ $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\ ++ else : ; fi ++endif ++# Catchall implicit rule for other installation targets from the parent. ++install-%: ; ++ ++$(inst_infodir)/libc.info: $(objpfx)libc.info ++ $(make-target-directory) ++ for file in $<*; do \ ++ $(INSTALL_DATA) $$file $(@D)/; \ ++ done ++ ++TAGS: $(minimal-dist) ++ $(ETAGS) -o $@ $^ +--- a/stdio-common/Makefile ++++ b/stdio-common/Makefile +@@ -251,7 +251,7 @@ + # generated + endif # $(run-built-tests) + +-tests-special += $(objpfx)tst-errno-manual.out ++# tests-special += $(objpfx)tst-errno-manual.out + + include ../Rules + +--- a/sysdeps/mach/hurd/Makefile ++++ b/sysdeps/mach/hurd/Makefile +@@ -88,7 +88,7 @@ + -e 's, \.\./, $(..),g' > $@t + mv -f $@t $@ + +-$(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ; ++$(hurd)/bits/errno-disabled.h: $(common-objpfx)stamp-errnos ; + $(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \ + $(mach-errnos-deps) $(common-objpfx)errnos.d + mkdir -p $(hurd-objpfx)bits diff --git a/autobuild/patches/glibc/series b/debian/patches/glibc/series similarity index 89% rename from autobuild/patches/glibc/series rename to debian/patches/glibc/series index b9dd46e..ca87bfb 100644 --- a/autobuild/patches/glibc/series +++ b/debian/patches/glibc/series @@ -9,3 +9,5 @@ 0009-prepend-trusted-dirs.patch 0010-Add-___brk_addr-symbol.patch 0011-siglist-errlist-add-compact-statements.patch +local-remove-manual.diff +local-ld-multiarch.diff diff --git a/autobuild/patches/patchelf/0001-add-remap-symvers.patch b/debian/patches/patchelf/0001-add-remap-symvers.patch similarity index 100% rename from autobuild/patches/patchelf/0001-add-remap-symvers.patch rename to debian/patches/patchelf/0001-add-remap-symvers.patch diff --git a/autobuild/patches/patchelf/series b/debian/patches/patchelf/series similarity index 100% rename from autobuild/patches/patchelf/series rename to debian/patches/patchelf/series diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..c1c4eab --- /dev/null +++ b/debian/rules @@ -0,0 +1,401 @@ +#! /usr/bin/make -f + + +include /usr/share/dpkg/pkg-info.mk + +glibc-ver := 2.40 +patchelf-ver := 0.18.0 +libxcrypt-ver := 4.4.36 + +SUBSTVARS += -VglibcVer="$(glibc-ver)" -VlibxcryptVer="$(libxcrypt-ver)" + +glibc-orig = ../liblol_$(DEB_VERSION_UPSTREAM).orig-glibc.tar.xz +patchelf-orig = ../liblol_$(DEB_VERSION_UPSTREAM).orig-patchelf.tar.gz +libxcrypt-orig = ../liblol_$(DEB_VERSION_UPSTREAM).orig-libxcrypt.tar.xz +main-orig = ../liblol_$(DEB_VERSION_UPSTREAM).orig.tar.xz + +DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) +lol_target_gnu_type := loongarch64-debian-linux-gnuow + +build_cflags := -pipe $(shell dpkg-buildflags --get CFLAGS_FOR_BUILD) $(shell dpkg-buildflags --get CPPFLAGS_FOR_BUILD) +build_cxxflags := -pipe $(shell dpkg-buildflags --get CXXFLAGS_FOR_BUILD) $(shell dpkg-buildflags --get CPPFLAGS_FOR_BUILD) +build_ldflags := $(shell dpkg-buildflags --get LDFLAGS_FOR_BUILD) +host_cflags := -pipe $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS) +host_ldflags := $(shell dpkg-buildflags --get LDFLAGS) + +ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) +NJOBS := -j $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) +endif + +BASE_CC = gcc +DEB_GCC_VERSION = -14 + +CC = $(DEB_HOST_GNU_TYPE)-$(BASE_CC)$(DEB_GCC_VERSION) +BUILD_CC = $(DEB_BUILD_GNU_TYPE)-$(BASE_CC) + +prefix=/usr +bindir=$(prefix)/bin +datadir=$(prefix)/share +complocaledir=$(prefix)/lib/locale +sysconfdir=/etc +libexecdir=$(prefix)/lib +rootsbindir=/sbin +includedir=$(prefix)/include +docdir=$(prefix)/share/doc +mandir=$(prefix)/share/man +sbindir=$(prefix)/sbin +vardbdir=/var/lib/misc +rtlddir=/lib64 +slibdir=/lib/$(DEB_HOST_MULTIARCH) +libdir=/usr/lib/$(DEB_HOST_MULTIARCH) + +get-orig-source: $(glibc-orig) $(patchelf-orig) $(libxcrypt-orig) $(main-orig) + : + +$(glibc-orig): + curl -sSfL -o $@ https://ftp.debian.org/debian/pool/main/g/glibc/glibc_$(glibc-ver).orig.tar.xz +$(patchelf-orig): + curl -sSfL -o $@ https://ftp.debian.org/debian/pool/main/p/patchelf/patchelf_$(patchelf-ver).orig.tar.gz +$(libxcrypt-orig): + curl -sSfL -o $@ https://ftp.debian.org/debian/pool/main/libx/libxcrypt/libxcrypt_$(libxcrypt-ver).orig.tar.xz +$(main-orig): + tar -cJf $@ -T /dev/null +%: + dh $@ --without autoreconf + +config-libxcrypt config-libxcrypt-normal: autoreconf + mkdir -p debian/build-dir/$(subst config-,,$@) + cd debian/build-dir/$(subst config-,,$@) && \ + $(CURDIR)/libxcrypt/configure \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(lol_target_gnu_type) \ + --prefix=/usr \ + --disable-werror \ + --disable-xcrypt-compat-files \ + --enable-obsolete-api=glibc \ + --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \ + CFLAGS='$(host_cflags)' \ + LDFLAGS='$(host_ldflags)' + +patchelf_build_dir := debian/build-dir/patchelf + +config-patchelf: patch-src.patchelf autoreconf + mkdir -p $(patchelf_build_dir) + cd $(patchelf_build_dir) && \ + $(CURDIR)/patchelf/configure \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_BUILD_GNU_TYPE) \ + CFLAGS='$(build_cflags)' \ + CXXFLAGS='$(build_cxxflags)' \ + LDFLAGS='$(build_ldflags)' + +autoreconf: patch-src + dh_autoreconf autoreconf -- -f -i patchelf/ libxcrypt/ + +glibc_build_dir := debian/build-dir/glibc +config-glibc: patch-src.glibc + mkdir -p $(glibc_build_dir) + rm -rf $(glibc_build_dir)/configparms + echo "BUILD_CC = $(BUILD_CC)" >> $(glibc_build_dir)/configparms + echo "CFLAGS = $(host_cflags)" >> $(glibc_build_dir)/configparms + echo "ASFLAGS = $(host_cflags)" >> $(glibc_build_dir)/configparms + echo "BUILD_CFLAGS = $(build_cflags)" >> $(glibc_build_dir)/configparms + echo "LDFLAGS = " >> $(glibc_build_dir)/configparms + echo "BASH := /bin/bash" >> $(glibc_build_dir)/configparms + echo "KSH := /bin/bash" >> $(glibc_build_dir)/configparms + echo "SHELL := /bin/bash" >> $(glibc_build_dir)/configparms + echo "LIBGD = no" >> $(glibc_build_dir)/configparms + echo "bindir = $(bindir)" >> $(glibc_build_dir)/configparms + echo "datadir = $(datadir)" >> $(glibc_build_dir)/configparms + echo "complocaledir = $(complocaledir)" >> $(glibc_build_dir)/configparms + echo "sysconfdir = $(sysconfdir)/liblol" >> $(glibc_build_dir)/configparms + echo "localtime-file = $(sysconfdir)/localtime" >> $(glibc_build_dir)/configparms + echo "libexecdir = $(libexecdir)" >> $(glibc_build_dir)/configparms + echo "rootsbindir = $(rootsbindir)" >> $(glibc_build_dir)/configparms + echo "includedir = $(includedir)" >> $(glibc_build_dir)/configparms + echo "docdir = $(docdir)" >> $(glibc_build_dir)/configparms + echo "mandir = $(mandir)" >> $(glibc_build_dir)/configparms + echo "sbindir = $(sbindir)" >> $(glibc_build_dir)/configparms + echo "vardbdir = $(vardbdir)" >> $(glibc_build_dir)/configparms + echo "libdir = $(libdir)" >> $(glibc_build_dir)/configparms + echo "slibdir = $(slibdir)" >> $(glibc_build_dir)/configparms + echo "rtlddir = $(rtlddir)" >> $(glibc_build_dir)/configparms + echo "user-defined-trusted-dirs-pre = /usr/local/lib/$(lol_target_gnu_type)/preload:/usr/lib/$(lol_target_gnu_type)/preload" >> $(glibc_build_dir)/configparms + echo "user-defined-trusted-dirs = /usr/local/lib/$(lol_target_gnu_type):/usr/lib/$(lol_target_gnu_type)" >> $(glibc_build_dir)/configparms + cd $(glibc_build_dir) && \ + CC=$(CC) \ + AUTOCONF=false \ + MAKEINFO=: \ + $(CURDIR)/glibc/configure \ + --host=$(lol_target_gnu_type) \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --prefix=/usr \ + --without-selinux \ + --enable-bind-now \ + --enable-fortify-source \ + --enable-stackguard-randomization \ + --enable-stack-protector=strong \ + --with-pkgversion="LibLoL $(DEB_VERSION)" \ + --with-bugurl="https://github.com/AOSC-Dev/liblol/issues" \ + --disable-nscd \ + --disable-werror \ + --enable-multi-arch \ + --enable-obsolete-rpc + +glibc_real_libs = \ + libc.so.6 \ + nptl/libpthread.so.0 \ + elf/ld.so.1 \ + math/libm.so.6 \ + resolv/libresolv.so.2 \ + malloc/libc_malloc_debug.so.0 \ + nptl_db/libthread_db.so.1 \ + locale/libBrokenLocale.so.1 +glibc_no_promote_libs = \ + resolv/libanl.so.1 \ + dlfcn/libdl.so.2 \ + rt/librt.so.1 \ + login/libutil.so.1 \ + nis/libnsl.so.1 +glibc_merged_libs = \ + $(filter-out, nis/libnsl.so.1, $(glibc_no_promote_libs)) \ + nptl/libpthread.so.0 + +glibc_libs = $(glibc_real_libs) $(glibc_no_promote_libs) + +glibc_libs_targets = $(addprefix $(glibc_build_dir)/,$(glibc_libs)) +glibc_libs_targets_after = $(addprefix $(glibc_build_dir)/,$(filter-out libc.so.6 elf/ld.so.1,$(glibc_libs))) + +glibc_libs_install_targets = $(addprefix install-glibc-,$(subst /,-,$(glibc_libs))) + +patchelf_bin := $(patchelf_build_dir)/src/patchelf + +build-patchelf: $(patchelf_bin) + +build-glibc: $(glibc_libs_targets) + : + +$(glibc_libs_targets_after): $(glibc_build_dir)/libc.so.6 $(glibc_build_dir)/linkobj/libc.so $(glibc_build_dir)/elf/ld.so.1 $(glibc_build_dir)/stamp_elfpatched +$(glibc_libs_targets): $(glibc_build_dir)/config.status +$(addprefix $(glibc_build_dir)/,$(glibc_real_libs)): $(patchelf_bin) + +define patchelf_pthread +$(patchelf_bin) \ + --page-size "$$(( 16 * 1024 ))" \ + --remap-symvers "GLIBC_2.27=GLIBC_2.0,GLIBC_2.2,GLIBC_2.2.1,GLIBC_2.2.2,GLIBC_2.2.3,GLIBC_2.2.4,GLIBC_2.2.6,GLIBC_2.3,GLIBC_2.3.2,GLIBC_2.3.3,GLIBC_2.3.4,GLIBC_2.4,GLIBC_2.5,GLIBC_2.6,GLIBC_2.7,GLIBC_2.8,GLIBC_2.9,GLIBC_2.10,GLIBC_2.11,GLIBC_2.12,GLIBC_2.13,GLIBC_2.14,GLIBC_2.15,GLIBC_2.16,GLIBC_2.17,GLIBC_2.18,GLIBC_2.19,GLIBC_2.20,GLIBC_2.21,GLIBC_2.22,GLIBC_2.23,GLIBC_2.24,GLIBC_2.25,GLIBC_2.26" \ + --also-remap-verneed +endef + +define patchelf_normal +$(patchelf_bin) \ + --page-size "$$(( 16 * 1024 ))" \ + --remap-symvers "GLIBC_2.36=GLIBC_2.27,GLIBC_2.28" \ + --also-remap-verneed +endef + +$(glibc_build_dir)/linkobj/libc.so $(glibc_build_dir)/elf/ld.so.1 $(glibc_build_dir)/libc.so.6: $(glibc_build_dir)/stamp_subdir_lib +$(glibc_build_dir)/linkobj/libc.so: $(glibc_build_dir)/libc.so.6 +$(glibc_build_dir)/libc.so.6 $(glibc_build_dir)/linkobj/libc.so: + $(MAKE) -C $(glibc_build_dir) "$(CURDIR)/$@" $(NJOBS) +$(glibc_build_dir)/stamp_subdir_lib: + $(MAKE) -C $(glibc_build_dir) subdir_lib $(NJOBS) + touch $@ + +$(glibc_build_dir)/stamp_elfpatched: $(glibc_build_dir)/libc.so.6 $(glibc_build_dir)/linkobj/libc.so $(glibc_build_dir)/elf/ld.so.1 $(patchelf_bin) + $(patchelf_pthread) $(glibc_build_dir)/libc.so.6 + $(patchelf_normal) $(glibc_build_dir)/libc.so.6 + $(patchelf_pthread) $(glibc_build_dir)/linkobj/libc.so + $(patchelf_normal) $(glibc_build_dir)/linkobj/libc.so + touch $@ + +glibc_cur_lib = $(*) +glibc_cur_lib_dir = $(subst /,,$(dir $(glibc_cur_lib))) +glibc_cur_lib_name = $(notdir $(glibc_cur_lib)) + +$(glibc_build_dir)/%: + $(MAKE) -C $(CURDIR)/glibc/$(glibc_cur_lib_dir) \ + "$(CURDIR)/$(glibc_build_dir)/$(glibc_cur_lib)" \ + subdir=$(glibc_cur_lib_dir) \ + ..=../ \ + objdir="$(CURDIR)/$(glibc_build_dir)" \ + $(NJOBS) + if [ "x$(filter-out libc.so.6 nptl/libpthread.so.0,$(glibc_cur_lib))" = "x" ]; then \ + $(patchelf_pthread) $@; \ + fi + if [ "x$(filter-out $(glibc_real_libs),$(glibc_cur_lib))" = "x" ]; then \ + $(patchelf_normal) $@; \ + fi + [ -f $@ ] + +build-libxcrypt build-libxcrypt-normal: build-%: debian/build-dir/%/.libs/libcrypt.so.1 + : +libxcrypt_libs_targets := debian/build-dir/libxcrypt/.libs/libcrypt.so.1 +debian/build-dir/libxcrypt/.libs/libcrypt.so.1 debian/build-dir/libxcrypt-normal/.libs/libcrypt.so.1: debian/build-dir/%/.libs/libcrypt.so.1: debian/build-dir/%/config.status $(patchelf_bin) + cd $(subst .libs/libcrypt.so.1,,$@) && \ + rm -f crypt-symbol-vers.h crypt-symbol-vers.h.stamp && \ + $(MAKE) $(NJOBS) \ + "libcrypt.la" \ + $(if $(findstring normal, $@), , "SYMVER_FLOOR=GLIBC_2.27") + $(if $(findstring normal, $@), , \ + $(patchelf_normal) $@; \ + $(patchelf_bin) \ + --page-size "$$(( 16 * 1024 ))" \ + --replace-needed "ld-linux-loongarch-lp64d.so.1" "ld.so.1" \ + $@; \ + ) + [ -f $@ ] + +dummy_ld_so := debian/build-dir/ld-linux-loongarch-lp64d.so.1 +$(dummy_ld_so): $(glibc_build_dir)/elf/ld.so.1 + $(CC) -shared \ + $(host_cflags) \ + $(host_ldflags) \ + -x c /dev/null \ + -o $@ \ + -Wl,--version-script -Wl,$(glibc_build_dir)/ld.map \ + -nostdlib + +TMPDIR ?= debian/tmp +install_libs_dir := $(TMPDIR)/usr/lib/$(lol_target_gnu_type) +install_preload_libs_dir := $(install_libs_dir)/preload +$(install_preload_libs_dir) $(install_libs_dir): + mkdir -p $@ + +all-libs-with-abi := $(libxcrypt_libs_targets) $(glibc_libs_targets) +all-libs := $(all-libs-with-abi) $(dummy_ld_so) + +install-libs: $(addprefix $(install_preload_libs_dir)/, $(notdir $(all-libs))) $(TMPDIR)/lib64/ld.so.1 + : +$(TMPDIR)/lib64/ld.so.1: $(install_preload_libs_dir)/ld.so.1 + mkdir -p $(dir $@) + ln -sfvr $< $@ + +define install-lib-rule +$(addprefix $(install_preload_libs_dir)/,$(notdir $(1))): $(1) + install -Dvm644 $$< $$@ +ifeq ($(filter-out libc.so.6 ld.so.1,$(notdir $(1))),) + chmod +x $$@ +endif +endef + +$(foreach lib-target, $(all-libs), $(eval $(call install-lib-rule,$(lib-target)))) + +symlink-hostlibs: $(install_libs_dir) $(install_preload_libs_dir) + ln -sfv $(libdir)/libstdc++.so.6 $(install_preload_libs_dir)/ + +so_basename=$(foreach so,$(1),$(firstword $(subst ., ,$(notdir $(so))))) + +abi_checking_dir := debian/build-dir/abi +actual_abi_targets := $(addprefix $(abi_checking_dir)/actual/,$(addsuffix .abilist,$(call so_basename,$(notdir $(all-libs-with-abi))))) +nw_abi_dir := glibc/sysdeps/unix/sysv/linux/loongarch/lp64 +ow_abi_dir := debian/abiversions + +define gen-abilist + LC_ALL=C objdump --dynamic-syms "$(1)" | \ + LC_ALL=C awk -f "glibc/scripts/abilist.awk" +endef + +define gen-actual-abi-rule +$(addprefix $(abi_checking_dir)/actual/,$(addsuffix .abilist,$(call so_basename,$(notdir $(1))))): $(1) + mkdir -p $$(dir $$@) + $(call gen-abilist,$(1)) > $$@ +endef + +$(foreach abi-target, $(all-libs-with-abi), $(eval $(call gen-actual-abi-rule,$(abi-target)))) + +$(abi_checking_dir)/ow/libc.abilist: $(addprefix $(ow_abi_dir)/,$(addsuffix .abilist, $(call so_basename,$(glibc_merged_libs) libc.so.6))) + mkdir -p $(dir $@) + cat $^ > $@ + +$(addprefix $(abi_checking_dir)/ow/,$(addsuffix .abilist, $(call so_basename,$(glibc_merged_libs)))):$(abi_checking_dir)/ow/%:$(ow_abi_dir)/% + mkdir -p $(dir $@) + cut -d" " -f 1 $< | uniq | \ + sed 's/$$/ __'$(basename $(notdir $@))'_version_placeholder F/' \ + >$@ + +$(abi_checking_dir)/ow/%.abilist: + mkdir -p $(dir $@) + if [ -f $(ow_abi_dir)/$(notdir $@) ]; then \ + cp $(ow_abi_dir)/$(notdir $@) $@; \ + else \ + touch $@; \ + fi + +$(abi_checking_dir)/nw/%.abilist: + mkdir -p $(dir $@) + if [ -f $(nw_abi_dir)/$(notdir $@) ]; then \ + cp $(nw_abi_dir)/$(notdir $@) $@; \ + else \ + touch $@; \ + fi + +$(abi_checking_dir)/nw/libcrypt.abilist: debian/build-dir/libxcrypt-normal/.libs/libcrypt.so.1 + mkdir -p $(dir $@) + $(call gen-abilist,$<) > $@ + +$(abi_checking_dir)/expected/%.abilist: $(abi_checking_dir)/ow/%.abilist $(abi_checking_dir)/nw/%.abilist + mkdir -p $(dir $@) + cat $^ | sort | uniq > $@ + +abi-check-%: $(abi_checking_dir)/expected/%.abilist $(abi_checking_dir)/actual/%.abilist $(abi_checking_dir)/actual/libc.abilist + missing=$$(bash -c "comm -23 $(word 1,$^) <(cat $(word 2,$^) $(word 3,$^) | sort | uniq)"); \ + extra=$$(comm -13 $(word 1,$^) $(word 2,$^)); \ + if [ "" != "$$missing" ]; then \ + echo "Missing symbols in $(patsubst abi-check-%,%,$@): $$missing"; \ + exit 1; \ + fi; \ + if [ "" != "$$extra" ]; then \ + echo "Extra symbols in $(patsubst abi-check-%,%,$@): $$extra"; \ + fi + +abi-check: | $(addprefix abi-check-,$(sort $(basename $(notdir $(wildcard $(nw_abi_dir)/*.abilist) $(wildcard $(ow_abi_dir)/*.abilist))))) + : + +$(patchelf_bin): + $(MAKE) -C $(patchelf_build_dir) all $(NJOBS) + [ -f $@ ] + +patch-src: patch-src.patchelf patch-src.glibc + +patch-src.%: + cd $* && QUILT_PATCHES=../debian/patches/$* quilt push -a + +override_dh_auto_configure: patch-src config-glibc config-patchelf config-libxcrypt config-libxcrypt-normal +override_dh_auto_build: $(all-libs) +override_dh_auto_install: install-libs symlink-hostlibs +override_dh_auto_test: abi-check + +override_dh_clean: clean-patch clean-patchelf + dh_clean + rm -rf debian/build-dir + +override_dh_shlibdeps: + dh_shlibdeps -l /usr/lib/$(lol_target_gnu_type)/preload + +override_dh_gencontrol: + dh_gencontrol -- $(SUBSTVARS) + +override_dh_fixperms: + dh_fixperms -Xld.so.1 -Xlibc.so.6 + +clean-patchelf: + dh_autoreconf_clean + +clean-patch: clean-patch.patchelf clean-patch.glibc + +clean-patch.%: + if [ -s $*/.pc/applied-patches ]; then \ + cd $* && QUILT_PATCHES=../debian/patches/$* quilt pop -q -a; \ + rm -rf .pc; \ + fi + +# dwz cannot handle our patched libs +override_dh_dwz: + : + +.PHONY: get-orig-source patch-src clean-patch \ + config-glibc config-patchelf config-libxcrypt config-libxcrypt-normal \ + build-glibc build-patchelf \ + install-glibc symlink-hostlibs diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/genspec b/genspec deleted file mode 100644 index 8eefee3..0000000 --- a/genspec +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash - -# This script should be run in the rootfs of loongnix DaoXiangHu-stable - -set -e -o pipefail - -sed -i '/deb-src/s/#//' /etc/apt/sources.list -apt-get update -apt-get install --no-install-recommends -y \ - libgdk-pixbuf2.0-bin \ - libgtk2.0-0 \ - libgtk-3-0 \ - librsvg2-common \ - dconf-gsettings-backend \ - gvfs \ - glib-networking \ - gvfs-libs \ - fcitx-frontend-gtk2 \ - fcitx-frontend-gtk3 \ - ibus-gtk \ - ibus-gtk3 - -exec 3> spec.new - -echo "# AUTOGENERATED FILE from spec.main using genspec" >&3 - -cat spec.main >&3 - -fetch_pkg(){ - local pkg="$1" - local tag="$2" - - [ "$tag" ] - - info=$(apt-get --print-uris download "$pkg") - if [ "$?" -ne 0 ]; then - return 1 - fi - url=$(echo "$info" | sed "s/^[^']*'\([^']*\)'.*$/\1/" | sed 's/^.*\(pool.*\)$/\1/') - sum=$(echo "$info" | sed 's/^.*SHA256:\([^ ]*\) *.*$/\1/') - printf 'SRCS="$SRCS file::rename=%s%s.deb::${_mirror}/%s \\\n"\n' "$tag" "$pkg" "$url" - printf 'CHKSUMS="$CHKSUMS sha256::%s \\\n"\n' "$sum" -} - -fetch_src(){ - local pkg="$1" - - info=$(apt-get --print-uris -qq source "$pkg") - if [ "$?" -ne 0 ]; then - return 1 - fi - url=$(echo "$info" | sed "s/^[^']*'\([^']*\)'.*$/\1/" | sed 's/^.*\(pool.*\)$/\1/') - sum=$(echo "$info" | sed 's/^.*SHA256:\([^ ]*\) *.*$/\1/') - echo -n 'SRCS="$SRCS ' - echo "$url" | sed 's@^\(.*/\([^/]*\)\)$@file::rename=\2::${_mirror}/\1@; s@$@ \\@' - echo '"' - echo -n 'CHKSUMS="$CHKSUMS ' - echo "$sum" | sed 's@^@sha256::@; s@$@ \\@' - echo '"' -} -while read pkg; do - if [ -z "$pkg" ]; then - continue - fi - nodbg=0 - dev=0 - src=0 - while :; do - case $pkg in - *:nodbg) - nodbg=1 - pkg=${pkg%:nodbg} - ;; - *:src) - src=1 - pkg=${pkg%:src} - ;; - *:dev) - dev=1 - pkg=${pkg%:dev} - ;; - *) - break - ;; - esac - done - case $pkg in - *-dev) - devpkg=1 - ;; - *) - devpkg=0 - ;; - esac - if [ "$src" = "0" ]; then - tag="" - if [ "$devpkg" = 0 ]; then - tag="${tag}dist_" - fi - if [ "$dev" = 1 ]; then - tag="${tag}dev_" - fi - fetch_pkg "$pkg" "$tag">&3 - if [ "$nodbg" = "0" ] && [ "$devpkg" = "0" ] ; then - fetch_pkg "$pkg-dbgsym" "dist_" >&3 || fetch_pkg "$pkg-dbg" "dist_" >&3 - fi - else - fetch_src "$pkg" >&3 - fi -done < manifest - -exec 3>&- -mv spec.new spec diff --git a/manifest b/manifest deleted file mode 100644 index e69de29..0000000 diff --git a/spec b/spec deleted file mode 100644 index 5f8ec8f..0000000 --- a/spec +++ /dev/null @@ -1,16 +0,0 @@ -# AUTOGENERATED FILE from spec.main using genspec -VER=0.1.6~pre2 -_mirror="http://pkg.loongnix.cn/loongnix" -__GLIBC_VER=2.40 -__LIBXCRYPT_VER=4.4.36 - -SRCS="\ - file::rename=glibc.tar.xz::https://ftp.gnu.org/gnu/glibc/glibc-${__GLIBC_VER}.tar.xz \ - file::rename=patchelf.tar.gz::https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.gz \ - file::rename=libxcrypt.tar.xz::https://github.com/besser82/libxcrypt/releases/download/v${__LIBXCRYPT_VER}/libxcrypt-${__LIBXCRYPT_VER}.tar.xz \ -" -CHKSUMS="\ - sha256::19a890175e9263d748f627993de6f4b1af9cd21e03f080e4bfb3a1fac10205a2 \ - sha256::64de10e4c6b8b8379db7e87f58030f336ea747c0515f381132e810dbf84a86e7 \ - sha256::e5e1f4caee0a01de2aee26e3138807d6d3ca2b8e67287966d1fefd65e1fd8943 \ -" diff --git a/spec.main b/spec.main deleted file mode 100644 index ad45dfb..0000000 --- a/spec.main +++ /dev/null @@ -1,15 +0,0 @@ -VER=0.1.6~pre2 -_mirror="http://pkg.loongnix.cn/loongnix" -__GLIBC_VER=2.40 -__LIBXCRYPT_VER=4.4.36 - -SRCS="\ - file::rename=glibc.tar.xz::https://ftp.gnu.org/gnu/glibc/glibc-${__GLIBC_VER}.tar.xz \ - file::rename=patchelf.tar.gz::https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.gz \ - file::rename=libxcrypt.tar.xz::https://github.com/besser82/libxcrypt/releases/download/v${__LIBXCRYPT_VER}/libxcrypt-${__LIBXCRYPT_VER}.tar.xz \ -" -CHKSUMS="\ - sha256::19a890175e9263d748f627993de6f4b1af9cd21e03f080e4bfb3a1fac10205a2 \ - sha256::64de10e4c6b8b8379db7e87f58030f336ea747c0515f381132e810dbf84a86e7 \ - sha256::e5e1f4caee0a01de2aee26e3138807d6d3ca2b8e67287966d1fefd65e1fd8943 \ -"