From 8cd74669bd53f1e506746d247293978ca5cd32e1 Mon Sep 17 00:00:00 2001 From: Ivan Max Date: Thu, 20 Jul 2023 08:48:14 +0000 Subject: [PATCH] new packages: gpkg-dev/cgt and gpkg-dev/cbt (#46) --- .github/workflows/build-dev.yml | 8 +- gpkg-dev/cbt/PKGBUILD | 58 +++++++++ gpkg-dev/cgt/PKGBUILD | 134 ++++++++++++++++++++ gpkg-dev/cgt/collect2.cc.patch | 39 ++++++ gpkg-dev/cgt/gcc-Makefile.in.patch | 20 +++ gpkg-dev/cgt/gcc-configure.patch | 22 ++++ gpkg-dev/cgt/gcc.cc.patch | 55 ++++++++ gpkg-dev/cgt/set_glibc_dynamic_linker.patch | 111 ++++++++++++++++ script/build-dev.sh | 22 ++-- script/init.sh | 5 +- script/utils/get_depends.sh | 12 +- script/utils/set_data.sh | 8 ++ 12 files changed, 473 insertions(+), 21 deletions(-) create mode 100644 gpkg-dev/cbt/PKGBUILD create mode 100644 gpkg-dev/cgt/PKGBUILD create mode 100644 gpkg-dev/cgt/collect2.cc.patch create mode 100644 gpkg-dev/cgt/gcc-Makefile.in.patch create mode 100644 gpkg-dev/cgt/gcc-configure.patch create mode 100644 gpkg-dev/cgt/gcc.cc.patch create mode 100644 gpkg-dev/cgt/set_glibc_dynamic_linker.patch create mode 100644 script/utils/set_data.sh diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index a27792e71..270c7bb5c 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -37,10 +37,12 @@ jobs: il=(${i//// }) if [ "${il[0]}" = "gpkg-dev" ]; then if [ -d "${il[0]}/${il[1]}" ]; then - echo "${il[1]}" >> "pkgs/gpkg-dev-need.txt" - curl -L "https://raw.githubusercontent.com/termux-pacman/glibc-packages/$(git log -n 2 --format=format:%H gpkg-dev/${il[1]} | tail -1)/gpkg-dev/${il[1]}/PKGBUILD" -o pkgs/PKGBUILDs/${il[1]} + if [ ! -f pkgs/gpkg-dev-need.txt ] || ! $(grep -q '^'${il[1]}'$' pkgs/gpkg-dev-need.txt); then + echo "${il[1]}" >> pkgs/gpkg-dev-need.txt + curl -L "https://raw.githubusercontent.com/termux-pacman/glibc-packages/$(git log -n 2 --format=format:%H gpkg-dev/${il[1]} | tail -1)/gpkg-dev/${il[1]}/PKGBUILD" -o pkgs/PKGBUILDs/${il[1]} + fi else - echo "${il[1]}" >> "pkgs/deleted_gpkg-dev_packages.txt" + echo "${il[1]}" >> pkgs/deleted_gpkg-dev_packages.txt fi fi done diff --git a/gpkg-dev/cbt/PKGBUILD b/gpkg-dev/cbt/PKGBUILD new file mode 100644 index 000000000..76466744f --- /dev/null +++ b/gpkg-dev/cbt/PKGBUILD @@ -0,0 +1,58 @@ +pkgname=cbt +pkgver=2.40 +pkgrel=0 +pkgdesc='Cross Binutils for Termux (only for Linux)' +arch=(x86_64) +url='https://www.gnu.org/software/binutils/' +license=('GPL3' 'GPL' 'FDL1.3' 'custom:FSFAP') +source=(https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz) +sha256sums=('0f8a4c272d7f17f369ded10a4aca28b8e304828e95526da482b0ccc4dfc9d8e1') +groups=('cgct') + +build() { + unset CFLAGS CXXFLAGS AR LD CC CXX + CFLAGS="-O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fstack-clash-protection" + CXXFLAGS="${CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS" + + for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do + arch_build=${target/-*} + CGCT_PREFIX="${DIR_TERMUX}/cgct/${arch_build}" + mkdir binutils-${arch_build} + cd binutils-${arch_build} + + "$srcdir"/binutils-${pkgver}/configure \ + --target=$target \ + --prefix=$CGCT_PREFIX \ + --disable-multilib \ + --with-gnu-as \ + --with-gnu-ld \ + --disable-nls \ + --enable-ld=default \ + --enable-plugins \ + --enable-deterministic-archives + make + + cd .. + done +} + +package() { + for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do + arch_build=${target/-*} + CGCT_PREFIX="${DIR_TERMUX}/cgct/${arch_build}" + cd binutils-${arch_build} + + make DESTDIR="$pkgdir" install + + mv $pkgdir/${CGCT_PREFIX}/$target/bin/* $pkgdir/${CGCT_PREFIX}/bin + mv $pkgdir/${CGCT_PREFIX}/$target/lib/* $pkgdir/${CGCT_PREFIX}/lib + rm -fr $pkgdir/${CGCT_PREFIX}/$target + rm -fr $pkgdir/${CGCT_PREFIX}/share + rm -fr $pkgdir/${CGCT_PREFIX}/include + rm -fr $pkgdir/${CGCT_PREFIX}/etc + + cd .. + done + + replace_hard_with_symbolic "$pkgdir" +} diff --git a/gpkg-dev/cgt/PKGBUILD b/gpkg-dev/cgt/PKGBUILD new file mode 100644 index 000000000..c3c776983 --- /dev/null +++ b/gpkg-dev/cgt/PKGBUILD @@ -0,0 +1,134 @@ +pkgname=cgt +pkgver=13.1.0 +pkgrel=0 +pkgdesc='Cross GCCs for Termux (only for Linux)' +arch=(x86_64) +url='https://gcc.gnu.org/' +license=(GPL LGPL FDL) +source=(https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz + collect2.cc.patch + gcc.cc.patch + gcc-Makefile.in.patch + gcc-configure.patch + set_glibc_dynamic_linker.patch) +sha256sums=('61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86' + '102f7791ace23391eef292efd0ba193cd05421ad02b7b6ca25bc5f9422ec3d96' + '205bbdd2dee34e9d83a892c1985c25cf2d20089cc0497b74dbff019436148873' + 'ac3f2b2b225d3464c9c600f2042cf2f115cb5053c611a5f69ad4095f65fa9aaf' + '344cb82c63326bab5e7200a0a0f017a00b15c2c440497752fd8946c12c83beb6' + '7c4e3f5f31ed59beee30aa40675b339a6d6b05b3d46b98a2f468bb4db95075c4') +groups=('cgct') + +prepare() { + for i in *.patch; do + patch -Np1 -i ${srcdir}/$i + done + + cd gcc-${pkgver} + sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in + sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64 + sed -i '/lp64=/s/lib64/lib/' gcc/config/aarch64/t-aarch64-linux +} + +build() { + unset CFLAGS CXXFLAGS AR LD CC CXX + CFLAGS="-O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fstack-clash-protection" + CXXFLAGS="${CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS" + + for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do + arch_build=${target/-*} + CGCT_PREFIX=${DIR_TERMUX}/cgct/${arch_build} + mkdir gcc-${arch_build} + cd gcc-${arch_build} + + REPO_URL="${GPKG_DEV_SERVER_URL}/gpkg-dev/${arch_build}" + curl "${REPO_URL}/gpkg-dev.json" -o gpkg-dev.json + for i in glibc linux-api-headers libxcrypt-glibc; do + FILENAME=$(cat gpkg-dev.json | jq -r '."'$i'"."FILENAME"') + curl "${REPO_URL}/$FILENAME" -o $i.tar.xz + tar xJf $i.tar.xz -C / data + done + + FLAGS_FOR_TARGET="-I$GLIBC_PREFIX/include -L$GLIBC_PREFIX/lib -Wl,-rpath=$GLIBC_PREFIX/lib" + CONFIGFLAG="" + case "$arch_build" in + "aarch64") CONFIGFLAG="--with-arch=armv8-a --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419";; + "arm") CONFIGFLAG="--with-arch=armv7-a --with-float=hard --with-fpu=neon";; + "x86_64") CONFIGFLAG="--with-arch=x86-64";; + "i686") CONFIGFLAG="--with-arch=i686 --with-as=/usr/bin/i686-elf-as --with-ld=/usr/bin/i686-elf-ld AR_FOR_TARGET=/usr/bin/i686-elf-ar RANLIB_FOR_TARGET=/usr/bin/i686-elf-ranlib NM_FOR_TARGET=/usr/bin/i686-elf-nm";; + esac + + "$srcdir"/gcc-${pkgver}/configure \ + --host=${CHOST} \ + --build=${CHOST} \ + --target=${target} \ + --prefix=${CGCT_PREFIX} \ + --with-local-prefix=${CGCT_PREFIX} \ + --libdir=${CGCT_PREFIX}/lib \ + --libexecdir=${CGCT_PREFIX}/lib \ + --includedir=${GLIBC_PREFIX}/include \ + --with-bugurl=https://github.com/termux-pacman/glibc-packages/issues \ + $CONFIGFLAG \ + --enable-languages=c,c++ \ + --enable-checking=release \ + --enable-threads=posix \ + --enable-lto \ + --disable-multilib \ + --disable-bootstrap \ + --disable-nls \ + --enable-clocale=gnu \ + --enable-default-pie \ + --enable-default-ssp \ + --with-system-zlib \ + --enable-__cxa_atexit \ + --enable-linker-build-id \ + --enable-plugin \ + --with-linker-hash-style=gnu \ + --enable-gnu-indirect-function \ + --enable-gnu-unique-object \ + --enable-shared \ + --disable-werror \ + --disable-libssp \ + --disable-libstdcxx-pch \ + --disable-libunwind-exceptions \ + CFLAGS_FOR_TARGET="$FLAGS_FOR_TARGET $CFLAGS" \ + CXXFLAGS_FOR_TARGET="$FLAGS_FOR_TARGET $CXXFLAGS" + make + + cd .. + rm -fr /data/data + done +} + +package() { + for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do + arch_build=${target/-*} + CGCT_PREFIX=${DIR_TERMUX}/cgct/${arch_build} + cd gcc-${arch_build} + + for i in glibc linux-api-headers libxcrypt-glibc; do + tar xJf $i.tar.xz -C / data + done + + make DESTDIR="$pkgdir" install-gcc install-target-{libgcc,libstdc++-v3,libgomp,libquadmath,libatomic} + + if [ -d $pkgdir/${CGCT_PREFIX}/$target/lib ]; then + mv $pkgdir/${CGCT_PREFIX}/$target/lib/* $pkgdir/${CGCT_PREFIX}/lib + fi + if [ -d $pkgdir/${CGCT_PREFIX}/$target/include ]; then + mv $pkgdir/${CGCT_PREFIX}/$target/include/* $pkgdir/${CGCT_PREFIX}/include + fi + if [ -d $pkgdir/${CGCT_PREFIX}/include/$pkgver ]; then + mkdir $pkgdir/${CGCT_PREFIX}/include/c++ + mv $pkgdir/${CGCT_PREFIX}/include/$pkgver $pkgdir/${CGCT_PREFIX}/include/c++ + fi + rm -fr $pkgdir/${CGCT_PREFIX}/share + rm -fr $pkgdir/${CGCT_PREFIX}/$target + rm -fr $pkgdir/${DIR_TERMUX}/files + + cd .. + rm -fr /data/data + done + + replace_hard_with_symbolic "$pkgdir" +} diff --git a/gpkg-dev/cgt/collect2.cc.patch b/gpkg-dev/cgt/collect2.cc.patch new file mode 100644 index 000000000..c9c1571ed --- /dev/null +++ b/gpkg-dev/cgt/collect2.cc.patch @@ -0,0 +1,39 @@ +--- src/gcc-13.1.0/gcc/collect2.cc 2022-05-06 10:30:56.000000000 +0300 ++++ src/gcc-13.1.0/gcc/collect2.cc.patch 2022-07-07 16:22:05.983834993 +0300 +@@ -1188,8 +1188,7 @@ + prefix_from_env ("LIBPATH", &libpath_lib_dirs); + /* Add to this list also two standard directories where + AIX loader always searches for libraries. */ +- add_prefix (&libpath_lib_dirs, "/lib"); +- add_prefix (&libpath_lib_dirs, "/usr/lib"); ++ add_prefix (&libpath_lib_dirs, "/data/data/com.termux/files/usr/glibc/lib"); + #endif + + /* Get any options that the upper GCC wants to pass to the sub-GCC. +@@ -2678,20 +2677,12 @@ + /* Array of standard AIX libraries which should not + be scanned for ctors/dtors. */ + static const char *const aix_std_libs[] = { +- "/unix", +- "/lib/libc.a", +- "/lib/libm.a", +- "/lib/libc_r.a", +- "/lib/libm_r.a", +- "/usr/lib/libc.a", +- "/usr/lib/libm.a", +- "/usr/lib/libc_r.a", +- "/usr/lib/libm_r.a", +- "/usr/lib/threads/libc.a", +- "/usr/ccs/lib/libc.a", +- "/usr/ccs/lib/libm.a", +- "/usr/ccs/lib/libc_r.a", +- "/usr/ccs/lib/libm_r.a", ++ "/data/data/com.termux/files/usr/glibc/lib/unix", ++ "/data/data/com.termux/files/usr/glibc/lib/libc.a", ++ "/data/data/com.termux/files/usr/glibc/lib/libm.a", ++ "/data/data/com.termux/files/usr/glibc/lib/libc_r.a", ++ "/data/data/com.termux/files/usr/glibc/lib/libm_r.a", ++ "/data/data/com.termux/files/usr/glibc/lib/threads/libc.a", + NULL + }; + diff --git a/gpkg-dev/cgt/gcc-Makefile.in.patch b/gpkg-dev/cgt/gcc-Makefile.in.patch new file mode 100644 index 000000000..5c30e07de --- /dev/null +++ b/gpkg-dev/cgt/gcc-Makefile.in.patch @@ -0,0 +1,20 @@ +--- src/gcc-13.1.0/gcc/Makefile.in 2023-07-14 18:39:16.751580302 +0300 ++++ src/gcc-13.1.0/gcc/Makefile.in.patch 2023-07-15 22:33:23.067390433 +0300 +@@ -689,7 +689,7 @@ + # Used in install-cross. + gcc_tooldir = @gcc_tooldir@ + # Since gcc_tooldir does not exist at build-time, use -B$(build_tooldir)/bin/ +-build_tooldir = $(exec_prefix)/$(target_noncanonical) ++build_tooldir = /data/data/com.termux/files/usr/glibc + # Directory in which the compiler finds target-independent g++ includes. + gcc_gxx_include_dir = @gcc_gxx_include_dir@ + gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@ +@@ -3067,7 +3067,7 @@ + -DGPLUSPLUS_LIBCXX_INCLUDE_DIR=\"$(gcc_gxx_libcxx_include_dir)\" \ + -DGPLUSPLUS_LIBCXX_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_libcxx_include_dir_add_sysroot) \ + -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \ +- -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \ ++ -DCROSS_INCLUDE_DIR=\"/data/data/com.termux/files/usr/glibc/include\" \ + -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \ + -DNATIVE_SYSTEM_HEADER_DIR=\"$(NATIVE_SYSTEM_HEADER_DIR)\" \ + -DPREFIX=\"$(prefix)/\" \ diff --git a/gpkg-dev/cgt/gcc-configure.patch b/gpkg-dev/cgt/gcc-configure.patch new file mode 100644 index 000000000..bd270e2fb --- /dev/null +++ b/gpkg-dev/cgt/gcc-configure.patch @@ -0,0 +1,22 @@ +--- src/gcc-13.1.0/gcc/configure 2023-04-26 10:11:18.000000000 +0300 ++++ src/gcc-13.1.0/gcc/configure.patch 2023-07-16 13:12:24.569064972 +0300 +@@ -3734,9 +3734,6 @@ + gcc_gxx_include_dir='${libsubdir}/include/c++' + else + libstdcxx_incdir='include/c++/$(version)' +- if test x$host != x$target; then +- libstdcxx_incdir="$target_alias/$libstdcxx_incdir" +- fi + gcc_gxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libstdcxx_incdir" + fi + elif test "${with_sysroot+set}" = set; then +@@ -3780,9 +3777,6 @@ + gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1' + else + libcxx_incdir='libc++_include/c++/$(version)/v1' +- if test x$host != x$target; then +- libcxx_incdir="$target_alias/$libcxx_incdir" +- fi + gcc_gxx_libcxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libcxx_incdir" + fi + elif test "${with_sysroot+set}" = set; then diff --git a/gpkg-dev/cgt/gcc.cc.patch b/gpkg-dev/cgt/gcc.cc.patch new file mode 100644 index 000000000..af8a737e9 --- /dev/null +++ b/gpkg-dev/cgt/gcc.cc.patch @@ -0,0 +1,55 @@ +--- src/gcc-13.1.0/gcc/gcc.cc 2023-04-26 10:09:40.000000000 +0300 ++++ src/gcc-13.1.0/gcc/gcc.cc.patch 2023-07-14 19:53:28.743169982 +0300 +@@ -1585,10 +1585,7 @@ + /* Default prefixes to attach to command names. */ + + #ifndef STANDARD_STARTFILE_PREFIX_1 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib/" +-#endif +-#ifndef STANDARD_STARTFILE_PREFIX_2 +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" ++#define STANDARD_STARTFILE_PREFIX_1 "/data/data/com.termux/files/usr/glibc/lib/" + #endif + + #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */ +@@ -1625,10 +1622,7 @@ + static const char *md_exec_prefix = MD_EXEC_PREFIX; + static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; + static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; +-static const char *const standard_startfile_prefix_1 +- = STANDARD_STARTFILE_PREFIX_1; +-static const char *const standard_startfile_prefix_2 +- = STANDARD_STARTFILE_PREFIX_2; ++static const char *const standard_startfile_prefix_1 = STANDARD_STARTFILE_PREFIX_1; + + /* A relative path to be used in finding the location of tools + relative to the driver. */ +@@ -8409,7 +8403,7 @@ + } + /* We should eventually get rid of all these and stick to + startfile_prefix_spec exclusively. */ +- else if (*cross_compile == '0' || target_system_root) ++ else + { + if (*md_startfile_prefix) + add_sysrooted_prefix (&startfile_prefixes, md_startfile_prefix, +@@ -8430,7 +8424,7 @@ + add_sysrooted_prefix (&startfile_prefixes, + standard_startfile_prefix, "BINUTILS", + PREFIX_PRIORITY_LAST, 0, 1); +- else if (*cross_compile == '0') ++ else + { + add_prefix (&startfile_prefixes, + concat (gcc_exec_prefix +@@ -8446,10 +8440,6 @@ + add_sysrooted_prefix (&startfile_prefixes, + standard_startfile_prefix_1, "BINUTILS", + PREFIX_PRIORITY_LAST, 0, 1); +- if (*standard_startfile_prefix_2) +- add_sysrooted_prefix (&startfile_prefixes, +- standard_startfile_prefix_2, "BINUTILS", +- PREFIX_PRIORITY_LAST, 0, 1); + } + + /* Process any user specified specs in the order given on the command diff --git a/gpkg-dev/cgt/set_glibc_dynamic_linker.patch b/gpkg-dev/cgt/set_glibc_dynamic_linker.patch new file mode 100644 index 000000000..93be8f06a --- /dev/null +++ b/gpkg-dev/cgt/set_glibc_dynamic_linker.patch @@ -0,0 +1,111 @@ +--- src/gcc-13.1.0/gcc/config/aarch64/aarch64-linux.h ++++ src/gcc-13.1.0/gcc/config/aarch64/aarch64-linux.h +@@ -21,10 +21,10 @@ + #ifndef GCC_AARCH64_LINUX_H + #define GCC_AARCH64_LINUX_H + +-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" ++#define GLIBC_DYNAMIC_LINKER "/data/data/com.termux/files/usr/glibc/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" + + #undef MUSL_DYNAMIC_LINKER +-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" ++#define MUSL_DYNAMIC_LINKER "/data/data/com.termux/files/usr/glibc/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1" + + #undef ASAN_CC1_SPEC + #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" +--- src/gcc-13.1.0/gcc/config/alpha/linux-elf.h ++++ src/gcc-13.1.0/gcc/config/alpha/linux-elf.h +@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see + #define EXTRA_SPECS \ + { "elf_dynamic_linker", ELF_DYNAMIC_LINKER }, + +-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" + #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" + #if DEFAULT_LIBC == LIBC_UCLIBC + #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" +--- src/gcc-13.1.0/gcc/config/arm/linux-eabi.h ++++ src/gcc-13.1.0/gcc/config/arm/linux-eabi.h +@@ -65,8 +65,8 @@ + GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */ + + #undef GLIBC_DYNAMIC_LINKER +-#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3" +-#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3" ++#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.3" ++#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/data/data/com.termux/files/usr/glibc/lib/ld-linux-armhf.so.3" + #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT + + #define GLIBC_DYNAMIC_LINKER \ +--- src/gcc-13.1.0/gcc/config/arm/linux-elf.h ++++ src/gcc-13.1.0/gcc/config/arm/linux-elf.h +@@ -60,7 +60,7 @@ + + #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc" + +-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" + + #define LINUX_TARGET_LINK_SPEC "%{h*} \ + %{static:-Bstatic} \ +--- src/gcc-13.1.0/gcc/config/i386/linux.h ++++ src/gcc-13.1.0/gcc/config/i386/linux.h +@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see + . */ + + #define GNU_USER_LINK_EMULATION "elf_i386" +-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" + + #undef MUSL_DYNAMIC_LINKER + #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" +--- src/gcc-13.1.0/gcc/config/i386/linux64.h ++++ src/gcc-13.1.0/gcc/config/i386/linux64.h +@@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define GNU_USER_LINK_EMULATION64 "elf_x86_64" + #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" + +-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" +-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" +-#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2" ++#define GLIBC_DYNAMIC_LINKER32 "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER64 "/data/data/com.termux/files/usr/glibc/lib/ld-linux-x86-64.so.2" ++#define GLIBC_DYNAMIC_LINKERX32 "/data/data/com.termux/files/usr/glibc/lib/ld-linux-x32.so.2" + + #undef MUSL_DYNAMIC_LINKER32 + #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" +--- src/gcc-13.1.0/gcc/config/sh/linux.h ++++ src/gcc-13.1.0/gcc/config/sh/linux.h +@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see + "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \ + "%{mfdpic:-fdpic}.so.1" + +-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" + + #undef SUBTARGET_LINK_EMUL_SUFFIX + #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}" +--- src/gcc-13.1.0/gcc/config/sparc/linux.h ++++ src/gcc-13.1.0/gcc/config/sparc/linux.h +@@ -78,7 +78,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); + When the -shared link option is used a final link is not being + done. */ + +-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" + + #undef LINK_SPEC + #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ +--- src/gcc-13.1.0/gcc/config/sparc/linux64.h ++++ src/gcc-13.1.0/gcc/config/sparc/linux64.h +@@ -78,8 +78,8 @@ along with GCC; see the file COPYING3. If not see + When the -shared link option is used a final link is not being + done. */ + +-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" +-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER32 "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" ++#define GLIBC_DYNAMIC_LINKER64 "/data/data/com.termux/files/usr/glibc/lib/ld-linux.so.2" + + #ifdef SPARC_BI_ARCH + diff --git a/script/build-dev.sh b/script/build-dev.sh index 5447595b7..1dc42d217 100755 --- a/script/build-dev.sh +++ b/script/build-dev.sh @@ -13,6 +13,7 @@ case $ARCH in esac . ${PWD_SCRIPT}/functions/get_name.sh . ${PWD_SCRIPT}/utils/set_makepkg.sh +. ${PWD_SCRIPT}/utils/set_data.sh . ${PWD_SCRIPT}/utils/get_deleted_pkgs.sh . ${PWD_SCRIPT}/utils/get_depends.sh export PATH="${PWD_SCRIPT}/tools:/usr/bin/core_perl:$PATH" @@ -42,15 +43,20 @@ fi cd $PKGNAME chmod a+rwx * - # packages removal check - get_deleted_pkgs + arch_pkg=$(grep 'arch=(.*)' PKGBUILD | sed 's\arch=(\\; s\)\\') - # Installing dependencies - get_depends + if [ "$arch_pkg" = "any" ] || [ "$arch_pkg" = "$ARCH" ]; then + # packages removal check + get_deleted_pkgs - # start building - sudo -Es -H -u ${GPKG_DEV_USER_NAME} bash -c "makepkg" + # Installing dependencies + get_depends - mv *.pkg.* ${GPKG_DEV_DIR_BUILD} - echo " ${PKGNAME} " >> ${GPKG_DEV_DIR_BUILD}/gpkg-dev-done.txt + # start building + sudo -Es -H -u ${GPKG_DEV_USER_NAME} bash -c "makepkg" + + mv *.pkg.* ${GPKG_DEV_DIR_BUILD} + fi + + echo "${PKGNAME}" >> ${GPKG_DEV_DIR_BUILD}/gpkg-dev-done.txt ) diff --git a/script/init.sh b/script/init.sh index d2936c761..1df1b82be 100644 --- a/script/init.sh +++ b/script/init.sh @@ -2,8 +2,10 @@ # system definitions export LANG="en_US.UTF-8" -export TERMUX_PREFIX="/data/data/com.termux/files/usr" +export DIR_TERMUX="/data/data/com.termux" +export TERMUX_PREFIX="${DIR_TERMUX}/files/usr" export GLIBC_PREFIX="${TERMUX_PREFIX}/glibc" +export GPKG_DEV_SERVER_URL="https://s3.amazonaws.com/termux-pacman.us" export GPKG_DEV_FLAGS="-O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -L${GLIBC_PREFIX}/lib -I${GLIBC_PREFIX}/include -Wl,-rpath=${GLIBC_PREFIX}/lib" export GPKG_DEV_CC="" export GPKG_DEV_CXX="" @@ -21,5 +23,4 @@ GPKG_DEV_DIR_BUILD="${GPKG_DEV_USER_HOME}/${DIR_BUILD}" GPKG_DEV_DIR_SCRIPT="${GPKG_DEV_USER_HOME}/${DIR_SCRIPT}" GPKG_DEV_IMAGE="ghcr.io/termux-pacman/archlinux-builder" GPKG_DEV_FILE_DELETING="deleted_gpkg-dev_packages.txt" -GPKG_DEV_SERVER_URL="https://s3.amazonaws.com/termux-pacman.us" GPKG_DEV_REPO_JSON="/mnt/pkgs.json" diff --git a/script/utils/get_depends.sh b/script/utils/get_depends.sh index cedbac532..8ad9591c1 100644 --- a/script/utils/get_depends.sh +++ b/script/utils/get_depends.sh @@ -17,16 +17,12 @@ get_depends() { fi curl "${GPKG_DEV_REPO_URL}/${FILENAME}" -o /mnt/${FILENAME} if [ "$i" = "glibc" ]; then - tar xJf /mnt/${FILENAME} -C / data/data/com.termux/files/usr/glibc/lib + sudo -H -u ${GPKG_DEV_USER_NAME} tar xJf /mnt/${FILENAME} -C / data/data/com.termux/files/usr/glibc/lib elif [ "$i" = "binutils-glibc" ]; then - tar xJf /mnt/${FILENAME} -C / data/data/com.termux/files/usr/glibc/lib - tar xJf /mnt/${FILENAME} -C / data/data/com.termux/files/usr/glibc/bin + sudo -H -u ${GPKG_DEV_USER_NAME} tar xJf /mnt/${FILENAME} -C / data/data/com.termux/files/usr/glibc/lib + sudo -H -u ${GPKG_DEV_USER_NAME} tar xJf /mnt/${FILENAME} -C / data/data/com.termux/files/usr/glibc/bin else - tar xJf /mnt/${FILENAME} -C / - fi - if [ -d ${GLIBC_PREFIX}/lib64 ]; then - mv ${GLIBC_PREFIX}/lib64/* ${GLIBC_PREFIX}/lib - rm -fr ${GLIBC_PREFIX}/lib64 + sudo -H -u ${GPKG_DEV_USER_NAME} tar xJf /mnt/${FILENAME} -C / data fi done fi diff --git a/script/utils/set_data.sh b/script/utils/set_data.sh new file mode 100644 index 000000000..ec82c8b99 --- /dev/null +++ b/script/utils/set_data.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [ ! -d /data ]; then + mkdir /data + chmod a+rwx /data + chown ${GPKG_DEV_USER_NAME} /data + chgrp ${GPKG_DEV_USER_NAME} /data +fi