Browse code

Fixing CLASSPATH for zookeeper service And added patch to disable cygwin detection

Change-Id: Id516ac4561c7436a2568f1261b504ba826c36c97
Reviewed-on: http://photon-jenkins.eng.vmware.com/775
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Sharath George
Reviewed-on: http://photon-jenkins.eng.vmware.com/791
Reviewed-by: suezzelur <anishs@vmware.com>

dthaluru authored on 2016/04/29 16:37:33
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,68 @@
0
+#!/usr/bin/env bash
1
+
2
+# Licensed to the Apache Software Foundation (ASF) under one or more
3
+# contributor license agreements.  See the NOTICE file distributed with
4
+# this work for additional information regarding copyright ownership.
5
+# The ASF licenses this file to You under the Apache License, Version 2.0
6
+# (the "License"); you may not use this file except in compliance with
7
+# the License.  You may obtain a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS,
13
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+# See the License for the specific language governing permissions and
15
+# limitations under the License.
16
+
17
+# This script should be sourced into other zookeeper
18
+# scripts to setup the env variables
19
+
20
+# We use ZOOCFGDIR if defined,
21
+# otherwise we use /etc/zookeeper
22
+# or the conf directory that is
23
+# a sibling of this script's directory
24
+
25
+ZOOBINDIR="${ZOOBINDIR:-/usr/bin}"
26
+ZOOKEEPER_PREFIX="${ZOOBINDIR}/.."
27
+ZOOCFGDIR="/etc/zookeeper"
28
+ZOO_LOG_DIR="/var/log/zookeeper"
29
+ZOOPIDFILE="/var/run/zookeeper/zookeeper_server.pid"
30
+ZOO_JAR_DIR="/usr/lib/java/zookeeper"
31
+
32
+if [ -f "${ZOOCFGDIR}/zookeeper-env.sh" ]; then
33
+  . "${ZOOCFGDIR}/zookeeper-env.sh"
34
+fi
35
+
36
+if [ "x$ZOOCFG" = "x" ]
37
+then
38
+    ZOOCFG="zoo.cfg"
39
+fi
40
+
41
+ZOOCFG="$ZOOCFGDIR/$ZOOCFG"
42
+
43
+if [ -f "$ZOOCFGDIR/java.env" ]
44
+then
45
+    . "$ZOOCFGDIR/java.env"
46
+fi
47
+
48
+if [ "x${ZOO_LOG_DIR}" = "x" ]
49
+then
50
+    ZOO_LOG_DIR="."
51
+fi
52
+
53
+if [ "x${ZOO_LOG4J_PROP}" = "x" ]
54
+then
55
+    ZOO_LOG4J_PROP="INFO,CONSOLE"
56
+fi
57
+
58
+if [ "$JAVA_HOME" != "" ]; then
59
+  JAVA="$JAVA_HOME/bin/java"
60
+else
61
+  JAVA=java
62
+fi
63
+
64
+for i in $ZOO_JAR_DIR/*.jar
65
+do
66
+ CLASSPATH="$i:$CLASSPATH"
67
+done
0 68
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+diff --git a/bin/zkServer.sh b/bin/zkServer.sh
1
+index 0490982..b4766e5 100755
2
+--- a/bin/zkServer.sh
3
+@@ -69,14 +69,7 @@ then
4
+     ZOOCFG="$2"
5
+ fi
6
+ 
7
+-if $cygwin
8
+-then
9
+-    ZOOCFG=`cygpath -wp "$ZOOCFG"`
10
+-    # cygwin has a "kill" in the shell itself, gets confused
11
+-    KILL=/bin/kill
12
+-else
13
+-    KILL=kill
14
+-fi
15
++KILL=kill
16
+ 
17
+ echo "Using config: $ZOOCFG" >&2
18
+ 
0 19
new file mode 100644
... ...
@@ -0,0 +1,16 @@
0
+[Unit]
1
+Description=Apache ZooKeeper
2
+After=network.target
3
+ConditionPathExists=/etc/zookeeper/zoo.cfg
4
+
5
+[Service]
6
+Type=forking
7
+ExecStart=/usr/bin/zkServer.sh start /etc/zookeeper/zoo.cfg
8
+ExecStop=/usr/bin/zkServer.sh stop
9
+User=zookeeper
10
+Group=hadoop
11
+Restart=always
12
+RestartSec=30
13
+
14
+[Install]
15
+WantedBy=multi-user.target
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:	Highly reliable distributed coordination
2 2
 Name:		zookeeper
3 3
 Version:	3.4.8
4
-Release:	1%{?dist}
4
+Release:	2%{?dist}
5 5
 URL:		http://zookeeper.apache.org/
6 6
 License:	Apache License, Version 2.0
7 7
 Group:		Applications/System
... ...
@@ -9,6 +9,9 @@ Vendor:		VMware, Inc.
9 9
 Distribution: 	Photon
10 10
 Source:	http://www.carfab.com/apachesoftware/zookeeper/stable/%{name}-%{version}.tar.gz
11 11
 %define sha1 zookeeper=51b61611a329294f75aed82f3a4517a4b6ff116f
12
+Source1:	zookeeper.service
13
+Source2:	zkEnv.sh
14
+Patch0:		zookeeper-3.4.8-server.patch
12 15
 BuildRequires:  systemd
13 16
 Requires:       systemd
14 17
 Requires: shadow
... ...
@@ -19,27 +22,29 @@ ZooKeeper is a centralized service for maintaining configuration information, na
19 19
 
20 20
 %prep
21 21
 %setup -q
22
+%patch0 -p1
22 23
 
23 24
 %install
24 25
 mkdir -p %{buildroot}%{_prefix}
25 26
 mkdir -p %{buildroot}%{_bindir}
26
-mkdir -p %{buildroot}%{_libdir}
27
+mkdir -p %{buildroot}%{_libdir}/java/zookeeper
28
+mkdir -p %{buildroot}%{_libdir}/zookeeper
27 29
 mkdir -p %{buildroot}%{_var}/log/zookeeper
28 30
 mkdir -p %{buildroot}%{_sysconfdir}/zookeeper
29
-mkdir -p %{buildroot}%{_var}/run
31
+mkdir -p %{buildroot}%{_var}/run/zookeeper
30 32
 mkdir -p %{buildroot}/sbin
31 33
 mkdir -p %{buildroot}%{_prefix}/share/zookeeper/templates/conf
32 34
 mkdir -p %{buildroot}%{_var}/zookeeper
33 35
 
34
-cp zookeeper-%{version}.jar %{buildroot}%{_libdir}
36
+cp zookeeper-%{version}.jar %{buildroot}%{_libdir}/java/zookeeper
35 37
 cp src/packages/update-zookeeper-env.sh %{buildroot}/sbin/update-zookeeper-env.sh
36 38
 cp src/packages/templates/conf/zookeeper-env.sh %{buildroot}%{_prefix}/share/zookeeper/templates/conf
37 39
 cp conf/zoo_sample.cfg %{buildroot}%{_prefix}/share/zookeeper/templates/conf/zoo.cfg
38 40
 chmod 0755 %{buildroot}/sbin/*
39 41
 
40
-sed -i 's/.*ZOOBINDIR.*\/etc.*/    ZOOBINDIR=\/etc\/zookeeper/g' bin/zkEnv.sh
41 42
 mv bin/* %{buildroot}%{_bindir}
42
-mv lib/* %{buildroot}%{_libdir}
43
+mv lib/*.jar %{buildroot}%{_libdir}/java/zookeeper
44
+mv lib/* %{buildroot}%{_libdir}/zookeeper
43 45
 mv conf/zoo_sample.cfg %{buildroot}%{_sysconfdir}/zookeeper/zoo.cfg
44 46
 mv conf/* %{buildroot}%{_sysconfdir}/zookeeper
45 47
 pushd ..
... ...
@@ -47,25 +52,8 @@ rm -rf %{buildroot}/%{name}-%{version}
47 47
 popd
48 48
 
49 49
 mkdir -p %{buildroot}/lib/systemd/system
50
-cat << EOF >> %{buildroot}/lib/systemd/system/zookeeper.service
51
-[Unit]
52
-Description=Apache ZooKeeper
53
-After=network.target
54
-ConditionPathExists=/etc/zookeeper/zoo.cfg
55
-
56
-[Service]
57
-Type=forking
58
-ExecStart=/usr/bin/zkServer.sh start /etc/zookeeper/zoo.cfg
59
-ExecStop=/usr/bin/zkServer.sh stop
60
-User=zookeeper
61
-Group=hadoop
62
-Restart=always
63
-RestartSec=30
64
-
65
-[Install]
66
-WantedBy=multi-user.target
67
-EOF
68
-
50
+cp %{SOURCE1} %{buildroot}/lib/systemd/system/zookeeper.service
51
+cp %{SOURCE2} %{buildroot}%{_bindir}/zkEnv.sh
69 52
 %pre
70 53
 getent group hadoop >/dev/null || /usr/sbin/groupadd -r hadoop
71 54
 getent passwd zookeeper >/dev/null || /usr/sbin/useradd --comment "ZooKeeper" --shell /bin/bash -M -r --groups hadoop --home %{_prefix}/share/zookeeper zookeeper
... ...
@@ -76,7 +64,7 @@ bash %{_prefix}/sbin/update-zookeeper-env.sh \
76 76
        --prefix=%{_prefix} \
77 77
        --conf-dir=%{_sysconfdir}/zookeeper \
78 78
        --log-dir=%{_var}/log/zookeeper \
79
-       --pid-dir=%{_var}/run \
79
+       --pid-dir=%{_var}/run/zookeeper \
80 80
        --var-dir=%{_var}/zookeeper
81 81
 %{_sbindir}/ldconfig 
82 82
 if [ $1 -eq 1 ] ; then
... ...
@@ -91,7 +79,7 @@ bash %{_prefix}/sbin/update-zookeeper-env.sh \
91 91
        --prefix=%{_prefix} \
92 92
        --conf-dir=%{_sysconfdir}/zookeeper \
93 93
        --log-dir=%{_var}/log/zookeeper \
94
-       --pid-dir=%{_var}/run \
94
+       --pid-dir=%{_var}/run/zookeeper \
95 95
        --var-dir=%{_var}/zookeeper \
96 96
        --uninstall
97 97
 /bin/systemctl disable zookeeper.service
... ...
@@ -102,14 +90,16 @@ bash %{_prefix}/sbin/update-zookeeper-env.sh \
102 102
 
103 103
 %files
104 104
 %defattr(-,root,root)
105
-%attr(0755,root,hadoop) %{_var}/log/zookeeper
106
-%attr(0775,root,hadoop) %{_var}/run
107
-%attr(0775,root,hadoop) /sbin/update-zookeeper-env.sh
105
+%attr(0755,zookeeper,hadoop) %{_var}/log/zookeeper
106
+%attr(0775,zookeeper,hadoop) %{_var}/run/zookeeper
107
+%attr(0775,zookeeper,hadoop) /sbin/update-zookeeper-env.sh
108 108
 %config(noreplace) %{_sysconfdir}/zookeeper/*
109 109
 /lib/systemd/system/zookeeper.service
110 110
 %{_prefix}
111 111
 
112 112
 %changelog
113
+*   Thu Apr 28 2016 Divya Thaluru <dthaluru@vmware.com>  3.4.8-2
114
+-   Added logic to set classpath
113 115
 *   Wed Feb 24 2016 Kumar Kaushik <kaushikk@vmware.com>  3.4.8-1
114 116
 -   Updating version.
115 117
 *   Fri Feb 05 2016 Anish Swaminathan <anishs@vmware.com>  3.4.6-8