Project

General

Profile

PathInterposer » History » Version 7

dl lud, 04/30/2021 09:16 PM
Fix markup syntax.

1 1 Denis 'GNUtoo' Carikli
h1. PathInterposer
2
3 7 dl lud
h2. Warnings
4 1 Denis 'GNUtoo' Carikli
5
This page is a work in progress, so it might contains mistakes, inaccuracies, etc.
6
7
h2. Introduction
8
9
TODO
10
11
h2. how it works
12 2 Denis 'GNUtoo' Carikli
13
During the build:
14
* The host path is saved to out/.path_interposer_origpath
15
* The host path is changed to a new one
16
* The path interposer is used to access host binaries. It uses the saved path for that.
17
18 5 Denis 'GNUtoo' Carikli
With Trisquel 8, and Replicant 11, here's an example of how the path looks like for applications being launched through the path interposer[1]:
19 2 Denis 'GNUtoo' Carikli
<pre>
20
/home/replicant/replicant-11/prebuilts/jdk/jdk11/linux-x86/bin
21
/home/replicant/replicant-11/prebuilts/jdk/jdk11/linux-x86/bin
22
/home/replicant/replicant-11/out/soong/host/linux-x86/bin
23
/home/replicant/replicant-11/out/host/linux-x86/bin
24
/home/replicant/replicant-11/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin
25
/home/replicant/replicant-11/development/scripts
26
/home/replicant/replicant-11/prebuilts/devtools/tools
27
/home/replicant/replicant-11/external/selinux/prebuilts/bin
28
/home/replicant/replicant-11/prebuilts/misc/linux-x86/dtc
29
/home/replicant/replicant-11/prebuilts/misc/linux-x86/libufdt
30
/home/replicant/replicant-11/prebuilts/clang/host/linux-x86/llvm-binutils-stable
31
/home/replicant/replicant-11/prebuilts/android-emulator/linux-x86_64
32
/home/replicant/replicant-11/prebuilts/asuite/acloud/linux-x86
33
/home/replicant/replicant-11/prebuilts/asuite/aidegen/linux-x86
34
/home/replicant/replicant-11/prebuilts/asuite/atest/linux-x86
35
/home/replicant/bin
36
/home/replicant/.local/bin
37
/usr/local/sbin
38
/usr/local/bin
39
/usr/sbin
40
/usr/bin
41
/sbin
42
/bin
43
/usr/games
44
</pre>
45
46 6 Denis 'GNUtoo' Carikli
Here we can deduce that the paths set by the Android build system take precedence over the host paths.
47 2 Denis 'GNUtoo' Carikli
48
fn1. This has been deduced by prints with the following patch:
49
<pre>
50
--- a/cmd/path_interposer/main.go
51
+++ b/cmd/path_interposer/main.go
52
@@ -116,6 +116,10 @@ func Main(stdout, stderr io.Writer, interposer string, args []string, opts mainO
53
                return 1, fmt.Errorf("Failed to set PATH env: %v", err)
54
        }
55
 
56
+       fmt.Fprintln(os.Stderr, "####################################")
57
+       fmt.Fprintln(os.Stderr, os.Getenv("PATH"))
58
+       fmt.Fprintln(os.Stderr, "####################################")
59
+
60
        if config := opts.config(base); config.Log || config.Error {
61
                var procs []paths.LogProcess
62
                if opts.lookupParents != nil {
63
</pre>
64
65
h2. Launching host binaries without touching the prebuilts
66
67
In Replicant 10, we could use out/.path/python3 as python3 interpreter assuming that we enabled it in build/soong/ui/build/paths/config.go
68
69
for instance in the Mesa (external/mesa3d) Android.mk we had:
70
<pre>
71
MESA_PYTHON2 := out/.path/python2
72
MESA_PYTHON3 := out/.path/python3
73
</pre>
74 3 Denis 'GNUtoo' Carikli
75
This worked because 'python2' and 'python3' were only available in the host path:
76
<pre>
77
$ for path in $(echo /home/replicant/replicant-10/prebuilts/jdk/jdk9/linux-x86/bin:/home/replicant/replicant-10/prebuilts/jdk/jdk9/linux-x86/bin:/home/replicant/replicant-10/out/soong/host/linux-x86/bin:/home/replicant/replicant-10/out/host/linux-x86/bin:/home/replicant/replicant-10/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:/home/replicant/replicant-10/development/scripts:/home/replicant/replicant-10/prebuilts/devtools/tools:/home/replicant/replicant-10/external/selinux/prebuilts/bin:/home/replicant/replicant-10/prebuilts/misc/linux-x86/dtc:/home/replicant/replicant-10/prebuilts/misc/linux-x86/libufdt:/home/replicant/replicant-10/prebuilts/android-emulator/linux-x86_64:/home/replicant/replicant-10/prebuilts/asuite/acloud/linux-x86:/home/replicant/replicant-10/prebuilts/asuite/aidegen/linux-x86:/home/replicant/replicant-10/prebuilts/asuite/atest/linux-x86:/home/replicant/bin:/home/replicant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games | sed 's#:#\n#g') ; do ls "${path}/python3" ; done
78
ls: cannot access '/home/replicant/replicant-10/prebuilts/jdk/jdk9/linux-x86/bin/python3': No such file or directory
79
ls: cannot access '/home/replicant/replicant-10/prebuilts/jdk/jdk9/linux-x86/bin/python3': No such file or directory
80
ls: cannot access '/home/replicant/replicant-10/out/soong/host/linux-x86/bin/python3': No such file or directory
81
ls: cannot access '/home/replicant/replicant-10/out/host/linux-x86/bin/python3': No such file or directory
82
ls: cannot access '/home/replicant/replicant-10/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/python3': No such file or directory
83
ls: cannot access '/home/replicant/replicant-10/development/scripts/python3': No such file or directory
84
ls: cannot access '/home/replicant/replicant-10/prebuilts/devtools/tools/python3': No such file or directory
85
ls: cannot access '/home/replicant/replicant-10/external/selinux/prebuilts/bin/python3': No such file or directory
86
ls: cannot access '/home/replicant/replicant-10/prebuilts/misc/linux-x86/dtc/python3': No such file or directory
87
ls: cannot access '/home/replicant/replicant-10/prebuilts/misc/linux-x86/libufdt/python3': No such file or directory
88
ls: cannot access '/home/replicant/replicant-10/prebuilts/android-emulator/linux-x86_64/python3': No such file or directory
89
ls: cannot access '/home/replicant/replicant-10/prebuilts/asuite/acloud/linux-x86/python3': No such file or directory
90
ls: cannot access '/home/replicant/replicant-10/prebuilts/asuite/aidegen/linux-x86/python3': No such file or directory
91
ls: cannot access '/home/replicant/replicant-10/prebuilts/asuite/atest/linux-x86/python3': No such file or directory
92
ls: cannot access '/home/replicant/bin/python3': No such file or directory
93
ls: cannot access '/home/replicant/.local/bin/python3': No such file or directory
94
ls: cannot access '/usr/local/sbin/python3': No such file or directory
95
ls: cannot access '/usr/local/bin/python3': No such file or directory
96
ls: cannot access '/usr/sbin/python3': No such file or directory
97
/usr/bin/python3
98
ls: cannot access '/sbin/python3': No such file or directory
99
ls: cannot access '/bin/python3': No such file or directory
100
ls: cannot access '/usr/games/python3': No such file or directory
101
</pre>
102 4 Denis 'GNUtoo' Carikli
103
For instance @prebuilts/python/linux-x86/2.7.5/bin/python@ wasn't in the path.