200 lines
8.4 KiB
Bash
200 lines
8.4 KiB
Bash
# This is the recipe.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
|
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
|
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
|
|
|
# The prepare function is executed in the root of the temp directory
|
|
# This function is used for putting downloaded files to the correct location or applying patches
|
|
prepare() {
|
|
cd "$BPM_SOURCE"
|
|
|
|
# Use the --oauth2-client-id= and --oauth2-client-secret= switches for
|
|
# setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
|
|
# runtime -- this allows signing into Chromium without baked-in values
|
|
patch -Np1 -i "$BPM_WORKDIR"/use-oauth2-client-switches-as-default.patch
|
|
|
|
# Fixes from Gentoo
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-138-nodejs-version-check.patch
|
|
|
|
# Increase _FORTIFY_SOURCE level
|
|
patch -Np1 -i "$BPM_WORKDIR"/increase-fortify-level.patch
|
|
|
|
# Fix issue about missing compiler flag. Can be fixed by upgrading to LLVM 23
|
|
# clang++: error: unknown argument: '-fsanitize-ignore-for-ubsan-feature=array-bounds'
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-149-drop-unknown-clang-flag.patch
|
|
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-147-rust-1.95-bytemuck.patch
|
|
|
|
# Fixes unknown argument error
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-147-revert-clang-no-lifetime-dse-flag.patch
|
|
|
|
# https://crbug.com/456218403
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-145-fix-SYS_SECCOMP.patch
|
|
|
|
patch -Np1 -i "$BPM_WORKDIR"/ungoogled-chromium-145-build-with-wasm-rollup.patch
|
|
|
|
patch -Np1 -i "$BPM_WORKDIR"/dont_require_profiler_builtins.rlib.patch
|
|
|
|
# Chromium bundles a patched minizip with extra features.
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-149-unbundle-minizip-undo-unicode.patch
|
|
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-149-use-of-undeclared-identifier-ERROR.patch
|
|
|
|
# Fix issue about missing AR file
|
|
# Credit: https://github.com/ungoogled-software/ungoogled-chromium/pull/3837
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-150-fix-ar-unbundle.patch
|
|
|
|
# Fix issue about missing sysroot path
|
|
# Credit: https://github.com/ungoogled-software/ungoogled-chromium/pull/3837#issuecomment-4836756738
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-150-fix-sysroot-path-error.patch
|
|
|
|
# Fix issue about missing AVX functions
|
|
# Credit: https://github.com/ungoogled-software/ungoogled-chromium/pull/3837
|
|
patch -Np1 -i "$BPM_WORKDIR"/chromium-150-revert-avx-flag-change.patch
|
|
|
|
# Allow building against system libraries in official builds
|
|
sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' tools/generate_shim_headers/generate_shim_headers.py
|
|
|
|
# Link to system tools required by the build
|
|
mkdir -p third_party/node/linux/node-linux-x64/bin \
|
|
third_party/rust-toolchain/bin \
|
|
third_party/jdk/current/bin
|
|
|
|
ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
|
|
ln -s /usr/bin/rustc third_party/rust-toolchain/bin/
|
|
ln -s /usr/bin/java third_party/jdk/current/bin/
|
|
|
|
# Use system gperf binary
|
|
rm -f third_party/gperf/cipd/bin/gperf
|
|
ln -s /usr/bin/gperf third_party/gperf/cipd/bin/
|
|
|
|
local _system_libs=(
|
|
brotli
|
|
flac
|
|
fontconfig
|
|
freetype
|
|
harfbuzz
|
|
libjpeg
|
|
libwebp
|
|
libxml
|
|
libxslt
|
|
opus
|
|
zlib
|
|
)
|
|
|
|
# Remove bundled libraries for which we will use the system copies; this
|
|
# *should* do what the remove_bundled_libraries.py script does, with the
|
|
# added benefit of not having to list all the remaining libraries
|
|
local _lib
|
|
for _lib in "${_system_libs[@]//libjpeg/libjpeg_turbo}"; do
|
|
find "third_party/$_lib" -type f \
|
|
\! -path "third_party/$_lib/chromium/*" \
|
|
\! -path "third_party/$_lib/google/*" \
|
|
\! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
|
|
\! -regex '.*\.\(gn\|gni\|isolate\)' \
|
|
-delete
|
|
done
|
|
|
|
./build/linux/unbundle/replace_gn_files.py --system-libraries "${_system_libs[@]}"
|
|
|
|
# Use correct libadler lib
|
|
sed -i 's/rustc_nightly_capability = use_chromium_rust_toolchain/rustc_nightly_capability = true/' build/config/rust.gni
|
|
}
|
|
|
|
# The build function is executed in the source directory
|
|
# This function is used to compile the source code
|
|
build() {
|
|
export CC=clang CXX=clang++ AR=ar NM=nm
|
|
|
|
local _flags=(
|
|
'custom_toolchain="//build/toolchain/linux/unbundle:default"'
|
|
'host_toolchain="//build/toolchain/linux/unbundle:default"'
|
|
'is_official_build=true' # implies is_cfi=true on x86_64
|
|
'symbol_level=0' # sufficient for backtraces on x86(_64)
|
|
'treat_warnings_as_errors=false'
|
|
'fatal_linker_warnings=false'
|
|
'disable_fieldtrial_testing_config=true'
|
|
'blink_enable_generated_code_formatting=false'
|
|
'ffmpeg_branding="Chrome"'
|
|
'proprietary_codecs=true'
|
|
'rtc_use_pipewire=true'
|
|
'link_pulseaudio=true'
|
|
'use_custom_libcxx=true' # https://github.com/llvm/llvm-project/issues/61705
|
|
'use_sysroot=false'
|
|
'use_system_libffi=true'
|
|
'enable_hangout_services_extension=true'
|
|
'enable_widevine=true'
|
|
'use_qt5=false'
|
|
'use_qt6=true'
|
|
'moc_qt6_path="/usr/lib/qt6"'
|
|
'use_clang_modules=false'
|
|
'clang_base_path="/usr"'
|
|
'clang_use_chrome_plugins=false'
|
|
"clang_version=$(clang --version | grep -m1 version | sed 's/.* \([0-9]\+\).*/\1/')"
|
|
'chrome_pgo_phase=0'
|
|
'rust_sysroot_absolute="/usr"'
|
|
'rust_bindgen_root="/usr"'
|
|
"rustc_version=\"$(rustc --version | awk '{print $2 ;}')\""
|
|
)
|
|
|
|
export RUSTC_BOOTSTRAP=1
|
|
|
|
# Make builds deterministic and ignore unknown option warnings
|
|
export CFLAGS="${CFLAGS} -Wno-builtin-macro-redefined -Wno-unknown-warning-option"
|
|
export CXXFLAGS="${CXXFLAGS} -Wno-builtin-macro-redefined -Wno-unknown-warning-option"
|
|
export CPPFLAGS="${CPPFLAGS} -D__DATE__= -D__TIME__= -D__TIMESTAMP__="
|
|
|
|
gn gen out/Release --args="${_flags[*]}"
|
|
ninja -C out/Release chrome chrome_sandbox chromedriver.unstripped
|
|
}
|
|
|
|
# The package function is executed in the source directory
|
|
# This function is used to move the compiled files into the output directory
|
|
package() {
|
|
install -Dm755 out/Release/chrome "$BPM_OUTPUT"/usr/lib/chromium/chromium
|
|
install -Dm755 out/Release/chrome_crashpad_handler "$BPM_OUTPUT"/usr/lib/chromium/chrome_crashpad_handler
|
|
install -Dm755 out/Release/chromedriver.unstripped "$BPM_OUTPUT"/usr/lib/chromium/chromedriver
|
|
install -Dm755 out/Release/libEGL.so "$BPM_OUTPUT"/usr/lib/chromium/libEGL.so
|
|
install -Dm755 out/Release/libGLESv2.so "$BPM_OUTPUT"/usr/lib/chromium/libGLESv2.so
|
|
install -Dm755 out/Release/libvk_swiftshader.so "$BPM_OUTPUT"/usr/lib/chromium/libvk_swiftshader.so
|
|
install -Dm755 out/Release/libvulkan.so.1 "$BPM_OUTPUT"/usr/lib/chromium/libvulkan.so.1
|
|
install -Dm755 out/Release/vk_swiftshader_icd.json "$BPM_OUTPUT"/usr/lib/chromium/vk_swiftshader_icd.json
|
|
install -Dm755 out/Release/libqt6_shim.so "$BPM_OUTPUT"/usr/lib/chromium/libqt6_shim.so
|
|
install -Dm644 out/Release/icudtl.dat "$BPM_OUTPUT"/usr/lib/chromium/icudtl.dat
|
|
install -Dm644 out/Release/locales/*.pak -t "$BPM_OUTPUT"/usr/lib/chromium/locales/
|
|
install -Dm644 out/Release/*.bin -t "$BPM_OUTPUT"/usr/lib/chromium
|
|
install -Dm644 out/Release/*.pak -t "$BPM_OUTPUT"/usr/lib/chromium
|
|
|
|
# Install chromium launcher script
|
|
install -Dm755 "$BPM_WORKDIR"/chromium.sh "$BPM_OUTPUT"/usr/bin/chromium
|
|
|
|
# Create symbolic link to usr/bin
|
|
ln -sf /usr/lib/chromium/chromedriver "$BPM_OUTPUT"/usr/bin/chromedriver
|
|
|
|
# Install desktop icons
|
|
for size in 24 48 64 128 256; do
|
|
install -Dm644 chrome/app/theme/chromium/product_logo_${size}.png "$BPM_OUTPUT"/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png
|
|
done
|
|
for size in 16 32; do
|
|
install -Dm644 chrome/app/theme/default_100_percent/chromium/product_logo_${size}.png "$BPM_OUTPUT"/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png
|
|
done
|
|
|
|
# Install desktop file
|
|
install -Dm644 chrome/installer/linux/common/desktop.template "$BPM_OUTPUT"/usr/share/applications/chromium.desktop
|
|
|
|
# Install man page
|
|
install -Dm644 chrome/app/resources/manpage.1.in "$BPM_OUTPUT"/usr/share/man/man1/chromium.1
|
|
|
|
# Replace placeholders in desktop file and man page
|
|
sed -i \
|
|
-e 's/@@MENUNAME/Chromium/g' \
|
|
-e 's/@@PACKAGE/chromium/g' \
|
|
-e 's/@@usr_bin_symlink_name/chromium/g' \
|
|
-e 's|@@uri_scheme|x-scheme-handler/chromium;|g' \
|
|
-e 's/@@extra_desktop_entries//g' \
|
|
"$BPM_OUTPUT"/usr/share/applications/chromium.desktop \
|
|
"$BPM_OUTPUT"/usr/share/man/man1/chromium.1
|
|
|
|
# Install package license
|
|
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/chromium/LICENSE
|
|
}
|