diff --git a/.github/workflows/package_continuous.yml b/.github/workflows/package_continuous.yml index 9dd162cee..d3045fbc2 100644 --- a/.github/workflows/package_continuous.yml +++ b/.github/workflows/package_continuous.yml @@ -544,10 +544,143 @@ jobs: name: build-status-${{ matrix.target_arch }}-${{ github.sha }} path: ./build-status + build-6: + runs-on: ubuntu-22.04 + needs: build-5 + env: + ANDROID_HOME: "/opt/termux/android-sdk" + NDK: "/opt/termux/android-ndk" + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + TUR_CONTINUOUS_FLAG: true + strategy: + matrix: + target_arch: [aarch64, arm, i686, x86_64] + fail-fast: false + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + fetch-depth: 1000 + submodules: true + - name: Merge repos + run: ./setup-environment.sh + - name: Free additional disk space + run: | + sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(cabal-|dotnet-|ghc-|libmono|php|aspnetcore)') \ + mono-runtime-common monodoc-manual ruby + sudo apt autoremove -yq + sudo rm -rf /opt/hostedtoolcache /usr/local /usr/share/dotnet /usr/share/swift + - name: Download build deps + uses: actions/download-artifact@v3 + with: + name: build-deps-${{ matrix.target_arch }}-${{ github.sha }} + path: ./build-deps + - name: Download build status + uses: actions/download-artifact@v3 + with: + name: build-status-${{ matrix.target_arch }}-${{ github.sha }} + path: ./build-status + - name: Extract build status + run: | + tar xf build-status/${{ matrix.target_arch }}-${{ github.sha }}.tar + rm -f build-status/${{ matrix.target_arch }}-${{ github.sha }}.tar + - name: Build packages + run: | + if [ "$(cat ./build-status/tur-continuous-finished-flag)" = "true" ]; then + exit 0 + fi + declare -a packages + for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do + repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) + if [ -f ./built_${repo}_packages.txt ]; then + packages="$packages $(cat ./built_${repo}_packages.txt)" + fi + done + if [ ! -z "$packages" ]; then + ./continuous-build-wrapper.sh ./build-package.sh -I -a ${{ matrix.target_arch }} $packages + fi + - name: Waiting for debugger + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + - name: Generate build status + run: | + tar cf build-status/${{ matrix.target_arch }}-${{ github.sha }}.tar ./*.txt ./debs ./artifacts ./output + - name: Upload build status + uses: actions/upload-artifact@v3 + with: + name: build-status-${{ matrix.target_arch }}-${{ github.sha }} + path: ./build-status + + build-7: + runs-on: ubuntu-22.04 + needs: build-6 + env: + ANDROID_HOME: "/opt/termux/android-sdk" + NDK: "/opt/termux/android-ndk" + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + TUR_CONTINUOUS_FLAG: true + strategy: + matrix: + target_arch: [aarch64, arm, i686, x86_64] + fail-fast: false + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + fetch-depth: 1000 + submodules: true + - name: Merge repos + run: ./setup-environment.sh + - name: Free additional disk space + run: | + sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(cabal-|dotnet-|ghc-|libmono|php|aspnetcore)') \ + mono-runtime-common monodoc-manual ruby + sudo apt autoremove -yq + sudo rm -rf /opt/hostedtoolcache /usr/local /usr/share/dotnet /usr/share/swift + - name: Download build deps + uses: actions/download-artifact@v3 + with: + name: build-deps-${{ matrix.target_arch }}-${{ github.sha }} + path: ./build-deps + - name: Download build status + uses: actions/download-artifact@v3 + with: + name: build-status-${{ matrix.target_arch }}-${{ github.sha }} + path: ./build-status + - name: Extract build status + run: | + tar xf build-status/${{ matrix.target_arch }}-${{ github.sha }}.tar + rm -f build-status/${{ matrix.target_arch }}-${{ github.sha }}.tar + - name: Build packages + run: | + if [ "$(cat ./build-status/tur-continuous-finished-flag)" = "true" ]; then + exit 0 + fi + declare -a packages + for repo_path in $(jq --raw-output 'keys | .[]' repo.json); do + repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) + if [ -f ./built_${repo}_packages.txt ]; then + packages="$packages $(cat ./built_${repo}_packages.txt)" + fi + done + if [ ! -z "$packages" ]; then + ./continuous-build-wrapper.sh ./build-package.sh -I -a ${{ matrix.target_arch }} $packages + fi + - name: Waiting for debugger + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + - name: Generate build status + run: | + tar cf build-status/${{ matrix.target_arch }}-${{ github.sha }}.tar ./*.txt ./debs ./artifacts ./output + - name: Upload build status + uses: actions/upload-artifact@v3 + with: + name: build-status-${{ matrix.target_arch }}-${{ github.sha }} + path: ./build-status finished-build: runs-on: ubuntu-22.04 - needs: build-5 + needs: build-7 env: ANDROID_HOME: "/opt/termux/android-sdk" NDK: "/opt/termux/android-ndk" diff --git a/continuous-build-wrapper.sh b/continuous-build-wrapper.sh index bf8bf3b2a..bb5d95a43 100755 --- a/continuous-build-wrapper.sh +++ b/continuous-build-wrapper.sh @@ -35,7 +35,12 @@ : "${TUR_CONTINUOUS_FLAG:=false}" -: "${TUR_CONTINUOUS_TIMEOUT:=240m}" +: "${TUR_CONTINUOUS_TIMEOUT:=200m}" + +# XXX: For the CI, we always pass the packages as the last param. +TUR_CONTINUOUS_PACKAGE="${@: -1}" + +echo "==> Package to be built: $TUR_CONTINUOUS_PACKAGE" # Get the builder docker image if necessary. ./scripts/run-docker.sh bash -c "exit 0" @@ -83,10 +88,12 @@ elif [[ $EXIT_CODE == 124 ]]; then # https://www.gnu.org/software/coreutils/manu echo "==> Generating the build status..." df -h # XXX: This will create a pretty large file, hope that Github Action has enough space. - # XXX: I think the build status is just the `build`, `src` and `tmp` folder. `cache` - # XXX: often contains the source tar ball and will not be modified. - # TODO: Parse the package name from command line. - time ./scripts/run-docker.sh bash -c 'sudo tar -I zstd --remove-files -cf ./build-status/tur-continuous-status.tar.zst /home/builder/.termux-build/chromium/{build,src,tmp}' + # XXX: I think the build status is just the `build` folder. If this package performs + # XXX: an in-source building, please move the origin `src` folder to `build` folder + # XXX: and use symlinks to provide `src` folder. Folder like `src`, `cache`, or `tmp` + # XXX: often contains the source files or scripts and will not be modified during + # XXX: the building process. + time ./scripts/run-docker.sh bash -c 'sudo tar -I zstd --remove-files -cf ./build-status/tur-continuous-status.tar.zst /home/builder/.termux-build/'"$TUR_CONTINUOUS_PACKAGE"'/build' echo "==> Successfully generate build status." # Create the deps file if the package is built the first time. if [ "$TUR_CONTINUOUS_FLAG" = "false" ]; then diff --git a/tur-continuous/chromium/0011-chromium-impl-sysinfo.patch b/tur-continuous/chromium/0011-chromium-impl-sysinfo.patch index 037fd3ea9..210ce4cfb 100644 --- a/tur-continuous/chromium/0011-chromium-impl-sysinfo.patch +++ b/tur-continuous/chromium/0011-chromium-impl-sysinfo.patch @@ -21,7 +21,7 @@ + +#include "base/logging.h" + -+#if (__ANDROID_API__ >= 21 /* 5.0 - Lollipop */) ++#if 0 // (__ANDROID_API__ >= 21 /* 5.0 - Lollipop */) + +namespace { + diff --git a/tur-continuous/chromium/0043-x11-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0043-x11-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..45d62b6d9 --- /dev/null +++ b/tur-continuous/chromium/0043-x11-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,28 @@ +--- a/ui/base/x/x11_cursor_loader.cc ++++ b/ui/base/x/x11_cursor_loader.cc +@@ -139,7 +139,11 @@ + void operator()(void* ptr) const { dlclose(ptr); } + }; + ++#ifdef __TERMUX__ ++ std::unique_ptr lib(dlopen("libXcursor.so", RTLD_LAZY)); ++#else + std::unique_ptr lib(dlopen("libXcursor.so.1", RTLD_LAZY)); ++#endif + if (!lib) + return ""; + +--- a/ui/gfx/x/xlib_support.cc ++++ b/ui/gfx/x/xlib_support.cc +@@ -41,7 +41,11 @@ + CHECK(xlib_loader->Load("libX11.so.6")); + + auto* xlib_xcb_loader = GetXlibXcbLoader(); ++#ifndef __TERMUX__ + CHECK(xlib_xcb_loader->Load("libX11-xcb.so.1")); ++#else ++ CHECK(xlib_xcb_loader->Load("libX11-xcb.so")); ++#endif + + CHECK(xlib_loader->XInitThreads()); + diff --git a/tur-continuous/chromium/0043-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0044-ozone-fix-dynamic-loaded-libraries.patch similarity index 80% rename from tur-continuous/chromium/0043-fix-dynamic-loaded-libraries.patch rename to tur-continuous/chromium/0044-ozone-fix-dynamic-loaded-libraries.patch index 4f2ad52ba..b11ecae13 100644 --- a/tur-continuous/chromium/0043-fix-dynamic-loaded-libraries.patch +++ b/tur-continuous/chromium/0044-ozone-fix-dynamic-loaded-libraries.patch @@ -1,17 +1,3 @@ ---- a/ui/gfx/x/xlib_support.cc -+++ b/ui/gfx/x/xlib_support.cc -@@ -41,7 +41,11 @@ - CHECK(xlib_loader->Load("libX11.so.6")); - - auto* xlib_xcb_loader = GetXlibXcbLoader(); -+#ifndef __TERMUX__ - CHECK(xlib_xcb_loader->Load("libX11-xcb.so.1")); -+#else -+ CHECK(xlib_xcb_loader->Load("libX11-xcb.so")); -+#endif - - CHECK(xlib_loader->XInitThreads()); - --- a/ui/ozone/platform/wayland/host/wayland_connection.cc +++ b/ui/ozone/platform/wayland/host/wayland_connection.cc @@ -139,14 +139,22 @@ diff --git a/tur-continuous/chromium/0045-gtk-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0045-gtk-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..f7d4f9761 --- /dev/null +++ b/tur-continuous/chromium/0045-gtk-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,50 @@ +--- a/ui/gtk/gtk_compat.cc ++++ b/ui/gtk/gtk_compat.cc +@@ -62,27 +62,47 @@ + } + + void* GetLibGio() { ++#ifdef __TERMUX__ ++ static void* libgio = DlOpen("libgio-2.0.so"); ++#else + static void* libgio = DlOpen("libgio-2.0.so.0"); ++#endif + return libgio; + } + + void* GetLibGdkPixbuf() { ++#ifdef __TERMUX__ ++ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so"); ++#else + static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); ++#endif + return libgdk_pixbuf; + } + + void* GetLibGdk3() { ++#ifdef __TERMUX__ ++ static void* libgdk3 = DlOpen("libgdk-3.so"); ++#else + static void* libgdk3 = DlOpen("libgdk-3.so.0"); ++#endif + return libgdk3; + } + + void* GetLibGtk3(bool check = true) { ++#ifdef __TERMUX__ ++ static void* libgtk3 = DlOpen("libgtk-3.so", check); ++#else + static void* libgtk3 = DlOpen("libgtk-3.so.0", check); ++#endif + return libgtk3; + } + + void* GetLibGtk4(bool check = true) { ++#ifdef __TERMUX__ ++ static void* libgtk4 = DlOpen("libgtk-4.so", check); ++#else + static void* libgtk4 = DlOpen("libgtk-4.so.1", check); ++#endif + return libgtk4; + } + diff --git a/tur-continuous/chromium/0046-pulse-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0046-pulse-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..18f726b6b --- /dev/null +++ b/tur-continuous/chromium/0046-pulse-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,29 @@ +--- a/media/audio/pulse/pulse_util.cc ++++ b/media/audio/pulse/pulse_util.cc +@@ -44,8 +44,12 @@ + + #if defined(DLOPEN_PULSEAUDIO) + static const base::FilePath::CharType kPulseLib[] = ++#ifdef __TERMUX__ ++ FILE_PATH_LITERAL("libpulse.so"); ++#else + FILE_PATH_LITERAL("libpulse.so.0"); + #endif ++#endif + + void DestroyMainloop(pa_threaded_mainloop* mainloop) { + pa_threaded_mainloop_stop(mainloop); +--- a/third_party/webrtc/modules/audio_device/linux/pulseaudiosymboltable_linux.cc ++++ b/third_party/webrtc/modules/audio_device/linux/pulseaudiosymboltable_linux.cc +@@ -30,7 +30,11 @@ + namespace webrtc { + namespace adm_linux_pulse { + ++#ifdef __TERMUX__ ++LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(PulseAudioSymbolTable, "libpulse.so") ++#else + LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(PulseAudioSymbolTable, "libpulse.so.0") ++#endif + #define X(sym) \ + LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(PulseAudioSymbolTable, sym) + PULSE_AUDIO_SYMBOLS_LIST diff --git a/tur-continuous/chromium/0047-crypt-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0047-crypt-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..6b2f46752 --- /dev/null +++ b/tur-continuous/chromium/0047-crypt-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,28 @@ +--- a/components/os_crypt/keyring_util_linux.cc ++++ b/components/os_crypt/keyring_util_linux.cc +@@ -68,7 +68,11 @@ + if (keyring_loaded) + return true; + ++#ifdef __TERMUX__ ++ void* handle = dlopen("libgnome-keyring.so", RTLD_NOW | RTLD_GLOBAL); ++#else + void* handle = dlopen("libgnome-keyring.so.0", RTLD_NOW | RTLD_GLOBAL); ++#endif + if (!handle) { + // We wanted to use GNOME Keyring, but we couldn't load it. Warn, because + // either the user asked for this, or we autodetected it incorrectly. (Or +--- a/components/os_crypt/libsecret_util_linux.cc ++++ b/components/os_crypt/libsecret_util_linux.cc +@@ -102,7 +102,11 @@ + if (libsecret_loaded_) + return true; + ++#ifdef __TERMUX__ ++ static void* handle = dlopen("libsecret-1.so", RTLD_NOW | RTLD_GLOBAL); ++#else + static void* handle = dlopen("libsecret-1.so.0", RTLD_NOW | RTLD_GLOBAL); ++#endif + if (!handle) { + // We wanted to use libsecret, but we couldn't load it. Warn, because + // either the user asked for this, or we autodetected it incorrectly. (Or diff --git a/tur-continuous/chromium/0048-swiftshader-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0048-swiftshader-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..d801af4eb --- /dev/null +++ b/tur-continuous/chromium/0048-swiftshader-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,40 @@ +--- a/third_party/swiftshader/src/WSI/libWaylandClient.cpp ++++ b/third_party/swiftshader/src/WSI/libWaylandClient.cpp +@@ -56,7 +56,11 @@ + } + else + { ++#ifdef __TERMUX__ ++ libwl = loadLibrary("libwayland-client.so"); ++#else + libwl = loadLibrary("libwayland-client.so.0"); ++#endif + } + + return LibWaylandClientExports(libwl); +--- a/third_party/swiftshader/src/WSI/libXCB.cpp ++++ b/third_party/swiftshader/src/WSI/libXCB.cpp +@@ -55,7 +55,11 @@ + } + else + { ++#ifdef __TERMUX__ ++ libxcb = loadLibrary("libxcb.so"); ++#else + libxcb = loadLibrary("libxcb.so.1"); ++#endif + } + + if(getProcAddress(RTLD_DEFAULT, "xcb_shm_query_version")) // Search the global scope for pre-loaded XCB library. +@@ -64,7 +68,11 @@ + } + else + { ++#ifdef __TERMUX__ ++ libshm = loadLibrary("libxcb-shm.so"); ++#else + libshm = loadLibrary("libxcb-shm.so.0"); ++#endif + } + + return LibXcbExports(libxcb, libshm); diff --git a/tur-continuous/chromium/0049-dawn-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0049-dawn-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..4e1e595db --- /dev/null +++ b/tur-continuous/chromium/0049-dawn-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,14 @@ +--- a/third_party/dawn/src/dawn/native/XlibXcbFunctions.cpp ++++ b/third_party/dawn/src/dawn/native/XlibXcbFunctions.cpp +@@ -17,7 +17,11 @@ + namespace dawn::native { + + XlibXcbFunctions::XlibXcbFunctions() { ++#ifdef __TERMUX__ ++ if (!mLib.Open("libX11-xcb.so") || !mLib.GetProc(&xGetXCBConnection, "XGetXCBConnection")) { ++#else + if (!mLib.Open("libX11-xcb.so.1") || !mLib.GetProc(&xGetXCBConnection, "XGetXCBConnection")) { ++#endif + mLib.Close(); + } + } diff --git a/tur-continuous/chromium/0050-weston-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0050-weston-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..25da25769 --- /dev/null +++ b/tur-continuous/chromium/0050-weston-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,14 @@ +--- a/third_party/weston/src/libweston/backend-drm/drm-gbm.c ++++ b/third_party/weston/src/libweston/backend-drm/drm-gbm.c +@@ -61,7 +61,11 @@ + * only the gl-renderer module links to it, the call above won't make + * these symbols globally available, and loading the DRI driver fails. + * Workaround this by dlopen()'ing libglapi with RTLD_GLOBAL. */ ++#ifdef __TERMUX__ ++ dlopen("libglapi.so", RTLD_LAZY | RTLD_GLOBAL); ++#else + dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL); ++#endif + + gbm = gbm_create_device(fd); + diff --git a/tur-continuous/chromium/0051-unity-fix-dynamic-loaded-libraries.patch b/tur-continuous/chromium/0051-unity-fix-dynamic-loaded-libraries.patch new file mode 100644 index 000000000..b64491db2 --- /dev/null +++ b/tur-continuous/chromium/0051-unity-fix-dynamic-loaded-libraries.patch @@ -0,0 +1,11 @@ +--- a/chrome/browser/download/download_status_updater_linux.cc ++++ b/chrome/browser/download/download_status_updater_linux.cc +@@ -77,6 +77,8 @@ + if (!unity_lib) + unity_lib = dlopen("libunity.so.9", RTLD_LAZY); + if (!unity_lib) ++ unity_lib = dlopen("libunity.so", RTLD_LAZY); ++ if (!unity_lib) + return; + + unity_inspector_get_default_func inspector_get_default = diff --git a/tur-continuous/chromium/0052-v8-disable-trap-handler.patch b/tur-continuous/chromium/0052-v8-disable-trap-handler.patch new file mode 100644 index 000000000..c78e570c8 --- /dev/null +++ b/tur-continuous/chromium/0052-v8-disable-trap-handler.patch @@ -0,0 +1,11 @@ +--- a/v8/src/trap-handler/trap-handler.h ++++ b/v8/src/trap-handler/trap-handler.h +@@ -19,7 +19,7 @@ + + // X64 on Linux, Windows, MacOS, FreeBSD. + #if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \ +- ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_DARWIN || \ ++ (V8_OS_LINUX || V8_OS_WIN || V8_OS_DARWIN || \ + V8_OS_FREEBSD) + #define V8_TRAP_HANDLER_SUPPORTED true + // Arm64 (non-simulator) on Mac. diff --git a/tur-continuous/chromium/0053-breakpad-include-cstring.patch b/tur-continuous/chromium/0053-breakpad-include-cstring.patch new file mode 100644 index 000000000..c16a04bd1 --- /dev/null +++ b/tur-continuous/chromium/0053-breakpad-include-cstring.patch @@ -0,0 +1,12 @@ +To solve error like +../../third_party/breakpad/breakpad/src/common/dwarf/elf_reader.cc:200:10: error: no member named 'strcmp' in namespace 'std'; did you mean simply 'strcmp'? +--- a/third_party/breakpad/breakpad/src/common/dwarf/elf_reader.cc ++++ b/third_party/breakpad/breakpad/src/common/dwarf/elf_reader.cc +@@ -39,6 +39,7 @@ + #include + + #include ++#include + #include + #include + #include diff --git a/tur-continuous/chromium/0054-ffmpeg-5.1.patch.disable b/tur-continuous/chromium/0054-ffmpeg-5.1.patch.disable new file mode 100644 index 000000000..8b36f3fe4 --- /dev/null +++ b/tur-continuous/chromium/0054-ffmpeg-5.1.patch.disable @@ -0,0 +1,29 @@ +--- a/media/filters/audio_file_reader.cc ++++ b/media/filters/audio_file_reader.cc +@@ -243,10 +243,10 @@ + // silence from being output. In the case where we are also discarding some + // portion of the packet (as indicated by a negative pts), we further want to + // adjust the duration downward by however much exists before zero. +- if (audio_codec_ == AudioCodec::kAAC && frame->duration) { ++ if (audio_codec_ == AudioCodec::kAAC && frame->pkt_duration) { + const base::TimeDelta pkt_duration = ConvertFromTimeBase( + glue_->format_context()->streams[stream_index_]->time_base, +- frame->duration + std::min(static_cast(0), frame->pts)); ++ frame->pkt_duration + std::min(static_cast(0), frame->pts)); + const base::TimeDelta frame_duration = + base::Seconds(frames_read / static_cast(sample_rate_)); + +Remove this if termux/termux-packages#13743 is merged +--- a/media/filters/ffmpeg_demuxer.cc ++++ b/media/filters/ffmpeg_demuxer.cc +@@ -91,6 +91,10 @@ + sample_rate); + } + ++static inline int64_t av_stream_get_first_dts(const AVStream*) { ++ return kNoFFmpegTimestamp; ++} ++ + static base::TimeDelta ExtractStartTime(AVStream* stream) { + // The default start time is zero. + base::TimeDelta start_time; diff --git a/tur-continuous/chromium/build.sh b/tur-continuous/chromium/build.sh index 6e009cfcc..50eae6e07 100644 --- a/tur-continuous/chromium/build.sh +++ b/tur-continuous/chromium/build.sh @@ -4,31 +4,20 @@ TERMUX_PKG_LICENSE="BSD 3-Clause" TERMUX_PKG_MAINTAINER="Chongyun Lee " _CHROMIUM_VERSION=107.0.5304.107 TERMUX_PKG_VERSION=$_CHROMIUM_VERSION -TERMUX_PKG_REVISION=1 +TERMUX_PKG_REVISION=2 TERMUX_PKG_SRCURL=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$_CHROMIUM_VERSION.tar.xz) TERMUX_PKG_SHA256=(49d96b1247690b5ecc061d91fdb203eaef38c6d6e1bb60ca4472eaa99bba1a3e) -TERMUX_PKG_DEPENDS="atk, cups, dbus, fontconfig, freetype, gtk3, krb5, libc++, libdrm, libxkbcommon, libminizip, libnss, libwayland, libjpeg-turbo, libpng, libx11, mesa-chromium, openssl, pango, qt5-qtbase, vulkan-loader-android, zlib" +TERMUX_PKG_DEPENDS="atk, cups, dbus, gtk3, krb5, libc++, libxkbcommon, libminizip, libnss, libwayland, libx11, mesa-chromium, openssl, pango, pulseaudio, libdrm, libjpeg-turbo, libpng, libwebp, libflac, fontconfig, freetype, zlib, libxml2, libxslt, libopus, libre2, libsnappy" # TODO: Split chromium-common and chromium-headless # TERMUX_PKG_DEPENDS+=", chromium-common" # TERMUX_PKG_SUGGESTS="chromium-headless, chromium-driver" -TERMUX_PKG_BUILD_DEPENDS="vulkan-headers, qt5-qtbase-cross-tools" -TERMUX_PKG_BUILD_IN_SRC=true +TERMUX_PKG_SUGGESTS="qt5-qtbase" +TERMUX_PKG_BUILD_DEPENDS="qt5-qtbase, qt5-qtbase-cross-tools" # Chromium doesn't support i686 on Linux. TERMUX_PKG_BLACKLISTED_ARCHES="i686" -SYSTEM_LIBRARIES=" -libdrm -libjpeg -libpng -fontconfig -freetype -zlib -" - -# TERMUX_PKG_DEPENDS+=", harfbuzz, libdav1d" -# `harfbuzz-ng` and `dav1d` cannot be used as system libraries because -# Google-provided rootfs doesn't have these libraries. Maybe we should -# construct our own rootfs later. +SYSTEM_LIBRARIES=" libdrm libjpeg libpng libwebp flac fontconfig freetype zlib libxml libxslt opus re2 snappy " +# TERMUX_PKG_DEPENDS="libdrm, libjpeg-turbo, libpng, libwebp, libflac, fontconfig, freetype, zlib, libxml2, libxslt, libopus, libre2, libsnappy" termux_step_post_get_source() { local _lib @@ -49,9 +38,14 @@ termux_step_post_get_source() { python3 build/linux/unbundle/replace_gn_files.py --system-libraries \ $SYSTEM_LIBRARIES python3 third_party/libaddressinput/chromium/tools/update-strings.py + + # allow system dependencies in "official builds" + sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \ + tools/generate_shim_headers/generate_shim_headers.py } termux_step_configure() { + cd $TERMUX_PKG_SRCDIR termux_setup_gn termux_setup_ninja termux_setup_nodejs @@ -138,17 +132,27 @@ termux_step_configure() { touch $_common_args_file echo " +# Set google key to disable the warning slogan +# Please DO NOT USE THIS KEY OUTSIDE OF TUR! +google_api_key = \"$_google_api_key\" +google_default_client_id = \"$_google_default_client_id\" +google_default_client_secret = \"$_google_default_client_secret\" +# Do official build to decrease file size +is_official_build = true +is_debug = false +symbol_level = 0 +# Use our custom toolchain use_sysroot = true target_cpu = \"$_TARGET_CPU\" target_rpath = \"$TERMUX_PREFIX/lib\" target_sysroot = \"$TERMUX_PKG_TMPDIR/sysroot\" custom_toolchain = \"//build/toolchain/linux/unbundle:default\" -is_debug = false clang_base_path = \"$TERMUX_STANDALONE_TOOLCHAIN\" clang_use_chrome_plugins = false dcheck_always_on = false chrome_pgo_phase = 0 treat_warnings_as_errors = false +# Use system libraries as much as possible use_system_freetype = true use_system_libdrm = true use_system_libffi = true @@ -159,11 +163,28 @@ use_custom_libcxx = false use_allocator_shim = false use_allocator = \"none\" use_nss_certs = true -is_official_build = false use_udev = false -google_api_key = \"$_google_api_key\" -google_default_client_id = \"$_google_default_client_id\" -google_default_client_secret = \"$_google_default_client_secret\" +use_ozone = true +ozone_auto_platforms = false +ozone_platform = \"x11\" +ozone_platform_x11 = true +ozone_platform_wayland = true +ozone_platform_headless = true +angle_enable_vulkan = true +angle_enable_swiftshader = true +# Use Chrome-branded ffmpeg for more codecs +is_component_ffmpeg = true +ffmpeg_branding = \"Chrome\" +proprietary_codecs = true +use_gnome_keyring = false +use_qt = true +use_libpci = false +use_alsa = false +use_pulseaudio = true +rtc_use_pipewire = false +use_vaapi_x11 = false +# See comments below +enable_nacl = false " > $_common_args_file # For aarch64, remove the `libatomic.a` in `NDK Toolchain` for x86_64 @@ -190,9 +211,6 @@ google_default_client_secret = \"$_google_default_client_secret\" if [ -f "$_invalid_atomic" ]; then mv $_invalid_atomic{,.backup} fi - # FIXME: Disable nacl on arm due to the following error. Need to figure out why this happens. - # FIXME: ninja: error: '../../native_client/toolchain/linux_x86/pnacl_newlib/bin/arm-nacl-objcopy', needed by 'nacl_irt_arm.nexe', missing and no known rule to make it - echo "enable_nacl = false" >> $_common_args_file fi # When building for x64, these variables must be set to tell @@ -220,46 +238,21 @@ google_default_client_secret = \"$_google_default_client_secret\" echo "host_toolchain = \"//build/toolchain/linux/unbundle:host\"" >> $_common_args_file echo "v8_snapshot_toolchain = \"//build/toolchain/linux/unbundle:host\"" >> $_common_args_file - # FIXME: Disable nacl on x86_64 due to the error above. - echo "enable_nacl = false" >> $_common_args_file fi - # Headless Chromium - # mkdir -p out/Headless - # rm -f out/Headless/args.gn - # echo "import(\"//build/args/headless.gn\")" > out/Headless/args.gn - # cat $_common_args_file >> out/Headless/args.gn - # gn gen out/Headless --export-compile-commands || bash - # Chromium Binary - mkdir -p out/Release - rm -f out/Release/args.gn - cat $_common_args_file >> out/Release/args.gn - echo " -use_ozone = true -ozone_auto_platforms = false -ozone_platform = \"x11\" -ozone_platform_x11 = true -ozone_platform_wayland = true -ozone_platform_headless = true -angle_enable_vulkan = true -angle_enable_swiftshader = true -use_gnome_keyring = false -use_qt = true -use_libpci = false -use_alsa = false -use_pulseaudio = false -rtc_use_pipewire = false -use_vaapi_x11 = false -" >> out/Release/args.gn - gn gen out/Release --export-compile-commands + mkdir -p $TERMUX_PKG_BUILDDIR/out/Release + cat $_common_args_file > $TERMUX_PKG_BUILDDIR/out/Release/args.gn + gn gen $TERMUX_PKG_BUILDDIR/out/Release --export-compile-commands || bash } termux_step_make() { + cd $TERMUX_PKG_BUILDDIR ninja -C out/Release chromedriver chrome chrome_crashpad_handler headless_shell || bash } termux_step_make_install() { + cd $TERMUX_PKG_BUILDDIR mkdir -p $TERMUX_PREFIX/lib/chromium local normal_files=( @@ -302,6 +295,12 @@ termux_step_make_install() { libvk_swiftshader.so libVkLayer_khronos_validation.so vk_swiftshader_icd.json + + # FFmpeg + libffmpeg.so + + # Qt + libqt5_shim.so ) cp "${normal_files[@]/#/out/Release/}" "$TERMUX_PREFIX/lib/chromium/" @@ -311,7 +310,11 @@ termux_step_make_install() { cp -Rf out/Release/MEIPreload $TERMUX_PREFIX/lib/chromium/ cp -Rf out/Release/resources $TERMUX_PREFIX/lib/chromium/ - ln -sfr $TERMUX_PREFIX/lib/chromium/chrome $TERMUX_PREFIX/bin/ + sed "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \ + $TERMUX_PKG_BUILDER_DIR/chromium-launcher.sh.in > $TERMUX_PREFIX/lib/chromium/chromium-launcher.sh + chmod +x $TERMUX_PREFIX/lib/chromium/chromium-launcher.sh + + ln -sfr $TERMUX_PREFIX/lib/chromium/chromium-launcher.sh $TERMUX_PREFIX/bin/chromium-browser ln -sfr $TERMUX_PREFIX/lib/chromium/chromedriver $TERMUX_PREFIX/bin/ ln -sfr $TERMUX_PREFIX/lib/chromium/headless_shell $TERMUX_PREFIX/bin/ } @@ -333,13 +336,45 @@ termux_step_post_make_install() { } # TODO: -# (1) Split packages -# (2) Use system libraries as much as possible -# (3) Enable ffmpeg +# (2) Split packages # (4) Enable Sandbox (AFAIK this is impossible) # (5) Package man pages -# (6) Enable pulseaudio # (7) Use libreolv-wrapper # (8) Refator the GN files (Add a variant is_termux in the configure files) -# (9) Figure out what packages in vulkan and mesa are actually needed -# (10) Figure out why nacl cannot be enabled + +# ######################### About system libraries ############################ +# We only pick up a few libraries to let chromium link against. Others may +# contains +# FYI, all the available libraries and whether they can be used for linking +# are listed below. +# +# Name in Chromium | libdrm libjpeg libpng libwebp fontconfig libxslt +# Name in Termux | libdrm libjpeg-turbo libpng libwebp fontconfig libxslt +# +# Name in Chromium | freetype libxml opus re2 snappy flac zlib +# Name in Termux | freetype libxml2 libopus libre2 libsnappy libflac zlib +# +# These libraries cannot be used as system libraries, because Chromium-provided +# debian rootfs doesn't have them (or their headers). Maybe we should construct +# our own rootfs later. +# Name in Chromium | harfbuzz-ng dav1d ffmpeg libaom libjxl libvpx libevent double-conversion jsoncpp +# Name in Termux | harfbuzz libdav1d ffmpeg libaom libjxl libvpx libevent double-conversion jsoncpp +# +# These libraries cannot be used due to configuation errors like +# `error: '/usr/bin/brotli', needed by 'clang_x64/brotli', missing and no known rule to make it`/ +# Name in Chromium | brotli icu +# Name in Termux | brotli libicu +# +# These libraries cannot be used because they don't exist in Termux. +# Name in Chromium | absl* crc32c, libavif, libXNVCtrl, libyuv, openh264, libSPIRV-Tools +# +# TODO: link against system ffmpeg +# ############################################################################# + +# ######################### About Native Client ############################### +# When set `enable_nacl = true`, the following error occurs. +# ninja: error: 'native_client/toolchain/linux_x86/pnacl_newlib/bin/arm-nacl-objcopy', needed by 'nacl_irt_arm.nexe', missing and no known rule to make it. +# If we want to enable NaCi, maybe we should build the toolchain of NaCl too. +# But I don't think this is necessary. NaCl existing or not will take little +# influence on Chromium. So I'd like to disable NaCl. +# ############################################################################# diff --git a/tur-continuous/chromium/chromium-launcher.sh.in b/tur-continuous/chromium/chromium-launcher.sh.in new file mode 100644 index 000000000..e02282904 --- /dev/null +++ b/tur-continuous/chromium/chromium-launcher.sh.in @@ -0,0 +1,44 @@ +#!@TERMUX_PREFIX@/bin/sh + +# Origin: https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/chromium/chromium-launcher.sh + +# Allow the user to override command-line flags, bug #357629. +# This is based on Debian's chromium-browser package, and is intended +# to be consistent with Debian. +for f in @TERMUX_PREFIX@/etc/chromium/*.conf; do + [ -f ${f} ] && . "${f}" +done + +# Prefer user defined CHROMIUM_USER_FLAGS (from env) over system +# default CHROMIUM_FLAGS (from /etc/chromium/default). +CHROMIUM_FLAGS=${CHROMIUM_USER_FLAGS:-"$CHROMIUM_FLAGS"} + +# Let the wrapped binary know that it has been run through the wrapper +export CHROME_WRAPPER=$(readlink -f "$0") + +PROGDIR=${CHROME_WRAPPER%/*} + +case ":$PATH:" in + *:$PROGDIR:*) + # $PATH already contains $PROGDIR + ;; + *) + # Append $PROGDIR to $PATH + export PATH="$PATH:$PROGDIR" + ;; +esac + +if [ $(id -u) -eq 0 ] && [ $(stat -c %u -L ${XDG_CONFIG_HOME:-${HOME}}) -eq 0 ]; then + # Running as root with HOME owned by root. + # Pass --user-data-dir to work around upstream failsafe. + CHROMIUM_FLAGS="--user-data-dir=${XDG_CONFIG_HOME:-${HOME}/.config}/chromium + ${CHROMIUM_FLAGS}" +fi + +# No matter what, pass `--no-sandbox` +CHROMIUM_FLAGS="${CHROMIUM_FLAGS} --no-sandbox" + +# Set the .desktop file name +# export CHROME_DESKTOP="chromium.desktop" + +exec "$PROGDIR/chrome" --extra-plugin-dir=@TERMUX_PREFIX@/lib/nsbrowser/plugins ${CHROMIUM_FLAGS} "$@"