##
##  synctool.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package information
Name:         synctool
Summary:      Cluster Configuration Management Tool
URL:          http://walterdejong.github.io/synctool/
Vendor:       Walter de Jong
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        System
License:      GPL
Version:      7.0
Release:      20240831

#   list of sources
Source0:      https://github.com/walterdejong/synctool/archive/v%{version}.tar.gz
Source1:      synctool.conf

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101, python

%description
    SyncTool is a tool that can help you administer your cluster of
    computers. It is meant for copying configuration files to groups (or
    classes) of computers within a cluster. There are other tools in
    existence that do the same thing, and ironically, none of them are
    as easy to understand and use as synctool.

%track
    prog synctool = {
        version   = %{version}
        url       = http://walterdejong.github.io/synctool/
        regex     = v(__VER__)\.tar\.gz
    }

%prep
    %setup -q

%build

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/etc/synctool \
        $RPM_BUILD_ROOT%{l_prefix}/lib/synctool \
        $RPM_BUILD_ROOT%{l_prefix}/var/synctool/master \
        $RPM_BUILD_ROOT%{l_prefix}/var/synctool/log
    %{l_bash} setup.sh \
        --fix --installdir=$RPM_BUILD_ROOT%{l_prefix}/lib/synctool
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/synctool/doc
    ( echo "#!/bin/sh"
      echo "exec %{l_prefix}/lib/synctool/bin/synctool \${1+\"\$@\"}"
    ) >synctool.sh
    %{l_shtool} install -c -m 755 \
        synctool.sh $RPM_BUILD_ROOT%{l_prefix}/bin/synctool
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE synctool.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/synctool/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/synctool/*'

%files -f files

%clean

