2 * Copyright (c) 2004, 2005 Elan Ruusamäe <glen@pld-linux.org>.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Elan Ruusamäe
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY ELAN RUUSAMÄE AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * This simple program is aimed to be used as a workaround when installing over
38 * glibc which has placed glibc.so into /lib/i686.
40 * For example, in glibc.spec:
42 * %post -p /sbin/postshell
43 * /sbin/glibc-postinst /%{_lib}/%{_host_cpu}
44 * /sbin/ldconfig /%{_lib} %{_prefix}/%{_lib}
46 * Patches and bugreports are welcome, direct them to Elan Ruusamäe
47 * <glen@pld-linux.org>.
58 #define error(msg) write(2, msg, strlen(msg))
59 #define warn(msg) write(2, msg, strlen(msg))
61 int main (int argc, char *argv[])
67 error("This program is intended to be used by glibc postinstall stage.\n");
71 for (i = 1; i < argc; i++) {
74 if (stat(path, &st) == -1) {
75 // doesn't exist. good. next please.
76 if (errno == ENOENT) {
83 if (S_ISDIR(st.st_mode)) {
85 char p[l + sizeof(".rpmsave") + 1];
88 strcpy(p + l, ".rpmsave");
89 warn("Renaming "); warn(path); warn(" to "); warn(p); warn("\n");
90 if (rename(path, p) == -1) {