summaryrefslogtreecommitdiff
path: root/firefox/Pkgfile
blob: dc71ff2deb310cbb258d3379d6dbb9e0edafe8e5 (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: aom autoconf-2.13 brotli cbindgen dav1d dbus-glib ffmpeg graphite2 libevent libnotify libvpx libwebp libxkbcommon lld nodejs nss pulseaudio unzip wasi-libc++ xorg-libxcomposite xorg-libxcursor xorg-libxinerama xorg-libxt zip
    5 # Optional: sccache jack pipewire
    6 
    7 name=firefox
    8 version=109.0
    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 	no-ccache-stats.patch)
   14 
   15 _clear_vendor_checksums() {
   16 	sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$1/.cargo-checksum.json
   17 }
   18 
   19 build() {
   20 	cd $name-$version
   21 
   22 	for p in $SRC/*.patch; do
   23 		patch -p1 -i $p
   24 	done
   25 
   26 	if [ "$(/usr/bin/python3 -c "import sys; print(sys.stdout.encoding)")" != 'utf-8' ]; then
   27 		printf "\e[031mError: set an UTF-8 locale to compile this!\033[0m\n"
   28 		exit 1
   29 	fi
   30 
   31 	if [ -e '/usr/bin/ccache' ]; then
   32 		export OS_CCACHE_COMPILERCHECK="$(/usr/bin/clang -dumpversion | sed -z 's/\n/ /g'; crux | cut -d' ' -f3)"
   33 		export CCACHE_COMPILERCHECK="string:$OS_CCACHE_COMPILERCHECK"
   34 		PATH=$(echo ${PATH} | awk -v RS=: -v ORS=: '/ccache/ {next} {print}' | sed 's/:*$//')
   35 	fi
   36 
   37 	prt-get isinst sccache && export RUSTC_WRAPPER='/usr/bin/sccache'
   38 	mkdir "$PKGMK_SOURCE_DIR/rust" || true
   39 	export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"
   40 
   41 cat <<- EOF > .mozconfig
   42 	export NODEJS="$SRC/node-stdout-nonblocking-wrapper"
   43 	mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/firefox-shared
   44 	unset MOZ_TELEMETRY_REPORTING
   45 	ac_add_options --prefix=/usr
   46 	ac_add_options --enable-application=browser
   47 	#ac_add_options --with-system-harfbuzz
   48 	#ac_add_options --with-system-graphite2
   49 	#ac_add_options --with-system-av1
   50 	ac_add_options --with-system-jpeg
   51 	ac_add_options --with-system-zlib
   52 	ac_add_options --with-system-png
   53 	ac_add_options --with-system-nspr
   54 	ac_add_options --with-system-nss
   55 	ac_add_options --with-system-libevent
   56 	ac_add_options --with-system-libvpx
   57 	ac_add_options --with-system-webp
   58 	ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
   59 	ac_add_options --enable-av1
   60 	ac_add_options --enable-system-ffi
   61 	ac_add_options --enable-system-pixman
   62 	ac_add_options --enable-optimize
   63 	ac_add_options --enable-release
   64 	ac_add_options --enable-rust-simd
   65 	ac_add_options --enable-sandbox
   66 	ac_add_options --disable-debug-symbols
   67 	ac_add_options --enable-official-branding
   68 	ac_add_options --with-distribution-id=nu.crux
   69 	ac_add_options --enable-linker=lld
   70 	ac_add_options --enable-lto=thin
   71 	ac_add_options --disable-tests
   72 	ac_add_options --disable-debug-symbols
   73 	ac_add_options --disable-updater
   74 	ac_add_options --disable-crashreporter
   75 	ac_add_options --disable-necko-wifi
   76 	ac_add_options --disable-parental-controls
   77 	ac_add_options --disable-elf-hack
   78 EOF
   79 
   80 	# audio
   81 	prt-get isinst alsa-lib && echo 'ac_add_options --enable-alsa' >> .mozconfig
   82 	prt-get isinst jack && echo 'ac_add_options --enable-jack' >> .mozconfig
   83 	prt-get isinst pulseaudio && echo 'ac_add_options --enable-pulseaudio' >> .mozconfig
   84 
   85 	prt-get isinst wayland-protocols && \
   86 		echo 'ac_add_options --enable-default-toolkit=cairo-gtk3-wayland' >> .mozconfig || \
   87 		echo 'ac_add_options --enable-default-toolkit=cairo-gtk3' >> .mozconfig
   88 
   89 	[[ -e '/usr/bin/ccache' ]] && echo 'ac_add_options --enable-ccache' >> .mozconfig
   90 
   91 	export CC=clang CXX=clang++ AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib RUSTFLAGS="-C opt-level=2 $RUSTFLAGS"
   92 	export MOZ_MAKE_FLAGS="-j ${JOBS-1}" LDFLAGS+=" -Wl,--thinlto-jobs=$((JOBS / 2))"
   93 	export MOZBUILD_STATE_PATH="$SRC"/mozbuild
   94 
   95 	# Disable notification when build system has finished
   96 	export MOZ_NOSPAM=1
   97 
   98 	# Use system's Python environment
   99 	export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS=mach
  100 	#export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
  101 	export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=pip
  102 	mkdir $SRC/bin
  103 	ln -s /usr/bin/pip3 $SRC/bin/pip
  104 	ln -s /usr/bin/python3 $SRC/bin/python
  105 	export PATH="$SRC/bin:$PATH"
  106 
  107 	# Show flags set at the beginning
  108 	echo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}"
  109 	echo "Current CFLAGS:\t\t${CFLAGS:-no value set}"
  110 	echo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}"
  111 	echo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}"
  112 	echo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}"
  113 
  114 	# python/mach/mach/mixin/process.py fails to detect SHELL
  115 	export SHELL='/usr/bin/bash'
  116 
  117 	./mach build
  118 	#./mach build toolkit/library/rust
  119 	DESTDIR=$PKG ./mach install
  120 
  121 	install -d $PKG/usr/share/pixmaps
  122 	ln -s /usr/lib/firefox/browser/chrome/icons/default/default48.png $PKG/usr/share/pixmaps/firefox_default48.png
  123 	install -D -m 0644 $SRC/firefox.desktop $PKG/usr/share/applications/firefox.desktop
  124 	# Remove crap
  125 	rm -r $PKG/usr/lib/firefox/browser/features
  126 	rm $PKG/usr/lib/firefox/removed-files
  127 
  128 	install -d $PKG/etc/revdep.d
  129 	echo "/usr/lib/firefox" > $PKG/etc/revdep.d/firefox
  130 }

Generated by cgit