r2376 - / branches/clfs-1.0/BOOK/final-system/multilib

jim at linuxfromscratch.org jim at linuxfromscratch.org
Thu Aug 31 16:48:37 PDT 2006


Author: jim
Date: 2006-08-31 17:48:36 -0600 (Thu, 31 Aug 2006)
New Revision: 2376

Added:
   branches/clfs-1.0/BOOK/final-system/multilib/multiarch_wrapper.xml
Modified:
   /
Log:
 r5479 at server (orig r2513):  jciccone | 2006-08-31 13:31:32 -0700
 Added missing file.



Property changes on: 
___________________________________________________________________
Name: svk:merge
   - b6734a72-470d-0410-b049-f317dca95413:/:2512
   + b6734a72-470d-0410-b049-f317dca95413:/:2513

Added: branches/clfs-1.0/BOOK/final-system/multilib/multiarch_wrapper.xml
===================================================================
--- branches/clfs-1.0/BOOK/final-system/multilib/multiarch_wrapper.xml	                        (rev 0)
+++ branches/clfs-1.0/BOOK/final-system/multilib/multiarch_wrapper.xml	2006-08-31 23:48:36 UTC (rev 2376)
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+  <!ENTITY % general-entities SYSTEM "../../general.ent">
+  %general-entities;
+]>
+
+<sect1 id="ch-system-multiarch-wrapper" role="wrap">
+  <?dbhtml filename="multiarch_wrapper.html"?>
+
+  <title>Creating a Muliarch Wrapper</title>
+
+  <indexterm zone="ch-system-multiarch-wrapper">
+    <primary sortas="a-File">Multiarch Wrapper</primary>
+  </indexterm>
+
+  <sect2 role="package">
+    <title/>
+
+    <para>The Multiarch Wrapper is used to wrap certain binaries that have
+    hardcoded paths to libraries or are architecture specific.</para>
+
+  </sect2>
+
+  <sect2 role="installation">
+    <title>Installation of The Multiarch Wrapper</title>
+
+    <para os="a">Create the source file:</para>
+
+<screen os="b"><userinput>cat > multiarch_wrapper.c << "EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#ifndef DEFAULT_ARCH
+# define DEFAULT_ARCH "64"
+#endif
+
+int main (int argc, char *argv[])
+{
+  char *use_arch;
+  if ((use_arch = getenv("USE_ARCH")) == NULL)
+    use_arch = DEFAULT_ARCH;
+
+  char *filename = malloc(strlen(argv[0]) + strlen(use_arch) + 2);
+  strcpy(filename, argv[0]);
+  strcat(filename, "-");
+  strcat(filename, use_arch);
+
+  int ret = execvp(filename, argv);
+  if ((ret != 0)&&(errno != 0))
+  {
+    char *errmsg = malloc(strlen(filename) + 19);
+    strcpy(errmsg, "Unable to execute ");
+    strcat(errmsg, filename);
+    perror(errmsg);
+    free(errmsg);
+  }
+
+  free(filename);
+
+  return ret;
+}
+EOF</userinput></screen>
+
+    <para os="c">Compile and Install the Multiarch Wrapper:</para>
+
+<screen os="d"><userinput>gcc ${BUILD64} multiarch_wrapper.c -o /usr/bin/multiarch_wrapper</userinput></screen>
+
+    <para os="e">This multiarch wrapper is going to be used later on in the book
+    with perl. It will also be very useful outside of the base CLFS system.</para>
+
+    <para os="f">Creating the testcase:</para>
+
+<screen os="g"><userinput>echo 'echo "32bit Version"' > test-32
+echo 'echo "64bit Version"' > test-64
+chmod 755 test-32 test-64
+ln -sv /usr/bin/multiarch_wrapper test</userinput></screen>
+
+    <para os="h">Testing the wrapper:</para>
+
+<screen os="i"><userinput>USE_ARCH=32 ./test
+USE_ARCH=64 ./test</userinput></screen>
+
+    <para os="j">The output of the above command should be:</para>
+
+<screen os="k"><userinput>32bit Version
+64bit Version</userinput></screen>
+
+  </sect2>
+
+  <sect2 id="contents-multiarch-wrapper" role="content">
+    <title>Contents of The Multiarch Wrapper</title>
+
+    <segmentedlist>
+      <segtitle>Installed programs</segtitle>
+
+      <seglistitem>
+        <seg>multiarch_wrapper</seg>
+      </seglistitem>
+    </segmentedlist>
+
+    <variablelist>
+      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
+      <?dbfo list-presentation="list"?>
+      <?dbhtml list-presentation="table"?>
+
+      <varlistentry id="multiarch_wrapper">
+        <term><command>multiarch_wrapper</command></term>
+        <listitem>
+          <para>Will execute a different program based on the
+          <envar>USE_ARCH</envar> variable. The <envar>USE_ARCH</envar>
+          variable will be the suffix of the executed program.</para>
+          <indexterm zone="ch-system-multiarch-wrapper multiarch_wrapper">
+            <primary sortas="b-multiarch_wrapper">multiarch_wrapper</primary>
+          </indexterm>
+        </listitem>
+      </varlistentry>
+
+    </variablelist>
+
+  </sect2>
+
+</sect1>




More information about the cross-lfs mailing list