##
##  yum.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_yum_major  3.0
%define       V_yum_minor  6

#   package information
Name:         yum
Summary:      Automatic RPM Updater and Installer
URL:          http://linux.duke.edu/projects/yum/
Vendor:       Seth Vidal
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Bootstrapping
License:      GPL
Version:      %{V_yum_major}.%{V_yum_minor}
Release:      20080101

#   list of sources
Source0:      http://linux.duke.edu/projects/yum/download/%{V_yum_major}/yum-%{version}.tar.gz

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

%description
    Yum is a utility that can check for and automatically download
    and install updated RPM packages. Dependencies are obtained and
    downloaded automatically prompting the user as necessary.

%track
    prog yum = {
        version   = %{version}
        url       = http://linux.duke.edu/projects/yum/download/
        regex     = (%{V_yum_major})
        url       = http://linux.duke.edu/projects/yum/download/__NEWVER__/
        regex     = yum-(__VER__)\.tar\.gz
    }

%prep
    %setup -q
    %{l_shtool} subst \
        -e 's;\(DESTDIR[})/\]]*\)/usr;\1%{l_prefix};g' \
        -e 's;\(DESTDIR[})/\]]*\)/etc;\1%{l_prefix}/etc/yum;g' \
        -e 's;/share/yum-cli;/lib/python/site-packages/yum-cli;g' \
        -e 's;/share/man;/man;g' \
        docs/Makefile etc/Makefile Makefile
    %{l_shtool} subst \
        -e 's;$(PYVER);;g' \
        yum/Makefile rpmUtils/Makefile
    find . -name "*.py" -print |\
    xargs %{l_shtool} subst \
        -e 's;^#!/usr/bin/python;#!%{l_prefix}/bin/python;'

%build
    %{l_make} %{l_mflags -O}

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib \
        $RPM_BUILD_ROOT%{l_prefix}/man/man5 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man8
    %{l_make} %{l_mflags} install DESTDIR="$RPM_BUILD_ROOT"
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/yum/rc.d
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/yum/logrotate.d
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/etc/yum/dbus-1
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/yum/*/*.conf'

%files -f files

%clean

