Blob Blame History Raw
%global distro  CentOS Stream
%global variant Hyperscale
%global variant_lc %(echo %{variant} | tr "A-Z" "a-z")
%global major   9

Name:           centos-stream-spin-hyperscale-release
Version:        %{major}
Release:        4%{?dist}
Summary:        %{distro} %{variant} release files
License:        GPLv2
URL:            https://centos.org
BuildArch:      noarch

# Make this higher than all other centos-release providers
# to make it compatible with centos-gpg-keys and other packages
Provides:       centos-release = 9.12-1

# conflicts with vanilla centos-stream-release
Conflicts:      centos-stream-release

# upgrade path from old release packages
Obsoletes:      centos-release < 9.12-1

# upgrade path from RHEL
Obsoletes:      redhat-release < 10

# Replace centos-stream-release for comps compatibility
Obsoletes:      centos-stream-release < 9.12-1
Provides:       centos-stream-release = 9.12-1

# upgrade path from Hyperscale 8
Obsoletes:      centos-stream-hyperscale-spin-release < 9
Provides:       centos-stream-hyperscale-spin-release = %{version}-%{release}

# Required for a lorax run (to generate install media)
Requires:       centos-stream-hyperscale-repos(%{major})
Provides:       centos-release-eula
Provides:       redhat-release-eula

# required by epel-release
Provides:       redhat-release = 9.12-1

# required by dnf
# https://github.com/rpm-software-management/dnf/blob/4.2.23/dnf/const.py.in#L26
Provides:       system-release = %{version}-%{release}
Provides:       system-release(releasever) = %{major}

# required by libdnf
# https://github.com/rpm-software-management/libdnf/blob/0.48.0/libdnf/module/ModulePackage.cpp#L472
Provides:       base-module(platform:el%{major})

Source200:      EULA
Source201:      LICENSE
Source202:      Contributors

Source300:      85-display-manager.preset
Source301:      90-default.preset
Source302:      90-default-user.preset
Source303:      99-default-disable.preset
Source304:      50-redhat.conf

Source500:      centos.repo
Source501:      centos-addons.repo

%package -n centos-stream-spin-hyperscale-repos
Summary:        CentOS Stream package repositories

# conflicts with vanilla centos-stream-repos
Conflicts:      centos-stream-repos
# Replace centos-stream-repos for comps compatibility
Obsoletes:      centos-stream-repos < 9.12-1
Provides:       centos-stream-repos = 9.12-1

Provides:       system-repos = %{version}-%{release}
Provides:       centos-stream-repos(%{major}) = %{version}
Provides:       centos-stream-hyperscale-repos(%{major}) = %{version}
Requires:       centos-stream-spin-hyperscale-release = %{version}-%{release}
# Depend on the correct centos-gpg-keys package from the main distribution
Requires:       (centos-gpg-keys >= 9.0-12 with centos-gpg-keys < 10)
# yes, this is actually a repos package :/
Requires:       centos-release-hyperscale-spin

%description
%{distro} release files.

%description -n centos-stream-spin-hyperscale-repos
This package provides the package repository files for CentOS Stream Hyperscale.


%install
# copy license and contributors doc here for %%license and %%doc macros
mkdir -p ./docs
cp %{SOURCE201} %{SOURCE202} ./docs

# create /etc/system-release and /etc/redhat-release
install -d -m 0755 %{buildroot}%{_sysconfdir}
echo "%{distro} release %{major}" > %{buildroot}%{_sysconfdir}/centos-release
ln -s centos-release %{buildroot}%{_sysconfdir}/system-release
ln -s centos-release %{buildroot}%{_sysconfdir}/redhat-release

# Create the os-release file
install -d -m 0755 %{buildroot}%{_prefix}/lib
cat > %{buildroot}%{_prefix}/lib/os-release << EOF
NAME="%{distro}"
VERSION="%{major} (%{variant})"
ID=centos
ID_LIKE="rhel fedora"
VERSION_ID="%{major}"
PLATFORM_ID="platform:el%{major}"
PRETTY_NAME="%{distro} %{major}"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:centos:centos:%{major}"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux %{major}"
REDHAT_SUPPORT_PRODUCT_VERSION="%{distro}"
VARIANT="%{variant}"
VARIANT_ID=%{variant_lc}
EOF

# Create the symlink for /etc/os-release
ln -s ../usr/lib/os-release %{buildroot}%{_sysconfdir}/os-release

# write cpe to /etc/system/release-cpe
echo "cpe:/o:centos:centos:%{major}" > %{buildroot}%{_sysconfdir}/system-release-cpe

# create /etc/issue, /etc/issue.net and /etc/issue.d
echo '\S' > %{buildroot}%{_sysconfdir}/issue
echo 'Kernel \r on an \m' >> %{buildroot}%{_sysconfdir}/issue
cp %{buildroot}%{_sysconfdir}/issue{,.net}
echo >> %{buildroot}%{_sysconfdir}/issue
mkdir -p %{buildroot}%{_sysconfdir}/issue.d

# set up the dist tag macros
mkdir -p %{buildroot}%{_rpmmacrodir}
cat > %{buildroot}%{_rpmmacrodir}/macros.dist << EOF
# dist macros.

%%__bootstrap ~bootstrap
%%centos_ver %{major}
%%centos_hs 1
%%centos %{major}
%%rhel %{major}
%%dist %%{!?distprefix0:%%{?distprefix}}%%{expand:%%{lua:for i=0,9999 do print("%%{?distprefix" .. i .."}") end}}.hs.el%{major}%%{?with_bootstrap:%{__bootstrap}}
%%el%{major} 1
EOF

# use unbranded datadir
install -d -m 0755 %{buildroot}%{_datadir}/centos-release
ln -s centos-release %{buildroot}%{_datadir}/redhat-release
install -p -m 0644 %{SOURCE200} %{buildroot}%{_datadir}/centos-release/

# copy systemd presets
install -d -m 0755 %{buildroot}%{_prefix}/lib/systemd/system-preset/
install -d -m 0755 %{buildroot}%{_prefix}/lib/systemd/user-preset
install -p -m 0644 %{SOURCE300} %{buildroot}%{_prefix}/lib/systemd/system-preset/
install -p -m 0644 %{SOURCE301} %{buildroot}%{_prefix}/lib/systemd/system-preset/
install -p -m 0644 %{SOURCE302} %{buildroot}%{_prefix}/lib/systemd/user-preset/

# installing the same file for both system and user presets to set the same behavior for both
install -p -m 0644 %{SOURCE303} %{buildroot}%{_prefix}/lib/systemd/system-preset/
install -p -m 0644 %{SOURCE303} %{buildroot}%{_prefix}/lib/systemd/user-preset/

# copy sysctl presets
mkdir -p %{buildroot}/%{_prefix}/lib/sysctl.d/
install -m 0644 %{SOURCE304} %{buildroot}/%{_prefix}/lib/sysctl.d/

# Create stub yum repos
mkdir %{buildroot}%{_sysconfdir}/yum.repos.d
touch %{buildroot}%{_sysconfdir}/yum.repos.d/redhat.repo

# copy yum repos
install -d -m 0755 %{buildroot}%{_sysconfdir}/yum.repos.d
install -p -m 0644 %{SOURCE500} %{buildroot}%{_sysconfdir}/yum.repos.d/
install -p -m 0644 %{SOURCE501} %{buildroot}%{_sysconfdir}/yum.repos.d/

# dnf variables
install -d -m 0755 %{buildroot}%{_sysconfdir}/dnf/vars
echo "%{major}-stream" > %{buildroot}%{_sysconfdir}/dnf/vars/stream


%files
%license docs/LICENSE
%doc docs/Contributors
%{_sysconfdir}/redhat-release
%{_sysconfdir}/system-release
%{_sysconfdir}/centos-release
%config(noreplace) %{_sysconfdir}/os-release
%config %{_sysconfdir}/system-release-cpe
%config(noreplace) %{_sysconfdir}/issue
%config(noreplace) %{_sysconfdir}/issue.net
%dir %{_sysconfdir}/issue.d
%dir %{_sysconfdir}/yum.repos.d
%ghost %{_sysconfdir}/yum.repos.d/redhat.repo
%{_rpmmacrodir}/macros.dist
%{_datadir}/redhat-release
%{_datadir}/centos-release
%{_prefix}/lib/os-release
%{_prefix}/lib/systemd/system-preset/*
%{_prefix}/lib/systemd/user-preset/*
%{_prefix}/lib/sysctl.d/50-redhat.conf

%files -n centos-stream-spin-hyperscale-repos
%config(noreplace) %{_sysconfdir}/yum.repos.d/centos.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/centos-addons.repo
%config(noreplace) %{_sysconfdir}/dnf/vars/stream


%changelog
* Thu Mar 03 2022 Neal Gompa <ngompa@centosproject.org> - 9-4
- Enable rpmdb rebuild/migrate services

* Wed Mar 02 2022 Neal Gompa <ngompa@centosproject.org> - 9-3
- The Extras key was re-signed to get rid of a SHA1 algo
  Related: rhbz#2059424

* Sun Feb 20 2022 Neal Gompa <ngompa@centosproject.org> - 9-2
- Fix author email in initial changelog entry

* Sun Feb 20 2022 Neal Gompa <ngompa@centosproject.org> - 9-1
- Initial spin release package based on centos-stream-release