Browse code

Added elasticsearch package

Change-Id: Id6f79dbc9b44f483f179484af0daf1e1cc3e51c3
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5387
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Tapas Kundu authored on 2018/07/23 22:46:13
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,121 @@
0
+%define debug_package %{nil}
1
+
2
+Summary:        Elastic Serch
3
+Name:           elasticsearch
4
+Version:        6.3.0
5
+Release:        1%{?dist}
6
+License:        Apache License Version 2.0
7
+URL:            https://artifacts.elastic.co/downloads/elasticsearch/%{name}-%{version}.tar.gz
8
+Source0:        %{name}-%{version}.tar.gz
9
+%define sha1    %{name}-%{version}.tar.gz=3f356bf80bd31c0107622cf7213d0ee9f43536d8
10
+Source1:        cacerts
11
+%define sha1    cacerts=f584c7c1f48c552f39acfb5560a300a657d9f3bb
12
+Group:          Development/Daemons
13
+Vendor:         VMware, Inc.
14
+Distribution:   Photon
15
+BuildRequires:  openjdk10
16
+BuildRequires:  unzip
17
+BuildRequires:  curl
18
+BuildRequires:  which
19
+BuildRequires:  git
20
+BuildRequires:  make
21
+BuildRequires:  automake
22
+BuildRequires:  autoconf
23
+BuildRequires:  libtool
24
+BuildRequires:  tar
25
+BuildRequires:  wget
26
+BuildRequires:  patch
27
+BuildRequires:  texinfo
28
+Requires(pre):  /usr/sbin/useradd /usr/sbin/groupadd
29
+Requires(postun):/usr/sbin/userdel /usr/sbin/groupdel
30
+
31
+%description
32
+Elasticsearch is a highly distributed RESTful search engine built for the cloud.
33
+
34
+%prep
35
+%setup -qn %{name}-%{version}
36
+
37
+%build
38
+export LANG="en_US.UTF-8"
39
+export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
40
+export JAVA_HOME=/usr/lib/jvm/OpenJDK-%{JAVA10_VERSION}
41
+export PATH=$JAVA_HOME/bin:$PATH
42
+export _JAVA_OPTIONS="-Xmx10g"
43
+cp %{SOURCE1} /usr/lib/jvm/OpenJDK-%{JAVA10_VERSION}/lib/security/
44
+./gradlew assemble
45
+
46
+%install
47
+rm -rf %{buildroot}
48
+mkdir -p %{buildroot}%{_datadir}/%{name}
49
+mkdir -p %{buildroot}/etc/%{name}
50
+mkdir -p %{buildroot}/usr/lib/sysctl.d/
51
+mkdir -p %{buildroot}/usr/lib/systemd/system/
52
+mkdir -p %{buildroot}/usr/lib/tmpfiles.d/
53
+mkdir -p %{buildroot}/etc/init.d/elasticsearch
54
+mkdir -p %{buildroot}/etc/sysconfig/elasticsearch
55
+mkdir -p %{buildroot}/var/lib/elasticsearch
56
+mkdir -p %{buildroot}/var/log/elasticsearch
57
+mkdir -p %{buildroot}/var/run/elasticsearch
58
+mkdir -p %{buildroot}%{_datadir}/%{name}/data
59
+
60
+tar -xvf distribution/archives/oss-tar/build/distributions/elasticsearch-oss-6.3.0-SNAPSHOT.tar.gz
61
+cp elasticsearch-6.3.0-SNAPSHOT/LICENSE.txt %{buildroot}%{_datadir}/%{name}/
62
+cp elasticsearch-6.3.0-SNAPSHOT/NOTICE.txt %{buildroot}%{_datadir}/%{name}/
63
+cp elasticsearch-6.3.0-SNAPSHOT/README.textile %{buildroot}%{_datadir}/%{name}/
64
+cp -r elasticsearch-6.3.0-SNAPSHOT/* %{buildroot}%{_datadir}/%{name}/
65
+cp distribution/packages/build/packaging/oss-rpm/systemd/sysctl/elasticsearch.conf %{buildroot}/usr/lib/sysctl.d/
66
+cp distribution/packages/build/packaging/oss-rpm/systemd/elasticsearch.service %{buildroot}/usr/lib/systemd/system/
67
+cp distribution/packages/build/packaging/oss-rpm/systemd/elasticsearch.conf %{buildroot}/usr/lib/tmpfiles.d/
68
+cp elasticsearch-6.3.0-SNAPSHOT/config/log4j2.properties %{buildroot}/etc/%{name}/
69
+cp elasticsearch-6.3.0-SNAPSHOT/config/jvm.options %{buildroot}/etc/%{name}/
70
+
71
+chmod 755 %{buildroot}%{_datadir}/%{name}/
72
+chmod 755 %{buildroot}/etc/%{name}/
73
+chmod 755 %{buildroot}/var/log/%{name}/
74
+chmod 755 %{buildroot}/var/lib/%{name}/
75
+chmod 755 %{buildroot}/var/run/%{name}/
76
+chmod 755 %{buildroot}%{_datadir}/%{name}/data
77
+
78
+%pre
79
+
80
+getent group elasticsearch >/dev/null || /usr/sbin/groupadd -r elasticsearch
81
+getent passwd elasticsearch >/dev/null || /usr/sbin/useradd --comment "ElasticSearch" --shell /bin/bash -M -r --groups elasticsearch --home /usr/share/elasticsearch elasticsearch
82
+
83
+
84
+%post
85
+%systemd_post elasticsearch.service
86
+
87
+%preun
88
+%systemd_preun elasticsearch.service
89
+
90
+%postun
91
+%systemd_postun_with_restart elasticsearch.service
92
+if [ $1 -eq 0 ] ; then
93
+    /usr/sbin/userdel elasticsearch
94
+    /usr/sbin/groupdel elasticsearch
95
+fi
96
+
97
+
98
+%check
99
+
100
+%clean
101
+rm -rf %{buildroot}/*
102
+
103
+%files
104
+%defattr(-,root,root)
105
+%attr(755,elasticsearch,elasticsearch) /var/log/elasticsearch
106
+%attr(755,elasticsearch,elasticsearch) /usr/share/elasticsearch/data
107
+%attr(755,elasticsearch,elasticsearch) /var/lib/elasticsearch
108
+%attr(755,elasticsearch,elasticsearch) /var/run/elasticsearch
109
+%attr(755,elasticsearch,elasticsearch) /usr/share/elasticsearch
110
+%attr(755,elasticsearch,elasticsearch) /usr/share/elasticsearch/logs
111
+%dir %{_datadir}/%{name}
112
+%{_datadir}/%{name}
113
+%attr(755,elasticsearch,elasticsearch) /etc/%{name}
114
+%attr(755,elasticsearch,elasticsearch) /usr/lib/systemd/system/elasticsearch.service
115
+%attr(755,elasticsearch,elasticsearch) /usr/lib/sysctl.d/elasticsearch.conf
116
+%attr(755,elasticsearch,elasticsearch) /usr/lib/tmpfiles.d/elasticsearch.conf
117
+
118
+%changelog
119
+*    Mon Jul 09 2018 Tapas Kundu <tkundu@vmware.com> 6.3.0-1
120
+-    Initial build added for Photon.
... ...
@@ -258,6 +258,19 @@ class SPECS(object):
258 258
         java8version = spec.getVersion()
259 259
         constants.addMacro("JAVA8_VERSION", java8version)
260 260
 
261
+        # adding openjre9 version rpm macro
262
+        if platform.machine() == "x86_64":
263
+            spec = Specutils(constants.specPath + "/openjdk9/openjdk9.spec")
264
+            java9version = spec.getVersion()
265
+            constants.addMacro("JAVA9_VERSION", java9version)
266
+
267
+
268
+        # adding openjre10 version rpm macro
269
+        if platform.machine() == "x86_64":
270
+            spec = Specutils(constants.specPath + "/openjdk10/openjdk10.spec")
271
+            java10version = spec.getVersion()
272
+            constants.addMacro("JAVA10_VERSION", java10version)
273
+
261 274
         # adding kernelversion rpm macro
262 275
         spec = Specutils(constants.specPath + "/linux/linux.spec")
263 276
         kernelversion = spec.getVersion()