File SLES-release.spec of Package 000release-packages

#
# spec file for package SLES-release
#
# 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 http://bugs.opensuse.org/
#

# old location  was /etc/YaST2/licenses/, see jsc#SLE-3067
%define product_license_dir /usr/share/licenses/product/

%define product SLES
%if 0%{?beta_flag} == 1
%define betaversion %{current_milestone}
%endif

# hardcode productrelease to not change during a minor release (bsc#1252026)
%define         productversion %{version}
%define         productrelease 0

Name:           %{product}-release
Summary:        SUSE Linux Enterprise Server 16.0
License:        MIT
Group:          System/Fhs
Version:        16.0
Release:        0
#BuildRequires:  skelcd-control-%{product}
BuildRequires:  skelcd-%{product}
BuildRequires:  skelcd-EULA-%{product}
# in rare cases, 'ln' is not found...
Requires(post): (coreutils or busybox-coreutils)
Recommends:     issue-generator
# bsc#1078737#c7

Conflicts:      otherproviders(distribution-release)

Provides:	branding
Conflicts:	otherproviders(branding)
Requires:   branding-SLE

Provides:       %name-%productversion
Provides:       product() = SLES
Provides:       product(SLES) = %{productversion}-%{productrelease}
Provides:       product(SUSE_SLE) = %{productversion}-%{productrelease}
# If there is more than one product in the FTP tree, we need to give YaST/Agama a hint
Provides:       system-installation() = SLES
%ifarch x86_64
Provides:       product-register-target() = sle%%2D16%%2Dx86_64
%endif
%ifarch s390x
Provides:       product-register-target() = sle%%2D16%%2Ds390x
%endif
%ifarch aarch64
Provides:       product-register-target() = sle%%2D16%%2Daarch64
%endif
%ifarch ppc64le
Provides:       product-register-target() = sle%%2D16%%2Dppc64le
%endif
Provides:       product-label() = SUSE%%20Linux%%20Enterprise%%20Server
Provides:       product-cpeid() = cpe%%3A%%2Fo%%3Asuse%%3Asles%%3A16.0
Provides:       product-url(releasenotes) = https%%3A%%2F%%2Fwww.suse.com%%2Freleasenotes%%2F%{_target_cpu}%%2FSLES%%2F16.0%%2Frelease%%2Dnotes%%2Dsles.rpm
Provides:       product-endoflife() = 2027%%2D11%%2D30

Provides:       distribution-release

# old modules which are migratable to 16.0 should be obsoleted
Obsoletes:	sle-module-basesystem-release
Obsoletes:	sle-module-certifications-release
Obsoletes:	sle-module-containers-release
Obsoletes:	sle-module-desktop-applications-release
Obsoletes:	sle-module-development-tools-release
Obsoletes:	sle-module-legacy-release
Obsoletes:	sle-module-live-patching-release
Obsoletes:	sle-module-public-cloud-release
Obsoletes:	sle-module-python3-release
Obsoletes:	sle-module-sap-business-one-release
Obsoletes:	sle-module-server-applications-release
Obsoletes:	sle-module-systems-management-release
Obsoletes:	sle-module-web-scripting-release

# jsc#PED-12182
Provides:       sles-release

# old package obsoletes removed. If we support 11 SP4 migration to 15, we may
# need to re-add some.

# ./.

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# this package should only be available for the "basearchs" of a product
# i586 added as installation-images-SLES reequires it.
ExclusiveArch:  x86_64 ppc64le s390x aarch64

Source100:      weakremovers.inc
%include %{SOURCE100}

%description
SUSE Linux Enterprise Server 16.0



%prep
%setup -qcT
mkdir license
if [ -f /CD1/license.tar.gz ]; then
  tar -C license -xzf /CD1/license.tar.gz
elif [ -f %{_prefix}/lib/skelcd/CD1/license.tar.gz ]; then
  tar -C license -xzf %{_prefix}/lib/skelcd/CD1/license.tar.gz
fi

%build

%install
mkdir -p %{buildroot}%{_sysconfdir} %{buildroot}%{_prefix}/lib/issue.d %{buildroot}/run

echo -e "\nWelcome to SUSE Linux Enterprise Server %{version}%{?betaversion: %{betaversion}} (%{_target_cpu}) - Kernel \\\r (\\\l).\n" > $RPM_BUILD_ROOT/usr/lib/issue.d/10-SUSE
echo -e "\n" >  $RPM_BUILD_ROOT/usr/lib/issue.d/90-SUSE

#%if 0%{?betaversion}
#echo -e "This is an early sneak preview release  not intended for production environment.\n" > %{buildroot}%{_prefix}/lib/issue.d/90-ALP.conf
#%endif

mkdir -p %{buildroot}%{_sysconfdir}
cat >%{buildroot}%{_sysconfdir}/os-release << EOF
# The NAME and PRETTY_NAME fields have been chosen to state compatibility between our products.
# The use of "SLES" and "SUSE Linux Enterprise" rather than a more generic name is due to backward compatibility with existing OS detection code in applications of third party vendors.
NAME="SLES"
PRETTY_NAME="SUSE Linux Enterprise Server %{version}"
VARIANT="Enterprise Server"
VARIANT_ID="server"
VERSION="%{version}%{?betaversion: %{betaversion}}"
VERSION_ID="%{version}"
ANSI_COLOR="0;32"
ID="sles"
ID_LIKE="suse opensuse"
CPE_NAME="cpe:/o:suse:sles:16:%{version}"
SUSE_SUPPORT_PRODUCT="SUSE Linux Enterprise Server"
SUSE_SUPPORT_PRODUCT_VERSION="%{version}"
EOF


mv  %{buildroot}%{_sysconfdir}/os-release %{buildroot}%{_prefix}/lib/os-release
ln -s ..%{_prefix}/lib/os-release %{buildroot}%{_sysconfdir}/os-release

cat << EOF >> $RPM_BUILD_ROOT/%{_prefix}/lib/os-release
HOME_URL="https://www.suse.com/products/server/"
DOCUMENTATION_URL="https://documentation.suse.com/sles/16.0/"
LOGO="distributor-logo"
EOF

cat << EOF > $RPM_BUILD_ROOT/%{_sysconfdir}/SUSE-brand
VERSION=%{version}
GRUB_OS_ID="SLES %{version}"
EOF

mkdir -p %{buildroot}%{_prefix}/lib/motd.d/
echo "Have a lot of fun..." > %{buildroot}%{_prefix}/lib/motd.d/welcome

# enable vendor change openSUSE,SUSE for DUP from 15.3 to TW (boo#1198332)
mkdir -p %{buildroot}%{_sysconfdir}/zypp/vendors.d
echo -e "[main]\nvendors=openSUSE,SUSE,SUSE LLC <https://www.suse.com/>\n" > %{buildroot}%{_sysconfdir}/zypp/vendors.d/00-SUSE.conf

# fate#319341, make openSUSE-release own YaST license files. TODO:
# get rid of /etc/YaST2/licenses
install -D -d -m 755 "%{buildroot}%_defaultlicensedir/product/base"
install -D -d -m 755 "%{buildroot}%_defaultlicensedir"
cp -a license "%{buildroot}%_defaultlicensedir/%name"
pushd license
for i in *; do
	ln -s "%_defaultlicensedir/%name/$i" %{buildroot}%_defaultlicensedir/product/base/$i
done

mkdir -p %{buildroot}%{_sysconfdir}/products.d
cat >%{buildroot}%{_sysconfdir}/products.d/SLES.prod << EOF
<?xml version="1.0" encoding="UTF-8"?>
<product schemeversion="0">
  <vendor>SUSE</vendor>
  <name>SLES</name>
  <version>%{productversion}</version>
  <release>%{productrelease}</release>
  <endoflife>2027-11-30</endoflife>
  <arch>%{_target_cpu}</arch>
  <cpeid>cpe:/o:suse:sles:16.0:server</cpeid>
  <productline>SLES</productline>
  <codestream>
    <name>SUSE Linux Enterprise Server 16</name>
    <endoflife>2035-11-30</endoflife>
  </codestream>
  <register>
    <pool>
      <repository project="SUSE:Products:SLES:16.0:x86_64" name="images" medium="product" arch="x86_64">
        <zypp name="SLES-16.0-Pool" alias="SLES-16.0-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:s390x" name="images" medium="product" arch="s390x">
        <zypp name="SLES-16.0-Pool" alias="SLES-16.0-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:aarch64" name="images" medium="product" arch="aarch64">
        <zypp name="SLES-16.0-Pool" alias="SLES-16.0-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:ppc64le" name="images" medium="product" arch="ppc64le">
        <zypp name="SLES-16.0-Pool" alias="SLES-16.0-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:x86_64" name="images" medium="product_debug" arch="x86_64">
        <zypp name="SLES-16.0-Debuginfo-Pool" alias="SLES-16.0-Debuginfo-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:s390x" name="images" medium="product_debug" arch="s390x">
        <zypp name="SLES-16.0-Debuginfo-Pool" alias="SLES-16.0-Debuginfo-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:aarch64" name="images" medium="product_debug" arch="aarch64">
        <zypp name="SLES-16.0-Debuginfo-Pool" alias="SLES-16.0-Debuginfo-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:ppc64le" name="images" medium="product_debug" arch="ppc64le">
        <zypp name="SLES-16.0-Debuginfo-Pool" alias="SLES-16.0-Debuginfo-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:x86_64" name="images" medium="product_source" arch="x86_64">
        <zypp name="SLES-16.0-Source-Pool" alias="SLES-16.0-Source-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:s390x" name="images" medium="product_source" arch="s390x">
        <zypp name="SLES-16.0-Source-Pool" alias="SLES-16.0-Source-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:aarch64" name="images" medium="product_source" arch="aarch64">
        <zypp name="SLES-16.0-Source-Pool" alias="SLES-16.0-Source-Pool"/>
      </repository>
      <repository project="SUSE:Products:SLES:16.0:ppc64le" name="images" medium="product_source" arch="ppc64le">
        <zypp name="SLES-16.0-Source-Pool" alias="SLES-16.0-Source-Pool"/>
      </repository>
    </pool>
    <updates>
      <distrotarget arch="x86_64">sle-15-x86_64</distrotarget>
      <distrotarget arch="s390x">sle-15-s390x</distrotarget>
      <distrotarget arch="aarch64">sle-15-aarch64</distrotarget>
      <distrotarget arch="ppc64le">sle-15-ppc64le</distrotarget>
    </updates>
  </register>
  <repositories>
%ifarch x86_64
      <repository type="pool" repoid="obsproduct://build.suse.de/SUSE:Products:SLES:16.0:x86_64/SLES/16.0/%{_target_cpu}" />
%endif
%ifarch s390x
      <repository type="pool" repoid="obsproduct://build.suse.de/SUSE:Products:SLES:16.0:s390x/SLES/16.0/%{_target_cpu}" />
%endif
%ifarch aarch64
      <repository type="pool" repoid="obsproduct://build.suse.de/SUSE:Products:SLES:16.0:aarch64/SLES/16.0/%{_target_cpu}" />
%endif
%ifarch ppc64le
      <repository type="pool" repoid="obsproduct://build.suse.de/SUSE:Products:SLES:16.0:ppc64le/SLES/16.0/%{_target_cpu}" />
%endif
  </repositories>
  <summary>SUSE Linux Enterprise Server 16.0</summary>
  <shortsummary>SUSE Linux Enterprise Server</shortsummary>
  <description>SUSE Linux Enterprise Server 16.0</description>
  <linguas>
    <language>en</language>
  </linguas>
  <urls>
    <url name="releasenotes">https://www.suse.com/releasenotes/%{_target_cpu}/SLES/16.0/release-notes-sles.rpm</url>
  </urls>
  <buildconfig>
    <producttheme>SLES</producttheme>
%if 0%{?beta_flag} == 1
    <betaversion>%{betaversion}</betaversion>
%endif
  </buildconfig>
  <installconfig>
    <defaultlang>en_US</defaultlang>
    <releasepackage name="%{name}" flag="EQ" version="%{version}" release="%{release}"/>
    <distribution>SUSE</distribution>
  </installconfig>
  <runtimeconfig/>
  <productdependency relationship="requires" name="SLES" baseversion="16.0" flag="EQ"/>
</product>

EOF



# this is a base product, create symlink
ln -s %{product}.prod %{buildroot}%{_sysconfdir}/products.d/baseproduct

%posttrans
# Launch the issue-generator: we have a new config file in /usr/lib/issue.d that needs to be represented
if [ -x %{_sbindir}/issue-generator ]; then
    if [ -x %{_bindir}/systemd-tmpfiles ]; then
      %{_bindir}/systemd-tmpfiles --create issue-generator.conf || :
    fi
    %{_sbindir}/issue-generator || :
fi

%files
%defattr(644,root,root,755)
%dir %_defaultlicensedir/product
%_defaultlicensedir/product/base
%license license/*
%{_sysconfdir}/os-release
%{_sysconfdir}/SUSE-brand
%{_prefix}/lib/os-release
%dir %{_sysconfdir}/zypp
%dir %{_sysconfdir}/zypp/vendors.d
%config %{_sysconfdir}/zypp/vendors.d/00-SUSE.conf
%{_prefix}/lib/motd.d/welcome
%{_prefix}/lib/issue.d
%{_sysconfdir}/products.d

%changelog
openSUSE Build Service is sponsored by