2014-09-03 22:09:53 +02:00
|
|
|
This patch is used on openSUSE 12.2 or newer. Nowadays,
|
|
|
|
/etc/localtime is by default a symbolic link to a zone
|
|
|
|
file in /usr/share/zoneinfo.
|
|
|
|
|
|
|
|
By default, zic tries the following approaches to create
|
|
|
|
/etc/localtime:
|
|
|
|
|
|
|
|
1. Hard link
|
|
|
|
2. Symbolic link
|
|
|
|
3. File copy
|
|
|
|
|
|
|
|
This patch changes the logic slightly: keep using symbolic
|
|
|
|
links if /etc/localtime is already one. If it isn't, use
|
|
|
|
the default order as listed above.
|
|
|
|
|
2014-10-24 17:32:31 +02:00
|
|
|
Index: timezone-2014i/zic.c
|
2014-03-26 15:07:41 +01:00
|
|
|
===================================================================
|
2014-10-24 17:32:31 +02:00
|
|
|
--- timezone-2014i.orig/zic.c
|
|
|
|
+++ timezone-2014i/zic.c
|
2014-09-03 22:09:53 +02:00
|
|
|
@@ -106,7 +106,7 @@ static int addtype(zic_t, char const *,
|
|
|
|
static void leapadd(zic_t, bool, int, int);
|
2012-10-27 14:44:04 +02:00
|
|
|
static void adjleap(void);
|
|
|
|
static void associate(void);
|
2012-08-25 23:03:54 +02:00
|
|
|
-static void dolink(const char * fromfield, const char * tofield);
|
|
|
|
+static void dolink(const char * fromfield, const char * tofield, int defaultsymlink);
|
2012-10-27 14:44:04 +02:00
|
|
|
static char ** getfields(char * buf);
|
2014-09-03 22:09:53 +02:00
|
|
|
static zic_t gethms(const char * string, const char * errstring,
|
|
|
|
bool);
|
|
|
|
@@ -608,7 +608,7 @@ _("%s: More than one -L option specified
|
2012-08-25 23:03:54 +02:00
|
|
|
*/
|
|
|
|
for (i = 0; i < nlinks; ++i) {
|
|
|
|
eat(links[i].l_filename, links[i].l_linenum);
|
|
|
|
- dolink(links[i].l_from, links[i].l_to);
|
2014-09-03 22:09:53 +02:00
|
|
|
+ dolink(links[i].l_from, links[i].l_to, false);
|
2012-08-25 23:03:54 +02:00
|
|
|
if (noise)
|
|
|
|
for (j = 0; j < nlinks; ++j)
|
|
|
|
if (strcmp(links[i].l_to,
|
2014-09-03 22:09:53 +02:00
|
|
|
@@ -617,11 +617,11 @@ _("%s: More than one -L option specified
|
2012-08-25 23:03:54 +02:00
|
|
|
}
|
|
|
|
if (lcltime != NULL) {
|
2014-09-03 22:09:53 +02:00
|
|
|
eat(_("command line"), 1);
|
2012-08-25 23:03:54 +02:00
|
|
|
- dolink(lcltime, TZDEFAULT);
|
2014-09-03 22:09:53 +02:00
|
|
|
+ dolink(lcltime, TZDEFAULT, true);
|
2012-08-25 23:03:54 +02:00
|
|
|
}
|
|
|
|
if (psxrules != NULL) {
|
2014-09-03 22:09:53 +02:00
|
|
|
eat(_("command line"), 1);
|
2012-08-25 23:03:54 +02:00
|
|
|
- dolink(psxrules, TZDEFRULES);
|
2014-09-03 22:09:53 +02:00
|
|
|
+ dolink(psxrules, TZDEFRULES, false);
|
2012-08-25 23:03:54 +02:00
|
|
|
}
|
2014-09-03 22:09:53 +02:00
|
|
|
if (warnings && (ferror(stderr) || fclose(stderr) != 0))
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
@@ -687,8 +687,9 @@ namecheck(const char *name)
|
2012-08-25 23:03:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-27 14:44:04 +02:00
|
|
|
-dolink(const char *const fromfield, const char *const tofield)
|
|
|
|
+dolink(const char *const fromfield, const char *const tofield, int defaultsymlink)
|
2012-08-25 23:03:54 +02:00
|
|
|
{
|
2013-10-14 16:25:26 +02:00
|
|
|
+ struct stat st;
|
2012-08-25 23:03:54 +02:00
|
|
|
register char * fromname;
|
|
|
|
register char * toname;
|
2014-09-03 22:09:53 +02:00
|
|
|
register int fromisdir;
|
|
|
|
@@ -701,6 +702,10 @@ dolink(const char *const fromfield, cons
|
2013-10-14 16:25:26 +02:00
|
|
|
fromname = ecatalloc(fromname, "/");
|
|
|
|
fromname = ecatalloc(fromname, fromfield);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ if (lstat(fromname, &st) == 0 && S_ISLNK(st.st_mode))
|
2014-09-03 22:09:53 +02:00
|
|
|
+ defaultsymlink = true;
|
2013-10-14 16:25:26 +02:00
|
|
|
+
|
|
|
|
if (tofield[0] == '/')
|
|
|
|
toname = ecpyalloc(tofield);
|
|
|
|
else {
|
2014-09-03 22:09:53 +02:00
|
|
|
@@ -721,14 +726,15 @@ dolink(const char *const fromfield, cons
|
|
|
|
}
|
|
|
|
if (itsdir(toname) <= 0)
|
|
|
|
remove(toname);
|
|
|
|
- if (link(fromname, toname) != 0) {
|
|
|
|
+ if (defaultsymlink || link(fromname, toname) != 0) {
|
2012-08-25 23:03:54 +02:00
|
|
|
int result;
|
|
|
|
|
2014-09-03 22:09:53 +02:00
|
|
|
if (! mkdirs(toname))
|
2012-08-25 23:03:54 +02:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
- result = link(fromname, toname);
|
2013-10-02 10:08:58 +02:00
|
|
|
- if (result != 0) {
|
2014-09-03 22:09:53 +02:00
|
|
|
+ if (!defaultsymlink)
|
|
|
|
+ result = link(fromname, toname);
|
2013-10-02 10:08:58 +02:00
|
|
|
+ if ((defaultsymlink || (!defaultsymlink && result != 0))) {
|
2013-10-14 16:25:26 +02:00
|
|
|
const char *s = fromname;
|
2013-10-02 10:08:58 +02:00
|
|
|
const char *t;
|
|
|
|
register char * symlinkcontents = NULL;
|