Browse code

Fixing package update pre/post/un section in SPECS Addressing review comments

Change-Id: I9d819123565f0f855043a5a7eca179623954ea97
Reviewed-on: http://photon-jenkins.eng.vmware.com/814
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Priyesh Padmavilasom <ppadmavilasom@vmware.com>
Reviewed-by: Sharath George

Kumar Kaushik authored on 2016/05/06 10:01:32
Showing 9 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Fast distributed version control system
2 2
 Name:		git
3 3
 Version:	2.8.1
4
-Release:	1%{?dist}
4
+Release:	2%{?dist}
5 5
 License:	GPLv2
6 6
 URL:		http://git-scm.com/
7 7
 Group:		System Environment/Programming
... ...
@@ -59,8 +59,12 @@ make DESTDIR=%{buildroot} install
59 59
 make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
60 60
 
61 61
 %post
62
-git config --system http.sslCAPath /etc/ssl/certs
63
-exit 0
62
+if [$1 -eq 1];then
63
+    # This is first installation.
64
+    git config --system http.sslCAPath /etc/ssl/certs
65
+    exit 0
66
+fi
67
+
64 68
 %clean
65 69
 rm -rf %{buildroot}/*
66 70
 %files
... ...
@@ -83,6 +87,8 @@ rm -rf %{buildroot}/*
83 83
 %defattr(-,root,root)
84 84
 
85 85
 %changelog
86
+*       Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 2.8.1-2
87
+-       Handling the upgrade scenario.
86 88
 *   	Fri Apr 15 2016 Anish Swaminathan <anishs@vmware.com> 2.8.1-1
87 89
 -   	Updated to version 2.8.1 
88 90
 *   	Tue Feb 23 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 2.7.1-1
... ...
@@ -10,7 +10,7 @@
10 10
 Summary:	Go 
11 11
 Name:		go
12 12
 Version:	1.4.2
13
-Release:	2%{?dist}
13
+Release:	3%{?dist}
14 14
 License:	BSD
15 15
 URL:		https://golang/org
16 16
 Group:		System Environment/Security
... ...
@@ -88,9 +88,12 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
88 88
 
89 89
 %postun
90 90
 /sbin/ldconfig
91
-rm /etc/profile.d/go-exports.sh
92
-rm -rf /opt/%{name}
93
-exit 0
91
+if[ $1 -eq 0 ]; then
92
+  #This is uninstall
93
+  rm /etc/profile.d/go-exports.sh
94
+  rm -rf /opt/%{name}
95
+  exit 0
96
+fi
94 97
 
95 98
 %clean
96 99
 rm -rf %{buildroot}/*
... ...
@@ -112,6 +115,8 @@ rm -rf %{buildroot}/*
112 112
 %{_bindir}/*
113 113
 
114 114
 %changelog
115
+*       Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 1.4.2-3
116
+-       Handling upgrade scenario pre/post/un scripts.
115 117
 *	Wed Dec 09 2015 Anish Swaminathan <anishs@vmware.com> 1.4.2-2
116 118
 -	Edit post script.
117 119
 *	Mon Aug 03 2015 Vinay Kulkarni <kulkarniv@vmware.com> 1.4.2-1
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:    The Apache HTTP Server
2 2
 Name:       httpd
3 3
 Version:    2.4.18
4
-Release:    2%{?dist}
4
+Release:    3%{?dist}
5 5
 License:    Apache License 2.0
6 6
 URL:        http://httpd.apache.org/
7 7
 Group:      Applications/System
... ...
@@ -92,39 +92,46 @@ WantedBy=multi-user.target
92 92
 EOF
93 93
 ln -s /usr/sbin/httpd %{buildroot}/usr/sbin/apache2
94 94
 ln -s /etc/httpd/conf/httpd.conf %{buildroot}/etc/httpd/httpd.conf
95
+
95 96
 %post
96 97
 /sbin/ldconfig
97
-if ! getent group apache >/dev/null; then
98
-    groupadd -g 25 apache
99
-fi
100
-if ! getent passwd apache >/dev/null; then
101
-    useradd -c "Apache Server" -d /srv/www -g apache \
102
-        -s /bin/false -u 25 apache
103
-fi
104
-
105
-if [ -h /etc/mime.types ]; then
106
-    mv /etc/mime.types /etc/mime.types.orig
98
+if [ $1 -eq 1 ]; then
99
+    # this is initial installation
100
+    if ! getent group apache >/dev/null; then
101
+        groupadd -g 25 apache
102
+    fi
103
+    if ! getent passwd apache >/dev/null; then
104
+        useradd -c "Apache Server" -d /srv/www -g apache \
105
+            -s /bin/false -u 25 apache
106
+    fi
107
+
108
+    if [ -h /etc/mime.types ]; then
109
+        mv /etc/mime.types /etc/mime.types.orig
110
+    fi
107 111
 fi
108 112
 
109 113
 ln -sf /etc/httpd/conf/mime.types /etc/mime.types
110
-/bin/systemctl enable httpd.service
114
+%systemd_post httpd.service
111 115
 
112 116
 %preun
113
-/bin/systemctl stop httpd.service
114
-/bin/systemctl disable httpd.service
117
+%systemd_preun httpd.service
115 118
 
116 119
 %postun
117 120
 /sbin/ldconfig
118
-if getent passwd apache >/dev/null; then
119
-    userdel apache
120
-fi
121
-if getent group apache >/dev/null; then
122
-    groupdel apache
123
-fi
124
-
125
-if [ -f /etc/mime.types.orig ]; then
126
-    mv /etc/mime.types.orig /etc/mime.types
121
+if [ $1 -eq 0 ]; then
122
+    # this is delete operation
123
+    if getent passwd apache >/dev/null; then
124
+        userdel apache
125
+    fi
126
+    if getent group apache >/dev/null; then
127
+        groupdel apache
128
+    fi
129
+
130
+    if [ -f /etc/mime.types.orig ]; then
131
+        mv /etc/mime.types.orig /etc/mime.types
132
+    fi
127 133
 fi
134
+%systemd_postun_with_restart httpd.service
128 135
 
129 136
 %files devel
130 137
 %defattr(-,root,root)
... ...
@@ -157,6 +164,8 @@ fi
157 157
 %{_bindir}/dbmmanage
158 158
 
159 159
 %changelog
160
+*   Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 2.4.18-3
161
+-   Adding upgrade support in pre/post/un script.
160 162
 *   Mon Mar 21 2016 Mahmoud Bassiouny <mbassiouny@vmware.com> 2.4.18-2
161 163
 -   Fixing systemd service
162 164
 *   Fri Jan 22 2016 Xiaolin Li <xiaolinl@vmware.com> 2.4.18-1
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Linux kernel packet control tool
2 2
 Name:		iptables
3 3
 Version:	1.6.0
4
-Release:	2%{?dist}
4
+Release:	3%{?dist}
5 5
 License:	GPLv2+
6 6
 URL:		http://www.netfilter.org/projects/iptables
7 7
 Group:		System Environment/Security
... ...
@@ -56,12 +56,18 @@ find %{buildroot} -name '*.la' -delete
56 56
 %{_fixperms} %{buildroot}/*
57 57
 %check
58 58
 make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
59
+
60
+%preun
61
+%systemd_preun iptables.service
62
+
59 63
 %post
60 64
 /sbin/ldconfig
61
-systemctl enable iptables.service
65
+%systemd_post iptables.service
66
+
62 67
 %postun
63 68
 /sbin/ldconfig
64
-systemctl disable iptables.service
69
+%systemd_postun_with_restart iptables.service
70
+
65 71
 %clean
66 72
 rm -rf %{buildroot}/*
67 73
 %files
... ...
@@ -79,6 +85,8 @@ rm -rf %{buildroot}/*
79 79
 %{_mandir}/man3/*
80 80
 %{_mandir}/man8/*
81 81
 %changelog
82
+*   Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 1.6.0-3
83
+-   Adding package support in pre/post/un scripts section.
82 84
 *   Thu Apr 21 2016 Divya Thaluru <dthaluru@vmware.com> 1.6.0-2
83 85
 -   Enabled iptable service. Added iptable rule to accept ssh connections by default.
84 86
 *   Fri Jan 15 2016 Xiaolin Li <xiaolinl@vmware.com> 1.6.0-1
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Irqbalance daemon
2 2
 Name:		irqbalance
3 3
 Version:	1.1.0
4
-Release:	1%{?dist}
4
+Release:	2%{?dist}
5 5
 License:	GPLv2
6 6
 URL:		https://github.com/Irqbalance/irqbalance
7 7
 Group:		System Environment/Services
... ...
@@ -29,10 +29,14 @@ make DESTDIR=%{buildroot} install
29 29
 install -D -m 0644 misc/irqbalance.env %{buildroot}/etc/sysconfig/irqbalance
30 30
 sed -i 's#/path/to/irqbalance.env#/etc/sysconfig/irqbalance#' misc/irqbalance.service
31 31
 install -D -m 0644 misc/irqbalance.service %{buildroot}%{_prefix}/lib/systemd/system/irqbalance.service
32
+
32 33
 %post
33 34
 %systemd_post %{name}.service
34 35
 %preun
35 36
 %systemd_preun %{name}.service
37
+%postun
38
+%systemd_postun_with_restart %{name}.service
39
+
36 40
 %files
37 41
 %defattr(-,root,root)
38 42
 %config(noreplace) %{_sysconfdir}/*
... ...
@@ -42,5 +46,7 @@ install -D -m 0644 misc/irqbalance.service %{buildroot}%{_prefix}/lib/systemd/sy
42 42
 %{_datadir}/*
43 43
 
44 44
 %changelog
45
+*  Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 1.1.0-2
46
+-  Adding package upgrade support.
45 47
 *  Fri Jan 15 2016 Alexey Makhalov <amakhalov@vmware.com> 1.1.0-1
46 48
 -  Initial version
... ...
@@ -4,7 +4,7 @@
4 4
 Summary:	Kubernetes cluster management
5 5
 Name:		kubernetes
6 6
 Version:	1.1.8
7
-Release:	1%{?dist}
7
+Release:	2%{?dist}
8 8
 License:	ASL 2.0
9 9
 URL:		https://github.com/GoogleCloudPlatform/kubernetes
10 10
 Source0:	https://github.com/GoogleCloudPlatform/kubernetes/releases/download/v%{version}/%{name}-v%{version}.tar.gz
... ...
@@ -65,9 +65,19 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
65 65
 rm -rf %{buildroot}/*
66 66
 
67 67
 %pre
68
-getent group kube >/dev/null || groupadd -r kube
69
-getent passwd kube >/dev/null || useradd -r -g kube -d / -s /sbin/nologin \
70
-        -c "Kubernetes user" kube
68
+if [$1 -eq 1]; then
69
+    # Initial installation.
70
+    getent group kube >/dev/null || groupadd -r kube
71
+    getent passwd kube >/dev/null || useradd -r -g kube -d / -s /sbin/nologin \
72
+            -c "Kubernetes user" kube
73
+fi
74
+
75
+%postun
76
+if [$1 -eq 0]; then
77
+    # Package deletion
78
+    userdel kube
79
+    groupdel kube 
80
+fi
71 81
 
72 82
 %files
73 83
 %defattr(-,root,root)
... ...
@@ -89,8 +99,10 @@ getent passwd kube >/dev/null || useradd -r -g kube -d / -s /sbin/nologin \
89 89
 %config(noreplace) %{_sysconfdir}/%{name}/scheduler
90 90
 
91 91
 %changelog
92
-*   Tue Feb 23 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 1.1.8-1
93
--   Upgraded to version 1.1.8
92
+*       Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 1.1.8-2
93
+-       Adding support to pre/post/un scripts for package upgrade.
94
+*       Tue Feb 23 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 1.1.8-1
95
+-       Upgraded to version 1.1.8
94 96
 *	Mon Aug 3 2015 Tom Scanlan <tscanlan@vmware.com> 1.0.2-1
95 97
 -	bump up to latest release
96 98
 *	Thu Jul 23 2015 Vinay Kulkarni <kulkarniv@vmware.com> 1.0.1-1
... ...
@@ -1,7 +1,7 @@
1 1
 Summary: Intel LLDP Agent
2 2
 Name:    lldpad
3 3
 Version: 1.0.1
4
-Release: 2%{?dist}
4
+Release: 3%{?dist}
5 5
 License: GPLv2
6 6
 URL: http://open-lldp.org/
7 7
 Source: %{name}-%{version}.tar.gz
... ...
@@ -42,13 +42,13 @@ mv %{buildroot}/%{_libdir}/systemd/system/lldpad.socket  \
42 42
 	%{buildroot}/lib/systemd/system/lldpad.socket
43 43
 
44 44
 %preun
45
-/bin/systemctl disable lldpad.socket
45
+%systemd_preun lldpad.socket
46 46
 %post
47 47
 /sbin/ldconfig
48
-/bin/systemctl enable lldpad.socket
49
-
48
+%systemd_post lldpad.socket
50 49
 %postun
51 50
 /sbin/ldconfig
51
+%systemd_postun_with_restart lldpad.socket
52 52
 
53 53
 %files
54 54
 %defattr(-,root,root)
... ...
@@ -65,9 +65,11 @@ mv %{buildroot}/%{_libdir}/systemd/system/lldpad.socket  \
65 65
 
66 66
 
67 67
 %changelog
68
+*   Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com>  1.0.1-3
69
+-   Adding support in pre/post/un scripts for upgrade.
68 70
 *   Thu Dec 10 2015 Xiaolin Li <xiaolinl@vmware.com>  1.0.1-2
69 71
 -   Add systemd to Requires and BuildRequires.
70 72
 -   The source is based on git://open-lldp.org/open-lldp commit 036e314
71 73
 -   Use systemctl to enable/disable service.
72
-*	Tue Nov 24 2015 Xiaolin Li <xiaolinl@vmware.com> 1.0.1-1
74
+*   Tue Nov 24 2015 Xiaolin Li <xiaolinl@vmware.com> 1.0.1-1
73 75
 -   Initial build.  First version
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Userland logical volume management tools 
2 2
 Name:		lvm2
3 3
 Version:	2.02.141
4
-Release:	3%{?dist}
4
+Release:	4%{?dist}
5 5
 License:	GPLv2
6 6
 Group:		System Environment/Base
7 7
 URL:		http://sources.redhat.com/dm
... ...
@@ -122,14 +122,21 @@ This package contains the dmeventd daemon for monitoring the state
122 122
 of device-mapper devices.
123 123
 
124 124
 %post -n device-mapper-event
125
-%systemd_post dm-event.socket
126
-systemctl enable dm-event.service
127
-systemctl enable dm-event.socket
128
-systemctl start dm-event.socket
129
-
125
+%systemd_post dm-event.service dm-event.socket 
126
+if [ $1 -eq 1 ];then
127
+    # This is initial installation
128
+    systemctl start dm-event.socket
129
+fi
130 130
 %preun -n device-mapper-event
131
+if [ $1 -eq 0];then
132
+    # This is erase operation
133
+    systemctl stop dm-event.socket
134
+fi
131 135
 %systemd_preun dm-event.service dm-event.socket
132 136
 
137
+%postun -n device-mapper-event
138
+%systemd_postun_with_restart dm-event.service dm-event.socket
139
+
133 140
 %package -n	device-mapper-event-libs
134 141
 Summary:	Device-mapper event daemon shared library
135 142
 License:	LGPLv2
... ...
@@ -204,14 +211,17 @@ make install_systemd_units DESTDIR=%{buildroot}
204 204
 make install_systemd_generators DESTDIR=%{buildroot}
205 205
 make install_tmpfiles_configuration DESTDIR=%{buildroot}
206 206
 cp %{SOURCE1} %{buildroot}/lib/systemd/system/lvm2-activate.service
207
+
208
+%preun
209
+%systemd_preun lvm2-lvmetad.service lvm2-monitor.service lvm2-activate.service
210
+
207 211
 %post
208 212
 /sbin/ldconfig
209
-systemctl enable lvm2-lvmetad.service
210
-systemctl enable lvm2-monitor.service
211
-systemctl enable lvm2-activate.service
213
+%systemd_post lvm2-lvmetad.service lvm2-monitor.service lvm2-activate.service
212 214
 
213 215
 %postun
214 216
 /sbin/ldconfig
217
+%systemd_postun_with_restart lvm2-lvmetad.service lvm2-monitor.service lvm2-activate.service
215 218
 
216 219
 %files	devel
217 220
 %defattr(-,root,root,-)
... ...
@@ -414,6 +424,8 @@ systemctl enable lvm2-activate.service
414 414
 /etc/lvm/profile/cache-smq.profile
415 415
 
416 416
 %changelog
417
+*   Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 2.02.141-4
418
+-   Adding upgrade support in pre/post/un scripts.
417 419
 *   Thu Jan 28 2016 Anish Swaminathan <anishs@vmware.com> 2.02.141-3 
418 420
 -   Fix post scripts for lvm
419 421
 *   Thu Jan 28 2016 Anish Swaminathan <anishs@vmware.com> 2.02.141-2 
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Programs for finding and viewing man pages
2 2
 Name:		man-db
3 3
 Version:	2.7.5
4
-Release:	1%{?dist}
4
+Release:	2%{?dist}
5 5
 License:	GPLv2+
6 6
 URL:		http://www.nongnu.org/man-db
7 7
 Group:		Applications/System
... ...
@@ -39,23 +39,31 @@ find %{buildroot}%{_libdir} -name '*.la' -delete
39 39
 %find_lang %{name} --all-name
40 40
 %check
41 41
 make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
42
+
42 43
 %pre
43
-if ! getent group man >/dev/null; then
44
-    groupadd -r man
45
-fi
46
-if ! getent passwd apache >/dev/null; then
47
-    useradd -c "man" -d /var/cache/man -g man \
48
-        -s /bin/false -M -r man
44
+if [$1 -eq 1]; then
45
+    # This is first installation
46
+    if ! getent group man >/dev/null; then
47
+        groupadd -r man
48
+    fi
49
+    if ! getent passwd apache >/dev/null; then
50
+        useradd -c "man" -d /var/cache/man -g man \
51
+            -s /bin/false -M -r man
52
+    fi
49 53
 fi
54
+
50 55
 %post -p /sbin/ldconfig
51 56
 
52
-%postun	
57
+%postun
53 58
 /sbin/ldconfig
54
-if getent passwd man >/dev/null; then
55
-    userdel man
56
-fi
57
-if getent group man >/dev/null; then
58
-    groupdel man
59
+if [$1 -eq 0];then
60
+    # This is delete operation
61
+    if getent passwd man >/dev/null; then
62
+        userdel man
63
+    fi
64
+    if getent group man >/dev/null; then
65
+        groupdel man
66
+    fi
59 67
 fi
60 68
 
61 69
 %files -f %{name}.lang
... ...
@@ -69,6 +77,8 @@ fi
69 69
 %{_mandir}/*/*
70 70
 %{_libdir}/tmpfiles.d/man-db.conf
71 71
 %changelog
72
+*       Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 2.7.5-2
73
+-       Adding support for upgrade in pre/post/un scripts.
72 74
 *       Wed Feb 24 2016 Kumar Kaushik <kaushikk@vmware.com> 2.7.5-1
73 75
 -       Updated to new version.
74 76
 *	Tue Nov 10 2015 Xiaolin Li <xiaolinl@vmware.com> 2.6.6-2