##
##  libjio.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:         libjio
Summary:      Journaled Transactional I/O Library
URL:          http://blitiri.com.ar/p/libjio/
Vendor:       Alberto Bertogli
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Libraries
License:      OSL
Version:      1.02
Release:      20110228

#   list of sources
Source0:      http://blitiri.com.ar/p/libjio/files/%{version}/libjio-%{version}.tar.gz
Patch0:       libjio.patch

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

%description
    Libjio is a user-space C library to do journaled,
    transaction-oriented I/O. It provides a very simple API to commit
    and rollback transactions, and on top of that a UNIX-alike set of
    functions to perform most regular operations (i.e. open(), read(),
    write()) in a non-intrusive threadsafe and atomic way, with safe
    and fast crash recovery. This allows the library to guarantee file
    integrity even after unexpected crashes, never leaving your files in
    an inconsistent state. On the disk, the file you work on is exactly
    like a regular one, but a special directory is created to store
    in-flight transactions.

%track
    prog libjio = {
        version   = %{version}
        url       = http://blitiri.com.ar/p/libjio/
        regex     = libjio-(__VER__)\.tar\.gz
    }

%prep
    %setup -q
    %patch -p0

%build
    ( cd libjio
      %{l_make} %{l_mflags} \
          CC="%{l_cc}" \
          CFLAGS="%{l_cflags -O} -std=c99" \
          build/libjio.a build/libjio.pc build/jiofsck
    ) || exit $?

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/include \
        $RPM_BUILD_ROOT%{l_prefix}/lib \
        $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig \
        $RPM_BUILD_ROOT%{l_prefix}/man/cat3
    ( cd libjio
      %{l_shtool} install -c -s -m 755 \
          build/jiofsck $RPM_BUILD_ROOT%{l_prefix}/bin/
      %{l_shtool} install -c -m 644 \
          libjio.h $RPM_BUILD_ROOT%{l_prefix}/include/
      %{l_shtool} install -c -m 644 \
          build/libjio.a $RPM_BUILD_ROOT%{l_prefix}/lib/
      %{l_shtool} install -c -m 644 \
          build/libjio.pc $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
    ) || exit $?
    %{l_shtool} install -c -m 644 \
        doc/libjio.rst $RPM_BUILD_ROOT%{l_prefix}/man/cat3/libjio.1
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

