From fb055028b8c3541998e92f1066ff7a3eb3c0666a Mon Sep 17 00:00:00 2001 From: "kedia,Akanksha" Date: Thu, 3 Aug 2023 15:03:24 +0530 Subject: [PATCH 1/2] BIGTOP-3959: RPM packaging for TRINO --- .../src/common/ranger/install_ranger.sh | 2 +- .../src/common/trino/developers.rst | 28 +++ .../src/common/trino/do-component-build | 41 ++++ .../src/common/trino/getting-started.rst | 20 ++ .../src/common/trino/install_trino.sh | 193 ++++++++++++++++++ .../src/common/trino/trino-server.svc | 125 ++++++++++++ bigtop-packages/src/common/trino/trino.conf | 17 ++ bigtop-packages/src/deb/trino/control | 41 ++++ bigtop-packages/src/deb/trino/copyright | 15 ++ bigtop-packages/src/deb/trino/rules | 45 ++++ bigtop-packages/src/deb/trino/trino.install | 10 + bigtop-packages/src/deb/trino/trino.postinst | 99 +++++++++ bigtop-packages/src/deb/trino/trino.prerm | 38 ++++ .../src/rpm/ranger/SPECS/ranger.spec | 18 +- bigtop-packages/src/rpm/trino/RPMS/.gitignore | 0 .../src/rpm/trino/SOURCES/.gitignore | 0 .../src/rpm/trino/SPECS/trino.spec | 175 ++++++++++++++++ .../src/rpm/trino/SRPMS/.gitignore | 0 bigtop-packages/src/templates/trino-server | 182 +++++++++++++++++ bigtop.bom | 10 + install_trino.sh | 124 +++++++++++ 21 files changed, 1173 insertions(+), 10 deletions(-) create mode 100644 bigtop-packages/src/common/trino/developers.rst create mode 100644 bigtop-packages/src/common/trino/do-component-build create mode 100644 bigtop-packages/src/common/trino/getting-started.rst create mode 100644 bigtop-packages/src/common/trino/install_trino.sh create mode 100644 bigtop-packages/src/common/trino/trino-server.svc create mode 100644 bigtop-packages/src/common/trino/trino.conf create mode 100644 bigtop-packages/src/deb/trino/control create mode 100644 bigtop-packages/src/deb/trino/copyright create mode 100644 bigtop-packages/src/deb/trino/rules create mode 100644 bigtop-packages/src/deb/trino/trino.install create mode 100644 bigtop-packages/src/deb/trino/trino.postinst create mode 100644 bigtop-packages/src/deb/trino/trino.prerm create mode 100644 bigtop-packages/src/rpm/trino/RPMS/.gitignore create mode 100644 bigtop-packages/src/rpm/trino/SOURCES/.gitignore create mode 100644 bigtop-packages/src/rpm/trino/SPECS/trino.spec create mode 100644 bigtop-packages/src/rpm/trino/SRPMS/.gitignore create mode 100755 bigtop-packages/src/templates/trino-server create mode 100644 install_trino.sh diff --git a/bigtop-packages/src/common/ranger/install_ranger.sh b/bigtop-packages/src/common/ranger/install_ranger.sh index d79c3ecf34..cbfe872af1 100644 --- a/bigtop-packages/src/common/ranger/install_ranger.sh +++ b/bigtop-packages/src/common/ranger/install_ranger.sh @@ -146,7 +146,7 @@ else COMPONENT_LIB_DIR=${PREFIX}/${RANGER_COMPONENT_DIR}/tomcat/webapps/kylin/WEB-INF/lib elif [ "${RANGER_COMPONENT}" = "elasticsearch" ]; then COMPONENT_LIB_DIR=${PREFIX}/${RANGER_COMPONENT_DIR}/plugins - elif [ "${RANGER_COMPONENT}" = "presto" ]; then + elif [ "${RANGER_COMPONENT}" = "trino" ]; then COMPONENT_LIB_DIR=${PREFIX}/${RANGER_COMPONENT_DIR}/plugin/ranger if [ ! -d "${COMPONENT_LIB_DIR}" ]; then echo "INFO: Creating ${COMPONENT_LIB_DIR}" diff --git a/bigtop-packages/src/common/trino/developers.rst b/bigtop-packages/src/common/trino/developers.rst new file mode 100644 index 0000000000..f153f2bfce --- /dev/null +++ b/bigtop-packages/src/common/trino/developers.rst @@ -0,0 +1,28 @@ +For Developers: Building a component from Git repository + +Prerequisites + +You will need git installed. +You will need java 17 installed for Trino +Java 8 for bigtop +You will need to use gradlew which is included in the source code. (Right in the root of the project folder) +This project's gradlew has more documentation here +Use git to download BigTop : +git clone https://github.com/apache/bigtop.git + +move into the root project folder: +cd bigtop + +To fetch source from a Git repository, there're two ways to achieve this: a). modify ./bigtop.bom and add JSON snippets to your component/package, or b). specify properties at command line + +bigtop.bom +Add following JSON snippets to the desired component/package: + +git { repo = ""; ref = ""; dir = ""; commit_hash = "" } +repo - SSH, HTTP or local path to Git repo. +ref - branch, tag or commit hash to check out. +dir - [OPTIONAL] directory name to write source into. +commit_hash - [OPTIONAL] a commit hash to reset to. +Some packages have different names for source directory and source tarball (hbase-0.98.5-src.tar.gz contains hbase-0.98.5 directory). By default source will be fetched in a directory named by tarball { source = TARBALL_SRC } without .t* extension. To explicitly set directory name use the dir option. + +When commit_hash specified, the repo to build the package will be reset to the commit hash. diff --git a/bigtop-packages/src/common/trino/do-component-build b/bigtop-packages/src/common/trino/do-component-build new file mode 100644 index 0000000000..bdff77a465 --- /dev/null +++ b/bigtop-packages/src/common/trino/do-component-build @@ -0,0 +1,41 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + + +. `dirname $0`/bigtop.bom +mkdir trino +export trino_java_url=https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz +wget -O java.tar.gz "${trino_java_url}" --no-check-certificate +tar zxvf java.tar.gz && rm -rf java.tar.gz +OLD_JAVA=$JAVA_HOME +echo JAVA_HOME=`pwd`/`ls | grep "jdk-*"` >> ~/.bash_profile +source ~/.bash_profile + +# Setting versions for trino build +mvn clean -pl !plugin/trino-kafka,!testing/trino-benchto-benchmarks,!docs install -DskipTests -Dcheckstyle.skipExec -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Djavax.net.ssl.trustStore=/home/akedia/bigtop/cacerts -Djavax.net.ssl.trustStorePassword=changeit +sed -i '$ d' ~/.bash_profile +source ~/.bash_profile +rm -rf `pwd`/`ls | grep "jdk-*"` + +mkdir -p build/trino +mkdir -p build/trino-cli + +# Server +tar -C build/trino --strip-components=1 -xzf core/trino-server/target/*.tar.gz +# CLI +cp -ra client/trino-cli/target/*-executable.jar build/trino-cli/trino diff --git a/bigtop-packages/src/common/trino/getting-started.rst b/bigtop-packages/src/common/trino/getting-started.rst new file mode 100644 index 0000000000..d8946f641b --- /dev/null +++ b/bigtop-packages/src/common/trino/getting-started.rst @@ -0,0 +1,20 @@ +Getting started with bigtop packaging. + +1) You will have to package rpm. + +2) Here are some steps you can follow to bring a new bigtop package in. + +determine where your source is, and add it to bigtop.bom +update the bigtop-packages/src/common/ folder to have your component, +and the do-component-build for it (which usually just builds a jar). +Why is there a "common" directory? Simply because deb and rpm packaging share some tasks (like do-component-build, +which just usually runs a mvn or gradle command), and so we keep a common install directory which they can both leverage for packaging. +(for RPM) now add a .spec file into bigtop-packages/src//... into the appropriate directory +(i.e. bigtop-packages/src/rpm/tachyon/SPECS/tachyon.spec). +Obviously, your tachyon.spec file will use whats in common/ in a RPM specific way, to install the RPM package. +create a rules file using do-component-build + +Test it with gradle -rpm for the others. +Finally add a smoke test! This is as easy as adding a new groovy file to bitop-tests/smoke-tests//TestThisStuff.groovy, +following conventions that others have created. +3) As always, we will improve on the directions above, but this should help to get you started. . \ No newline at end of file diff --git a/bigtop-packages/src/common/trino/install_trino.sh b/bigtop-packages/src/common/trino/install_trino.sh new file mode 100644 index 0000000000..bb43d6a26c --- /dev/null +++ b/bigtop-packages/src/common/trino/install_trino.sh @@ -0,0 +1,193 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +usage() { + echo " +usage: $0 + Required not-so-options: + --build-dir=DIR path to dist.dir + --source-dir=DIR path to package shared files dir + --prefix=PREFIX path to install into + Optional options: + --doc-dir=DIR path to install docs into [/usr/share/doc/trino] + --lib-dir=DIR path to install trino home [/usr/lib/trino] + --installed-lib-dir=DIR path where lib-dir will end up on target system + --bin-dir=DIR path to install bins [/usr/bin] + ... [ see source for more similar options ] + " + exit 1 +} + +OPTS=$(getopt \ + -n $0 \ + -o '' \ + -l 'prefix:' \ + -l 'lib-dir:' \ + -l 'installed-lib-dir:' \ + -l 'bin-dir:' \ + -l 'trino-version:' \ + -l 'source-dir:' \ + -l 'cli-dir:' \ + -l 'build-dir:' -- "$@") + +if [ $? != 0 ] ; then + usage +fi + +eval set -- "$OPTS" +while true ; do + case "$1" in + --prefix) + PREFIX=$2 ; shift 2 + ;; + --build-dir) + BUILD_DIR=$2 ; shift 2 + ;; + --source-dir) + SOURCE_DIR=$2 ; shift 2 + ;; + --cli-dir) + CLI_BUILD_DIR=$2 ; shift 2 + ;; + --lib-dir) + LIB_DIR=$2 ; shift 2 + ;; + --installed-lib-dir) + INSTALLED_LIB_DIR=$2 ; shift 2 + ;; + --bin-dir) + BIN_DIR=$2 ; shift 2 + ;; + --) + shift ; break + ;; + *) + echo "Unknown option: $1" + usage + exit 1 + ;; + esac +done + +for var in PREFIX BUILD_DIR SOURCE_DIR ; do + if [ -z "$(eval "echo \$$var")" ]; then + echo Missing param: $var + usage + fi +done + +if [ -f "$SOURCE_DIR/bigtop.bom" ]; then + . $SOURCE_DIR/bigtop.bom +fi + +MAN_DIR=${MAN_DIR:-/usr/share/man}/man1 +DOC_DIR=${DOC_DIR:-/usr/share/doc/trino} +CLI_DIR=${CLI_DIR:-/usr/lib/trino-cli} +LIB_DIR=${TRINO_DIR:-/usr/lib/trino} +VAR_DIR=${VAR_DIR:-/var/lib/trino} +LOG_DIR=${LOG_DIR:-/var/log/trino} +RUN_DIR=${RUN_DIR:-/var/run/trino} +INSTALLED_LIB_DIR=${INSTALLED_LIB_DIR:-/usr/lib/trino} +BIN_DIR=${BIN_DIR:-/usr/bin} +CONF_DIR=${CONF_DIR:-/etc/trino} +CONF_DIST_DIR=${CONF_DIST_DIR:-/etc/trino.dist} +DEFAULT_DIR=${DEFAULT_DIR:-/etc/default} + +install -d -m 0755 $PREFIX/$CONF_DIST_DIR +install -d -m 0755 $PREFIX/$LIB_DIR +install -d -m 0755 $PREFIX/$CLI_DIR +install -d -m 0755 $PREFIX/$DOC_DIR +install -d -m 0755 $PREFIX/$VAR_DIR +install -d -m 0755 $PREFIX/$LOG_DIR +install -d -m 0755 $PREFIX/$RUN_DIR +install -d -m 0755 $PREFIX/$DEFAULT_DIR + +cp -ra ${BUILD_DIR}/* $PREFIX/$LIB_DIR/ +cp -ra ${CLI_BUILD_DIR}/* $PREFIX/$CLI_DIR/ + +chmod +x $PREFIX/$LIB_DIR/bin/launcher + +install -d -m 0755 $PREFIX/$CONF_DIST_DIR +install -d -m 0755 $PREFIX/$CONF_DIST_DIR/catalog + +cat > $PREFIX/$CONF_DIST_DIR/node.properties < $PREFIX/$CONF_DIST_DIR/jvm.config < $PREFIX/$CONF_DIST_DIR/config.properties < $PREFIX/$CONF_DIST_DIR/log.properties < $PREFIX/$CONF_DIST_DIR/catalog/tpch.properties < $PREFIX/$CONF_DIST_DIR/catalog/tpcds.properties < $PREFIX/$CONF_DIST_DIR/catalog/jmx.properties < +Build-Depends: debhelper (>= 9) +Standards-Version: 3.4.5 + +Package: trino +Architecture: any +Depends: adduser, bigtop-utils (>= 0.7) +Description: + trino is an open source distributed SQL query engine for running + interactive analytic queries against data sources of all sizes ranging + from gigabytes to petabytes. + +Package: trino-server +Architecture: all +Depends: trino (= ${source:Version}), python (>= 2.6) +Description: Server for trino + Server for trino + +Package: trino-cli +Architecture: all +Depends: trino (= ${source:Version}) +Description: trino CLI + trino CLI \ No newline at end of file diff --git a/bigtop-packages/src/deb/trino/copyright b/bigtop-packages/src/deb/trino/copyright new file mode 100644 index 0000000000..2a73a85bce --- /dev/null +++ b/bigtop-packages/src/deb/trino/copyright @@ -0,0 +1,15 @@ +Format: http://dep.debian.net/deps/dep5 +Source: https://trinodb.io/ +Upstream-Name: trino + +Files: * +Copyright: 2013, Facebook +License: Apache-2.0 + +Files debian/* +Copyright: 2011, The Apache Software Foundation +License: Apache-2.0 + +License: Apache-2.0 +On Debian systems, the complete text of the Apache 2.0 license +can be found in "/usr/share/common-licenses/Apache-2.0". \ No newline at end of file diff --git a/bigtop-packages/src/deb/trino/rules b/bigtop-packages/src/deb/trino/rules new file mode 100644 index 0000000000..6cc6d95e24 --- /dev/null +++ b/bigtop-packages/src/deb/trino/rules @@ -0,0 +1,45 @@ +#!/usr/bin/make -f + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +%: + dh $@ + +override_dh_auto_build: + bash debian/do-component-build + +svcs=trino-server + +$(svcs): debian/init.d.tmpl + bash $< debian/$@.svc deb debian/$@.init + touch $@ + +override_dh_auto_install: $(svcs) + bash -x debian/install_trino.sh \ + --build-dir=build/trino-${trino_VERSION} \ + --doc-dir=/usr/share/doc/trino \ + --source-dir=debian \ + --prefix=debian/tmp + + mkdir -p debian/tmp/etc/security/limits.d + cp debian/trino.conf debian/tmp/etc/security/limits.d diff --git a/bigtop-packages/src/deb/trino/trino.install b/bigtop-packages/src/deb/trino/trino.install new file mode 100644 index 0000000000..f3558a1613 --- /dev/null +++ b/bigtop-packages/src/deb/trino/trino.install @@ -0,0 +1,10 @@ +/etc/security/limits.d/trino.conf +/etc/trino.dist +/usr/lib/trino/README.txt +/usr/lib/trino/NOTICE +/usr/lib/trino/bin +/usr/lib/trino/lib +/usr/lib/trino/plugin +/var/lib/trino +/var/log/trino +/var/run/trino diff --git a/bigtop-packages/src/deb/trino/trino.postinst b/bigtop-packages/src/deb/trino/trino.postinst new file mode 100644 index 0000000000..c6022af9d8 --- /dev/null +++ b/bigtop-packages/src/deb/trino/trino.postinst @@ -0,0 +1,99 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +case "$1" in + configure) + # Install config alternatives + update-alternatives --install /etc/trino/etc trino-etc /etc/trino/etc.dist 30 + chown -R trino:trino /var/log/trino /var/lib/trino /var/run/trino + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + 62 bigtop-packages/src/deb/trino/trino.preinst +Viewed +@@ -0,0 +1,62 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# preinst script for trino +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + if ! getent passwd trino >/dev/null; then + # Adding system user: trino . + adduser \ + --system \ + --group \ + --home /var/lib/trino \ + --gecos "trino" \ + --shell /bin/false \ + trino >/dev/null + fi + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/bigtop-packages/src/deb/trino/trino.prerm b/bigtop-packages/src/deb/trino/trino.prerm new file mode 100644 index 0000000000..c6ebe56614 --- /dev/null +++ b/bigtop-packages/src/deb/trino/trino.prerm @@ -0,0 +1,38 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +case "$1" in + remove|upgrade|deconfigure) + update-alternatives --remove trino-etc /etc/trino/etc.dist || : + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 \ No newline at end of file diff --git a/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec b/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec index 794d986772..b74694a378 100644 --- a/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec +++ b/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec @@ -31,7 +31,7 @@ %define usr_lib_sqoop %{parent_dir}/usr/lib/sqoop %define usr_lib_kylin %{parent_dir}/usr/lib/kylin %define usr_lib_elasticsearch %{parent_dir}/usr/lib/elasticsearch -%define usr_lib_presto %{parent_dir}/usr/lib/presto +%define usr_lib_trino %{parent_dir}/usr/lib/trino %define doc_dir %{parent_dir}/%{_docdir} @@ -392,8 +392,8 @@ AutoReq: no %description elasticsearch-plugin Ranger ELASTICSEARCH plugin component runs within elasticsearch to provide enterprise security using ranger framework -%package presto-plugin -Summary: ranger plugin for presto +%package trino-plugin +Summary: ranger plugin for trino Group: System/Daemons # On Rocky 8, find-requires picks up /usr/bin/python, but it's not provided by any package. # So installing ranger-*-plugin fails with a "nothing provides /usr/bin/python" message, @@ -401,8 +401,8 @@ Group: System/Daemons # Therefore we disable find-requires for each plugins with the following option. AutoReq: no -%description presto-plugin -Ranger PRESTO plugin component runs within presto to provide enterprise security using ranger framework +%description trino-plugin +Ranger trino plugin component runs within trino to provide enterprise security using ranger framework %prep @@ -421,7 +421,7 @@ bash %{SOURCE1} ######################### %install %__rm -rf $RPM_BUILD_ROOT -for comp in admin usersync kms tagsync hdfs-plugin yarn-plugin hive-plugin hbase-plugin knox-plugin storm-plugin kafka-plugin atlas-plugin sqoop-plugin solr-plugin kylin-plugin elasticsearch-plugin presto-plugin +for comp in admin usersync kms tagsync hdfs-plugin yarn-plugin hive-plugin hbase-plugin knox-plugin storm-plugin kafka-plugin atlas-plugin sqoop-plugin solr-plugin kylin-plugin elasticsearch-plugin trino-plugin do env RANGER_VERSION=%{ranger_base_version} /bin/bash %{SOURCE2} \ --prefix=$RPM_BUILD_ROOT \ @@ -580,7 +580,7 @@ fi %{usr_lib_ranger}-elasticsearch-plugin %{usr_lib_elasticsearch}/plugins -%files presto-plugin +%files trino-plugin %defattr(-,root,root,755) -%{usr_lib_ranger}-presto-plugin -%{usr_lib_presto}/plugin/ranger +%{usr_lib_ranger}-trino-plugin +%{usr_lib_trino}/plugin/ranger diff --git a/bigtop-packages/src/rpm/trino/RPMS/.gitignore b/bigtop-packages/src/rpm/trino/RPMS/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bigtop-packages/src/rpm/trino/SOURCES/.gitignore b/bigtop-packages/src/rpm/trino/SOURCES/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bigtop-packages/src/rpm/trino/SPECS/trino.spec b/bigtop-packages/src/rpm/trino/SPECS/trino.spec new file mode 100644 index 0000000000..21b038882d --- /dev/null +++ b/bigtop-packages/src/rpm/trino/SPECS/trino.spec @@ -0,0 +1,175 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +%define trino_name trino +%define trino_cli_name trino-cli +%define lib_trino /usr/lib/%{trino_name} +%define lib_trino_cli /usr/lib/%{trino_cli_name} +%define var_lib_trino /var/lib/%{trino_name} +%define var_run_trino /var/run/%{trino_name} +%define var_log_trino /var/log/%{trino_name} +%define bin_trino %{lib_trino}/bin/ +%define etc_trino %{lib_trino}/etc/ +%define config_trino /etc/%{trino_name} +%define bin /usr/bin/ +%define man_dir /usr/share/man/man1 +%define trino_services server +%define trino_current_version 415 +%define _binaries_in_noarch_packages_terminate_build 0 + +%if %{?suse_version:1}0 +%define doc_trino %{_docdir}/trino +%define alternatives_cmd update-alternatives +%else +%define doc_trino %{_docdir}/trino-%{trino_version} +%define alternatives_cmd alternatives +%endif + +# disable repacking jars +%define __os_install_post %{nil} + +Name: %{trino_name} +Version: %{trino_version} +Release: %{trino_release} +Summary: Distributed SQL Query Engine for Big Data +URL: https://trinodb.io/ +Group: Development/Libraries +BuildArch: noarch +Buildroot: %{_topdir}/INSTALL/%{name}-%{version} +License: ASL 2.0 +AutoReqProv: no +Source0: %{trino_name}.tar.gz +Source1: do-component-build +Source2: install_trino.sh +Source3: trino-server.svc +Source4: init.d.tmpl +Source5: bigtop.bom +Source6: trino.conf +Requires: python +Requires(preun): /sbin/service + +%define initd_link /etc/rc.d +%global initd_dir %{_sysconfdir}/rc.d/init.d +%global __provides_exclude_from ^%{_javadir}/%{name}/jbr/.*$ +%global __requires_exclude_from ^%{_javadir}/%{name}/jbr/.*$ + +%if %{?suse_version:1}0 && %{!?mgaversion:1}0 && %{!?amzn2:1}0 +# Required for init scripts +Requires: redhat-lsb +%endif + +# if amazonlinux2 +%if %{?amzn2:1}0 +Requires: sh-utils, system-lsb +%define initd_link /etc/rc.d + +%else +# Required for init scripts +Requires: /lib/lsb/init-functions +%define initd_link /etc/rc.d + +%endif + +%description +trino is an open source distributed SQL query engine for running +interactive analytic queries against data sources of all sizes ranging +from gigabytes to petabytes. + +%package server +Summary: trino Server +Group: Development/Libraries +BuildArch: noarch +Requires: %{name} = %{version}-%{release} + +%description server +Server for trino + +%package cli +Summary: trino CLI +Group: Development/Libraries +BuildArch: noarch +Requires: trino = %{version}-%{release} + +%description cli +CLI for trino + +%prep +%setup -n %{trino_name} + +%build +bash %{SOURCE1} + +%install +%__rm -rf $RPM_BUILD_ROOT +%__install -d -m 0755 $RPM_BUILD_ROOT/%{initd_dir}/ +bash %{SOURCE2} \ + --build-dir=build/trino \ + --cli-dir=build/trino-cli \ + --source-dir=$RPM_SOURCE_DIR \ + --prefix=$RPM_BUILD_ROOT + +for service in %{trino_services} +do + # Install init script + init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{trino_name}-${service} + bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/trino-${service}.svc rpm $init_file +done + +%post +%{alternatives_cmd} --install /etc/trino %{trino_name}-conf /etc/trino.dist 30 + +%preun +if [ "$1" = 0 ]; then + %{alternatives_cmd} --remove %{trino_name}-conf /etc/trino.dist || : +fi + +for service in %{trino_services}; do + /sbin/service %{trino_name}-${service} status > /dev/null 2>&1 + if [ $? -eq 0 ]; then + /sbin/service %{trino_name}-${service} stop > /dev/null 2>&1 + fi +done + + +%files +%defattr(-,root,root,755) +%config(noreplace) %{config_trino}.dist +%{lib_trino}/README.txt +%{lib_trino}/NOTICE +%{lib_trino}/bin +%{lib_trino}/lib +%{lib_trino}/plugin +%{lib_trino}/etc + +%files cli +%{lib_trino_cli}/trino + +%define service_macro() \ +%files %1 \ +%config(noreplace) %{initd_dir}/%{trino_name}-%1 \ +%post %1 \ +chkconfig --add %{trino_name}-%1 \ +%preun %1 \ +/sbin/service %{trino_name}-%1 status > /dev/null 2>&1 \ +if [ "$?" -eq 0 ]; then \ + service %{trino_name}-%1 stop > /dev/null 2>&1 \ + chkconfig --del %{trino_name}-%1 \ +fi \ +%postun %1 \ +if [ "$?" -ge 1 ]; then \ + service %{trino_name}-%1 condrestart > /dev/null 2>&1 || : \ +fi +%service_macro server + diff --git a/bigtop-packages/src/rpm/trino/SRPMS/.gitignore b/bigtop-packages/src/rpm/trino/SRPMS/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bigtop-packages/src/templates/trino-server b/bigtop-packages/src/templates/trino-server new file mode 100755 index 0000000000..51e98a8f6b --- /dev/null +++ b/bigtop-packages/src/templates/trino-server @@ -0,0 +1,182 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Starts a +# +# chkconfig: 345 85 15 +# description: +# pidfile: +### BEGIN INIT INFO +# Provides: +# Short-Description: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Required-Start: $syslog $remote_fs +# Required-Stop: $syslog $remote_fs +# Should-Start: +# Should-Stop: +### END INIT INFO + +. /lib/lsb/init-functions +BIGTOP_DEFAULTS_DIR=${BIGTOP_DEFAULTS_DIR-/etc/default} +[ -n "${BIGTOP_DEFAULTS_DIR}" -a -r ${BIGTOP_DEFAULTS_DIR}/hadoop ] && . ${BIGTOP_DEFAULTS_DIR}/hadoop +[ -n "${BIGTOP_DEFAULTS_DIR}" -a -r ${BIGTOP_DEFAULTS_DIR}/ ] && . ${BIGTOP_DEFAULTS_DIR}/ + +# Autodetect JAVA_HOME if not defined +. /usr/lib/bigtop-utils/bigtop-detect-javahome + +RETVAL_SUCCESS=0 + +STATUS_RUNNING=0 +STATUS_DEAD=1 +STATUS_DEAD_AND_LOCK=2 +STATUS_NOT_RUNNING=3 +STATUS_OTHER_ERROR=102 + + +ERROR_PROGRAM_NOT_INSTALLED=5 +ERROR_PROGRAM_NOT_CONFIGURED=6 + + +RETVAL=0 +SLEEP_TIME=5 +PROC_NAME="java" + +DAEMON="" +DESC="" +EXEC_PATH="" +SVC_USER="" +DAEMON_FLAGS="" +CONF_DIR="" +CONF_FILE="" +LOGFILE="" +PIDFILE="" +LOCKDIR="/var/lock/subsys" +LOCKFILE="$LOCKDIR/" +WORKING_DIR="~/" + +install -d -m 0755 -o -g 1>/dev/null 2>&1 || : +[ -d "$LOCKDIR" ] || install -d -m 0755 $LOCKDIR 1>/dev/null 2>&1 || : + +start() { + [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED + [ -d $CONF_DIR ] || exit $ERROR_PROGRAM_NOT_CONFIGURED + + runuser -s /bin/bash $SVC_USER -c "cd $WORKING_DIR && $EXEC_PATH --config '$CONF_DIR' start $DAEMON_FLAGS" + + # Some processes are slow to start + sleep $SLEEP_TIME + checkstatusofproc + RETVAL=$? + + if [ $RETVAL -eq $STATUS_RUNNING ]; then + touch $LOCKFILE + log_success_msg "Started ${DESC}: " + else + log_failure_msg "Failed to start ${DESC}. Return value: $RETVAL" + fi + return $RETVAL +} + + +stop() { + start_daemon $EXEC_PATH --config "$CONF_DIR" stop $DAEMON_FLAGS + RETVAL=$? + + if [ $RETVAL -eq $RETVAL_SUCCESS ]; then + log_success_msg "Stopped ${DESC}: " + rm -f $LOCKFILE $PIDFILE + else + log_failure_msg "Failed to stop ${DESC}. Return value: $RETVAL." + fi +} + +restart() { + stop + start +} + +checkstatusofproc(){ + pidofproc -p $PIDFILE $PROC_NAME > /dev/null +} + +checkstatus(){ + checkstatusofproc + status=$? + case "$status" in + $STATUS_RUNNING) + log_success_msg "${DESC} is running" + ;; + $STATUS_DEAD) + log_failure_msg "${DESC} is dead and pid file exists" + ;; + $STATUS_DEAD_AND_LOCK) + log_failure_msg "${DESC} is dead and lock file exists" + ;; + $STATUS_NOT_RUNNING) + log_failure_msg "${DESC} is not running" + ;; + *) + log_failure_msg "${DESC} status is unknown" + ;; + esac + return $status +} + +condrestart(){ + [ -e $LOCKFILE ] && restart || : +} + +check_for_root() { + if [ $(id -ur) -ne 0 ]; then + echo 'Error: root user required' + echo + exit 1 + fi +} + +service() { + case "$1" in + start) + check_for_root + start + ;; + stop) + check_for_root + stop + ;; + status) + checkstatus + RETVAL=$? + ;; + restart|force-reload) + check_for_root + restart + ;; + condrestart|try-restart) + check_for_root + condrestart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart|force-reload}" + exit 1 + esac +} + +service "$@" + +exit $RETVAL diff --git a/bigtop.bom b/bigtop.bom index 6123b67930..1b46e883a7 100644 --- a/bigtop.bom +++ b/bigtop.bom @@ -378,5 +378,15 @@ bigtop { archive = site } packaging = 'rpm' } + 'trino' { + name = 'trino' + relNotes = 'Trino is an open source distributed SQL query engine' + version { base = '415'; pkg = base; release = 1 } + tarball { destination = "trino.tar.gz" + source = "trino.tar.gz" } + git { repo = "https://github.com/trinodb/trino.git" + ref = "release-v415" + dir = "$name" } + } } } diff --git a/install_trino.sh b/install_trino.sh new file mode 100644 index 0000000000..c04bbc6663 --- /dev/null +++ b/install_trino.sh @@ -0,0 +1,124 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +usage() { + echo " +usage: $0 + Required not-so-options: + --build-dir=DIR path to dist.dir + --source-dir=DIR path to package shared files dir + --prefix=PREFIX path to install into + Optional options: + --doc-dir=DIR path to install docs into [/usr/share/doc/trino] + --lib-dir=DIR path to install trino home [/usr/lib/trino] + --installed-lib-dir=DIR path where lib-dir will end up on target system + --bin-dir=DIR path to install bins [/usr/bin] + ... [ see source for more similar options ] + " + exit 1 +} + +OPTS=$(getopt \ + -n $0 \ + -o '' \ + -l 'prefix:' \ + -l 'lib-dir:' \ + -l 'installed-lib-dir:' \ + -l 'bin-dir:' \ + -l 'trino-version:' \ + -l 'source-dir:' \ + -l 'cli-dir:' \ + -l 'build-dir:' -- "$@") + +if [ $? != 0 ] ; then + usage +fi + +eval set -- "$OPTS" +while true ; do + case "$1" in + --prefix) + PREFIX=$2 ; shift 2 + ;; + --build-dir) + BUILD_DIR=$2 ; shift 2 + ;; + --source-dir) + SOURCE_DIR=$2 ; shift 2 + ;; + --cli-dir) + CLI_BUILD_DIR=$2 ; shift 2 + ;; + --lib-dir) + LIB_DIR=$2 ; shift 2 + ;; + --installed-lib-dir) + INSTALLED_LIB_DIR=$2 ; shift 2 + ;; + --bin-dir) + BIN_DIR=$2 ; shift 2 + ;; + --) + shift ; break + ;; + *) + echo "Unknown option: $1" + usage + exit 1 + ;; + esac +done + +for var in PREFIX BUILD_DIR SOURCE_DIR ; do + if [ -z "$(eval "echo \$$var")" ]; then + echo Missing param: $var + usage + fi +done + +if [ -f "$SOURCE_DIR/bigtop.bom" ]; then + . $SOURCE_DIR/bigtop.bom +fi + +MAN_DIR=${MAN_DIR:-/usr/share/man}/man1 +DOC_DIR=${DOC_DIR:-/usr/share/doc/trino} +CLI_DIR=${CLI_DIR:-/usr/lib/trino-cli} +LIB_DIR=${TRINO_DIR:-/usr/lib/trino} +VAR_DIR=${VAR_DIR:-/var/lib/trino} +LOG_DIR=${LOG_DIR:-/var/log/trino} +RUN_DIR=${RUN_DIR:-/var/run/trino} +INSTALLED_LIB_DIR=${INSTALLED_LIB_DIR:-/usr/lib/trino} +BIN_DIR=${BIN_DIR:-/usr/bin} +CONF_DIR=${CONF_DIR:-/etc/trino} +CONF_DIST_DIR=${CONF_DIST_DIR:-/etc/trino.dist} +DEFAULT_DIR=${DEFAULT_DIR:-/etc/default} + +install -d -m 0755 $PREFIX/$CONF_DIST_DIR +install -d -m 0755 $PREFIX/$LIB_DIR +install -d -m 0755 $PREFIX/$CLI_DIR +install -d -m 0755 $PREFIX/$DOC_DIR +install -d -m 0755 $PREFIX/$VAR_DIR +install -d -m 0755 $PREFIX/$LOG_DIR +install -d -m 0755 $PREFIX/$RUN_DIR +install -d -m 0755 $PREFIX/$DEFAULT_DIR + +cp -ra ${BUILD_DIR}/* $PREFIX/$LIB_DIR/ +cp -ra ${CLI_BUILD_DIR}/* $PREFIX/$CLI_DIR/ + +chmod +x $PREFIX/$LIB_DIR/bin/launcher From 07239d75e1ced538aff069b5392b5c7e41caf5bb Mon Sep 17 00:00:00 2001 From: "kedia,Akanksha" Date: Thu, 3 Aug 2023 15:03:24 +0530 Subject: [PATCH 2/2] BIGTOP-3959: RPM packaging for TRINO --- .../src/common/ranger/do-component-build | 1 - .../src/common/trino/developers.rst | 28 +++ .../src/common/trino/do-component-build | 41 ++++ .../src/common/trino/getting-started.rst | 20 ++ .../src/common/trino/install_trino.sh | 193 ++++++++++++++++++ .../src/common/trino/trino-server.svc | 125 ++++++++++++ bigtop-packages/src/common/trino/trino.conf | 17 ++ bigtop-packages/src/deb/trino/control | 41 ++++ bigtop-packages/src/deb/trino/copyright | 15 ++ bigtop-packages/src/deb/trino/rules | 45 ++++ bigtop-packages/src/deb/trino/trino.install | 10 + bigtop-packages/src/deb/trino/trino.postinst | 99 +++++++++ bigtop-packages/src/deb/trino/trino.prerm | 38 ++++ .../src/rpm/ranger/SPECS/ranger.spec | 2 +- bigtop-packages/src/rpm/trino/RPMS/.gitignore | 0 .../src/rpm/trino/SOURCES/.gitignore | 0 .../src/rpm/trino/SPECS/trino.spec | 175 ++++++++++++++++ .../src/rpm/trino/SRPMS/.gitignore | 0 bigtop-packages/src/templates/trino-server | 182 +++++++++++++++++ bigtop.bom | 10 + bigtop_toolchain/manifests/jdk17.pp | 32 +++ 21 files changed, 1072 insertions(+), 2 deletions(-) create mode 100644 bigtop-packages/src/common/trino/developers.rst create mode 100644 bigtop-packages/src/common/trino/do-component-build create mode 100644 bigtop-packages/src/common/trino/getting-started.rst create mode 100644 bigtop-packages/src/common/trino/install_trino.sh create mode 100644 bigtop-packages/src/common/trino/trino-server.svc create mode 100644 bigtop-packages/src/common/trino/trino.conf create mode 100644 bigtop-packages/src/deb/trino/control create mode 100644 bigtop-packages/src/deb/trino/copyright create mode 100644 bigtop-packages/src/deb/trino/rules create mode 100644 bigtop-packages/src/deb/trino/trino.install create mode 100644 bigtop-packages/src/deb/trino/trino.postinst create mode 100644 bigtop-packages/src/deb/trino/trino.prerm create mode 100644 bigtop-packages/src/rpm/trino/RPMS/.gitignore create mode 100644 bigtop-packages/src/rpm/trino/SOURCES/.gitignore create mode 100644 bigtop-packages/src/rpm/trino/SPECS/trino.spec create mode 100644 bigtop-packages/src/rpm/trino/SRPMS/.gitignore create mode 100755 bigtop-packages/src/templates/trino-server create mode 100644 bigtop_toolchain/manifests/jdk17.pp diff --git a/bigtop-packages/src/common/ranger/do-component-build b/bigtop-packages/src/common/ranger/do-component-build index 016fa3ba7f..b73f4f0e26 100644 --- a/bigtop-packages/src/common/ranger/do-component-build +++ b/bigtop-packages/src/common/ranger/do-component-build @@ -18,7 +18,6 @@ set -e . `dirname $0`/bigtop.bom - mvn clean compile package install \ -DskipTests=true \ -Dcheckstyle.skip=true \ diff --git a/bigtop-packages/src/common/trino/developers.rst b/bigtop-packages/src/common/trino/developers.rst new file mode 100644 index 0000000000..f153f2bfce --- /dev/null +++ b/bigtop-packages/src/common/trino/developers.rst @@ -0,0 +1,28 @@ +For Developers: Building a component from Git repository + +Prerequisites + +You will need git installed. +You will need java 17 installed for Trino +Java 8 for bigtop +You will need to use gradlew which is included in the source code. (Right in the root of the project folder) +This project's gradlew has more documentation here +Use git to download BigTop : +git clone https://github.com/apache/bigtop.git + +move into the root project folder: +cd bigtop + +To fetch source from a Git repository, there're two ways to achieve this: a). modify ./bigtop.bom and add JSON snippets to your component/package, or b). specify properties at command line + +bigtop.bom +Add following JSON snippets to the desired component/package: + +git { repo = ""; ref = ""; dir = ""; commit_hash = "" } +repo - SSH, HTTP or local path to Git repo. +ref - branch, tag or commit hash to check out. +dir - [OPTIONAL] directory name to write source into. +commit_hash - [OPTIONAL] a commit hash to reset to. +Some packages have different names for source directory and source tarball (hbase-0.98.5-src.tar.gz contains hbase-0.98.5 directory). By default source will be fetched in a directory named by tarball { source = TARBALL_SRC } without .t* extension. To explicitly set directory name use the dir option. + +When commit_hash specified, the repo to build the package will be reset to the commit hash. diff --git a/bigtop-packages/src/common/trino/do-component-build b/bigtop-packages/src/common/trino/do-component-build new file mode 100644 index 0000000000..836141b709 --- /dev/null +++ b/bigtop-packages/src/common/trino/do-component-build @@ -0,0 +1,41 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + + +. `dirname $0`/bigtop.bom +mkdir trino +# Apply the Puppet manifest to download and extract JDK +sudo puppet apply jdk17_download.pp +# Set JAVA_HOME for this session to the JDK downloaded by the Puppet manifest +export JAVA_HOME=/opt/jdk-17.0.2 +echo JAVA_HOME=`pwd`/`ls | grep "jdk-*"` >> ~/.bash_profile +source ~/.bash_profile + +# Setting versions for trino build +mvn clean -pl !plugin/trino-kafka,!testing/trino-benchto-benchmarks,!docs install -DskipTests -Dcheckstyle.skipExec -Dmaven.wagon.http.ssl.allowall=true +sed -i '$ d' ~/.bash_profile +source ~/.bash_profile +rm -rf `pwd`/`ls | grep "jdk-*"` + +mkdir -p build/trino +mkdir -p build/trino-cli + +# Server +tar -C build/trino --strip-components=1 -xzf core/trino-server/target/*.tar.gz +# CLI +cp -ra client/trino-cli/target/*-executable.jar build/trino-cli/trino diff --git a/bigtop-packages/src/common/trino/getting-started.rst b/bigtop-packages/src/common/trino/getting-started.rst new file mode 100644 index 0000000000..d8946f641b --- /dev/null +++ b/bigtop-packages/src/common/trino/getting-started.rst @@ -0,0 +1,20 @@ +Getting started with bigtop packaging. + +1) You will have to package rpm. + +2) Here are some steps you can follow to bring a new bigtop package in. + +determine where your source is, and add it to bigtop.bom +update the bigtop-packages/src/common/ folder to have your component, +and the do-component-build for it (which usually just builds a jar). +Why is there a "common" directory? Simply because deb and rpm packaging share some tasks (like do-component-build, +which just usually runs a mvn or gradle command), and so we keep a common install directory which they can both leverage for packaging. +(for RPM) now add a .spec file into bigtop-packages/src//... into the appropriate directory +(i.e. bigtop-packages/src/rpm/tachyon/SPECS/tachyon.spec). +Obviously, your tachyon.spec file will use whats in common/ in a RPM specific way, to install the RPM package. +create a rules file using do-component-build + +Test it with gradle -rpm for the others. +Finally add a smoke test! This is as easy as adding a new groovy file to bitop-tests/smoke-tests//TestThisStuff.groovy, +following conventions that others have created. +3) As always, we will improve on the directions above, but this should help to get you started. . \ No newline at end of file diff --git a/bigtop-packages/src/common/trino/install_trino.sh b/bigtop-packages/src/common/trino/install_trino.sh new file mode 100644 index 0000000000..bb43d6a26c --- /dev/null +++ b/bigtop-packages/src/common/trino/install_trino.sh @@ -0,0 +1,193 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +usage() { + echo " +usage: $0 + Required not-so-options: + --build-dir=DIR path to dist.dir + --source-dir=DIR path to package shared files dir + --prefix=PREFIX path to install into + Optional options: + --doc-dir=DIR path to install docs into [/usr/share/doc/trino] + --lib-dir=DIR path to install trino home [/usr/lib/trino] + --installed-lib-dir=DIR path where lib-dir will end up on target system + --bin-dir=DIR path to install bins [/usr/bin] + ... [ see source for more similar options ] + " + exit 1 +} + +OPTS=$(getopt \ + -n $0 \ + -o '' \ + -l 'prefix:' \ + -l 'lib-dir:' \ + -l 'installed-lib-dir:' \ + -l 'bin-dir:' \ + -l 'trino-version:' \ + -l 'source-dir:' \ + -l 'cli-dir:' \ + -l 'build-dir:' -- "$@") + +if [ $? != 0 ] ; then + usage +fi + +eval set -- "$OPTS" +while true ; do + case "$1" in + --prefix) + PREFIX=$2 ; shift 2 + ;; + --build-dir) + BUILD_DIR=$2 ; shift 2 + ;; + --source-dir) + SOURCE_DIR=$2 ; shift 2 + ;; + --cli-dir) + CLI_BUILD_DIR=$2 ; shift 2 + ;; + --lib-dir) + LIB_DIR=$2 ; shift 2 + ;; + --installed-lib-dir) + INSTALLED_LIB_DIR=$2 ; shift 2 + ;; + --bin-dir) + BIN_DIR=$2 ; shift 2 + ;; + --) + shift ; break + ;; + *) + echo "Unknown option: $1" + usage + exit 1 + ;; + esac +done + +for var in PREFIX BUILD_DIR SOURCE_DIR ; do + if [ -z "$(eval "echo \$$var")" ]; then + echo Missing param: $var + usage + fi +done + +if [ -f "$SOURCE_DIR/bigtop.bom" ]; then + . $SOURCE_DIR/bigtop.bom +fi + +MAN_DIR=${MAN_DIR:-/usr/share/man}/man1 +DOC_DIR=${DOC_DIR:-/usr/share/doc/trino} +CLI_DIR=${CLI_DIR:-/usr/lib/trino-cli} +LIB_DIR=${TRINO_DIR:-/usr/lib/trino} +VAR_DIR=${VAR_DIR:-/var/lib/trino} +LOG_DIR=${LOG_DIR:-/var/log/trino} +RUN_DIR=${RUN_DIR:-/var/run/trino} +INSTALLED_LIB_DIR=${INSTALLED_LIB_DIR:-/usr/lib/trino} +BIN_DIR=${BIN_DIR:-/usr/bin} +CONF_DIR=${CONF_DIR:-/etc/trino} +CONF_DIST_DIR=${CONF_DIST_DIR:-/etc/trino.dist} +DEFAULT_DIR=${DEFAULT_DIR:-/etc/default} + +install -d -m 0755 $PREFIX/$CONF_DIST_DIR +install -d -m 0755 $PREFIX/$LIB_DIR +install -d -m 0755 $PREFIX/$CLI_DIR +install -d -m 0755 $PREFIX/$DOC_DIR +install -d -m 0755 $PREFIX/$VAR_DIR +install -d -m 0755 $PREFIX/$LOG_DIR +install -d -m 0755 $PREFIX/$RUN_DIR +install -d -m 0755 $PREFIX/$DEFAULT_DIR + +cp -ra ${BUILD_DIR}/* $PREFIX/$LIB_DIR/ +cp -ra ${CLI_BUILD_DIR}/* $PREFIX/$CLI_DIR/ + +chmod +x $PREFIX/$LIB_DIR/bin/launcher + +install -d -m 0755 $PREFIX/$CONF_DIST_DIR +install -d -m 0755 $PREFIX/$CONF_DIST_DIR/catalog + +cat > $PREFIX/$CONF_DIST_DIR/node.properties < $PREFIX/$CONF_DIST_DIR/jvm.config < $PREFIX/$CONF_DIST_DIR/config.properties < $PREFIX/$CONF_DIST_DIR/log.properties < $PREFIX/$CONF_DIST_DIR/catalog/tpch.properties < $PREFIX/$CONF_DIST_DIR/catalog/tpcds.properties < $PREFIX/$CONF_DIST_DIR/catalog/jmx.properties <> ~/.bash_profile + source ~/.bash_profile + echo $JAVA_HOME + export PATH=/tmp/jdk-17.0.2/bin:$PATH + echo $PATH +} + +__EOT__ +} + +generate_load_config() { + +cat << '__EOT__' + +USER="$SVC_USER" +CONF_DIR="${TRINO_HOME}/bin/" +. $CONF_DIR/launcher start + +trino_PID_DIR="${trino_PID_DIR:-/var/run/trino}" + +__EOT__ + +} + +generate_start() { + +cat <<'__EOT__' +start() { + trino_env + # node.id + sed -i -e "s#ffffffff-ffff-ffff-ffff-ffffffffffff#$(cat /proc/sys/kernel/random/uuid)#" ${CONF_DIR}/node.properties + + [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED + log_success_msg "Starting $DESC (${DAEMON}): " + + checkstatusofproc + status=$? + if [ "$status" -eq "$STATUS_RUNNING" ]; then + log_success_msg "${DESC} is running" + exit 0 + fi + + runuser -s /bin/bash $SVC_USER -c "${EXEC_PATH} start $DAEMON_FLAGS" + + sleep 3 + + checkstatusofproc + RETVAL=$? + if [ $RETVAL -eq $STATUS_RUNNING ]; then + touch $LOCKFILE + log_success_msg "Started ${DESC} (${DAEMON}): " + else + log_failure_msg "Failed to start ${DESC}. Return value: $RETVAL" + fi + + return $RETVAL +} +__EOT__ + +} + +generate_stop() { + +cat <<'__EOT__' +stop() { + log_success_msg "Stopping $DESC (${DAEMON}): " + runuser -s /bin/bash $SVC_USER -c "${EXEC_PATH} stop $DAEMON_FLAGS" + sleep 3 + RETVAL=$? + + if [ $RETVAL -eq $RETVAL_SUCCESS ]; then + log_success_msg "Stopped ${DESC}: " + rm -f $LOCKFILE $PIDFILE + else + log_failure_msg "Failure to stop ${DESC}. Return value: $RETVAL" + fi + + return $RETVAL +} +__EOT__ + +} + diff --git a/bigtop-packages/src/common/trino/trino.conf b/bigtop-packages/src/common/trino/trino.conf new file mode 100644 index 0000000000..ca160ff729 --- /dev/null +++ b/bigtop-packages/src/common/trino/trino.conf @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +trino - nofile 32768 +trino - nproc 65536 \ No newline at end of file diff --git a/bigtop-packages/src/deb/trino/control b/bigtop-packages/src/deb/trino/control new file mode 100644 index 0000000000..625803008b --- /dev/null +++ b/bigtop-packages/src/deb/trino/control @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Source: trino +Section: misc +Priority: extra +Maintainer: Bigtop +Build-Depends: debhelper (>= 9) +Standards-Version: 3.4.5 + +Package: trino +Architecture: any +Depends: adduser, bigtop-utils (>= 0.7) +Description: + trino is an open source distributed SQL query engine for running + interactive analytic queries against data sources of all sizes ranging + from gigabytes to petabytes. + +Package: trino-server +Architecture: all +Depends: trino (= ${source:Version}), python | python2 +Description: Server for trino + Server for trino + +Package: trino-cli +Architecture: all +Depends: trino (= ${source:Version}) +Description: trino CLI + trino CLI \ No newline at end of file diff --git a/bigtop-packages/src/deb/trino/copyright b/bigtop-packages/src/deb/trino/copyright new file mode 100644 index 0000000000..2a73a85bce --- /dev/null +++ b/bigtop-packages/src/deb/trino/copyright @@ -0,0 +1,15 @@ +Format: http://dep.debian.net/deps/dep5 +Source: https://trinodb.io/ +Upstream-Name: trino + +Files: * +Copyright: 2013, Facebook +License: Apache-2.0 + +Files debian/* +Copyright: 2011, The Apache Software Foundation +License: Apache-2.0 + +License: Apache-2.0 +On Debian systems, the complete text of the Apache 2.0 license +can be found in "/usr/share/common-licenses/Apache-2.0". \ No newline at end of file diff --git a/bigtop-packages/src/deb/trino/rules b/bigtop-packages/src/deb/trino/rules new file mode 100644 index 0000000000..6cc6d95e24 --- /dev/null +++ b/bigtop-packages/src/deb/trino/rules @@ -0,0 +1,45 @@ +#!/usr/bin/make -f + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +%: + dh $@ + +override_dh_auto_build: + bash debian/do-component-build + +svcs=trino-server + +$(svcs): debian/init.d.tmpl + bash $< debian/$@.svc deb debian/$@.init + touch $@ + +override_dh_auto_install: $(svcs) + bash -x debian/install_trino.sh \ + --build-dir=build/trino-${trino_VERSION} \ + --doc-dir=/usr/share/doc/trino \ + --source-dir=debian \ + --prefix=debian/tmp + + mkdir -p debian/tmp/etc/security/limits.d + cp debian/trino.conf debian/tmp/etc/security/limits.d diff --git a/bigtop-packages/src/deb/trino/trino.install b/bigtop-packages/src/deb/trino/trino.install new file mode 100644 index 0000000000..f3558a1613 --- /dev/null +++ b/bigtop-packages/src/deb/trino/trino.install @@ -0,0 +1,10 @@ +/etc/security/limits.d/trino.conf +/etc/trino.dist +/usr/lib/trino/README.txt +/usr/lib/trino/NOTICE +/usr/lib/trino/bin +/usr/lib/trino/lib +/usr/lib/trino/plugin +/var/lib/trino +/var/log/trino +/var/run/trino diff --git a/bigtop-packages/src/deb/trino/trino.postinst b/bigtop-packages/src/deb/trino/trino.postinst new file mode 100644 index 0000000000..c6022af9d8 --- /dev/null +++ b/bigtop-packages/src/deb/trino/trino.postinst @@ -0,0 +1,99 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +case "$1" in + configure) + # Install config alternatives + update-alternatives --install /etc/trino/etc trino-etc /etc/trino/etc.dist 30 + chown -R trino:trino /var/log/trino /var/lib/trino /var/run/trino + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + 62 bigtop-packages/src/deb/trino/trino.preinst +Viewed +@@ -0,0 +1,62 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# preinst script for trino +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + if ! getent passwd trino >/dev/null; then + # Adding system user: trino . + adduser \ + --system \ + --group \ + --home /var/lib/trino \ + --gecos "trino" \ + --shell /bin/false \ + trino >/dev/null + fi + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/bigtop-packages/src/deb/trino/trino.prerm b/bigtop-packages/src/deb/trino/trino.prerm new file mode 100644 index 0000000000..c6ebe56614 --- /dev/null +++ b/bigtop-packages/src/deb/trino/trino.prerm @@ -0,0 +1,38 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +case "$1" in + remove|upgrade|deconfigure) + update-alternatives --remove trino-etc /etc/trino/etc.dist || : + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 \ No newline at end of file diff --git a/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec b/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec index 794d986772..d55d15dd3b 100644 --- a/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec +++ b/bigtop-packages/src/rpm/ranger/SPECS/ranger.spec @@ -402,7 +402,7 @@ Group: System/Daemons AutoReq: no %description presto-plugin -Ranger PRESTO plugin component runs within presto to provide enterprise security using ranger framework +Ranger presto plugin component runs within presto to provide enterprise security using ranger framework %prep diff --git a/bigtop-packages/src/rpm/trino/RPMS/.gitignore b/bigtop-packages/src/rpm/trino/RPMS/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bigtop-packages/src/rpm/trino/SOURCES/.gitignore b/bigtop-packages/src/rpm/trino/SOURCES/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bigtop-packages/src/rpm/trino/SPECS/trino.spec b/bigtop-packages/src/rpm/trino/SPECS/trino.spec new file mode 100644 index 0000000000..21b038882d --- /dev/null +++ b/bigtop-packages/src/rpm/trino/SPECS/trino.spec @@ -0,0 +1,175 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +%define trino_name trino +%define trino_cli_name trino-cli +%define lib_trino /usr/lib/%{trino_name} +%define lib_trino_cli /usr/lib/%{trino_cli_name} +%define var_lib_trino /var/lib/%{trino_name} +%define var_run_trino /var/run/%{trino_name} +%define var_log_trino /var/log/%{trino_name} +%define bin_trino %{lib_trino}/bin/ +%define etc_trino %{lib_trino}/etc/ +%define config_trino /etc/%{trino_name} +%define bin /usr/bin/ +%define man_dir /usr/share/man/man1 +%define trino_services server +%define trino_current_version 415 +%define _binaries_in_noarch_packages_terminate_build 0 + +%if %{?suse_version:1}0 +%define doc_trino %{_docdir}/trino +%define alternatives_cmd update-alternatives +%else +%define doc_trino %{_docdir}/trino-%{trino_version} +%define alternatives_cmd alternatives +%endif + +# disable repacking jars +%define __os_install_post %{nil} + +Name: %{trino_name} +Version: %{trino_version} +Release: %{trino_release} +Summary: Distributed SQL Query Engine for Big Data +URL: https://trinodb.io/ +Group: Development/Libraries +BuildArch: noarch +Buildroot: %{_topdir}/INSTALL/%{name}-%{version} +License: ASL 2.0 +AutoReqProv: no +Source0: %{trino_name}.tar.gz +Source1: do-component-build +Source2: install_trino.sh +Source3: trino-server.svc +Source4: init.d.tmpl +Source5: bigtop.bom +Source6: trino.conf +Requires: python +Requires(preun): /sbin/service + +%define initd_link /etc/rc.d +%global initd_dir %{_sysconfdir}/rc.d/init.d +%global __provides_exclude_from ^%{_javadir}/%{name}/jbr/.*$ +%global __requires_exclude_from ^%{_javadir}/%{name}/jbr/.*$ + +%if %{?suse_version:1}0 && %{!?mgaversion:1}0 && %{!?amzn2:1}0 +# Required for init scripts +Requires: redhat-lsb +%endif + +# if amazonlinux2 +%if %{?amzn2:1}0 +Requires: sh-utils, system-lsb +%define initd_link /etc/rc.d + +%else +# Required for init scripts +Requires: /lib/lsb/init-functions +%define initd_link /etc/rc.d + +%endif + +%description +trino is an open source distributed SQL query engine for running +interactive analytic queries against data sources of all sizes ranging +from gigabytes to petabytes. + +%package server +Summary: trino Server +Group: Development/Libraries +BuildArch: noarch +Requires: %{name} = %{version}-%{release} + +%description server +Server for trino + +%package cli +Summary: trino CLI +Group: Development/Libraries +BuildArch: noarch +Requires: trino = %{version}-%{release} + +%description cli +CLI for trino + +%prep +%setup -n %{trino_name} + +%build +bash %{SOURCE1} + +%install +%__rm -rf $RPM_BUILD_ROOT +%__install -d -m 0755 $RPM_BUILD_ROOT/%{initd_dir}/ +bash %{SOURCE2} \ + --build-dir=build/trino \ + --cli-dir=build/trino-cli \ + --source-dir=$RPM_SOURCE_DIR \ + --prefix=$RPM_BUILD_ROOT + +for service in %{trino_services} +do + # Install init script + init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{trino_name}-${service} + bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/trino-${service}.svc rpm $init_file +done + +%post +%{alternatives_cmd} --install /etc/trino %{trino_name}-conf /etc/trino.dist 30 + +%preun +if [ "$1" = 0 ]; then + %{alternatives_cmd} --remove %{trino_name}-conf /etc/trino.dist || : +fi + +for service in %{trino_services}; do + /sbin/service %{trino_name}-${service} status > /dev/null 2>&1 + if [ $? -eq 0 ]; then + /sbin/service %{trino_name}-${service} stop > /dev/null 2>&1 + fi +done + + +%files +%defattr(-,root,root,755) +%config(noreplace) %{config_trino}.dist +%{lib_trino}/README.txt +%{lib_trino}/NOTICE +%{lib_trino}/bin +%{lib_trino}/lib +%{lib_trino}/plugin +%{lib_trino}/etc + +%files cli +%{lib_trino_cli}/trino + +%define service_macro() \ +%files %1 \ +%config(noreplace) %{initd_dir}/%{trino_name}-%1 \ +%post %1 \ +chkconfig --add %{trino_name}-%1 \ +%preun %1 \ +/sbin/service %{trino_name}-%1 status > /dev/null 2>&1 \ +if [ "$?" -eq 0 ]; then \ + service %{trino_name}-%1 stop > /dev/null 2>&1 \ + chkconfig --del %{trino_name}-%1 \ +fi \ +%postun %1 \ +if [ "$?" -ge 1 ]; then \ + service %{trino_name}-%1 condrestart > /dev/null 2>&1 || : \ +fi +%service_macro server + diff --git a/bigtop-packages/src/rpm/trino/SRPMS/.gitignore b/bigtop-packages/src/rpm/trino/SRPMS/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/bigtop-packages/src/templates/trino-server b/bigtop-packages/src/templates/trino-server new file mode 100755 index 0000000000..51e98a8f6b --- /dev/null +++ b/bigtop-packages/src/templates/trino-server @@ -0,0 +1,182 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Starts a +# +# chkconfig: 345 85 15 +# description: +# pidfile: +### BEGIN INIT INFO +# Provides: +# Short-Description: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Required-Start: $syslog $remote_fs +# Required-Stop: $syslog $remote_fs +# Should-Start: +# Should-Stop: +### END INIT INFO + +. /lib/lsb/init-functions +BIGTOP_DEFAULTS_DIR=${BIGTOP_DEFAULTS_DIR-/etc/default} +[ -n "${BIGTOP_DEFAULTS_DIR}" -a -r ${BIGTOP_DEFAULTS_DIR}/hadoop ] && . ${BIGTOP_DEFAULTS_DIR}/hadoop +[ -n "${BIGTOP_DEFAULTS_DIR}" -a -r ${BIGTOP_DEFAULTS_DIR}/ ] && . ${BIGTOP_DEFAULTS_DIR}/ + +# Autodetect JAVA_HOME if not defined +. /usr/lib/bigtop-utils/bigtop-detect-javahome + +RETVAL_SUCCESS=0 + +STATUS_RUNNING=0 +STATUS_DEAD=1 +STATUS_DEAD_AND_LOCK=2 +STATUS_NOT_RUNNING=3 +STATUS_OTHER_ERROR=102 + + +ERROR_PROGRAM_NOT_INSTALLED=5 +ERROR_PROGRAM_NOT_CONFIGURED=6 + + +RETVAL=0 +SLEEP_TIME=5 +PROC_NAME="java" + +DAEMON="" +DESC="" +EXEC_PATH="" +SVC_USER="" +DAEMON_FLAGS="" +CONF_DIR="" +CONF_FILE="" +LOGFILE="" +PIDFILE="" +LOCKDIR="/var/lock/subsys" +LOCKFILE="$LOCKDIR/" +WORKING_DIR="~/" + +install -d -m 0755 -o -g 1>/dev/null 2>&1 || : +[ -d "$LOCKDIR" ] || install -d -m 0755 $LOCKDIR 1>/dev/null 2>&1 || : + +start() { + [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED + [ -d $CONF_DIR ] || exit $ERROR_PROGRAM_NOT_CONFIGURED + + runuser -s /bin/bash $SVC_USER -c "cd $WORKING_DIR && $EXEC_PATH --config '$CONF_DIR' start $DAEMON_FLAGS" + + # Some processes are slow to start + sleep $SLEEP_TIME + checkstatusofproc + RETVAL=$? + + if [ $RETVAL -eq $STATUS_RUNNING ]; then + touch $LOCKFILE + log_success_msg "Started ${DESC}: " + else + log_failure_msg "Failed to start ${DESC}. Return value: $RETVAL" + fi + return $RETVAL +} + + +stop() { + start_daemon $EXEC_PATH --config "$CONF_DIR" stop $DAEMON_FLAGS + RETVAL=$? + + if [ $RETVAL -eq $RETVAL_SUCCESS ]; then + log_success_msg "Stopped ${DESC}: " + rm -f $LOCKFILE $PIDFILE + else + log_failure_msg "Failed to stop ${DESC}. Return value: $RETVAL." + fi +} + +restart() { + stop + start +} + +checkstatusofproc(){ + pidofproc -p $PIDFILE $PROC_NAME > /dev/null +} + +checkstatus(){ + checkstatusofproc + status=$? + case "$status" in + $STATUS_RUNNING) + log_success_msg "${DESC} is running" + ;; + $STATUS_DEAD) + log_failure_msg "${DESC} is dead and pid file exists" + ;; + $STATUS_DEAD_AND_LOCK) + log_failure_msg "${DESC} is dead and lock file exists" + ;; + $STATUS_NOT_RUNNING) + log_failure_msg "${DESC} is not running" + ;; + *) + log_failure_msg "${DESC} status is unknown" + ;; + esac + return $status +} + +condrestart(){ + [ -e $LOCKFILE ] && restart || : +} + +check_for_root() { + if [ $(id -ur) -ne 0 ]; then + echo 'Error: root user required' + echo + exit 1 + fi +} + +service() { + case "$1" in + start) + check_for_root + start + ;; + stop) + check_for_root + stop + ;; + status) + checkstatus + RETVAL=$? + ;; + restart|force-reload) + check_for_root + restart + ;; + condrestart|try-restart) + check_for_root + condrestart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart|force-reload}" + exit 1 + esac +} + +service "$@" + +exit $RETVAL diff --git a/bigtop.bom b/bigtop.bom index 6123b67930..1b46e883a7 100644 --- a/bigtop.bom +++ b/bigtop.bom @@ -378,5 +378,15 @@ bigtop { archive = site } packaging = 'rpm' } + 'trino' { + name = 'trino' + relNotes = 'Trino is an open source distributed SQL query engine' + version { base = '415'; pkg = base; release = 1 } + tarball { destination = "trino.tar.gz" + source = "trino.tar.gz" } + git { repo = "https://github.com/trinodb/trino.git" + ref = "release-v415" + dir = "$name" } + } } } diff --git a/bigtop_toolchain/manifests/jdk17.pp b/bigtop_toolchain/manifests/jdk17.pp new file mode 100644 index 0000000000..0e4c548b9e --- /dev/null +++ b/bigtop_toolchain/manifests/jdk17.pp @@ -0,0 +1,32 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +class bigtop_toolchain::jdk17 { + $jdk_version = '17.0.2' + $jdk_url = "https://download.java.net/java/GA/jdk${jdk_version}/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-${jdk_version}_linux-x64_bin.tar.gz" + $download_path = "/tmp/java${jdk_version}.tar.gz" + $extract_dir = "/opt/jdk-${jdk_version}" + + exec { 'download_jdk': + command => "/usr/bin/wget ${jdk_url} -O ${download_path}", + creates => $download_path, + } + + exec { 'extract_jdk': + command => "/bin/tar -xzf ${download_path} -C /opt", + creates => $extract_dir, + require => Exec['download_jdk'], + } +}