Browse code

Preserve /etc/localtime symlink for tzdata upgrade scenario

Change-Id: Icf36c3ce8eab8b7384af2212457d7dabe16159e7
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1870
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George

suezzelur authored on 2016/12/15 05:44:43
Showing 1 changed files
... ...
@@ -1,19 +1,19 @@
1
-Summary:	Time zone data
2
-Name:		tzdata
3
-Version:	2016h
4
-Release:	1%{?dist}
5
-URL:		http://www.iana.org/time-zones
6
-License:	Public Domain
7
-Group:		Applications/System
8
-Vendor:		VMware, Inc.
9
-Distribution: 	Photon
10
-Source0:	http://www.iana.org//time-zones/repository/releases/%{name}%{version}.tar.gz
1
+Summary:    Time zone data
2
+Name:       tzdata
3
+Version:    2016h
4
+Release:    2%{?dist}
5
+URL:        http://www.iana.org/time-zones
6
+License:    Public Domain
7
+Group:      Applications/System
8
+Vendor:     VMware, Inc.
9
+Distribution:   Photon
10
+Source0:    http://www.iana.org//time-zones/repository/releases/%{name}%{version}.tar.gz
11 11
 %define sha1 tzdata=2a43fc1665aab340d8d6505dff9f57b270b5dda2
12
-BuildArch:	noarch
12
+BuildArch:  noarch
13 13
 %description
14 14
 Sources for time zone and daylight saving time data
15 15
 %define sha1 tzdata=0fe77c8cca50b5f20d73e9c2a5b4fadca34c1504
16
-%define blddir		%{name}-%{version}
16
+%define blddir      %{name}-%{version}
17 17
 %prep
18 18
 rm -rf %{blddir}
19 19
 install -vdm 755 %{blddir}
... ...
@@ -25,25 +25,41 @@ cd %{blddir}
25 25
 ZONEINFO=%{buildroot}%{_datarootdir}/zoneinfo
26 26
 install -vdm 755 $ZONEINFO/{posix,right}
27 27
 for tz in etcetera southamerica northamerica europe africa antarctica  \
28
-	asia australasia backward pacificnew systemv; do
29
-	zic -L /dev/null	-d $ZONEINFO		-y "sh yearistype.sh" ${tz}
30
-	zic -L /dev/null	-d $ZONEINFO/posix	-y "sh yearistype.sh" ${tz}
31
-	zic -L leapseconds	-d $ZONEINFO/right	-y "sh yearistype.sh" ${tz}
28
+    asia australasia backward pacificnew systemv; do
29
+    zic -L /dev/null    -d $ZONEINFO        -y "sh yearistype.sh" ${tz}
30
+    zic -L /dev/null    -d $ZONEINFO/posix  -y "sh yearistype.sh" ${tz}
31
+    zic -L leapseconds  -d $ZONEINFO/right  -y "sh yearistype.sh" ${tz}
32 32
 done
33 33
 cp -v zone.tab iso3166.tab $ZONEINFO
34 34
 zic -d $ZONEINFO -p America/New_York
35 35
 install -vdm 755 %{buildroot}%{_sysconfdir}
36
-ln -svf %{_datarootdir}/zoneinfo/UTC %{buildroot}%{_sysconfdir}/localtime
36
+
37
+%pretrans
38
+if [ -f %{_sysconfdir}/localtime ]; then
39
+    mv %{_sysconfdir}/localtime %{_sysconfdir}/localtime.bak
40
+fi
41
+%posttrans
42
+# Install
43
+if [ $1 -eq 1 ]; then
44
+    ln -svf %{_datarootdir}/zoneinfo/UTC %{_sysconfdir}/localtime
45
+# Upgrade
46
+else
47
+    mv %{_sysconfdir}/localtime.bak %{_sysconfdir}/localtime
48
+fi
49
+
37 50
 %files
38 51
 %defattr(-,root,root)
39
-%{_sysconfdir}/localtime
52
+%ghost %{_sysconfdir}/localtime
40 53
 %{_datadir}/*
54
+
41 55
 %changelog
42
-*   	Thu Oct 27 2016 Anish Swaminathan <anishs@vmware.com> 2016h-1
43
--   	Upgrade to 2016h
44
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2016a-2
45
--	GA - Bump release of all rpms
46
-*   	Tue Feb 23 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 2016a-1
47
--   	Upgraded to version 2016a
48
-*	Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 2013i-1
49
--	Initial build. First version
56
+*   Wed Dec 14 2016 Anish Swaminathan <anishs@vmware.com> 2016h-2
57
+-   Preserve /etc/localtime symlink over upgrade
58
+*   Thu Oct 27 2016 Anish Swaminathan <anishs@vmware.com> 2016h-1
59
+-   Upgrade to 2016h
60
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2016a-2
61
+-   GA - Bump release of all rpms
62
+*   Tue Feb 23 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 2016a-1
63
+-   Upgraded to version 2016a
64
+*   Wed Nov 5 2014 Divya Thaluru <dthaluru@vmware.com> 2013i-1
65
+-   Initial build. First version