Commits:
-
0693577b
by Beatriz Rizental at 2025-11-27T12:48:48+01:00
fixup! [android] Modify build system
-
fc0668a4
by Beatriz Rizental at 2025-11-27T12:48:48+01:00
fixup! TB 41878: [android] Add standalone Tor Bootstrap
-
52aa72a6
by Beatriz Rizental at 2025-11-27T12:48:48+01:00
fixup! BB 43564: Modify ./mach bootstrap for Base Browser
-
2bd95ead
by Beatriz Rizental at 2025-11-27T12:48:48+01:00
fixup! BB 43564: Modify ./mach bootstrap for Tor Browser
-
8e60c9e7
by Dan Ballard at 2025-11-27T12:48:48+01:00
fixup! [android] Modify build system
add checks for empty env vars to not override mozconfig defaults in base-browser-android
8 changed files:
Changes:
browser/config/mozconfigs/base-browser-android
| ... |
... |
@@ -11,11 +11,22 @@ ac_add_options --enable-application=mobile/android |
|
11
|
11
|
CC="clang"
|
|
12
|
12
|
CXX="clang++"
|
|
13
|
13
|
ac_add_options --enable-linker=lld
|
|
14
|
|
-ac_add_options --with-java-bin-path=$JAVA_HOME/bin
|
|
15
|
|
-ac_add_options --with-android-sdk=$ANDROID_HOME
|
|
16
|
|
-ac_add_options --with-android-ndk=$ANDROID_NDK_HOME
|
|
|
14
|
+
|
|
|
15
|
+if test -n "$ANDROID_HOME"; then
|
|
|
16
|
+ ac_add_options --with-android-sdk=$ANDROID_HOME
|
|
|
17
|
+fi
|
|
|
18
|
+
|
|
|
19
|
+if test -n "$ANDROID_NDK_HOME"; then
|
|
|
20
|
+ ac_add_options --with-android-ndk=$ANDROID_NDK_HOME
|
|
|
21
|
+fi
|
|
|
22
|
+
|
|
17
|
23
|
ac_add_options --with-android-min-sdk=21
|
|
18
|
|
-ac_add_options --with-gradle=$GRADLE_HOME/bin/gradle
|
|
|
24
|
+
|
|
|
25
|
+if test -n "$GRADLE_HOME"; then
|
|
|
26
|
+ ac_add_options --with-gradle=$GRADLE_HOME/bin/gradle
|
|
|
27
|
+fi
|
|
|
28
|
+# Otherwise (as per /mobile/android/gradle.config) a version will be downloaded by the gradle wrapper when needed
|
|
|
29
|
+# so don't use this override, and let it do it's thing
|
|
19
|
30
|
|
|
20
|
31
|
ac_add_options --enable-strip
|
|
21
|
32
|
ac_add_options --enable-install-strip
|
build/moz.configure/basebrowser-resources.configure
| ... |
... |
@@ -55,6 +55,7 @@ option( |
|
55
|
55
|
nargs=1,
|
|
56
|
56
|
default=None,
|
|
57
|
57
|
help="Path to location of fonts directory.",
|
|
|
58
|
+ when=is_desktop_build,
|
|
58
|
59
|
)
|
|
59
|
60
|
|
|
60
|
61
|
|
| ... |
... |
@@ -63,8 +64,11 @@ option( |
|
63
|
64
|
mozbuild_state_path,
|
|
64
|
65
|
bootstrap_path(
|
|
65
|
66
|
"fonts",
|
|
66
|
|
- when=depends("--with-tor-browser-fonts")(lambda x: not x) & is_desktop_build,
|
|
|
67
|
+ when=depends("--with-tor-browser-fonts", when=is_desktop_build)(
|
|
|
68
|
+ lambda x: not x
|
|
|
69
|
+ ),
|
|
67
|
70
|
),
|
|
|
71
|
+ when=is_desktop_build,
|
|
68
|
72
|
)
|
|
69
|
73
|
@checking("for tor-browser fonts directory")
|
|
70
|
74
|
@imports(_from="pathlib", _import="Path")
|
build/moz.configure/torbrowser-resources.configure
| ... |
... |
@@ -4,6 +4,7 @@ option( |
|
4
|
4
|
nargs=1,
|
|
5
|
5
|
default=None,
|
|
6
|
6
|
help="Path to location of tor-expert-bundle directory.",
|
|
|
7
|
+ when=is_desktop_build,
|
|
7
|
8
|
)
|
|
8
|
9
|
|
|
9
|
10
|
|
| ... |
... |
@@ -12,8 +13,11 @@ option( |
|
12
|
13
|
mozbuild_state_path,
|
|
13
|
14
|
bootstrap_path(
|
|
14
|
15
|
"tor-expert-bundle",
|
|
15
|
|
- when=depends("--with-tor-expert-bundle")(lambda x: not x) & is_desktop_build,
|
|
|
16
|
+ when=depends("--with-tor-expert-bundle", when=is_desktop_build)(
|
|
|
17
|
+ lambda x: not x
|
|
|
18
|
+ ),
|
|
16
|
19
|
),
|
|
|
20
|
+ when=is_desktop_build,
|
|
17
|
21
|
)
|
|
18
|
22
|
@checking("for tor-expert-bundle")
|
|
19
|
23
|
@imports(_from="pathlib", _import="Path")
|
| ... |
... |
@@ -34,4 +38,155 @@ def tor_expert_bundle(value, mozbuild_state_path, _bootstrapped): |
|
34
|
38
|
return None
|
|
35
|
39
|
|
|
36
|
40
|
|
|
37
|
|
-set_config("TOR_EXPERT_BUNDLE", tor_expert_bundle) |
|
|
41
|
+set_config("TOR_EXPERT_BUNDLE", tor_expert_bundle, when=is_desktop_build)
|
|
|
42
|
+
|
|
|
43
|
+
|
|
|
44
|
+# Android
|
|
|
45
|
+# -------------------------------------------------
|
|
|
46
|
+
|
|
|
47
|
+
|
|
|
48
|
+@depends(build_project)
|
|
|
49
|
+def is_android_build(build_project):
|
|
|
50
|
+ return build_project == "mobile/android"
|
|
|
51
|
+
|
|
|
52
|
+
|
|
|
53
|
+@imports(_from="pathlib", _import="Path")
|
|
|
54
|
+def maven_local_default():
|
|
|
55
|
+ return str(Path.home() / ".m2/repository")
|
|
|
56
|
+
|
|
|
57
|
+
|
|
|
58
|
+option(
|
|
|
59
|
+ "--with-maven-local",
|
|
|
60
|
+ nargs=1,
|
|
|
61
|
+ default=maven_local_default(),
|
|
|
62
|
+ help="Path the maven local directory. Defaults to $HOME/.m2/repository",
|
|
|
63
|
+)
|
|
|
64
|
+
|
|
|
65
|
+
|
|
|
66
|
+@depends("--with-maven-local")
|
|
|
67
|
+def maven_local(value):
|
|
|
68
|
+ if value:
|
|
|
69
|
+ return value[0]
|
|
|
70
|
+
|
|
|
71
|
+
|
|
|
72
|
+option(
|
|
|
73
|
+ "--with-tor-expert-bundle-aar",
|
|
|
74
|
+ env="TOR_EXPERT_BUNDLE_AAR",
|
|
|
75
|
+ nargs=1,
|
|
|
76
|
+ default=None,
|
|
|
77
|
+ help="Path to location of tor-expert-bundle.aar archive.",
|
|
|
78
|
+ when=is_android_build,
|
|
|
79
|
+)
|
|
|
80
|
+
|
|
|
81
|
+
|
|
|
82
|
+@depends(
|
|
|
83
|
+ "--with-tor-expert-bundle-aar",
|
|
|
84
|
+ mozbuild_state_path,
|
|
|
85
|
+ bootstrap_path(
|
|
|
86
|
+ "tor-expert-bundle-aar",
|
|
|
87
|
+ no_unpack=True,
|
|
|
88
|
+ when=depends("--with-tor-expert-bundle-aar", when=is_android_build)(
|
|
|
89
|
+ lambda x: not x
|
|
|
90
|
+ ),
|
|
|
91
|
+ ),
|
|
|
92
|
+ when=is_android_build,
|
|
|
93
|
+)
|
|
|
94
|
+@checking("for tor-expert-bundle.aar")
|
|
|
95
|
+@imports(_from="pathlib", _import="Path")
|
|
|
96
|
+def tor_expert_bundle_aar(value, mozbuild_state_path, _bootstrapped):
|
|
|
97
|
+ if value:
|
|
|
98
|
+ path = Path(value[0])
|
|
|
99
|
+ if path.suffix.lower() == ".aar":
|
|
|
100
|
+ return value[0]
|
|
|
101
|
+ else:
|
|
|
102
|
+ die("--with-tor-expert-bundle-aar must point to a AAR archive.")
|
|
|
103
|
+
|
|
|
104
|
+ bootstrapped_location = Path(mozbuild_state_path) / "tor-expert-bundle.aar"
|
|
|
105
|
+ if bootstrapped_location.is_file():
|
|
|
106
|
+ return str(bootstrapped_location)
|
|
|
107
|
+
|
|
|
108
|
+ die(
|
|
|
109
|
+ "tor-expert-bundle-aar not found. Either enable bootstrap, or provide a path with --with-tor-expert-bundle-aar."
|
|
|
110
|
+ )
|
|
|
111
|
+
|
|
|
112
|
+
|
|
|
113
|
+set_config("TOR_EXPERT_BUNDLE_AAR", tor_expert_bundle_aar)
|
|
|
114
|
+
|
|
|
115
|
+
|
|
|
116
|
+option(
|
|
|
117
|
+ "--with-application-services",
|
|
|
118
|
+ env="APPLICATION_SERVICES",
|
|
|
119
|
+ nargs=1,
|
|
|
120
|
+ default=None,
|
|
|
121
|
+ help="Path to location of application-services gradle lib.",
|
|
|
122
|
+ when=is_android_build,
|
|
|
123
|
+)
|
|
|
124
|
+
|
|
|
125
|
+
|
|
|
126
|
+@depends(
|
|
|
127
|
+ maven_local,
|
|
|
128
|
+ "--with-application-services",
|
|
|
129
|
+ mozbuild_state_path,
|
|
|
130
|
+ bootstrap_path(
|
|
|
131
|
+ "application-services",
|
|
|
132
|
+ when=depends("--with-application-services", when=is_android_build)(
|
|
|
133
|
+ lambda x: not x
|
|
|
134
|
+ ),
|
|
|
135
|
+ ),
|
|
|
136
|
+ when=is_android_build,
|
|
|
137
|
+)
|
|
|
138
|
+@checking("for application-services")
|
|
|
139
|
+@imports(_from="pathlib", _import="Path")
|
|
|
140
|
+@imports("mozbuild.tbbutils")
|
|
|
141
|
+def application_services(maven_local, value, mozbuild_state_path, _bootstrapped):
|
|
|
142
|
+ as_location = None
|
|
|
143
|
+
|
|
|
144
|
+ if value:
|
|
|
145
|
+ path = Path(value[0])
|
|
|
146
|
+ if path.is_dir():
|
|
|
147
|
+ as_location = path
|
|
|
148
|
+ else:
|
|
|
149
|
+ die("--with-application-services must point to a directory.")
|
|
|
150
|
+ else:
|
|
|
151
|
+ bootstrapped_location = Path(mozbuild_state_path) / "application-services/maven"
|
|
|
152
|
+ if bootstrapped_location.is_dir():
|
|
|
153
|
+ as_location = bootstrapped_location
|
|
|
154
|
+
|
|
|
155
|
+ if not as_location:
|
|
|
156
|
+ # application-services is not required for building.
|
|
|
157
|
+ die(
|
|
|
158
|
+ "application-services not found. Either enable bootstrap, or provide a path with --with-application-services."
|
|
|
159
|
+ )
|
|
|
160
|
+
|
|
|
161
|
+ # Symlink a-s in the maven local repository.
|
|
|
162
|
+ # Note that this _overwrites_ whatever is already in there.
|
|
|
163
|
+ mozbuild.tbbutils.symlink_tree(as_location, maven_local)
|
|
|
164
|
+ return as_location
|
|
|
165
|
+
|
|
|
166
|
+
|
|
|
167
|
+option(
|
|
|
168
|
+ "--with-nimbus-fml",
|
|
|
169
|
+ env="NIMBUS_FML",
|
|
|
170
|
+ nargs=1,
|
|
|
171
|
+ default=None,
|
|
|
172
|
+ help="Path to location of nimbus-fml executable.",
|
|
|
173
|
+ when=is_android_build,
|
|
|
174
|
+)
|
|
|
175
|
+
|
|
|
176
|
+
|
|
|
177
|
+@depends("--with-nimbus-fml", when=is_android_build)
|
|
|
178
|
+@checking("for nimbus-fml")
|
|
|
179
|
+@imports(_from="pathlib", _import="Path")
|
|
|
180
|
+def nimbus_fml(value):
|
|
|
181
|
+ if value:
|
|
|
182
|
+ path = Path(value[0])
|
|
|
183
|
+ if path.is_file():
|
|
|
184
|
+ return value[0]
|
|
|
185
|
+ else:
|
|
|
186
|
+ die("--with-nimbus-fml must point to an existing file.")
|
|
|
187
|
+
|
|
|
188
|
+ # a-s nimbus-gradle-plugin will download nimbus-fml itself if not provided.
|
|
|
189
|
+ return None
|
|
|
190
|
+
|
|
|
191
|
+
|
|
|
192
|
+set_config("NIMBUS_FML", nimbus_fml) |
mobile/android/fenix/app/build.gradle
| ... |
... |
@@ -327,13 +327,10 @@ android.applicationVariants.configureEach { variant -> |
|
327
|
327
|
def isDebugOrDCD = isDebug || isDataCollectionDisabled
|
|
328
|
328
|
def useReleaseVersioning = variant.buildType.buildConfigFields['USE_RELEASE_VERSIONING']?.value ?: false
|
|
329
|
329
|
|
|
330
|
|
- // env var NIMBUS_FML always overrides this in the tbb built patched application services
|
|
331
|
|
- // https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/blob/main/projects/application-services/offline-nimbus-fml.diff?ref_type=heads
|
|
332
|
|
- // so safe to have always set so local builds and supply their expected location as fetched by
|
|
333
|
|
- // fenix/tools/tba-fetch-deps.sh
|
|
334
|
|
- // We normalize the path because it is valid to open/build from both tb and fenix roots
|
|
335
|
|
- def normalizedTBPath = rootProject.projectDir.absolutePath.minus("mobile/android/fenix")
|
|
336
|
|
- System.setProperty("nimbusFml", normalizedTBPath + "/mobile/android/fenix/tools/nimbus-fml")
|
|
|
330
|
+ // When this is set, a-s doesn't attempt to download NIMBUS_FML.
|
|
|
331
|
+ if (gradle.mozconfig.substs.NIMBUS_FML) {
|
|
|
332
|
+ System.setProperty("nimbusFml", gradle.mozconfig.substs.NIMBUS_FML)
|
|
|
333
|
+ }
|
|
337
|
334
|
|
|
338
|
335
|
def disableTor = false
|
|
339
|
336
|
if (project.hasProperty("disableTor")) {
|
| ... |
... |
@@ -774,7 +771,7 @@ dependencies { |
|
774
|
771
|
lintChecks project(':components:tooling-lint')
|
|
775
|
772
|
|
|
776
|
773
|
// Tor Expert Bundle
|
|
777
|
|
- implementation files('tor-expert-bundle.aar')
|
|
|
774
|
+ implementation files(gradle.mozconfig.substs.TOR_EXPERT_BUNDLE_AAR)
|
|
778
|
775
|
}
|
|
779
|
776
|
|
|
780
|
777
|
protobuf {
|
mobile/android/fenix/tools/tba-fetch-deps.sh
|
1
|
1
|
#!/bin/bash
|
|
2
|
2
|
|
|
3
|
|
-if [ $# -eq 0 ]; then
|
|
4
|
|
- echo "Usage: ./tba-fetch-deps.sh --\$MODE"
|
|
5
|
|
- echo " modes:"
|
|
6
|
|
- echo " --nightly Downloads the needed assets from the nightlies build server. Use when local version matches nightly build server version."
|
|
7
|
|
- echo " --tbb PATH Harvest most recently built assets from PATH assuming it points to a tor-browser-build dir. Use when local version does NOT match nightly build server version."
|
|
8
|
|
- exit -1
|
|
9
|
|
-fi
|
|
|
3
|
+echo -e "\033[1;33mThis file is deprecated.\033[0m"
|
|
|
4
|
+echo "Run ./mach bootstrap and/or define options in your mozconfig from now on."
|
|
|
5
|
+echo "See documentation at: https://gitlab.torproject.org/tpo/applications/wiki/-/wikis/Development-Information/Firefox-Android/Building"
|
|
10
|
6
|
|
|
11
|
|
-TBB_BUILD_06="https://tb-build-06.torproject.org/~tb-builder/tor-browser-build/out"
|
|
12
|
|
-
|
|
13
|
|
-if [[ $1 == "--tbb" && -z $2 ]]; then
|
|
14
|
|
- echo "--tbb needs path to tor-browser-build dir"
|
|
15
|
|
- exit -1
|
|
16
|
|
-fi
|
|
17
|
|
-TBB_PATH=$2
|
|
18
|
|
-
|
|
19
|
|
-cd "$(dirname $(realpath "$0"))/.."
|
|
20
|
|
-
|
|
21
|
|
-if [ -z "$TOR_BROWSER_BUILD" ]; then
|
|
22
|
|
- TOR_BROWSER_BUILD=../../../../tor-browser-build
|
|
23
|
|
-fi
|
|
24
|
|
-
|
|
25
|
|
-echo "Fetching tor-expert-bundle.aar..."
|
|
26
|
|
-
|
|
27
|
|
-if [[ $1 == "--tbb" ]]; then
|
|
28
|
|
- tor_expert_bundle_aar="$(ls -1td "$TOR_BROWSER_BUILD/out/tor-expert-bundle-aar/"tor-expert-bundle-aar-* | head -1)"
|
|
29
|
|
- cp "$tor_expert_bundle_aar"/* app/
|
|
30
|
|
-else
|
|
31
|
|
- tor_expert_bundle_aar_dirname="$(curl -s $TBB_BUILD_06/tor-expert-bundle-aar/ | sed -nE 's/.*href=""> | head -n 1)"
|
|
32
|
|
- curl -o app/tor-expert-bundle.aar $TBB_BUILD_06/tor-expert-bundle-aar/$tor_expert_bundle_aar_dirname/tor-expert-bundle.aar
|
|
33
|
|
-fi
|
|
34
|
|
-
|
|
35
|
|
-if [ -z app/tor_expert_bundle.aar ]; then
|
|
36
|
|
- echo "Cannot find Tor Expert Bundle arr artifacts!"
|
|
37
|
|
- exit 2
|
|
38
|
|
-fi
|
|
39
|
|
-echo ""
|
|
40
|
|
-
|
|
41
|
|
-echo "Fetching noscript..."
|
|
42
|
|
-
|
|
43
|
|
-mkdir -p "app/src/main/assets/extensions"
|
|
44
|
|
-
|
|
45
|
|
-if [[ $1 == "--tbb" ]]; then
|
|
46
|
|
- noscript="$(find "$TOR_BROWSER_BUILD/out/browser" -name 'noscript*.xpi' -print | sort | tail -1)"
|
|
47
|
|
- cp "$noscript" "app/src/main/assets/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
|
|
48
|
|
-else
|
|
49
|
|
- noscript_fname="$(curl -s $TBB_BUILD_06/browser/ | sed -nE 's/.*href="">)"
|
|
50
|
|
- curl -o "app/src/main/assets/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi" $TBB_BUILD_06/browser/$noscript_fname
|
|
51
|
|
-fi
|
|
52
|
|
-echo ""
|
|
53
|
|
-
|
|
54
|
|
-if [ -z "$GRADLE_MAVEN_REPOSITORIES" ]; then
|
|
55
|
|
- GRADLE_MAVEN_REPOSITORIES="$HOME/.m2/repository"
|
|
56
|
|
-fi
|
|
57
|
|
-
|
|
58
|
|
-os="$(uname -s)"
|
|
59
|
|
-case "${os}" in
|
|
60
|
|
- Linux*) os=unknown-linux;;
|
|
61
|
|
- Darwin*) os=apple-darwin;;
|
|
62
|
|
- # This is not quite correct, however the only option for the nimbus-fml
|
|
63
|
|
- # build are these three... so if it's not Linux or Darwin it's very likely
|
|
64
|
|
- # we are building from Windows. I apologize in advance to all the BSD users.
|
|
65
|
|
- *) os="pc-windows";;
|
|
66
|
|
-esac
|
|
67
|
|
-
|
|
68
|
|
-arch="$(uname -m)"
|
|
69
|
|
-case "${arch}" in
|
|
70
|
|
- # Also no quite correct, but again these are the only options for nimbus-fml.
|
|
71
|
|
- aarch64) arch=aarch64;;
|
|
72
|
|
- arm64) arch=aarch64;;
|
|
73
|
|
- *) arch="x86_64";;
|
|
74
|
|
-esac
|
|
75
|
|
-
|
|
76
|
|
-if [ "$os" = "unsupported" ] || [ "$arch" = "unsupported" ]; then
|
|
77
|
|
- echo "Android builds from $os-$arch are not supported."
|
|
78
|
|
- exit 2
|
|
79
|
|
-fi
|
|
80
|
|
-
|
|
81
|
|
-echo "Fetching application-services..."
|
|
82
|
|
-
|
|
83
|
|
-if [[ $1 == "--tbb" ]]; then
|
|
84
|
|
- app_services="$(ls -1t "$TOR_BROWSER_BUILD/out/application-services/"application-services*.tar.zst | head -1)"
|
|
85
|
|
- tar -C /tmp -xf "$app_services"
|
|
86
|
|
-else
|
|
87
|
|
- app_services_fname="$(curl -s $TBB_BUILD_06/application-services/ | sed -nE 's/.*href="">)"
|
|
88
|
|
- app_services=/tmp/$app_services_fname
|
|
89
|
|
- curl -o $app_services $TBB_BUILD_06/application-services/$app_services_fname
|
|
90
|
|
- tar -C /tmp -xf "$app_services"
|
|
91
|
|
- rm "$app_services"
|
|
92
|
|
-fi
|
|
93
|
|
-mkdir -p "$GRADLE_MAVEN_REPOSITORIES/org/mozilla"
|
|
94
|
|
-if [ -d /tmp/application-services ]; then
|
|
95
|
|
- cp -r /tmp/application-services/maven/org/mozilla/* "$GRADLE_MAVEN_REPOSITORIES/org/mozilla"
|
|
96
|
|
-
|
|
97
|
|
- # Over on tor-browser-build all build tools are built for x86_64-linux.
|
|
98
|
|
- # If we are not building from that platform, we need to fetch the correct
|
|
99
|
|
- # nimbus-fml binary.
|
|
100
|
|
- #
|
|
101
|
|
- # Even though we do modify nimbus-fml in tbb, all the changes are made to
|
|
102
|
|
- # support reproducibility and are not necessary for development builds.
|
|
103
|
|
- if [ "$os" != "unknown-linux" ] || [ "$arch" != "x86_64" ]; then
|
|
104
|
|
- echo "Downloading nimbus-fml binary for $arch-$os"
|
|
105
|
|
- app_services_version=$(echo "$app_services" | grep -oE 'application-services-[0-9]+\.[0-9]+(\.[0-9]{1,2})?' | grep -oE '[0-9]+\.[0-9]+(\.[0-9]{1,2})?')
|
|
106
|
|
-
|
|
107
|
|
- curl -L -o /tmp/nimbus-fml.zip "https://archive.mozilla.org/pub/app-services/releases/$app_services_version/nimbus-fml.zip"
|
|
108
|
|
- unzip -d /tmp/nimbus-fml /tmp/nimbus-fml.zip
|
|
109
|
|
- nimbus_fml="$(find "/tmp/nimbus-fml/" -name 'nimbus-fml*' | grep "$arch-$os")"
|
|
110
|
|
- echo "Using nimbus-fml binary: $nimbus_fml"
|
|
111
|
|
- cp $nimbus_fml tools/
|
|
112
|
|
-
|
|
113
|
|
- rm -rf /tmp/nimbus-fml
|
|
114
|
|
- rm /tmp/nimbus-fml.zip
|
|
115
|
|
- else
|
|
116
|
|
- cp /tmp/application-services/nimbus-fml tools/
|
|
117
|
|
- fi
|
|
118
|
|
- chmod +x tools/nimbus-fml
|
|
119
|
|
-
|
|
120
|
|
- rm -rf /tmp/application-services
|
|
121
|
|
-else
|
|
122
|
|
- echo "Cannot find application-services artifacts!"
|
|
123
|
|
- exit 2
|
|
124
|
|
-fi |
|
|
7
|
+exit 1 |
python/mozbuild/mozbuild/backend/base.py
| ... |
... |
@@ -258,8 +258,35 @@ class BuildBackend(LoggingMixin): |
|
258
|
258
|
os.remove(dst)
|
|
259
|
259
|
os.symlink(src, dst)
|
|
260
|
260
|
else:
|
|
|
261
|
+ self.log(
|
|
|
262
|
+ logging.ERROR,
|
|
|
263
|
+ "_setup_tor_browser_environment",
|
|
|
264
|
+ {},
|
|
|
265
|
+ "Error creating symlink.",
|
|
|
266
|
+ )
|
|
261
|
267
|
return
|
|
262
|
268
|
|
|
|
269
|
+ if app == "mobile/android":
|
|
|
270
|
+ # Set up NoScript extension
|
|
|
271
|
+ # We put it in the srcdir... It will be moved to the APK in the gradle build.
|
|
|
272
|
+ if noscript_location:
|
|
|
273
|
+ noscript_target = (
|
|
|
274
|
+ Path(config.topsrcdir)
|
|
|
275
|
+ / "mobile/android/fenix/app/src/main/assets/extensions"
|
|
|
276
|
+ / noscript_target_filename
|
|
|
277
|
+ )
|
|
|
278
|
+ self.log(
|
|
|
279
|
+ logging.INFO,
|
|
|
280
|
+ "_setup_tor_browser_environment",
|
|
|
281
|
+ {
|
|
|
282
|
+ "noscript_location": noscript_location,
|
|
|
283
|
+ "noscript_target": str(noscript_target),
|
|
|
284
|
+ },
|
|
|
285
|
+ "Creating symlink for NoScript from {noscript_location} to {noscript_target}",
|
|
|
286
|
+ )
|
|
|
287
|
+
|
|
|
288
|
+ _infallible_symlink(noscript_location, noscript_target)
|
|
|
289
|
+
|
|
263
|
290
|
if app == "browser":
|
|
264
|
291
|
tbdir = Path(config.topobjdir) / "dist" / "bin"
|
|
265
|
292
|
|
python/mozbuild/mozbuild/tbbutils.py
|
|
1
|
+import os
|
|
1
|
2
|
import re
|
|
|
3
|
+from pathlib import Path
|
|
2
|
4
|
from urllib.request import Request, urlopen
|
|
3
|
5
|
|
|
4
|
6
|
|
|
|
7
|
+def symlink_tree(src_dir, target_dir):
|
|
|
8
|
+ """
|
|
|
9
|
+ Recursively mirror the directory tree from `src_dir` into `target_dir`
|
|
|
10
|
+ using symbolic links.
|
|
|
11
|
+
|
|
|
12
|
+ Equivalent to: `cp -rs src_dir/* target_dir`
|
|
|
13
|
+
|
|
|
14
|
+ Notes:
|
|
|
15
|
+ - If a file or symlink already exists in the destination, it overwritten.
|
|
|
16
|
+ - The symlinks created here use absolute paths i.e. not relocatable.
|
|
|
17
|
+ """
|
|
|
18
|
+ src = Path(src_dir)
|
|
|
19
|
+ target = Path(target_dir)
|
|
|
20
|
+
|
|
|
21
|
+ target.mkdir(parents=True, exist_ok=True)
|
|
|
22
|
+
|
|
|
23
|
+ for root, _, files in os.walk(src):
|
|
|
24
|
+ target_path = target / Path(root).relative_to(src)
|
|
|
25
|
+ target_path.mkdir(parents=True, exist_ok=True)
|
|
|
26
|
+
|
|
|
27
|
+ for file in files:
|
|
|
28
|
+ src_file = Path(root) / file
|
|
|
29
|
+ target_file = target_path / file
|
|
|
30
|
+ if target_file.exists() or target_file.is_symlink():
|
|
|
31
|
+ target_file.unlink()
|
|
|
32
|
+ os.symlink(src_file, target_file)
|
|
|
33
|
+
|
|
|
34
|
+
|
|
5
|
35
|
def list_files_http(url):
|
|
6
|
36
|
try:
|
|
7
|
37
|
req = Request(url, method="GET")
|
| ... |
... |
@@ -17,7 +47,9 @@ def list_files_http(url): |
|
17
|
47
|
if href == "../":
|
|
18
|
48
|
continue
|
|
19
|
49
|
|
|
20
|
|
- if "tor-expert-bundle" in href:
|
|
|
50
|
+ if "tor-expert-bundle-aar" in href:
|
|
|
51
|
+ href = f"{href.rstrip('/')}/tor-expert-bundle.aar"
|
|
|
52
|
+ elif "tor-expert-bundle" in href:
|
|
21
|
53
|
href = f"{href.rstrip('/')}/tor-expert-bundle.tar.gz"
|
|
22
|
54
|
|
|
23
|
55
|
links.append(href)
|
| ... |
... |
@@ -30,6 +62,8 @@ TOR_BROWSER_BUILD_ARTIFACTS = [ |
|
30
|
62
|
"noscript",
|
|
31
|
63
|
"fonts",
|
|
32
|
64
|
"tor-expert-bundle",
|
|
|
65
|
+ "tor-expert-bundle-aar",
|
|
|
66
|
+ "application-services",
|
|
33
|
67
|
]
|
|
34
|
68
|
|
|
35
|
69
|
# Mapping of artifacts from taskcluster to tor-browser-build.
|
python/mozbuild/mozbuild/test/test_tbbutils.py
|
|
1
|
+import os
|
|
|
2
|
+import shutil
|
|
|
3
|
+import tempfile
|
|
1
|
4
|
import unittest
|
|
|
5
|
+from pathlib import Path
|
|
2
|
6
|
from types import SimpleNamespace
|
|
3
|
7
|
from unittest.mock import MagicMock, patch
|
|
4
|
8
|
|
|
5
|
9
|
import mozunit
|
|
6
|
10
|
|
|
7
|
|
-from mozbuild.tbbutils import get_artifact_index, get_artifact_path, list_files_http
|
|
|
11
|
+from mozbuild.tbbutils import (
|
|
|
12
|
+ get_artifact_index,
|
|
|
13
|
+ get_artifact_path,
|
|
|
14
|
+ list_files_http,
|
|
|
15
|
+ symlink_tree,
|
|
|
16
|
+)
|
|
|
17
|
+
|
|
|
18
|
+
|
|
|
19
|
+class TestSymlinkTree(unittest.TestCase):
|
|
|
20
|
+ def _create_sample_tree(self, base: Path):
|
|
|
21
|
+ (base / "subdir").mkdir()
|
|
|
22
|
+ (base / "file1.txt").write_text("content1")
|
|
|
23
|
+ (base / "subdir" / "file2.txt").write_text("content2")
|
|
|
24
|
+
|
|
|
25
|
+ def setUp(self):
|
|
|
26
|
+ self.tmpdir = tempfile.mkdtemp()
|
|
|
27
|
+ self.src = Path(self.tmpdir) / "src"
|
|
|
28
|
+ self.dst = Path(self.tmpdir) / "dst"
|
|
|
29
|
+ self.src.mkdir()
|
|
|
30
|
+ self.dst.mkdir()
|
|
|
31
|
+
|
|
|
32
|
+ def tearDown(self):
|
|
|
33
|
+ shutil.rmtree(self.tmpdir)
|
|
|
34
|
+
|
|
|
35
|
+ def test_symlinks_created_correctly(self):
|
|
|
36
|
+ self._create_sample_tree(self.src)
|
|
|
37
|
+
|
|
|
38
|
+ symlink_tree(self.src, self.dst)
|
|
|
39
|
+
|
|
|
40
|
+ self.assertTrue((self.dst / "file1.txt").is_symlink())
|
|
|
41
|
+ self.assertTrue((self.dst / "subdir" / "file2.txt").is_symlink())
|
|
|
42
|
+
|
|
|
43
|
+ self.assertEqual(
|
|
|
44
|
+ os.readlink(self.dst / "file1.txt"),
|
|
|
45
|
+ str(self.src / "file1.txt"),
|
|
|
46
|
+ )
|
|
|
47
|
+ self.assertEqual(
|
|
|
48
|
+ os.readlink(self.dst / "subdir" / "file2.txt"),
|
|
|
49
|
+ str(self.src / "subdir" / "file2.txt"),
|
|
|
50
|
+ )
|
|
|
51
|
+
|
|
|
52
|
+ def test_overwrites_existing_files(self):
|
|
|
53
|
+ self._create_sample_tree(self.src)
|
|
|
54
|
+
|
|
|
55
|
+ # Create a conflicting file in destination
|
|
|
56
|
+ (self.dst / "file1.txt").write_text("old")
|
|
|
57
|
+
|
|
|
58
|
+ symlink_tree(self.src, self.dst)
|
|
|
59
|
+
|
|
|
60
|
+ self.assertTrue((self.dst / "file1.txt").is_symlink())
|
|
|
61
|
+ self.assertEqual(
|
|
|
62
|
+ os.readlink(self.dst / "file1.txt"),
|
|
|
63
|
+ str(self.src / "file1.txt"),
|
|
|
64
|
+ )
|
|
|
65
|
+
|
|
|
66
|
+ def test_nested_directories_are_mirrored(self):
|
|
|
67
|
+ (self.src / "a" / "b" / "c").mkdir(parents=True)
|
|
|
68
|
+ (self.src / "a" / "b" / "c" / "deep.txt").write_text("deep content")
|
|
|
69
|
+
|
|
|
70
|
+ symlink_tree(self.src, self.dst)
|
|
|
71
|
+
|
|
|
72
|
+ deep_link = self.dst / "a" / "b" / "c" / "deep.txt"
|
|
|
73
|
+ self.assertTrue(deep_link.is_symlink())
|
|
|
74
|
+ self.assertEqual(
|
|
|
75
|
+ os.readlink(deep_link),
|
|
|
76
|
+ str(self.src / "a" / "b" / "c" / "deep.txt"),
|
|
|
77
|
+ )
|
|
|
78
|
+
|
|
|
79
|
+ def test_idempotence(self):
|
|
|
80
|
+ self._create_sample_tree(self.src)
|
|
|
81
|
+
|
|
|
82
|
+ symlink_tree(self.src, self.dst)
|
|
|
83
|
+ symlink_tree(self.src, self.dst) # Run again
|
|
|
84
|
+
|
|
|
85
|
+ self.assertTrue((self.dst / "file1.txt").is_symlink())
|
|
|
86
|
+ self.assertTrue((self.dst / "subdir" / "file2.txt").is_symlink())
|
|
|
87
|
+
|
|
|
88
|
+ def test_symlinks_use_absolute_paths(self):
|
|
|
89
|
+ (self.src / "file.txt").write_text("absolute")
|
|
|
90
|
+
|
|
|
91
|
+ symlink_tree(self.src, self.dst)
|
|
|
92
|
+
|
|
|
93
|
+ link_target = os.readlink(self.dst / "file.txt")
|
|
|
94
|
+ self.assertTrue(Path(link_target).is_absolute())
|
|
|
95
|
+ self.assertEqual(Path(link_target), self.src / "file.txt")
|
|
8
|
96
|
|
|
9
|
97
|
|
|
10
|
98
|
class TestGetArtifactName(unittest.TestCase):
|
| ... |
... |
@@ -152,6 +240,7 @@ class TestListFilesHttp(unittest.TestCase): |
|
152
|
240
|
def test_tor_expert_bundle_rewrites(self, mock_urlopen):
|
|
153
|
241
|
html = """
|
|
154
|
242
|
<a href="">"tor-expert-bundle">bundle</a>
|
|
|
243
|
+ <a href="">"tor-expert-bundle-aar">bundle</a>
|
|
155
|
244
|
"""
|
|
156
|
245
|
mock_resp = MagicMock()
|
|
157
|
246
|
mock_resp.status = 200
|
| ... |
... |
@@ -163,6 +252,7 @@ class TestListFilesHttp(unittest.TestCase): |
|
163
|
252
|
result,
|
|
164
|
253
|
[
|
|
165
|
254
|
"tor-expert-bundle/tor-expert-bundle.tar.gz",
|
|
|
255
|
+ "tor-expert-bundle-aar/tor-expert-bundle.aar",
|
|
166
|
256
|
],
|
|
167
|
257
|
)
|
|
168
|
258
|
|
|