From 1ce1df2cc49f9d265c0d64f994d2e564ffbed919 Mon Sep 17 00:00:00 2001 From: jialiang Date: Sat, 27 Jan 2024 15:18:07 +0800 Subject: [PATCH] add dinky support --- .../src/common/dinky/do-component-build | 21 +++ .../src/common/dinky/install_dinky.sh | 123 ++++++++++++++++++ .../src/rpm/dinky/SPECS/dinky.spec | 112 ++++++++++++++++ bigtop.bom | 14 ++ 4 files changed, 270 insertions(+) create mode 100644 bigtop-packages/src/common/dinky/do-component-build create mode 100644 bigtop-packages/src/common/dinky/install_dinky.sh create mode 100644 bigtop-packages/src/rpm/dinky/SPECS/dinky.spec diff --git a/bigtop-packages/src/common/dinky/do-component-build b/bigtop-packages/src/common/dinky/do-component-build new file mode 100644 index 0000000000..a1cd5456ca --- /dev/null +++ b/bigtop-packages/src/common/dinky/do-component-build @@ -0,0 +1,21 @@ +#!/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 + +mvn clean install -Dmaven.test.skip=true -Dspotless.check.skip=true -P web,aliyun,prod,scala-2.12,web,fast,flink-1.15,flink-single-version \ No newline at end of file diff --git a/bigtop-packages/src/common/dinky/install_dinky.sh b/bigtop-packages/src/common/dinky/install_dinky.sh new file mode 100644 index 0000000000..a5d58d93fb --- /dev/null +++ b/bigtop-packages/src/common/dinky/install_dinky.sh @@ -0,0 +1,123 @@ +#!/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. + + +usage() { + echo " +usage: $0 + Required not-so-options: + --build-dir=DIR path to dinky dist.dir + --prefix=PREFIX path to install into + + Optional options: + --lib-dir=DIR path to install dinky home [/usr/lib/dinky] + --bin-dir=DIR path to install bins [/usr/bin] + --etc-dinky=DIR path to install dinky conf [/etc/dinky] + ... [ see source for more similar options ] + " + exit 1 +} + +OPTS=$(getopt \ + -n $0 \ + -o '' \ + -l 'prefix:' \ + -l 'build-dir:' \ + -l 'bin-dir:' \ + -l 'lib-dir:' \ + -l 'etc-dinky:' -- "$@") + +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 + ;; + --bin-dir) + BIN_DIR=$2 ; shift 2 + ;; + --lib-dir) + LIB_DIR=$2 ; shift 2 + ;; + --etc-dinky) + ETC_DINKY=$2 ; shift 2 + ;; + --) + shift ; break + ;; + *) + echo "Unknown option: $1" + usage + exit 1 + ;; + esac +done + +for var in PREFIX BUILD_DIR ; do + if [ -z "$(eval "echo \$$var")" ]; then + echo Missing param: $var + usage + fi +done + +LIB_DIR=${LIB_DIR:-/usr/lib/dinky} +BIN_DIR=${BIN_DIR:-/usr/bin} +ETC_DINKY=${ETC_DINKY:-/etc/dinky} +RUN_DIR=${RUN_DIR:-/var/run/dinky} +LOG_DIR=${LOG_DIR:-/var/log/dinky} + +NP_ETC_DINKY=/etc/dinky +NP_VAR_LIB_DINKY_DATA=/var/lib/dinky/data + + +install -d -m 0755 $PREFIX/$LIB_DIR +install -d -m 0755 $PREFIX/$LIB_DIR/extends +install -d -m 0755 $PREFIX/$LIB_DIR/jar +install -d -m 0755 $PREFIX/$LIB_DIR/sql +install -d -m 0755 $PREFIX/$LIB_DIR/lib +install -d -m 0755 $PREFIX/$LIB_DIR/dink-loader +install -d -m 0755 $PREFIX/$LIB_DIR/config + +install -d -m 0755 $PREFIX/$NP_ETC_DINKY +install -d -m 0755 $PREFIX/$ETC_DINKY/conf.dist +install -d -m 0755 $PREFIX/$RUN_DIR +install -d -m 0755 $PREFIX/$LOG_DIR + +TMP_DIR=$BUILD_DIR/tmp +mkdir -p $BUILD_DIR/tmp +tar -zxf $BUILD_DIR/build/dinky-release*.tar.gz -C $TMP_DIR + +cp -ra ${TMP_DIR}/dinky-*/extends/* ${PREFIX}/${LIB_DIR}/extends/ +cp -ra ${TMP_DIR}/dinky-*/jar/* ${PREFIX}/${LIB_DIR}/jar/ +cp -ra ${TMP_DIR}/dinky-*/lib/* ${PREFIX}/${LIB_DIR}/lib/ +cp -ra ${TMP_DIR}/dinky-*/sql/* ${PREFIX}/${LIB_DIR}/sql/ +cp -ra ${TMP_DIR}/dinky-*/dink-loader/* ${PREFIX}/${LIB_DIR}/dink-loader/ +cp -ra ${TMP_DIR}/dinky-*/config/* $PREFIX/$ETC_DINKY/conf.dist/ +cp -ra ${TMP_DIR}/dinky-*/auto.sh ${PREFIX}/${LIB_DIR}/auto.sh + +ln -s $NP_ETC_DINKY/conf $PREFIX/$LIB_DIR/config +ln -s $LOG_DIR $PREFIX/$LIB_DIR/logs +ln -s $RUN_DIR $PREFIX/$LIB_DIR/run + +rm -rf $TMP_DIR diff --git a/bigtop-packages/src/rpm/dinky/SPECS/dinky.spec b/bigtop-packages/src/rpm/dinky/SPECS/dinky.spec new file mode 100644 index 0000000000..438b981412 --- /dev/null +++ b/bigtop-packages/src/rpm/dinky/SPECS/dinky.spec @@ -0,0 +1,112 @@ +# 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 dinky_name dinky +%define dinky_pkg_name dinky%{pkg_name_suffix} +%define _binaries_in_noarch_packages_terminate_build 0 +%define _unpackaged_files_terminate_build 0 + +%define etc_default %{parent_dir}/etc/default +%define usr_lib_dinky %{parent_dir}/usr/lib/%{dinky_name} +%define etc_dinky %{parent_dir}/etc/%{dinky_name} +%define bin_dir %{parent_dir}/%{_bindir} + +%define np_var_lib_dinky_data /var/lib/%{dinky_name}/data +%define np_var_run_dinky /var/run/%{dinky_name} +%define np_var_log_dinky /var/log/%{dinky_name} +%define np_etc_dinky /etc/%{dinky_name} + +%if %{?suse_version:1}0 +%define alternatives_cmd update-alternatives +%else +%define alternatives_cmd alternatives +%endif + + +# disable repacking jars +%define __os_install_post %{nil} + +Name: %{dinky_pkg_name} +Version: %{dinky_version} +Release: %{dinky_release} +Summary: Apache dinky +URL: http://ambari.apache.org +Group: Development +BuildArch: noarch +Buildroot: %{_topdir}/INSTALL/%{dinky_name}-%{version} +License: ASL 2.0 +Source0: %{dinky_name}-%{dinky_base_version}.tar.gz +Source1: do-component-build +Source2: install_dinky.sh +Source3: bigtop.bom +#BIGTOP_PATCH_FILES +# FIXME +AutoProv: no +AutoReqProv: no + +%description +Ambari + +%prep +%setup -n %{dinky_name}-%{dinky_base_version} + +#BIGTOP_PATCH_COMMANDS + +%build +bash $RPM_SOURCE_DIR/do-component-build + +%install +%__rm -rf $RPM_BUILD_ROOT +bash -x %{SOURCE2} \ + --prefix=$RPM_BUILD_ROOT \ + --etc-dinky=%{etc_dinky} \ + --lib-dir=%{usr_lib_dinky} \ + --bin-dir=%{bin_dir} \ + --build-dir=`pwd` + + + + +%pre +getent group dinky >/dev/null || groupadd -r dinky +getent passwd dinky >/dev/null || useradd -c "dinky" -s /sbin/nologin -g dinky -r -d %{var_lib_kafka} dinky 2> /dev/null || : + + +%post +%{alternatives_cmd} --install %{np_etc_dinky}/conf %{dinky_name}-conf %{etc_dinky}/conf.dist 30 + + +####################### +#### FILES SECTION #### +####################### + +%files +%defattr(-,root,root) +%attr(0755,dinky,dinky) %config(noreplace) %{np_etc_dinky} +%config(noreplace) %{etc_dinky}/conf.dist +%dir %{_sysconfdir}/%{dinky_name} + +%attr(0755,dinky,dinky) %{np_var_log_dinky} +%attr(0755,dinky,dinky) %{np_var_run_dinky} + +%{usr_lib_dinky}/extends +%{usr_lib_dinky}/jar +%{usr_lib_dinky}/sql +%{usr_lib_dinky}/lib +%{usr_lib_dinky}/dink-loader +%{usr_lib_dinky}/config +%{usr_lib_dinky}/logs +%{usr_lib_dinky}/run +%{usr_lib_dinky}/auto.sh diff --git a/bigtop.bom b/bigtop.bom index d58ee7d6b7..e6ec352fe7 100644 --- a/bigtop.bom +++ b/bigtop.bom @@ -348,5 +348,19 @@ bigtop { url { site = "https://github.com/apache/ranger/archive/refs/tags" archive = site } } + 'dinky' { + name = 'dinky' + rpm_pkg_suffix = "_" + bigtop.base_version.replace(".", "_") + relNotes = 'Dinky' + version { base = '1.0.0'; pkg = base-"-release"; release = 1 } + tarball { + source = "$name-${version.base}.tar.gz" + destination = source + } + url { download_path = "$name/${version.base}" + site = "https://github.com/DataLinkDC/dinky/archive/refs/tags" + archive = site + } + } } }