archrelease: copy trunk to community-any
[ArchLinux/community.git] / elasticsearch / trunk / PKGBUILD
blobcefc95989dba9b26cf9d1266d156040da1c84e2f
1 # Maintainer: Justin Kromlinger <hashworks@archlinux.org>
2 # Contributor: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
3 # Contributor: Marcello "mererghost" Rocha <https://github.com/mereghost>
4 # Refactored by Blaž "Speed" Hrastnik <https://github.com/archSeer>
6 pkgname=elasticsearch
7 pkgver=7.10.2
8 pkgrel=2
9 pkgdesc="Distributed RESTful search engine built on top of Lucene"
10 arch=('x86_64')
11 url="https://www.elastic.co/products/elasticsearch"
12 license=('Apache')
13 depends=('java-runtime-headless<=16' 'systemd' 'libxml2')
14 makedepends=('java-environment=11')
15 source=(
16   $pkgname-$pkgver.tar.gz::"https://github.com/elastic/elasticsearch/archive/v${pkgver}.tar.gz"
17   elasticsearch.service
18   elasticsearch@.service
19   elasticsearch-keystore.service
20   elasticsearch-keystore@.service
21   elasticsearch-sysctl.conf
22   elasticsearch-user.conf
23   elasticsearch-tmpfile.conf
24   elasticsearch.default
25   remove-systemd-distribution-check.patch
26   patch-log4j-JAR-to-remove-JndiLookup-class-81629.patch
28 sha256sums=('bdb7811882a0d9436ac202a947061b565aa71983c72e1c191e7373119a1cdd1c'
29             '9e1f68ff275ef2b5f2b93d2823efc5cc9643da696fcbe09a3ea7520ada35ffba'
30             '8a76ad9a44a34eca8d6cb7ec9d8f1b01d46c114765b0a76094de8d72f0477351'
31             'bac40d87acaa5bee209ceb6dfa253009a072e9243fe3b94be42fb5cd44727d6f'
32             '22a78a165a810608188faea6f2b0b381f27b1e9d60126c3b3e729124540589a8'
33             'b3feb1e9c7e7ce6b33cea6c727728ed700332aae942ca475c3bcc1d56b9f113c'
34             '815f6a39db6f54bb40750c382ffbdc298d2c4c187ee8ea7e2f855923e2ff354b'
35             '74a772e9f73e2cecda45dcd30ade2f6114db657ed36231292bdf9a7ca04eab78'
36             'bb74e5fb8bc28f2125e015395ab05bea117b72bfc6dadbca827694b362ee0bf8'
37             '96934e6518245a4110714c3e1c1eb7bfaf4dd0026cc917efc322f3bfa4c3b5ec'
38             '98724575d454a49ec419eb39c53565cba5d2901eef6246d63205d02b8c6a68e2')
40 backup=('etc/elasticsearch/elasticsearch.yml'
41         'etc/elasticsearch/log4j2.properties'
42         'etc/elasticsearch/jvm.options'
43         'etc/default/elasticsearch')
45 prepare() {
46   cd $pkgname-$pkgver
47   patch -Np1 -i "$srcdir"/remove-systemd-distribution-check.patch
48   patch -Np1 -i "$srcdir"/patch-log4j-JAR-to-remove-JndiLookup-class-81629.patch
49   sed -i 's|${versions.log4j}|2.11.1|' libs/log4j/build.gradle
52 build() {
53   cd $pkgname-$pkgver
54   export PATH=/usr/lib/jvm/java-11-openjdk/bin:$PATH
55   export GRADLE_OPTS="-Dbuild.snapshot=false -Dlicense.key=x-pack/plugin/core/snapshot.key"
56   ./gradlew :distribution:buildSystemdModule
57   ./gradlew :distribution:archives:linux-tar:build
60 package() {
61   cd $pkgname-$pkgver
63   install -dm755 "$pkgdir"/{usr/share,var/lib,var/log}/elasticsearch
64   install -dm755 "$pkgdir"/usr/bin
66   tar xf distribution/archives/linux-tar/build/distributions/elasticsearch-$pkgver-*linux-x86_64.tar.gz \
67       --strip 1 -C "$pkgdir"/usr/share/elasticsearch
68   rm -r "$pkgdir"/usr/share/elasticsearch/{jdk,logs}
70   install -dm755 "$pkgdir"/etc
71   mv "$pkgdir"/usr/share/elasticsearch/config "$pkgdir"/etc/elasticsearch
72   chmod 2750 "$pkgdir"/etc/elasticsearch
74   for bin in "$pkgdir"/usr/share/elasticsearch/bin/*; do
75     ln -sT /usr/share/elasticsearch/bin/$(basename $bin) "$pkgdir"/usr/bin/$(basename $bin)
76   done
78   ln -s /etc/elasticsearch "$pkgdir"/usr/share/elasticsearch/config
79   ln -s /var/log/elasticsearch "$pkgdir"/usr/share/elasticsearch/logs
80   ln -s /var/lib/elasticsearch "$pkgdir"/usr/share/elasticsearch/data
82   install -Dm644 "$srcdir"/elasticsearch.service "$pkgdir"/usr/lib/systemd/system/elasticsearch.service
83   install -Dm644 "$srcdir"/elasticsearch@.service "$pkgdir"/usr/lib/systemd/system/elasticsearch@.service
84   install -Dm644 "$srcdir"/elasticsearch-keystore.service "$pkgdir"/usr/lib/systemd/system/elasticsearch-keystore.service
85   install -Dm644 "$srcdir"/elasticsearch-keystore@.service "$pkgdir"/usr/lib/systemd/system/elasticsearch-keystore@.service
86   install -Dm644 "$srcdir"/elasticsearch-user.conf "$pkgdir"/usr/lib/sysusers.d/elasticsearch.conf
87   install -Dm644 "$srcdir"/elasticsearch-tmpfile.conf "$pkgdir"/usr/lib/tmpfiles.d/elasticsearch.conf
88   install -Dm644 "$srcdir"/elasticsearch-sysctl.conf "$pkgdir"/usr/lib/sysctl.d/elasticsearch.conf
89   install -Dm644 "$srcdir"/elasticsearch.default "$pkgdir"/etc/default/elasticsearch
91   cp -r distribution/build/outputs/systemd/modules/systemd "$pkgdir"/usr/share/elasticsearch/modules/
93   sed -i '2iJAVA_HOME=/usr/lib/jvm/default-runtime' "$pkgdir"/usr/share/elasticsearch/bin/elasticsearch-env
94   sed -i 's/ES_BUNDLED_JDK=true/ES_BUNDLED_JDK=false/g' "$pkgdir"/usr/share/elasticsearch/bin/elasticsearch-env
96   install -Dm644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"