/*
- * Copyright (c) 2004 Elan Ruusamäe <glen@pld-linux.org>.
+ * Copyright (c) 2004, 2005 Elan Ruusamäe <glen@pld-linux.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* For example, in glibc.spec:
*
* %post -p /sbin/postshell
- * /sbin/glibc-postrm /%{_lib}/i686
+ * /sbin/glibc-postinst /%{_lib}/%{_host_cpu}
+ * /sbin/ldconfig /%{_lib} %{_prefix}/%{_lib}
*
* Patches and bugreports are welcome, direct them to Elan Ruusamäe
* <glen@pld-linux.org>.
*/
-#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
-#include <limits.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#define error(msg) write(2, msg, strlen(msg))
+#define warn(msg) write(2, msg, strlen(msg))
+
int main (int argc, char *argv[])
{
struct stat st;
int i, rv = 0;
if (argc == 1) {
- fprintf(stderr, "This program is intended to be used by glibc postinstall stage.\n");
+ error("This program is intended to be used by glibc postinstall stage.\n");
exit(1);
}
}
if (S_ISDIR(st.st_mode)) {
- char p[strlen(path) + sizeof(".rpmsave") + 1];
+ int l = strlen(path);
+ char p[l + sizeof(".rpmsave") + 1];
- sprintf(p, "%s.rpmsave", path);
- fprintf(stderr, "Renaming %s to %s\n", path, p);
+ strcpy(p, path);
+ strcpy(p + l, ".rpmsave");
+ warn("Renaming "); warn(path); warn(" to "); warn(p); warn("\n");
if (rename(path, p) == -1) {
perror("rename");
rv = 1;
exit(rv);
}
-