##
##  newsyslog.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:         newsyslog
Summary:      Logfile Rotation Tool
URL:          http://www.planix.com/~woods/projects/newsyslog.html
Vendor:       Theodore Ts'o
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Logfile
License:      BSD
Version:      1.1.0.81
Release:      20090718

#   list of sources
Source0:      ftp://ftp.planix.com/pub/local/newsyslog-%{version}.tar.gz
Source1:      newsyslog.conf
Source2:      rc.newsyslog

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

%description
    Newsyslog is a program that is scheduled to run periodically by
    cron(8) for archiving log files. If a log file is determined
    to require archiving, newsyslog rearranges the files so that
    ``logfile'' is empty, ``logfile.0'' has the last period's logs in
    it, ``logfile.1'' has the next to last period's logs in it, and so
    on, up to a user-specified number of archived logs. The archived
    logs may also be compressed to save space. After all file operations
    are done newsyslog notifies the syslogd daemon, or optionally some
    log-file specific daemon, by sending a SIGHUP to the daemon process.

%track
    prog newsyslog = {
        version   = %{version}
        url       = ftp://ftp.planix.com/pub/local/
        regex     = newsyslog-(__VER__)\.tar\.gz
    }

%prep
    %setup -q

%build
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    ./configure \
        --prefix=%{l_prefix} \
        --sysconfdir=%{l_prefix}/etc/newsyslog \
        --with-newsyslog_conf=%{l_prefix}/etc/newsyslog/newsyslog.conf \
        --localstatedir=%{l_prefix}/var/newsyslog \
        --with-syslog_pid=%{l_prefix}/var/newsyslog/newsyslog.pid \
        --with-gzip
    %{l_make} %{l_mflags -O} newsyslog copy-dist-mans

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
        $RPM_BUILD_ROOT%{l_prefix}/etc/newsyslog \
        $RPM_BUILD_ROOT%{l_prefix}/var/newsyslog \
        $RPM_BUILD_ROOT%{l_prefix}/man/cat5 \
        $RPM_BUILD_ROOT%{l_prefix}/man/cat8
    %{l_shtool} install -c -s -m 755 \
        newsyslog $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_shtool} install -c -m 644 \
        newsyslog.cat8 \
        $RPM_BUILD_ROOT%{l_prefix}/man/cat8/newsyslog.8
    %{l_shtool} install -c -m 644 \
        newsyslog.conf.cat5 \
        $RPM_BUILD_ROOT%{l_prefix}/man/cat5/newsyslog.conf.5
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE newsyslog.conf} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/newsyslog/
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE rc.newsyslog} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/newsyslog/*'

%files -f files

%clean

