%global distro MSVSphere
%global release_name Inferit
%global major 9
%global minor 2
Name: sphere-release
Version: %{major}.%{minor}
Release: 1.3%{?dist}
Summary: %{distro} release files
License: GPLv2
URL: https://msvsphere.ru
Provides: centos-release = %{version}-%{release}
# Required for a lorax run (to generate install media)
Requires: sphere-repos = %{version}-%{release}
Provides: centos-release-eula
Provides: redhat-release-eula
# required by epel-release
Provides: redhat-release = %{version}-%{release}
# 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})
Source100: RPM-GPG-KEY-MSVSphere-9
Source200: LICENSE
Source201: EULA
Source300: 85-display-manager.preset
Source301: 90-default.preset
Source302: 90-default-user.preset
Source303: 99-default-disable.preset
Source304: 50-redhat.conf
# secureboot CA certificate
Source400: spheresecurebootca.cer
# kernel signing certificate
Source401: spheresecureboot001.cer
# grub2 signing certificate
Source402: spheresecureboot001.cer
# Fwupd signing certificate
Source403: spheresecureboot001.cer
# repository configuration files
Source500: msvsphere-baseos.repo
Source501: msvsphere-appstream.repo
Source502: msvsphere-crb.repo
Source503: msvsphere-extras.repo
Source504: msvsphere-devel.repo
Source505: msvsphere-rt.repo
Source506: msvsphere-nfv.repo
Source507: msvsphere-highavailability.repo
Source508: msvsphere-resilientstorage.repo
%description
%{distro} release files.
%package -n sphere-sb-certs
Summary: %{distro} public secureboot certificates
Group: System Environment/Base
Provides: system-sb-certs = %{version}-%{release}
Provides: redhat-sb-certs = %{version}-%{release}
%description -n sphere-sb-certs
%{distro} secureboot certificates.
%package -n sphere-repos
Summary: %{distro} package repositories
Requires: sphere-release = %{version}-%{release}
Requires: sphere-gpg-keys = %{version}-%{release}
%description -n sphere-repos
This package provides the package repository files for %{distro}.
%package -n sphere-repos-extra
Summary: %{distro} extra package repositories
Requires: sphere-release = %{version}-%{release}
Requires: sphere-gpg-keys = %{version}-%{release}
%description -n sphere-repos-extra
This package provides extra package repository files for %{distro},
like Devel.
%package -n sphere-gpg-keys
Summary: %{distro} RPM keys
%description -n sphere-gpg-keys
This package provides the RPM signature keys for %{distro}.
%install
mkdir -p ./docs
cp %{SOURCE200} ./docs
# create /etc/sphere-release, /etc/system-release and /etc/redhat-release files
install -d -m 0755 %{buildroot}%{_sysconfdir}
echo "%{distro} release %{major}.%{minor}%{?beta: %{beta}} (%{release_name})" > %{buildroot}%{_sysconfdir}/sphere-release
ln -s sphere-release %{buildroot}%{_sysconfdir}/system-release
ln -s sphere-release %{buildroot}%{_sysconfdir}/redhat-release
# generate /usr/lib/os-release file
install -d -m 0755 %{buildroot}%{_prefix}/lib
cat > %{buildroot}%{_prefix}/lib/os-release << EOF
NAME="%{distro}"
VERSION="%{major}.%{minor}%{?beta: %{beta}} (%{release_name})"
ID="msvsphere"
ID_LIKE="rhel centos fedora"
VERSION_ID="%{major}.%{minor}"
PLATFORM_ID="platform:el%{major}"
PRETTY_NAME="%{distro} %{major}.%{minor}%{?beta: %{beta}} (%{release_name})"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:ncsd:msvsphere:%{major}::baseos"
HOME_URL="https://msvsphere.ru/"
BUG_REPORT_URL="https://bugs.msvsphere.ru/"
MSVSPHERE_MANTISBT_PROJECT="%{distro}-%{major}"
MSVSPHERE_MANTISBT_PROJECT_VERSION="%{major}.%{minor}"
REDHAT_SUPPORT_PRODUCT="%{distro}"
REDHAT_SUPPORT_PRODUCT_VERSION="%{major}.%{minor}%{?beta: %{beta}}"
EOF
# create symlink for /etc/os-release
ln -s ../usr/lib/os-release %{buildroot}%{_sysconfdir}/os-release
# generate /etc/system-release-cpe
echo "cpe:/o:ncsd:msvsphere:%{major}::baseos" > %{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
%%msvsphere_ver %{major}
%%msvsphere %{major}
%%centos_ver %{major}
%%centos %{major}
%%rhel %{major}
%%dist %%{!?distprefix0:%%{?distprefix}}%%{expand:%%{lua:for i=0,9999 do print("%%{?distprefix" .. i .."}") end}}.el%{major}%%{?with_bootstrap:%{__bootstrap}}
%%el%{major} 1
EOF
# copy EULA
install -d -m 0755 %{buildroot}%{_datadir}/sphere-release
ln -s sphere-release %{buildroot}%{_datadir}/redhat-release
install -p -m 0644 %{SOURCE201} %{buildroot}%{_datadir}/sphere-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/
# dnf variables
install -d -m 0755 %{buildroot}%{_sysconfdir}/dnf/vars
echo "%{major}-stream" > %{buildroot}%{_sysconfdir}/dnf/vars/stream
# create secureboot certificate directories
install -d -m 0755 %{buildroot}%{_sysconfdir}/pki/sb-certs/
install -d -m 0755 %{buildroot}%{_datadir}/pki/sb-certs/
# install x86_64 secureboot certificates
install -m 644 %{SOURCE400} %{buildroot}%{_datadir}/pki/sb-certs/secureboot-ca-x86_64.cer
install -m 644 %{SOURCE401} %{buildroot}%{_datadir}/pki/sb-certs/secureboot-kernel-x86_64.cer
install -m 644 %{SOURCE402} %{buildroot}%{_datadir}/pki/sb-certs/secureboot-grub2-x86_64.cer
install -m 644 %{SOURCE403} %{buildroot}%{_datadir}/pki/sb-certs/secureboot-fwupd-x86_64.cer
# link x86_64 secureboot certificates
ln -sr %{buildroot}%{_datadir}/pki/sb-certs/secureboot-ca-x86_64.cer \
%{buildroot}%{_sysconfdir}/pki/sb-certs/secureboot-ca-x86_64.cer
ln -sr %{buildroot}%{_datadir}/pki/sb-certs/secureboot-kernel-x86_64.cer \
%{buildroot}%{_sysconfdir}/pki/sb-certs/secureboot-kernel-x86_64.cer
ln -sr %{buildroot}%{_datadir}/pki/sb-certs/secureboot-grub2-x86_64.cer \
%{buildroot}%{_sysconfdir}/pki/sb-certs/secureboot-grub2-x86_64.cer
ln -sr %{buildroot}%{_datadir}/pki/sb-certs/secureboot-fwupd-x86_64.cer \
%{buildroot}%{_sysconfdir}/pki/sb-certs/secureboot-fwupd-x86_64.cer
# copy DNF repositories
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/
install -p -m 0644 %{SOURCE502} %{buildroot}%{_sysconfdir}/yum.repos.d/
install -p -m 0644 %{SOURCE503} %{buildroot}%{_sysconfdir}/yum.repos.d/
install -p -m 0644 %{SOURCE504} %{buildroot}%{_sysconfdir}/yum.repos.d/
install -p -m 0644 %{SOURCE505} %{buildroot}%{_sysconfdir}/yum.repos.d/
install -p -m 0644 %{SOURCE506} %{buildroot}%{_sysconfdir}/yum.repos.d/
install -p -m 0644 %{SOURCE507} %{buildroot}%{_sysconfdir}/yum.repos.d/
install -p -m 0644 %{SOURCE508} %{buildroot}%{_sysconfdir}/yum.repos.d/
# copy GPG keys
install -d -m 0755 %{buildroot}%{_sysconfdir}/pki/rpm-gpg
install -p -m 0644 %{SOURCE100} %{buildroot}%{_sysconfdir}/pki/rpm-gpg/
%files
%license docs/LICENSE
%{_sysconfdir}/sphere-release
%{_sysconfdir}/redhat-release
%{_sysconfdir}/system-release
%config %{_sysconfdir}/system-release-cpe
%config(noreplace) %{_sysconfdir}/os-release
%{_prefix}/lib/os-release
%config(noreplace) %{_sysconfdir}/issue
%config(noreplace) %{_sysconfdir}/issue.net
%dir %{_sysconfdir}/issue.d
%{_rpmmacrodir}/macros.dist
%{_datadir}/redhat-release
%{_datadir}/sphere-release
%{_prefix}/lib/systemd/system-preset/*
%{_prefix}/lib/systemd/user-preset/*
%{_prefix}/lib/sysctl.d/50-redhat.conf
%files -n sphere-sb-certs
# Note to future packagers:
# resetting the symlinks in /etc/pki/sb-certs on upgrade is the intended behavior here
%dir %{_sysconfdir}/pki/sb-certs
%dir %{_datadir}/pki/sb-certs/
%{_sysconfdir}/pki/sb-certs/*.cer
%{_datadir}/pki/sb-certs/*.cer
%files -n sphere-repos
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-baseos.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-appstream.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-crb.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-extras.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-rt.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-nfv.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-highavailability.repo
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-resilientstorage.repo
%config(noreplace) %{_sysconfdir}/dnf/vars/stream
%files -n sphere-repos-extra
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-devel.repo
%files -n sphere-gpg-keys
%{_sysconfdir}/pki/rpm-gpg
%changelog
* Mon Jul 17 2023 Arkady L. Shane <ashejn@msvsphere.ru> - 9.2-1.3
- Disable optional repos
* Mon Jul 17 2023 Arkady L. Shane <ashejn@msvsphere.ru> - 9.2-1.2
- added rt, nfv, highavailabilit, resilientstorage repos
- fix debug and sources url in repo files
- added separate extra package for devel repo
* Thu Jul 6 2023 Sergey Cherevko <s.cherevko@msvsphere.ru> - 9.2-1.1
- Enable CRB by default (INF-387)
* Thu May 25 2023 Sergey Cherevko <s.cherevko@msvsphere.ru> - 9.2-1.0
- Update to MSVSphere 9.2
* Thu Apr 20 2023 Eugene Zamriy <ezamriy@msvsphere.ru> - 9.1-1.6
- Disabled CRB repo by default
- Added Extras repository config
* Mon Apr 10 2023 Eugene Zamriy <ezamriy@msvsphere.ru> - 9.1-1.5
- Added EULA
* Mon Apr 03 2023 Eugene Zamriy <ezamriy@msvsphere.ru> - 9.1-1.4
- Added BaseOS, AppStream and CRB repository configs
* Tue Mar 28 2023 Eugene Zamriy <ezamriy@msvsphere.ru> - 9.1-1.3
- Public key edit: added SHA256 digest
* Mon Mar 27 2023 Eugene Zamriy <ezamriy@msvsphere.ru> - 9.1-1.2
- Added MSVSPHERE_MANTISBT_PROJECT* variables for libreport plugin
* Mon Mar 27 2023 Eugene Zamriy <ezamriy@msvsphere.ru> - 9.1-1.1
- Added MSVSphere secureboot certificates
* Fri Feb 17 2023 Eugene Zamriy <ezamriy@msvsphere.ru> - 9.1-1.0
- Initial release for MSVSphere 9.1 beta