From 53609f38702bc34a027b9054f4e4d22cc4268611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 25 Apr 2025 00:27:40 -0300 Subject: [PATCH] Allow patching glibc to an older version during ecode build, enabled this feature in linux nightly. --- .github/workflows/ecode-nightly.yml | 4 +- .gitignore | 2 +- projects/linux/ecode/build.app.sh | 112 ++++++++++++++++++++-------- 3 files changed, 82 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ecode-nightly.yml b/.github/workflows/ecode-nightly.yml index 138a34735..93325499e 100644 --- a/.github/workflows/ecode-nightly.yml +++ b/.github/workflows/ecode-nightly.yml @@ -83,12 +83,12 @@ jobs: sudo update-alternatives --set c++ /usr/bin/g++ sudo update-alternatives --config gcc sudo update-alternatives --config g++ - sudo apt-get install -y libfuse2 fuse premake4 mesa-common-dev libgl1-mesa-dev + sudo apt-get install -y libfuse2 fuse premake4 mesa-common-dev libgl1-mesa-dev ninja-build bash projects/linux/scripts/install_sdl2.sh - name: Build ecode run: | bash projects/scripts/patch_commit_number.sh - bash projects/linux/ecode/build.app.sh --version ${{ env.INSTALL_REF }} --arch ${{ matrix.config.arch }} + bash projects/linux/ecode/build.app.sh --version ${{ env.INSTALL_REF }} --arch ${{ matrix.config.arch }} --patch-glibc - name: Upload Files uses: softprops/action-gh-release@v2 with: diff --git a/.gitignore b/.gitignore index b3e0fce0b..1f90993e0 100644 --- a/.gitignore +++ b/.gitignore @@ -69,4 +69,4 @@ ecode.dmg /compile_commands.json /bin/unit_tests/eepp* /bin/unit_tests/lib* - +/projects/linux/ecode/polyfill-glibc diff --git a/projects/linux/ecode/build.app.sh b/projects/linux/ecode/build.app.sh index 0bc48ff53..38e72ccdd 100755 --- a/projects/linux/ecode/build.app.sh +++ b/projects/linux/ecode/build.app.sh @@ -7,32 +7,36 @@ DEBUG_SYMBOLS= VERSION= ARCH=$(arch) for i in "$@"; do - case $i in - --with-debug-symbols) - DEBUG_SYMBOLS="--with-debug-symbols" - shift - ;; - --version) - if [[ -n $2 ]]; then VERSION="$2"; fi - shift - shift - ;; - --arch) - if [[ -n $2 ]]; then ARCH="$2"; fi - shift - shift - ;; - -*) - echo "Unknown option $i" - exit 1 - ;; - *) - ;; - esac + case $i in + --with-debug-symbols) + DEBUG_SYMBOLS="--with-debug-symbols" + shift + ;; + --version) + if [[ -n $2 ]]; then VERSION="$2"; fi + shift + shift + ;; + --arch) + if [[ -n $2 ]]; then ARCH="$2"; fi + shift + shift + ;; + --patch-glibc) + PATCH_GLIBC=1 + shift + ;; + -*) + echo "Unknown option $i" + exit 1 + ;; + *) + ;; + esac done if [ "$ARCH" = "aarch64" ]; then - ARCH="arm64" + ARCH="arm64" fi CONFIG_NAME= @@ -61,6 +65,48 @@ cp ecode.desktop ecode.app/ cp ../../../bin/assets/icon/ecode.png ecode.app/ecode.png cp ../../../libs/linux/libeepp.so ecode.app/libs/ cp ../../../bin/ecode ecode.app/ecode.bin + +if [ "$PATCH_GLIBC" = "1" ]; then + # Check if ninja is installed + if ! command -v ninja &> /dev/null; then + echo "Ninja not found. Attempting to install ninja-build..." + + # Try to detect the distro and install ninja + DISTRO_ID="" + if [ -r /etc/os-release ]; then + . /etc/os-release + DISTRO_ID=${ID,,} + fi + + case "$DISTRO_ID" in + ubuntu|debian) + sudo apt-get update + sudo apt-get install -y ninja-build + ;; + fedora) + sudo dnf install -y ninja-build + ;; + centos|rhel) + sudo yum install -y ninja-build + ;; + arch) + sudo pacman -Sy --noconfirm ninja + ;; + *) + echo "Could not detect distribution or unsupported distro. Please install ninja manually." + exit 1 + ;; + esac + fi + + git clone https://github.com/corsix/polyfill-glibc.git + cd polyfill-glibc || exit + ninja polyfill-glibc + echo "Patching ecode.bin" + ./polyfill-glibc --target-glibc=2.34 ../ecode.app/ecode.bin + cd .. +fi + cp -L "$(bash ../scripts/find_most_recent_sdl2.sh)" ecode.app/libs/ || exit ${STRIP:-strip} ecode.app/libs/libSDL2-2.0.so.0 mkdir -p ecode.app/assets/colorschemes @@ -105,22 +151,22 @@ export APPIMAGETOOL="appimagetool" if ! command -v appimagetool &> /dev/null then - wget -nc "https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-$(arch).AppImage" - APPIMAGETOOL="./appimagetool-$(arch).AppImage" - chmod +x "$APPIMAGETOOL" + wget -nc "https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-$(arch).AppImage" + APPIMAGETOOL="./appimagetool-$(arch).AppImage" + chmod +x "$APPIMAGETOOL" fi ECODE_NAME=ecode-linux-"$ECODE_VERSION"-"$ARCH" if [ -n "$DEBUG_SYMBOLS" ]; then - cp -r ecode.app ecode - rm ecode/.DirIcon - mv ecode/AppRun ecode/ecode - 7za a -t7z "$ECODE_NAME"-with-debug-symbols.7z ecode -mx9 -mmt"$(nproc)" - rm -rf ecode - objcopy -S ecode.app/ecode.bin ecode.app/ecode.bin - objcopy -S ecode.app/libs/libeepp.so ecode.app/libs/libeepp.so + cp -r ecode.app ecode + rm ecode/.DirIcon + mv ecode/AppRun ecode/ecode + 7za a -t7z "$ECODE_NAME"-with-debug-symbols.7z ecode -mx9 -mmt"$(nproc)" + rm -rf ecode + objcopy -S ecode.app/ecode.bin ecode.app/ecode.bin + objcopy -S ecode.app/libs/libeepp.so ecode.app/libs/libeepp.so fi echo "Generating $ECODE_NAME.AppImage"