OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.3 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../chrpath/chrpath-multilib.patch
  5. # Copyright (C) 2011 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. taken from gentoo
  17. http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-admin/chrpath/files/chrpath-multilib.patch?revision=1.1&view=markup
  18. --- a/configure.ac 2004-09-19 10:28:33.000000000 +0200
  19. +++ b/configure.ac 2006-02-27 16:12:00.282066250 +0100
  20. @@ -16,6 +16,7 @@
  21. dnl Checks for programs.
  22. AC_PROG_CC
  23. AC_PROG_INSTALL
  24. +AC_PROG_LIBTOOL
  25. dnl Checks for libraries.
  26. @@ -26,7 +27,6 @@
  27. dnl Checks for typedefs, structures, and compiler characteristics.
  28. AC_C_CONST
  29. AC_C_BIGENDIAN
  30. -AC_CHECK_SIZEOF(void *)
  31. dnl Checks for library functions.
  32. AC_CHECK_FUNCS(getopt_long)
  33. --- a/Makefile.am 2004-09-19 10:29:28.000000000 +0200
  34. +++ b/Makefile.am 2006-02-27 16:57:31.166290750 +0100
  35. @@ -12,12 +12,19 @@
  36. fakeroot debian/rules binary
  37. chrpath_SOURCES = \
  38. - chrpath.c \
  39. - killrpath.c \
  40. main.c \
  41. - elf.c \
  42. protos.h
  43. +chrpath_LDADD = -ldl
  44. +
  45. +lib_LTLIBRARIES = libchrpath32.la libchrpath64.la
  46. +libchrpath32_la_SOURCES = chrpath.c killrpath.c elf.c protos.h
  47. +libchrpath32_la_CFLAGS = -DSIZEOF_VOID_P=4
  48. +libchrpath32_la_LDFLAGS = -avoid-version
  49. +libchrpath64_la_SOURCES = chrpath.c killrpath.c elf.c protos.h
  50. +libchrpath64_la_CFLAGS = -DSIZEOF_VOID_P=8
  51. +libchrpath64_la_LDFLAGS = -avoid-version
  52. +
  53. EXTRA_DIST = ChangeLog.usermap $(man_MANS)
  54. CLEANFILES = *.bb *.bbg *.da *.gcov testsuite/*.bb testsuite/*.bbg
  55. --- a/main.c 2004-09-19 10:33:37.000000000 +0200
  56. +++ b/main.c 2006-02-27 17:23:39.400267750 +0100
  57. @@ -12,13 +12,19 @@
  58. # include "config.h"
  59. #endif
  60. +#include <dlfcn.h>
  61. +#include <elf.h>
  62. +#include <fcntl.h>
  63. #include <stdio.h>
  64. #include <stdlib.h>
  65. +#include <string.h>
  66. #include <unistd.h>
  67. #ifdef HAVE_GETOPT_H
  68. #include <getopt.h>
  69. #endif
  70. -#include "protos.h"
  71. +
  72. +typedef int (*killrpath_t)(const char *filename);
  73. +typedef int (*chrpath_t)(const char *filename, const char *newpath, int convert);
  74. #ifdef HAVE_GETOPT_LONG
  75. # define GETOPT_LONG getopt_long
  76. @@ -61,6 +67,30 @@
  77. printf("\n");
  78. }
  79. +static unsigned
  80. +elf_class(const char *filename)
  81. +{
  82. + Elf32_Ehdr ehdr;
  83. + int fd;
  84. +
  85. + fd = open(filename, O_RDONLY);
  86. + if (fd == -1)
  87. + return 0;
  88. + if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
  89. + {
  90. + close(fd);
  91. + return 0;
  92. + }
  93. + close(fd);
  94. + if ((memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0)
  95. + || (ehdr.e_ident[EI_VERSION] != EV_CURRENT))
  96. + {
  97. + fprintf(stderr, "`%s' probably isn't an ELF file.\n", filename);
  98. + return 0;
  99. + }
  100. + return ehdr.e_ident[EI_CLASS];
  101. +}
  102. +
  103. int
  104. main(int argc, char * const argv[])
  105. {
  106. @@ -73,6 +103,9 @@
  107. #ifdef HAVE_GETOPT_LONG
  108. int option_index = 0;
  109. #endif /* HAVE_GETOPT_LONG */
  110. + void* dll[2];
  111. + killrpath_t killrpath[2];
  112. + chrpath_t chrpath[2];
  113. if (argc < 2)
  114. {
  115. @@ -116,14 +149,31 @@
  116. }
  117. } while (-1 != opt);
  118. + dll[0] = dlopen("libchrpath32.so", RTLD_LAZY);
  119. + killrpath[0] = (killrpath_t)dlsym(dll[0], "killrpath");
  120. + chrpath[0] = (chrpath_t)dlsym(dll[0], "chrpath");
  121. +
  122. + dll[1] = dlopen("libchrpath64.so", RTLD_LAZY);
  123. + killrpath[1] = (killrpath_t)dlsym(dll[1], "killrpath");
  124. + chrpath[1] = (chrpath_t)dlsym(dll[1], "chrpath");
  125. +
  126. while (optind < argc && (!retval || keep_going))
  127. {
  128. + const char* program = argv[optind++];
  129. + unsigned eclass = elf_class(program);
  130. + if (!eclass)
  131. + {
  132. + retval = 1;
  133. + continue;
  134. + }
  135. if (remove)
  136. - retval |= killrpath(argv[optind++]);
  137. + retval |= killrpath[eclass - ELFCLASS32](program);
  138. else
  139. /* list by default, replace if path is set */
  140. - retval |= chrpath(argv[optind++], newpath, convert);
  141. + retval |= chrpath[eclass - ELFCLASS32](program, newpath, convert);
  142. }
  143. + dlclose(dll[0]);
  144. + dlclose(dll[1]);
  145. return retval;
  146. }