#
# spec file for package skelcd-SLES
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define PRODUCT_PATH_REL_NOTES SUSE_Linux_Enterprise_Server_16_1
%define PRODUCT SLES
%define PRODUCT_VERSION 16.1
%define PRODUCT_PRETTY_NAME SUSE Linux Enterprise Server %{PRODUCT_VERSION}
%define PRODUCT_UNDERLINE   =================================
%define product SLES
%define license_dir license.final
# SLE15 uses different paths
%if 0%{?suse_version} > 1320
%define skelcd1_path usr/lib/skelcd/CD1
%else
%define skelcd1_path CD1
%endif
Name:           skelcd-%{product}
Version:        2026.02.12
Release:        0
Summary:        CD skeleton
License:        GPL-2.0-only
Group:          Metapackages
Source:         skelcd.tar.bz2
Source2:        README
Source3:        README.BETA
Source99:       skelcd-SLES-rpmlintrc
BuildRequires:  suse-build-key
Conflicts:      skelcd
# please repo-checker (bsc#1089174)
Provides:       skelcd = %{version}

%description
Internal package only.

%package -n skelcd-EULA-%{product}
Summary:        EULA for media
Group:          Metapackages

%description -n skelcd-EULA-%{product}
Internal package only.

%prep
%setup -q -n skelcd

%build

%install
mkdir -p %{buildroot}/%{skelcd1_path}/boot
cp %{_prefix}/lib/rpm/gnupg/keys/* %{buildroot}/%{skelcd1_path}/
for i in README \
%if 0%{?beta_flag} == 1
        README.BETA \
%endif
        ; do
  sed \
      -e 's/{PRETTY_NAME}/%{PRODUCT_PRETTY_NAME}/g' \
      -e 's/{VERSION}/%{PRODUCT_VERSION}/g' \
      -e 's/{UNDERLINE}/%{PRODUCT_UNDERLINE}/g' \
      -e 's/{CURRENT_MILESTONE}/%{current_milestone}/g' \
      $RPM_SOURCE_DIR/$i > %{buildroot}/%{skelcd1_path}/$i
done
## The new way to do it...
mkdir -p %{buildroot}/%{skelcd1_path}/media.1
pushd %{license_dir}
ls -1 > directory.yast # required for downloading of EULAs from SCC
tar --sort=name --mtime=@${SOURCE_DATE_EPOCH:-$(date +%%s)} \
   --pax-option=exthdr.name=%%d/PaxHeaders/%%f,delete=atime,delete=ctime \
   -cvzf license-%{PRODUCT}.tar.gz --owner=root --group=root *txt directory.yast
cp license-%{PRODUCT}.tar.gz %{buildroot}/%{skelcd1_path}/
ln -s license-%{PRODUCT}.tar.gz %{buildroot}/%{skelcd1_path}/license.tar.gz
popd

#
# Install PDF documentation
#
mkdir -p %{buildroot}/%{skelcd1_path}/docu/
for i in ar cs de en es fr hu it ja ko pl pt_BR ru zh_CN zh_TW ; do
  test -f "%{_datadir}/doc/manual/%{product}-installquick_$i-pdf/*.pdf" || continue;
  mkdir -p %{buildroot}/%{skelcd1_path}/docu/$i
  for book in admin deployment installquick storage; do
    pdf="%{_datadir}/doc/manual/%{product}-${book}_$i-pdf/*.pdf"
    test -f $pdf && \
      cp -av $pdf %{buildroot}/%{skelcd1_path}/docu/$i/${book}.pdf
  done
  # remove empty directories
  rmdir %{buildroot}/%{skelcd1_path}/docu/$i ||:
done

%files
%defattr(644,root,root,755)
%exclude /%{skelcd1_path}/license*.tar.gz
%dir %{_prefix}/lib/skelcd/
/%{skelcd1_path}

%files -n skelcd-EULA-%{product}
%defattr(644,root,root,755)
/%{skelcd1_path}/license-%{PRODUCT}.tar.gz
/%{skelcd1_path}/license.tar.gz

%changelog
