timezone/tzcode-link.diff
Marcus Meissner 6620a7ba51 Accepting request 307993 from home:leonardocf:branches:Base:System
- Fix check for empty components in absolute path
- Fix post-install script to overwrite the temporary file when
  attempting to create /etc/localtime as a hard link [bsc#928841]
- Update to 2015d [bsc#928584, bsc#928246]

OBS-URL: https://build.opensuse.org/request/show/307993
OBS-URL: https://build.opensuse.org/package/show/Base:System/timezone?expand=0&rev=160
2015-05-19 15:52:15 +00:00

55 lines
1.2 KiB
Diff

This patch is used on openSUSE versions older than 12.2.
Back then, /etc/localtime was either a hard link to a zone
file in /usr/share/zoneinfo or a copy of it.
By default, zic tries the following approaches to create
/etc/localtime:
1. Hard link
2. Symbolic link
3. File copy
This patch changes the order to:
1. Hard link
2. File copy
3. Symbolic link
Index: timezone-2015d/zic.c
===================================================================
--- timezone-2015d.orig/zic.c
+++ timezone-2015d/zic.c
@@ -734,6 +734,23 @@ relname(char const *dir, char const *bas
}
}
+static int
+copy(fromname, toname)
+const char * const fromname;
+const char * const toname;
+{
+ if (!fork()) {
+ execl("/bin/cp", "cp", fromname, toname, (char*) NULL);
+ _exit(1);
+ }
+ int s;
+ if (wait(&s) < 0)
+ return -1;
+ if (!WIFEXITED(s))
+ return -1;
+ return -WEXITSTATUS(s);
+}
+
static void
dolink(const char *const fromfield, const char *const tofield)
{
@@ -763,6 +780,8 @@ dolink(const char *const fromfield, cons
exit(EXIT_FAILURE);
result = link(fromname, toname);
+ if (result != 0)
+ result = copy(fromname, toname);
if (result != 0) {
const char *s = fromname;
const char *t;