##
##  yourls-plugins.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 version
%define       V_opkg        20170722
%define       V_ldap        3e7f66652ddb7b3b155d2b7c1f3833e83c22c5ff
%define       V_r302        90efec3b8dfabf2c326540baa202461f5b98f64e
%define       V_aliases     c6db8471b96fee9c056cbd774c3d0375e873fa33
%define       V_appendqs    5060c7a1753f312b7f833abc67a51195ff783dae
%define       V_domain      af63f31b8e82ad496364e639c820032f3b9aa20f
%define       V_iqrcodes    1.4.2
%define       V_revproxy    63f90c1158629702f3f69c4679221f0f97829960
%define       V_users       c05feae0784d43366d49347d45979776c07bfa75
%define       V_charset     88fa79e4010421ea891b9e8a37912a1b67e59e3f

#   package information
Name:         yourls-plugins
Summary:      YOURLS Plugins
URL:          http://yourls.org/
Vendor:       YOURLS Community
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Web
License:      GPL
Version:      %{V_opkg}
Release:      20170722

#   package options
%option       with_ldap no

#   list of sources
Source0:      https://github.com/k3a/yourls-ldap-plugin/archive/%{V_ldap}.zip
Source1:      https://github.com/timcrockford/302-instead/archive/%{V_r302}.zip
Source2:      https://github.com/adigitalife/yourls-allow-aliases/archive/%{V_aliases}.zip
Source3:      https://github.com/drockney/append-qs/archive/%{V_appendqs}.zip
Source4:      https://github.com/nicwaller/yourls-domainlimit-plugin/archive/%{V_domain}.zip
Source5:      https://github.com/joshp23/YOURLS-IQRCodes/archive/%{V_iqrcodes}.tar.gz
Source6:      https://github.com/Diftraku/yourls_reverseproxy/archive/%{V_revproxy}.zip
Source7:      https://github.com/ianbarber/Yourls-Separate-Users/archive/%{V_users}.zip
Source8:      https://github.com/josheby/yourls-additional-charsets/archive/%{V_charset}.zip

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101
PreReq:       yourls
%if "%{with_ldap}" == "yes"
PreReq:       apache-php::with_ldap = yes
%endif

%description
    This is a set of plugins for YOURLS.

%track

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %setup -q -T -D -a 3
    %setup -q -T -D -a 4
    %setup -q -T -D -a 5
    %setup -q -T -D -a 6
    %setup -q -T -D -a 7
    %setup -q -T -D -a 8

%build

%install
    #   install plugin "ldap"
%if "%{with_ldap}" == "yes"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/ldap
    %{l_shtool} install -c -m 644 \
        yourls-ldap-plugin-%{V_ldap}/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/ldap/
%endif

    #   install plugin "302-instead"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/302-instead
    %{l_shtool} install -c -m 644 \
        302-instead-%{V_r302}/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/302-instead/

    #   install plugin "allow-aliases"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/allow-aliases
    %{l_shtool} install -c -m 644 \
        yourls-allow-aliases-%{V_aliases}/allow-aliases/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/allow-aliases/

    #   install plugin "append-qs"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/append-qs
    %{l_shtool} install -c -m 644 \
        append-qs-%{V_appendqs}/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/append-qs/

    #   install plugin "domain-limit"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/domain-limit
    %{l_shtool} install -c -m 644 \
        yourls-domainlimit-plugin-%{V_domain}/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/domain-limit/

    #   install plugin "iqrcodes"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/iqrcodes
    cp -rp \
        YOURLS-IQRCodes-%{V_iqrcodes}/iqrcodes/* \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/iqrcodes/

    #   install plugin "iqrcodes"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/reverseproxy
    %{l_shtool} install -c -m 644 \
        yourls_reverseproxy-%{V_revproxy}/reverseproxy/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/reverseproxy/

    #   install plugin "separate-users"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/separate-users
    %{l_shtool} install -c -m 644 \
        Yourls-Separate-Users-%{V_users}/plugins/separate-users/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/separate-users/

    #   install plugin "additional-charsets"
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/additional-charsets
    %{l_shtool} install -c -m 644 \
        yourls-additional-charsets-%{V_charset}/plugin.php \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yourls/user/plugins/additional-charsets/

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

%files -f files

%clean

