components/coreutils/patches/stdbuf.c.patch
author Matt Keenan <matt.keenan@oracle.com>
Fri, 19 Jun 2015 09:35:02 +0100
branchs11-update
changeset 4508 d8924d870370
parent 3072 1d751f6f8e9d
child 1895 1f133713df64
child 5249 8a7aa7f8367e
permissions -rw-r--r--
PSARC 2015/172 OpenStack Ironic (OpenStack Bare Metal Provisioning Service) PSARC 2015/070 pecan - Lightweight Python web-framework PSARC 2015/071 PyCA Python Cryptography PSARC 2015/170 OpenStack client for Ironic (Bare Metal Provisioning) PSARC 2015/171 scp - python secure copy PSARC 2015/196 singledispatch - Single-dispatch generic functions for Python PSARC 2015/197 logutils - Set of handlers for standard Python logging library PSARC 2015/198 Support for enumerations in Python 2.6 and 2.7 PSARC 2015/250 paramiko - SSHv2 protocol implementation in Python 20547142 Request to integrate Ironic into userland 17502639 The Python paramiko module should be added to Userland 20172780 The Python module scp should be added to Userland 20180376 The Python module ironicclient should be added to Userland 20182588 The Python module pecan should be added to Userland 20465525 The PyCA cryptography module should be added to Userland 20904396 The Python module singledispatch should be added to Userland 20904413 The Python module logutils should be added to Userland 20917993 The Python enum34 module should be added to Userland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3072
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
Changes needed to get stdbuf to successfully preload libstdbuf.so
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
for both 32-bit and 64-bit applications. See comment in the patch
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
for more details.
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
--- coreutils-8.16/src/stdbuf.c.orig	2013-09-04 19:05:35.225857588 -0700
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
+++ coreutils-8.16/src/stdbuf.c	2013-09-04 19:11:51.945113130 -0700
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
@@ -195,37 +195,13 @@
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
      gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBEXECDIR
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
      However we want the lookup done for the exec'd command not stdbuf.
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
 
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
-     Since we don't link against libstdbuf.so add it to PKGLIBEXECDIR
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
-     rather than to LIBDIR.  */
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
-  char const *const search_path[] = {
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
-    program_path,
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
-    PKGLIBEXECDIR,
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
-    NULL
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
-  };
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
+     Since we don't link against libstdbuf.so, we need to LD_PRELOAD it.
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
+     As libstdbuf.so lives in /usr/lib and /usr/lib/64, we just use
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
+     LD_PRELOAD=libstdbuf.so, and ld.so.1 finds the right one associated
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
+     with the process class. ie. we don't use full path names for the
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
+     preload names.  */
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
 
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
-  char const *const *path = search_path;
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
-  char *libstdbuf;
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
-
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
-  while (true)
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
-    {
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
-      struct stat sb;
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
-
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
-      if (!**path)              /* system default  */
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
-        {
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
-          libstdbuf = xstrdup (LIB_NAME);
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
-          break;
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
-        }
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
-      ret = asprintf (&libstdbuf, "%s/%s", *path, LIB_NAME);
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
-      if (ret < 0)
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
-        xalloc_die ();
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
-      if (stat (libstdbuf, &sb) == 0)   /* file_exists  */
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
-        break;
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
-      free (libstdbuf);
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
-
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
-      ++path;
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
-      if ( ! *path)
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
-        error (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME));
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
-    }
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
+  char *libstdbuf = xstrdup (LIB_NAME);
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
 
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
   /* FIXME: Do we need to support libstdbuf.dll, c:, '\' separators etc?  */
1d751f6f8e9d 17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50