# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
maintainers {ieee.org:s.t.smith @essandess} openmaintainer
description An open source enterprise search platform.
long_description Solr is the popular, blazing fast open source enterprise \
search platform from the Apache Lucene project.
homepage https://lucene.apache.org/solr/
master_sites apache:lucene/solr/${version}/
checksums rmd160 11bae37e629335375bea76c76f160964de892beb \
sha256 bfa4b39b236e5d714f4233138b8b5cb7e1996ddc0aad60052ce83c4b7bf33449 \
# see https://lucene.apache.org/solr/guide/8_1/solr-system-requirements.html
# JDK port to install if required java not found
add_users ${solrUser} group=${solrGroup} home=${prefix}/var/solr
# set the destination paths.
set java_basepath ${prefix}/share/java
set solr_destpath ${java_basepath}/${distname}
set solr_path ${solr_destpath}
# Used to define environment variables for bin/solr
set solr_home ${prefix}/var/solr
set solr_data_home ${prefix}/var/db/solr
set solr_logs_dir ${solr_home}/logs
set solr_pid_dir ${prefix}/var/run/solr
# This is what to set for fine-tuned Java memory control; see bin/solr
set solr_log_prestart_rotation true
set solr_ulimit_checks false
xinstall -d ${destroot}${java_basepath}
copy ${worksrcpath} ${destroot}${java_basepath}
# create default directories
xinstall -o ${solrUser} -g ${solrGroup} -m 755 -d ${destroot}${solr_home}
xinstall -o ${solrUser} -g ${solrGroup} -m 755 -d ${destroot}${solr_logs_dir}
xinstall -o ${solrUser} -g ${solrGroup} -m 755 -d ${destroot}${prefix}/var/db/solr
xinstall -o ${solrUser} -g ${solrGroup} -m 775 -d ${destroot}${solr_pid_dir}
# install the solr script
xinstall -m 755 ${filespath}/solr.in ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_path@|${solr_path}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_home@|${solr_home}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_data_home@|${solr_data_home}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_logs_dir@|${solr_logs_dir}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_pid_dir@|${solr_pid_dir}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_port@|${solr_port}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_heap@|${solr_heap}|g" ${destroot}${prefix}/bin/solr8
# reinplace "s|@solr_java_mem@|${solr_java_mem}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_log_prestart_rotation@|${solr_log_prestart_rotation}|g" ${destroot}${prefix}/bin/solr8
reinplace "s|@solr_ulimit_checks@|${solr_ulimit_checks}|g" ${destroot}${prefix}/bin/solr8
# copy the solr home files
xinstall -o ${solrUser} -g ${solrGroup} -m 644 ${filespath}/solr.xml ${destroot}${solr_home}/solr.xml
xinstall -o ${solrUser} -g ${solrGroup} -m 644 ${filespath}/solr.xml ${destroot}${solr_home}/solr.xml.default
# remove `nohup` from `bin/solr`, which causes this error on macOS:
# sudo -u solr solr8 start # hangs with this error
# nohup: can't detach from console: Inappropriate ioctl for device
reinplace -E {s|^([[:space:]]+)nohup[[:space:]]+|\1|} ${destroot}${solr_destpath}/bin/solr
# Make sure initial conf files are present and setup correctly