1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="ch-system-multiarch-wrapper" role="wrap">
|
---|
9 | <?dbhtml filename="multiarch_wrapper.html"?>
|
---|
10 |
|
---|
11 | <title>Creating a Multiarch Wrapper</title>
|
---|
12 |
|
---|
13 | <indexterm zone="ch-system-multiarch-wrapper">
|
---|
14 | <primary sortas="a-File">Multiarch Wrapper</primary>
|
---|
15 | </indexterm>
|
---|
16 |
|
---|
17 | <sect2 role="package">
|
---|
18 | <title/>
|
---|
19 |
|
---|
20 | <para>The Multiarch Wrapper is used to wrap certain binaries that have
|
---|
21 | hardcoded paths to libraries or are architecture specific.</para>
|
---|
22 |
|
---|
23 | </sect2>
|
---|
24 |
|
---|
25 | <sect2 role="installation">
|
---|
26 | <title>Installation of The Multiarch Wrapper</title>
|
---|
27 |
|
---|
28 | <para os="a">Create the source file:</para>
|
---|
29 |
|
---|
30 | <screen os="b"><userinput>cat > multiarch_wrapper.c << "EOF"
|
---|
31 | #include <unistd.h>
|
---|
32 | #include <stdlib.h>
|
---|
33 | #include <errno.h>
|
---|
34 | #include <string.h>
|
---|
35 |
|
---|
36 | #ifndef USE_ARCH
|
---|
37 | #define USE_ARCH "64"
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | int main(int argc, char **argv)
|
---|
41 | {
|
---|
42 | char *filename;
|
---|
43 | char *use_arch;
|
---|
44 |
|
---|
45 | if(!(use_arch = getenv("USE_ARCH")))
|
---|
46 | use_arch = USE_ARCH;
|
---|
47 |
|
---|
48 | filename = (char *) malloc(strlen(argv[0]) + strlen(use_arch) + 2);
|
---|
49 | strcpy(filename, argv[0]);
|
---|
50 | strcat(filename, "-");
|
---|
51 | strcat(filename, use_arch);
|
---|
52 |
|
---|
53 | execvp(filename, argv);
|
---|
54 | perror(argv[0]);
|
---|
55 | free(filename);
|
---|
56 | }
|
---|
57 | EOF</userinput></screen>
|
---|
58 |
|
---|
59 | <para os="c">Compile and Install the Multiarch Wrapper:</para>
|
---|
60 |
|
---|
61 | <screen os="d"><userinput>gcc ${BUILD64} multiarch_wrapper.c -o /usr/bin/multiarch_wrapper</userinput></screen>
|
---|
62 |
|
---|
63 | <para os="e">This multiarch wrapper is going to be used later on in the book
|
---|
64 | with Perl. It will also be very useful outside of the base CLFS system.</para>
|
---|
65 |
|
---|
66 | <para os="f">Create a testcase:</para>
|
---|
67 |
|
---|
68 | <screen os="g"><userinput>echo 'echo "32bit Version"' > test-32
|
---|
69 | echo 'echo "64bit Version"' > test-64
|
---|
70 | chmod 755 test-32 test-64
|
---|
71 | ln -sv /usr/bin/multiarch_wrapper test</userinput></screen>
|
---|
72 |
|
---|
73 | <para os="h">Test the wrapper:</para>
|
---|
74 |
|
---|
75 | <screen os="i"><userinput>USE_ARCH=32 ./test
|
---|
76 | USE_ARCH=64 ./test</userinput></screen>
|
---|
77 |
|
---|
78 | <para os="j">The output of the above command should be:</para>
|
---|
79 |
|
---|
80 | <screen os="k" role="nodump"><userinput>32bit Version
|
---|
81 | 64bit Version</userinput></screen>
|
---|
82 |
|
---|
83 | </sect2>
|
---|
84 |
|
---|
85 | <sect2 id="contents-multiarch-wrapper" role="content">
|
---|
86 | <title>Contents of The Multiarch Wrapper</title>
|
---|
87 |
|
---|
88 | <segmentedlist>
|
---|
89 | <segtitle>Installed programs</segtitle>
|
---|
90 |
|
---|
91 | <seglistitem>
|
---|
92 | <seg>multiarch_wrapper</seg>
|
---|
93 | </seglistitem>
|
---|
94 | </segmentedlist>
|
---|
95 |
|
---|
96 | <variablelist>
|
---|
97 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
98 | <?dbfo list-presentation="list"?>
|
---|
99 | <?dbhtml list-presentation="table"?>
|
---|
100 |
|
---|
101 | <varlistentry id="multiarch_wrapper">
|
---|
102 | <term><command>multiarch_wrapper</command></term>
|
---|
103 | <listitem>
|
---|
104 | <para>Will execute a different program based on the
|
---|
105 | <envar>USE_ARCH</envar> variable. The <envar>USE_ARCH</envar>
|
---|
106 | variable will be the suffix of the executed program.</para>
|
---|
107 | <indexterm zone="ch-system-multiarch-wrapper multiarch_wrapper">
|
---|
108 | <primary sortas="b-multiarch_wrapper">multiarch_wrapper</primary>
|
---|
109 | </indexterm>
|
---|
110 | </listitem>
|
---|
111 | </varlistentry>
|
---|
112 |
|
---|
113 | </variablelist>
|
---|
114 |
|
---|
115 | </sect2>
|
---|
116 |
|
---|
117 | </sect1>
|
---|