Summary: RESTful Avro schema registry for Kafka
Name: confluent-schema-registry
Version: ##RPMVERSION##
Release: ##RPMRELEASE##
Group: Applications/Internet
#
# Copyright 2018 Confluent Inc.
#
# Licensed 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.
#
License: Confluent Community License and Apache 2.0
Source0: confluent-schema-registry-%{version}.tar.gz
URL: http://confluent.io
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Vendor: Confluent, Inc.
Packager: Confluent Packaging <packages@confluent.io>
BuildArch: noarch

Requires: confluent-rest-utils

%description

Schema Registry provides a serving layer for your metadata. It provides a RESTful interface for storing and retrieving Avro schemas. It stores a versioned history of all schemas, provides multiple compatibility settings and allows evolution of schemas according to the configured compatibility setting. It provides serializers that plug into Kafka clients that handle schema storage and retrieval for Kafka messages that are sent in the Avro format.

%define __jar_repack %{nil}

%pre

_user=cp-schema-registry
_group=confluent

getent group $_group 2>&1 >/dev/null || groupadd -r $_group
getent passwd $_user 2>&1 >/dev/null || \
    useradd -r -g $_group --home-dir /tmp --no-create-home -s /sbin/nologin -c "Confluent Schema Registry" $_user

_permwarn=
for dir in /var/log/confluent ; do
    if [ $dir = /var/log/confluent ]; then
        # Confluent log directory should be writable by group
        _perm="chown ${_user}:${_group} $dir && chmod u+wx,g+wx,o= $dir"
    else
        # Other dirs are only readable by group
        _perm="chown ${_user}:${_group} $dir && chmod u+wx,g+r,o= $dir"
    fi

    if [ ! -d $dir ]; then
        echo "Creating directory $dir with owner $_user:$_group"
        mkdir -p $dir
        eval $_perm
    else
        echo "Notice: Not creating existing directory $dir, ensure proper permissions for user $_user group $_group"
        _permwarn="${_permwarn}${_perm}\n"
    fi
done

if [ -n "$_permwarn" ]; then
    echo "Notice: If you are planning to use the provided systemd service units for"
    echo "Notice: confluent-schema-registry, make sure that read-write permissions"
    echo "Notice: for user $_user and group $_group are set up according to the"
    echo "Notice: following commands:"
    /bin/echo -e "$_permwarn"
fi


%post

%preun

%postun

%prep

%setup

%build

%install

# Clean out any previous builds not on slash
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%{__mkdir_p} %{buildroot}
%{__cp} -R * %{buildroot}
# The spec file gets included, get rid of it
%{__rm} %{buildroot}/confluent-schema-registry.spec

%{__mkdir_p} %{buildroot}/var/log/confluent


%files
%defattr(-,root,root)
/usr/bin/*
/usr/share/java/schema-registry
/usr/share/java/kafka-serde-tools
/lib/systemd/system/

%doc
/usr/share/doc/schema-registry
/usr/share/doc/kafka-serde-tools

%config(noreplace) /etc/schema-registry/*


%clean
#used to cleanup things outside the build area and possibly inside.
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%changelog
* Tue Feb 3 2015 Confluent Packaging <packages@confluent.io>
- Initial import
