|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed with |
| 5 | +# this work for additional information regarding copyright ownership. |
| 6 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | +# (the "License"); you may not use this file except in compliance with |
| 8 | +# the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | +set -e |
| 19 | + |
| 20 | +usage() { |
| 21 | + echo " |
| 22 | +usage: $0 <options> |
| 23 | + Required not-so-options: |
| 24 | + --build-dir=DIR path to dist.dir |
| 25 | + --source-dir=DIR path to package shared files dir |
| 26 | + --prefix=PREFIX path to install into |
| 27 | + Optional options: |
| 28 | + --doc-dir=DIR path to install docs into [/usr/share/doc/trino] |
| 29 | + --lib-dir=DIR path to install trino home [/usr/lib/trino] |
| 30 | + --installed-lib-dir=DIR path where lib-dir will end up on target system |
| 31 | + --bin-dir=DIR path to install bins [/usr/bin] |
| 32 | + ... [ see source for more similar options ] |
| 33 | + " |
| 34 | + exit 1 |
| 35 | +} |
| 36 | + |
| 37 | +OPTS=$(getopt \ |
| 38 | + -n $0 \ |
| 39 | + -o '' \ |
| 40 | + -l 'prefix:' \ |
| 41 | + -l 'lib-dir:' \ |
| 42 | + -l 'installed-lib-dir:' \ |
| 43 | + -l 'bin-dir:' \ |
| 44 | + -l 'trino-version:' \ |
| 45 | + -l 'source-dir:' \ |
| 46 | + -l 'cli-dir:' \ |
| 47 | + -l 'build-dir:' -- "$@") |
| 48 | + |
| 49 | +if [ $? != 0 ] ; then |
| 50 | + usage |
| 51 | +fi |
| 52 | + |
| 53 | +eval set -- "$OPTS" |
| 54 | +while true ; do |
| 55 | + case "$1" in |
| 56 | + --prefix) |
| 57 | + PREFIX=$2 ; shift 2 |
| 58 | + ;; |
| 59 | + --build-dir) |
| 60 | + BUILD_DIR=$2 ; shift 2 |
| 61 | + ;; |
| 62 | + --source-dir) |
| 63 | + SOURCE_DIR=$2 ; shift 2 |
| 64 | + ;; |
| 65 | + --cli-dir) |
| 66 | + CLI_BUILD_DIR=$2 ; shift 2 |
| 67 | + ;; |
| 68 | + --lib-dir) |
| 69 | + LIB_DIR=$2 ; shift 2 |
| 70 | + ;; |
| 71 | + --installed-lib-dir) |
| 72 | + INSTALLED_LIB_DIR=$2 ; shift 2 |
| 73 | + ;; |
| 74 | + --bin-dir) |
| 75 | + BIN_DIR=$2 ; shift 2 |
| 76 | + ;; |
| 77 | + --) |
| 78 | + shift ; break |
| 79 | + ;; |
| 80 | + *) |
| 81 | + echo "Unknown option: $1" |
| 82 | + usage |
| 83 | + exit 1 |
| 84 | + ;; |
| 85 | + esac |
| 86 | +done |
| 87 | + |
| 88 | +for var in PREFIX BUILD_DIR SOURCE_DIR ; do |
| 89 | + if [ -z "$(eval "echo \$$var")" ]; then |
| 90 | + echo Missing param: $var |
| 91 | + usage |
| 92 | + fi |
| 93 | +done |
| 94 | + |
| 95 | +if [ -f "$SOURCE_DIR/bigtop.bom" ]; then |
| 96 | + . $SOURCE_DIR/bigtop.bom |
| 97 | +fi |
| 98 | + |
| 99 | +MAN_DIR=${MAN_DIR:-/usr/share/man}/man1 |
| 100 | +DOC_DIR=${DOC_DIR:-/usr/share/doc/trino} |
| 101 | +CLI_DIR=${CLI_DIR:-/usr/lib/trino-cli} |
| 102 | +LIB_DIR=${TRINO_DIR:-/usr/lib/trino} |
| 103 | +VAR_DIR=${VAR_DIR:-/var/lib/trino} |
| 104 | +LOG_DIR=${LOG_DIR:-/var/log/trino} |
| 105 | +RUN_DIR=${RUN_DIR:-/var/run/trino} |
| 106 | +INSTALLED_LIB_DIR=${INSTALLED_LIB_DIR:-/usr/lib/trino} |
| 107 | +BIN_DIR=${BIN_DIR:-/usr/bin} |
| 108 | +CONF_DIR=${CONF_DIR:-/etc/trino} |
| 109 | +CONF_DIST_DIR=${CONF_DIST_DIR:-/etc/trino.dist} |
| 110 | +DEFAULT_DIR=${DEFAULT_DIR:-/etc/default} |
| 111 | + |
| 112 | +install -d -m 0755 $PREFIX/$CONF_DIST_DIR |
| 113 | +install -d -m 0755 $PREFIX/$LIB_DIR |
| 114 | +install -d -m 0755 $PREFIX/$CLI_DIR |
| 115 | +install -d -m 0755 $PREFIX/$DOC_DIR |
| 116 | +install -d -m 0755 $PREFIX/$VAR_DIR |
| 117 | +install -d -m 0755 $PREFIX/$LOG_DIR |
| 118 | +install -d -m 0755 $PREFIX/$RUN_DIR |
| 119 | +install -d -m 0755 $PREFIX/$DEFAULT_DIR |
| 120 | + |
| 121 | +cp -ra ${BUILD_DIR}/* $PREFIX/$LIB_DIR/ |
| 122 | +cp -ra ${CLI_BUILD_DIR}/* $PREFIX/$CLI_DIR/ |
| 123 | + |
| 124 | +chmod +x $PREFIX/$LIB_DIR/bin/launcher |
0 commit comments