2014-09-07 11:11:41 +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.
|
|
|
|
|
2015-09-19 06:51:57 +02:00
|
|
|
Index: timezone-2015f/zic.c
|
2014-03-27 06:11:27 +01:00
|
|
|
===================================================================
|
2015-09-19 06:51:57 +02:00
|
|
|
--- timezone-2015f.orig/zic.c
|
|
|
|
+++ timezone-2015f/zic.c
|
|
|
|
@@ -105,7 +105,7 @@ static int addtype(zic_t, char const *,
|
2014-09-07 11:11:41 +02:00
|
|
|
static void leapadd(zic_t, bool, int, int);
|
2012-10-29 20:13:44 +01:00
|
|
|
static void adjleap(void);
|
|
|
|
static void associate(void);
|
2012-08-26 11:35:33 +02:00
|
|
|
-static void dolink(const char * fromfield, const char * tofield);
|
|
|
|
+static void dolink(const char * fromfield, const char * tofield, int defaultsymlink);
|
2012-10-29 20:13:44 +01:00
|
|
|
static char ** getfields(char * buf);
|
2014-09-07 11:11:41 +02:00
|
|
|
static zic_t gethms(const char * string, const char * errstring,
|
|
|
|
bool);
|
2015-09-19 06:51:57 +02:00
|
|
|
@@ -633,7 +633,7 @@ _("%s: More than one -L option specified
|
2012-08-26 11:35:33 +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-07 11:11:41 +02:00
|
|
|
+ dolink(links[i].l_from, links[i].l_to, false);
|
2012-08-26 11:35:33 +02:00
|
|
|
if (noise)
|
|
|
|
for (j = 0; j < nlinks; ++j)
|
|
|
|
if (strcmp(links[i].l_to,
|
2015-09-19 06:51:57 +02:00
|
|
|
@@ -642,11 +642,11 @@ _("%s: More than one -L option specified
|
2012-08-26 11:35:33 +02:00
|
|
|
}
|
|
|
|
if (lcltime != NULL) {
|
2014-09-07 11:11:41 +02:00
|
|
|
eat(_("command line"), 1);
|
2012-08-26 11:35:33 +02:00
|
|
|
- dolink(lcltime, TZDEFAULT);
|
2014-09-07 11:11:41 +02:00
|
|
|
+ dolink(lcltime, TZDEFAULT, true);
|
2012-08-26 11:35:33 +02:00
|
|
|
}
|
|
|
|
if (psxrules != NULL) {
|
2014-09-07 11:11:41 +02:00
|
|
|
eat(_("command line"), 1);
|
2012-08-26 11:35:33 +02:00
|
|
|
- dolink(psxrules, TZDEFRULES);
|
2014-09-07 11:11:41 +02:00
|
|
|
+ dolink(psxrules, TZDEFRULES, false);
|
2012-08-26 11:35:33 +02:00
|
|
|
}
|
2014-09-07 11:11:41 +02:00
|
|
|
if (warnings && (ferror(stderr) || fclose(stderr) != 0))
|
|
|
|
return EXIT_FAILURE;
|
2015-09-19 06:51:57 +02:00
|
|
|
@@ -739,14 +739,17 @@ relname(char const *dir, char const *bas
|
2012-08-26 11:35:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-19 06:51:57 +02:00
|
|
|
-dolink(char const *fromfield, char const *tofield)
|
|
|
|
+dolink(char const *fromfield, char const *tofield, int defaultsymlink)
|
2012-08-26 11:35:33 +02:00
|
|
|
{
|
2013-10-23 10:14:47 +02:00
|
|
|
+ struct stat st;
|
2012-08-26 11:35:33 +02:00
|
|
|
register char * fromname;
|
|
|
|
register char * toname;
|
2014-09-07 11:11:41 +02:00
|
|
|
register int fromisdir;
|
2015-05-22 16:26:56 +02:00
|
|
|
|
|
|
|
fromname = relname(directory, fromfield);
|
|
|
|
toname = relname(directory, tofield);
|
2013-10-23 10:14:47 +02:00
|
|
|
+ if (lstat(fromname, &st) == 0 && S_ISLNK(st.st_mode))
|
2014-09-07 11:11:41 +02:00
|
|
|
+ defaultsymlink = true;
|
2015-05-22 16:26:56 +02:00
|
|
|
/*
|
|
|
|
** We get to be careful here since
|
|
|
|
** there's a fair chance of root running us.
|
2015-09-19 06:51:57 +02:00
|
|
|
@@ -760,14 +763,14 @@ dolink(char const *fromfield, char const
|
2014-09-07 11:11:41 +02:00
|
|
|
}
|
|
|
|
if (itsdir(toname) <= 0)
|
|
|
|
remove(toname);
|
|
|
|
- if (link(fromname, toname) != 0) {
|
|
|
|
+ if (defaultsymlink || link(fromname, toname) != 0) {
|
2012-08-26 11:35:33 +02:00
|
|
|
int result;
|
|
|
|
|
2014-09-07 11:11:41 +02:00
|
|
|
if (! mkdirs(toname))
|
2012-08-26 11:35:33 +02:00
|
|
|
exit(EXIT_FAILURE);
|
2015-05-22 16:26:56 +02:00
|
|
|
-
|
2012-08-26 11:35:33 +02:00
|
|
|
- result = link(fromname, toname);
|
2013-10-02 13:34:00 +02:00
|
|
|
- if (result != 0) {
|
2014-09-07 11:11:41 +02:00
|
|
|
+ if (!defaultsymlink)
|
|
|
|
+ result = link(fromname, toname);
|
2013-10-02 13:34:00 +02:00
|
|
|
+ if ((defaultsymlink || (!defaultsymlink && result != 0))) {
|
2013-10-23 10:14:47 +02:00
|
|
|
const char *s = fromname;
|
2013-10-02 13:34:00 +02:00
|
|
|
const char *t;
|
2015-05-22 16:26:56 +02:00
|
|
|
char *p;
|