diff --git a/install-dependencies.sh b/install-dependencies.sh new file mode 100755 index 0000000..48bdd5c --- /dev/null +++ b/install-dependencies.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# This file is open source software, licensed to you under the terms +# of the Apache License, Version 2.0 (the "License"). See the NOTICE file +# distributed with this work for additional information regarding copyright +# ownership. 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. +# + +. /etc/os-release + +if [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ]; then + apt -y install maven openjdk-8-jdk-headless +elif [ "$ID" = "fedora" ] || [ "$ID" = "centos" ]; then + yum install -y maven java-1.8.0-openjdk-devel +fi diff --git a/reloc/build_reloc.sh b/reloc/build_reloc.sh new file mode 100755 index 0000000..f021dd2 --- /dev/null +++ b/reloc/build_reloc.sh @@ -0,0 +1,57 @@ +#!/bin/bash -e + +. /etc/os-release + +print_usage() { + echo "build_reloc.sh --clean --nodeps" + echo " --clean clean build directory" + echo " --nodeps skip installing dependencies" + exit 1 +} + +CLEAN= +NODEPS= +while [ $# -gt 0 ]; do + case "$1" in + "--clean") + CLEAN=yes + shift 1 + ;; + "--nodeps") + NODEPS=yes + shift 1 + ;; + *) + print_usage + ;; + esac +done + +is_redhat_variant() { + [ -f /etc/redhat-release ] +} +is_debian_variant() { + [ -f /etc/debian_version ] +} + + +if [ ! -e reloc/build_reloc.sh ]; then + echo "run build_reloc.sh in top of scylla dir" + exit 1 +fi + +if [ "$CLEAN" = "yes" ]; then + rm -rf build target +fi + +if [ -f build/scylla-jmx-package.tar.gz ]; then + rm build/scylla-jmx-package.tar.gz +fi + +if [ -z "$NODEPS" ]; then + sudo ./install-dependencies.sh +fi + +mvn -B install +./SCYLLA-VERSION-GEN +scripts/create-relocatable-package.py build/scylla-jmx-package.tar.gz diff --git a/scripts/create-relocatable-package.py b/scripts/create-relocatable-package.py new file mode 100755 index 0000000..bf22d4a --- /dev/null +++ b/scripts/create-relocatable-package.py @@ -0,0 +1,48 @@ +#!/usr/bin/python3 + +# +# Copyright (C) 2018 ScyllaDB +# + +# +# This file is part of Scylla. +# +# Scylla is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Scylla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Scylla. If not, see . +# + +import argparse +import io +import os +import tarfile +import pathlib + + +ap = argparse.ArgumentParser(description='Create a relocatable scylla package.') +ap.add_argument('dest', + help='Destination file (tar format)') + +args = ap.parse_args() + +output = args.dest + +ar = tarfile.open(output, mode='w|gz') +pathlib.Path('build/SCYLLA-RELOCATABLE-FILE').touch() +ar.add('build/SCYLLA-RELOCATABLE-FILE', arcname='SCYLLA-RELOCATABLE-FILE') +ar.add('build/SCYLLA-RELEASE-FILE', arcname='SCYLLA-RELEASE-FILE') +ar.add('build/SCYLLA-VERSION-FILE', arcname='SCYLLA-VERSION-FILE') +ar.add('dist') +ar.add('target/scylla-jmx-1.0.jar', arcname='scylla-jmx-1.0.jar') +ar.add('scripts/scylla-jmx', arcname='scylla-jmx') +ar.add('README.md') +ar.add('NOTICE')