##
##  op-cli.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:         op-cli
Summary:      Command-Line Interface (CLI) to 1Password Connect
URL:          http://1password.com/
Vendor:       AgileBits
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Cryptography
License:      Commercial
Version:      1.12.9
Release:      20240425

#   list of sources
Source0:      https://cache.agilebits.com/dist/1P/op/pkg/v%{version}/op_freebsd_amd64_v%{version}.zip
Source1:      https://cache.agilebits.com/dist/1P/op/pkg/v%{version}/op_linux_amd64_v%{version}.zip

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

%description
   1Password (OP) is the easiest way to store and use strong passwords.
   Log in to sites and fill forms securely with a single click.
   1Password Connect is the centeral 1Password cloud service. This is
   the "op" Command-Line Interface (CLI) to it.

%track
    prog op-cli = {
        version   = %{version}
        url       = https://app-updates.agilebits.com/product_history/CLI
        regex     = op_freebsd_amd64_v(__VER__)\.zip
    }

%prep
    %setup -q -T -c

%build
    #   unpack platform-specific distribution
    case "%{l_platform -t}" in
        *-freebsd* ) source="%{SOURCE0}" ;;
        *-linux*   ) source="%{SOURCE1}" ;;
        * ) echo "Sorry, platform %{l_platform -t} not supported" 1>&2; exit 1 ;;
    esac
    %{l_prefix}/bin/unzip -q -x $source

%install
    #   create installation hierarchy
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin

    #   install program
    %{l_shtool} install -c -m 755 \
        op $RPM_BUILD_ROOT%{l_prefix}/bin/

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

