summaryrefslogtreecommitdiff
path: root/firefox/Pkgfile
blob: 946b22ff770a680c29b00703a1d245e6a511f8a9 (plain)
    1 # Description: The Mozilla Firefox browser with Alsa support
    2 # URL: https://www.mozilla.com/firefox/
    3 # Maintainer: Danny Rawlins, crux at romster dot me
    4 # Depends on: alsa-lib autoconf-2.13 brotli cbindgen dav1d dbus-glib ffmpeg graphite2 libaom libdav1d libevent libnotify libvpx libwebp libxkbcommon lld nodejs nss unzip wasi-libc++ xorg-libxcomposite xorg-libxcursor xorg-libxinerama xorg-libxt zip
    5 # Optional: sccache jack
    6 
    7 name=firefox
    8 version=104.0.2
    9 release=1
   10 source=(https://archive.mozilla.org/pub/firefox/releases/$version/source/$name-$version.source.tar.xz
   11 	firefox.desktop
   12 	node-stdout-nonblocking-wrapper
   13 	0001-Don-t-use-build-id.patch
   14 	0002-Fortify-sources-properly.patch
   15 	0003-Check-additional-plugins-dir.patch
   16 	0004-bmo-847568-Support-system-harfbuzz.patch
   17 	0005-bmo-847568-Support-system-graphite2.patch
   18 	0006-bmo-1559213-Support-system-av1.patch
   19 	0007-bmo-878089-Don-t-fail-when-TERM-is-not-set.patch
   20 	0008-bmo-1516803-Fix-building-sandbox.patch
   21 	0009-musl-Add-alternate-name-for-private-siginfo-struct-m.patch
   22 	0010-musl-Fix-syscall-wrappers.patch
   23 	0011-musl-Only-use-system-heap-reporter-with-glibc.patch
   24 	0012-musl-Set-pthread-name-for-non-glibc-systems.patch
   25 	0013-musl-getcontext-is-only-avaliable-on-glibc-systems.patch
   26 	0014-musl-sys-auvx.h-avaliable-on-more-then-just-glibc-sy.patch
   27 	0015-musl-make-SYS_fork-non-fatal-musl-uses-it-for-fork-2.patch
   28 	0016-musl-include-net-if.h-before-linux-if.h-to-avoid-red.patch
   29 	0017-Make-PGO-use-toolchain.patch
   30 	0018-bmo-1516081-Disable-watchdog-during-PGO-builds.patch
   31 	0019-bmo-1516803-force-one-LTO-partition-for-sandbox-when.patch
   32 	0020-Fix-building-with-PGO-when-using-GCC.patch
   33 	0021-libaom-Use-NEON_FLAGS-instead-of-VPX_ASFLAGS-for-lib.patch
   34 	0022-build-Disable-Werror.patch
   35 	0023-LTO-Only-enable-LTO-for-Rust-when-complete-build-use.patch
   36 	0024-Enable-FLAC-on-platforms-without-ffvpx-via-ffmpeg.patch
   37 	0025-bmo-1670333-OpenH264-Fix-decoding-if-it-starts-on-no.patch
   38 	0026-bmo-1663844-OpenH264-Allow-using-OpenH264-GMP-decode.patch
   39 	0027-bgo-816975-fix-build-on-x86.patch
   40 	0028-bmo-1559213-fix-system-av1-libs.patch
   41 	0029-bmo-1196777-Set-GDK_FOCUS_CHANGE_MASK.patch
   42 	0030-bmo-1754469-memory_mozalloc_throw.patch
   43 	0031-bmo-1769631-python-3.11-compatibility.patch
   44 	0032-bmo-1773336-disable_audio_thread_priority_default_features.patch
   45 	0033-rhbz-2115253-vaapi-fixes.patch
   46 	0034-bgo-860033-firefox-wayland-no-dbus.patch
   47 	arc4random.patch
   48 	libwebrtc-screen-cast-sync-1.patch
   49 	no-ccache-stats.patch)
   50 
   51 _clear_vendor_checksums() {
   52 	sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$1/.cargo-checksum.json
   53 }
   54 
   55 build() {
   56 	cd $name-$version
   57 
   58 	for p in $SRC/*.patch; do
   59 		patch -p1 -i $p
   60 	done
   61 
   62 	_clear_vendor_checksums audioipc
   63 	_clear_vendor_checksums audioipc-client
   64 	_clear_vendor_checksums audioipc-server
   65 
   66 	if [ "$(/usr/bin/python3 -c "import sys; print(sys.stdout.encoding)")" != 'utf-8' ]; then
   67 		printf "\e[031mError: set an UTF-8 locale to compile this!\033[0m\n"
   68 		exit 1
   69 	fi
   70 
   71 	if [ -e '/usr/bin/ccache' ]; then
   72 		export OS_CCACHE_COMPILERCHECK="$(/usr/bin/clang -dumpversion | sed -z 's/\n/ /g'; crux | cut -d' ' -f3)"
   73 		export CCACHE_COMPILERCHECK="string:$OS_CCACHE_COMPILERCHECK"
   74 		PATH=$(echo ${PATH} | awk -v RS=: -v ORS=: '/ccache/ {next} {print}' | sed 's/:*$//')
   75 	fi
   76 
   77 	prt-get isinst sccache && export RUSTC_WRAPPER='/usr/bin/sccache'
   78 	mkdir "$PKGMK_SOURCE_DIR/rust" || true
   79 	export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"
   80 
   81 cat <<- EOF > .mozconfig
   82 	export NODEJS="$SRC/node-stdout-nonblocking-wrapper"
   83 	mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/firefox-shared
   84 	unset MOZ_TELEMETRY_REPORTING
   85 	ac_add_options --prefix=/usr
   86 	ac_add_options --enable-application=browser
   87 	ac_add_options --with-system-harfbuzz
   88 	#ac_add_options --with-system-graphite2
   89 	ac_add_options --with-system-av1
   90 	ac_add_options --with-system-jpeg
   91 	ac_add_options --with-system-zlib
   92 	ac_add_options --with-system-png
   93 	ac_add_options --with-system-nspr
   94 	ac_add_options --with-system-nss
   95 	ac_add_options --with-system-libevent
   96 	ac_add_options --with-system-libvpx
   97 	ac_add_options --with-system-webp
   98 	ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
   99 	ac_add_options --enable-av1
  100 	ac_add_options --enable-system-ffi
  101 	ac_add_options --enable-system-pixman
  102 	ac_add_options --enable-optimize
  103 	ac_add_options --enable-release
  104 	ac_add_options --enable-rust-simd
  105 	ac_add_options --disable-debug-symbols
  106 	ac_add_options --enable-official-branding
  107 	ac_add_options --with-distribution-id=nu.crux
  108 	ac_add_options --enable-linker=lld
  109 	ac_add_options --enable-lto=thin
  110 	ac_add_options --disable-tests
  111 	ac_add_options --disable-debug
  112 	ac_add_options --disable-updater
  113 	ac_add_options --disable-crashreporter
  114 	ac_add_options --disable-necko-wifi
  115 	ac_add_options --disable-elf-hack
  116 EOF
  117 
  118 	# audio
  119 	prt-get isinst alsa-lib && echo 'ac_add_options --enable-alsa' >> .mozconfig || echo 'ac_add_options --disable-alsa' >> .mozconfig
  120 	prt-get isinst jack && echo 'ac_add_options --enable-jack' >> .mozconfig || echo 'ac_add_options --disable-jack' >> .mozconfig
  121 	prt-get isinst pulseaudio && echo 'ac_add_options --enable-pulseaudio' >> .mozconfig || echo 'ac_add_options --disable-pulseaudio' >> .mozconfig
  122 
  123 	prt-get isinst wayland-protocols && \
  124 		echo 'ac_add_options --enable-default-toolkit=cairo-gtk3-wayland' >> .mozconfig || \
  125 		echo 'ac_add_options --enable-default-toolkit=cairo-gtk3' >> .mozconfig
  126 
  127 	[[ -e '/usr/bin/ccache' ]] && echo 'ac_add_options --enable-ccache' >> .mozconfig
  128 
  129 	export CC=clang CXX=clang++ AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib RUSTFLAGS="-C opt-level=2 $RUSTFLAGS"
  130 	export MOZ_MAKE_FLAGS="-j ${JOBS-1}"
  131 	export MOZBUILD_STATE_PATH="$SRC"/mozbuild
  132 
  133 	# Disable notification when build system has finished
  134 	export MOZ_NOSPAM=1
  135 
  136 	# Use system's Python environment
  137 	export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS=mach
  138 	#export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
  139 	export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=pip
  140 	mkdir $SRC/bin
  141 	ln -s /usr/bin/pip3 $SRC/bin/pip
  142 	ln -s /usr/bin/python3 $SRC/bin/python
  143 	export PATH="$SRC/bin:$PATH"
  144 	
  145 	# Show flags set at the beginning
  146 	echo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}"
  147 	echo "Current CFLAGS:\t\t${CFLAGS:-no value set}"
  148 	echo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}"
  149 	echo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}"
  150 	echo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}"
  151 
  152 	# python/mach/mach/mixin/process.py fails to detect SHELL
  153 	export SHELL='/usr/bin/bash'
  154 
  155 	./mach build
  156 	#./mach build toolkit/library/rust
  157 	DESTDIR=$PKG ./mach install
  158 
  159 	install -d $PKG/usr/share/pixmaps
  160 	ln -s /usr/lib/firefox/browser/chrome/icons/default/default48.png $PKG/usr/share/pixmaps/firefox_default48.png
  161 	install -D -m 0644 $SRC/firefox.desktop $PKG/usr/share/applications/firefox.desktop
  162 	# Remove crap
  163 	rm -r $PKG/usr/lib/firefox/browser/features
  164 	rm $PKG/usr/lib/firefox/removed-files
  165 
  166 	install -d $PKG/etc/revdep.d
  167 	echo "/usr/lib/firefox" > $PKG/etc/revdep.d/firefox
  168 }

Generated by cgit