1 |
hwoarang 11/08/29 19:23:22 |
2 |
|
3 |
Added: chrpath-0.13-multilib.patch |
4 |
Removed: chrpath-multilib.patch |
5 |
Log: |
6 |
revbump with improved patch for prefix. Thanks to Fabian Groffen and Mario Fetka for their help. Bug #365817 |
7 |
|
8 |
(Portage version: 2.2.0_alpha51/cvs/Linux x86_64) |
9 |
|
10 |
Revision Changes Path |
11 |
1.1 app-admin/chrpath/files/chrpath-0.13-multilib.patch |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/chrpath/files/chrpath-0.13-multilib.patch?rev=1.1&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/chrpath/files/chrpath-0.13-multilib.patch?rev=1.1&content-type=text/plain |
15 |
|
16 |
Index: chrpath-0.13-multilib.patch |
17 |
=================================================================== |
18 |
Index: chrpath-0.13/Makefile.am |
19 |
=================================================================== |
20 |
--- chrpath-0.13.orig/Makefile.am |
21 |
+++ chrpath-0.13/Makefile.am |
22 |
@@ -12,12 +12,19 @@ debs: |
23 |
fakeroot debian/rules binary |
24 |
|
25 |
chrpath_SOURCES = \ |
26 |
- chrpath.c \ |
27 |
- killrpath.c \ |
28 |
main.c \ |
29 |
- elf.c \ |
30 |
protos.h |
31 |
|
32 |
+chrpath_LDADD = $(LDLIBS) |
33 |
+ |
34 |
+lib_LTLIBRARIES = libchrpath32.la libchrpath64.la |
35 |
+libchrpath32_la_SOURCES = chrpath.c killrpath.c elf.c protos.h |
36 |
+libchrpath32_la_CFLAGS = -DSIZEOF_VOID_P=4 |
37 |
+libchrpath32_la_LDFLAGS = -avoid-version |
38 |
+libchrpath64_la_SOURCES = chrpath.c killrpath.c elf.c protos.h |
39 |
+libchrpath64_la_CFLAGS = -DSIZEOF_VOID_P=8 |
40 |
+libchrpath64_la_LDFLAGS = -avoid-version |
41 |
+ |
42 |
EXTRA_DIST = ChangeLog.usermap $(man_MANS) |
43 |
|
44 |
CLEANFILES = *.bb *.bbg *.da *.gcov testsuite/*.bb testsuite/*.bbg |
45 |
Index: chrpath-0.13/configure.ac |
46 |
=================================================================== |
47 |
--- chrpath-0.13.orig/configure.ac |
48 |
+++ chrpath-0.13/configure.ac |
49 |
@@ -16,6 +16,7 @@ CHRPATH_LDRPATH_OPTION |
50 |
dnl Checks for programs. |
51 |
AC_PROG_CC |
52 |
AC_PROG_INSTALL |
53 |
+AC_PROG_LIBTOOL |
54 |
|
55 |
dnl Checks for libraries. |
56 |
|
57 |
@@ -26,11 +27,18 @@ AC_CHECK_HEADERS([getopt.h elf.h fcntl.h |
58 |
dnl Checks for typedefs, structures, and compiler characteristics. |
59 |
AC_C_CONST |
60 |
AC_C_BIGENDIAN |
61 |
-AC_CHECK_SIZEOF(void *) |
62 |
|
63 |
dnl Checks for library functions. |
64 |
AC_CHECK_FUNCS(getopt_long) |
65 |
|
66 |
+dnl See if we need -ldl on this platform for dlopen |
67 |
+LDLIBS= |
68 |
+save_LIBS="$LIBS" |
69 |
+LIBS= |
70 |
+AC_SEARCH_LIBS([dlopen], [dl], [LDLIBS="-ldl"]) |
71 |
+LIBS="${save_LIBS}" |
72 |
+AC_SUBST([LDLIBS]) |
73 |
+ |
74 |
if eval "test x$GCC = xyes"; then |
75 |
for flag in \ |
76 |
-ansi \ |
77 |
Index: chrpath-0.13/main.c |
78 |
=================================================================== |
79 |
--- chrpath-0.13.orig/main.c |
80 |
+++ chrpath-0.13/main.c |
81 |
@@ -12,13 +12,19 @@ |
82 |
# include "config.h" |
83 |
#endif |
84 |
|
85 |
+#include <dlfcn.h> |
86 |
+#include <elf.h> |
87 |
+#include <fcntl.h> |
88 |
#include <stdio.h> |
89 |
#include <stdlib.h> |
90 |
+#include <string.h> |
91 |
#include <unistd.h> |
92 |
#ifdef HAVE_GETOPT_H |
93 |
#include <getopt.h> |
94 |
#endif |
95 |
-#include "protos.h" |
96 |
+ |
97 |
+typedef int (*killrpath_t)(const char *filename); |
98 |
+typedef int (*chrpath_t)(const char *filename, const char *newpath, int convert); |
99 |
|
100 |
#ifdef HAVE_GETOPT_LONG |
101 |
# define GETOPT_LONG getopt_long |
102 |
@@ -61,6 +67,30 @@ usage(char *progname) |
103 |
printf("\n"); |
104 |
} |
105 |
|
106 |
+static unsigned |
107 |
+elf_class(const char *filename) |
108 |
+{ |
109 |
+ Elf32_Ehdr ehdr; |
110 |
+ int fd; |
111 |
+ |
112 |
+ fd = open(filename, O_RDONLY); |
113 |
+ if (fd == -1) |
114 |
+ return 0; |
115 |
+ if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) |
116 |
+ { |
117 |
+ close(fd); |
118 |
+ return 0; |
119 |
+ } |
120 |
+ close(fd); |
121 |
+ if ((memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) |
122 |
+ || (ehdr.e_ident[EI_VERSION] != EV_CURRENT)) |
123 |
+ { |
124 |
+ fprintf(stderr, "`%s' probably isn't an ELF file.\n", filename); |
125 |
+ return 0; |
126 |
+ } |
127 |
+ return ehdr.e_ident[EI_CLASS]; |
128 |
+} |
129 |
+ |
130 |
int |
131 |
main(int argc, char * const argv[]) |
132 |
{ |
133 |
@@ -73,6 +103,9 @@ main(int argc, char * const argv[]) |
134 |
#ifdef HAVE_GETOPT_LONG |
135 |
int option_index = 0; |
136 |
#endif /* HAVE_GETOPT_LONG */ |
137 |
+ void* dll[2]; |
138 |
+ killrpath_t killrpath[2]; |
139 |
+ chrpath_t chrpath[2]; |
140 |
|
141 |
if (argc < 2) |
142 |
{ |
143 |
@@ -116,14 +149,31 @@ main(int argc, char * const argv[]) |
144 |
} |
145 |
} while (-1 != opt); |
146 |
|
147 |
+ dll[0] = dlopen("libchrpath32.so", RTLD_LAZY); |
148 |
+ killrpath[0] = (killrpath_t)dlsym(dll[0], "killrpath"); |
149 |
+ chrpath[0] = (chrpath_t)dlsym(dll[0], "chrpath"); |
150 |
+ |
151 |
+ dll[1] = dlopen("libchrpath64.so", RTLD_LAZY); |
152 |
+ killrpath[1] = (killrpath_t)dlsym(dll[1], "killrpath"); |
153 |
+ chrpath[1] = (chrpath_t)dlsym(dll[1], "chrpath"); |
154 |
+ |
155 |
while (optind < argc && (!retval || keep_going)) |
156 |
{ |
157 |
+ const char* program = argv[optind++]; |
158 |
+ unsigned eclass = elf_class(program); |
159 |
+ if (!eclass) |
160 |
+ { |
161 |
+ retval = 1; |
162 |
+ continue; |
163 |
+ } |
164 |
if (remove) |
165 |
- retval |= killrpath(argv[optind++]); |
166 |
+ retval |= killrpath[eclass - ELFCLASS32](program); |
167 |
else |
168 |
/* list by default, replace if path is set */ |
169 |
- retval |= chrpath(argv[optind++], newpath, convert); |
170 |
+ retval |= chrpath[eclass - ELFCLASS32](program, newpath, convert); |
171 |
} |
172 |
|
173 |
+ dlclose(dll[0]); |
174 |
+ dlclose(dll[1]); |
175 |
return retval; |
176 |
} |