-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
build.sh
119 lines (101 loc) · 3.81 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
TERMUX_PKG_HOMEPAGE=https://www.mozilla.org/firefox
TERMUX_PKG_DESCRIPTION="Mozilla Firefox web browser"
TERMUX_PKG_LICENSE="MPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="121.0.1"
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://ftp.mozilla.org/pub/firefox/releases/${TERMUX_PKG_VERSION}/source/firefox-${TERMUX_PKG_VERSION}.source.tar.xz
TERMUX_PKG_SHA256=b3a4216e01eaeb9a7c6ef4659d8dcd956fbd90a78a8279ee3a598881e63e49ce
# ffmpeg and pulseaudio are dependencies through dlopen(3):
TERMUX_PKG_DEPENDS="ffmpeg, fontconfig, freetype, gdk-pixbuf, glib, gtk3, libandroid-shmem, libc++, libcairo, libevent, libffi, libice, libicu, libjpeg-turbo, libnspr, libnss, libpixman, libsm, libvpx, libwebp, libx11, libxcb, libxcomposite, libxdamage, libxext, libxfixes, libxrandr, libxtst, pango, pulseaudio, zlib"
TERMUX_PKG_BUILD_DEPENDS="binutils-cross, libcpufeatures, libice, libsm"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_AUTO_UPDATE=true
termux_pkg_auto_update() {
# https://archive.mozilla.org/pub/firefox/releases/latest/README.txt
local e=0
local api_url="https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"
local api_url_r=$(curl -s "${api_url}")
local latest_version=$(echo "${api_url_r}" | sed -nE "s/.*firefox-(.*).tar.bz2.*/\1/p")
[[ -z "${api_url_r}" ]] && e=1
[[ -z "${latest_version}" ]] && e=1
local uptime_now=$(cat /proc/uptime)
local uptime_s="${uptime_now//.*}"
local uptime_h_limit=2
local uptime_s_limit=$((uptime_h_limit*60*60))
[[ -z "${uptime_s}" ]] && e=1
[[ "${uptime_s}" == 0 ]] && e=1
[[ "${uptime_s}" -gt "${uptime_s_limit}" ]] && e=1
if [[ "${e}" != 0 ]]; then
cat <<- EOL >&2
WARN: Auto update failure!
api_url_r=${api_url_r}
latest_version=${latest_version}
uptime_now=${uptime_now}
uptime_s=${uptime_s}
uptime_s_limit=${uptime_s_limit}
EOL
return
fi
termux_pkg_upgrade_version "${latest_version}"
}
termux_step_post_get_source() {
local f="media/ffvpx/config_unix_aarch64.h"
echo "Applying sed substitution to ${f}"
sed -E '/^#define (CONFIG_LINUX_PERF|HAVE_SYSCTL) /s/1$/0/' -i ${f}
}
termux_step_pre_configure() {
termux_setup_nodejs
termux_setup_rust
# https://github.com/rust-lang/rust/issues/49853
# https://github.com/rust-lang/rust/issues/45854
# Out of memory when building gkrust
# CI shows (signal: 9, SIGKILL: kill)
if [ "$TERMUX_DEBUG_BUILD" = false ]; then
case "${TERMUX_ARCH}" in
aarch64|arm|i686|x86_64) RUSTFLAGS+=" -C debuginfo=1" ;;
esac
fi
cargo install cbindgen
export HOST_CC=$(command -v clang)
export HOST_CXX=$(command -v clang++)
# https://reviews.llvm.org/D141184
CXXFLAGS+=" -U__ANDROID__ -D_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC"
LDFLAGS+=" -landroid-shmem -llog"
if [ "$TERMUX_ARCH" = "arm" ]; then
termux_setup_no_integrated_as
# For symbol android_getCpuFeatures
LDFLAGS+=" -l:libndk_compat.a"
fi
}
termux_step_configure() {
sed \
-e "s|@TERMUX_HOST_PLATFORM@|${TERMUX_HOST_PLATFORM}|" \
-e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|" \
-e "s|@CARGO_TARGET_NAME@|${CARGO_TARGET_NAME}|" \
$TERMUX_PKG_BUILDER_DIR/mozconfig.cfg > .mozconfig
if [ "$TERMUX_DEBUG_BUILD" = true ]; then
cat >>.mozconfig - <<END
ac_add_options --enable-debug-symbols
ac_add_options --disable-install-strip
END
fi
./mach configure
}
termux_step_make() {
./mach build
./mach buildsymbols
}
termux_step_make_install() {
./mach install
install -Dm644 -t "${TERMUX_PREFIX}/share/applications" "${TERMUX_PKG_BUILDER_DIR}/firefox.desktop"
}
termux_step_post_make_install() {
# https://github.com/termux/termux-packages/issues/18429
# https://phabricator.services.mozilla.com/D181687
# Android 8.x and older not support "-z pack-relative-relocs" / DT_RELR
local r=$("${READELF}" -d "${TERMUX_PREFIX}/bin/firefox")
if [[ -n "$(echo "${r}" | grep "(RELR)")" ]]; then
termux_error_exit "DT_RELR is unsupported on Android 8.x and older\n${r}"
fi
}