%global distro MSVSphere
# define MSVSphere products
%global release_name Server ARM
%global major 8
%global minor 9
Name: sphere-release
Version: %{major}.%{minor}
Release: 3%{?dist}
Summary: %{distro} release files
License: GPLv2
URL: https://msvsphere-os.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})
Requires: sphere-release-common = %{version}-%{release}
Source100: RPM-GPG-KEY-MSVSphere-8
Source200: LICENSE
Source201: EULA
Source202: EULA-ARM
Source203: EULA-SERVER
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-powertools.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
Source509: msvsphere-testing.repo
%description
%{distro} release files.
%package common
Summary: MSVSphere release files
Requires: sphere-release-variant = %{version}-%{release}
Requires: sphere-release = %{version}-%{release}
Requires: sphere-repos(%{version})
Requires: sphere-release-identity = %{version}-%{release}
Obsoletes: redhat-release-server < %{version}-%{release}
%description common
Release files common to all Editions and Spins of MSVSphere
%package server
Summary: Base package for MSVSphere Server-specific default configurations
RemovePathPostfixes: .Server
Provides: sphere-release-variant = %{version}-%{release}
Provides: system-release
Provides: system-release(%{version})
Provides: base-module(platform:f%{version})
Requires: sphere-release-common = %{version}-%{release}
# sphere-release-common Requires: sphere-release-identity, so at least one
# package must provide it. This Recommends: pulls in
# sphere-release-identity-server if nothing else is already doing so.
Recommends: sphere-release-identity-server
%description server
Provides a base package for MSVSphere Server-specific configuration files to
depend on.
%package identity-server
Summary: Package providing the identity for MSVSphere Server Edition
RemovePathPostfixes: .Server
Provides: sphere-release-identity = %{version}-%{release}
Conflicts: sphere-release-identity
Requires: sphere-release-server = %{version}-%{release}
Requires(pre): /usr/bin/ln
%description identity-server
Provides the necessary files for a MSVSphere installation that is identifying
itself as MSVSphere Server Edition.
%package arm
Summary: Base package for MSVSphere ARM-specific default configurations
RemovePathPostfixes: .ARM
Provides: sphere-release-variant = %{version}-%{release}
Provides: system-release
Provides: system-release(%{version})
Provides: base-module(platform:f%{version})
Requires: sphere-release-common = %{version}-%{release}
Provides: system-release-product
# sphere-release-common Requires: sphere-release-identity, so at least one
# package must provide it. This Recommends: pulls in
# sphere-release-identity-workstation if nothing else is already doing so.
Recommends: sphere-release-identity-arm
%description arm
Provides a base package for MSVSphere ARM-specific configuration files to
depend on.
%package identity-arm
Summary: Package providing the identity for MSVSPhere ARM Edition
RemovePathPostfixes: .ARM
Provides: sphere-release-identity = %{version}-%{release}
Conflicts: sphere-release-identity
Requires: sphere-release-arm = %{version}-%{release}
Requires(pre): /usr/bin/ln
%description identity-arm
Provides the necessary files for a MSVSphere installation that is identifying
itself as MSVSphere ARM Edition.
%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}
Provides: sphere-repos(%{version})
%description -n sphere-repos
This package provides the package repository files for %{distro}.
%package -n sphere-repos-extra
Summary: %{distro} extra packages repositories
Requires: sphere-release = %{version}-%{release}
Requires: sphere-gpg-keys = %{version}-%{release}
%description -n sphere-repos-extra
This package provides extra packages repository files for %{distro},
like Devel.
%package -n sphere-repos-testing
Summary: %{distro} testing packages repositories
Requires: sphere-release = %{version}-%{release}
Requires: sphere-gpg-keys = %{version}-%{release}
%description -n sphere-repos-testing
This package provides extra packages repository files for %{distro},
like Testing.
%package -n sphere-repos-flatpak
Summary: %{distro} flatpak package repositories
Requires: sphere-release = %{version}-%{release}
Requires: sphere-gpg-keys = %{version}-%{release}
Requires: flatpak
%description -n sphere-repos-flatpak
This package added Flathub and Fedora Flatpaks repositories
for %{distro}.
%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
# generate /usr/lib/os-release file
install -d -m 0755 %{buildroot}%{_prefix}/lib
for variant in %{release_name}; do
echo "%{distro} release %{major}.%{minor}%{?beta: %{beta}} (${variant})" > %{buildroot}%{_prefix}/lib/sphere-release.$variant
if [ "$variant" = "ARM" ]; then
ru_variant="А Р М "
elif [ "$variant" = "Server" ]; then
ru_variant="Сервер"
else
ru_variant=$variant
fi
cat > %{buildroot}%{_prefix}/lib/os-release.$variant << EOF
NAME="%{distro}"
VERSION="%{major}.%{minor}%{?beta: %{beta}} (${variant})"
ID="msvsphere"
ID_LIKE="rhel centos fedora"
VERSION_ID="%{major}.%{minor}"
PLATFORM_ID="platform:el%{major}"
PRETTY_NAME="%{distro} %{major}.%{minor}%{?beta: %{beta}} ${variant}"
ANSI_COLOR="1;35"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:ncsd:msvsphere:%{major}::baseos"
HOME_URL="https://msvsphere-os.ru/"
BUG_REPORT_URL="https://bugs.msvsphere-os.ru/"
DOCUMENTATION_URL="https://docs.msvsphere-os.ru/"
SUPPORT_URL="https://support.msvsphere-os.ru/"
VENDOR_NAME="LLC NCSD"
MSVSPHERE_MANTISBT_PROJECT="%{distro}-%{major}"
MSVSPHERE_MANTISBT_PROJECT_VERSION="%{major}.%{minor}"
MSVSPHERE_PRETTY_NAME="МСВСфера %{major}.%{minor}%{?beta: %{beta}} ${ru_variant}"
EOF
done
install -d -m 0755 %{buildroot}%{_sysconfdir}
# create symlink for /etc/os-release
ln -s ../usr/lib/os-release %{buildroot}%{_sysconfdir}/os-release
# create symlink for /etc/system-release
ln -s ../usr/lib/sphere-release %{buildroot}%{_sysconfdir}/sphere-release
# create /etc/sphere-release, /etc/system-release and /etc/redhat-release files
ln -s sphere-release %{buildroot}%{_sysconfdir}/system-release
ln -s sphere-release %{buildroot}%{_sysconfdir}/redhat-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 %{SOURCE202} %{buildroot}%{_datadir}/sphere-release/
install -p -m 0644 %{SOURCE203} %{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/
install -p -m 0644 %{SOURCE509} %{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/
%post -n sphere-repos-flatpak
/usr/bin/flatpak remote-add --system --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo ||:
/usr/bin/flatpak remote-add --system --if-not-exists fedora oci+https://registry.fedoraproject.org ||:
%postun -n sphere-repos-flatpak
/usr/bin/flatpak remote-delete --system flathub ||:
/usr/bin/flatpak remote-delete --system fedora ||:
%post identity-arm
/usr/bin/ln -srf /usr/share/sphere-release/EULA-ARM /usr/share/sphere-release/EULA
%preun identity-arm
/usr/bin/rm -f /usr/share/sphere-release/EULA
%post identity-server
/usr/bin/ln -srf /usr/share/sphere-release/EULA-SERVER /usr/share/sphere-release/EULA
%preun identity-server
/usr/bin/rm -f /usr/share/sphere-release/EULA
%files
%files common
%license docs/LICENSE
%{_sysconfdir}/sphere-release
%{_sysconfdir}/redhat-release
%{_sysconfdir}/system-release
%config %{_sysconfdir}/system-release-cpe
%config(noreplace) %{_sysconfdir}/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 server
%files identity-server
%{_prefix}/lib/os-release.Server
%{_prefix}/lib/sphere-release.Server
%{_datadir}/sphere-release/EULA-SERVER
%files arm
%files identity-arm
%{_prefix}/lib/os-release.ARM
%{_prefix}/lib/sphere-release.ARM
%{_datadir}/sphere-release/EULA-ARM
%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-powertools.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-repos-testing
%config(noreplace) %{_sysconfdir}/yum.repos.d/msvsphere-testing.repo
%files -n sphere-repos-flatpak
%files -n sphere-gpg-keys
%{_sysconfdir}/pki/rpm-gpg
%changelog
* Mon Mar 11 2024 Arkady L. Shane <tigro@msvsphere-os.ru> - 8.9-3
- Obsoletes redhat-release-server
* Wed Jan 24 2024 Arkady L. Shane <tigro@msvsphere-os.ru> - 8.9-2
- rename CRB to PowerTools
* Tue Dec 19 2023 Arkady L. Shane <tigro@msvsphere-os.ru> - 8.9-1
- Sync this MSVSphere 9 patches
* Tue Sep 12 2023 Sergey Cherevko <s.cherevko@msvsphere.ru> - 8.8-1.1
- Changed URLs from msvsphere.ru to msvsphere-os.ru
- Rebuilt for MSVSphere 8.8
* Mon Aug 14 2023 Sergey Cherevko <s.cherevko@msvsphere.ru> - 8.8-1.0
- Rebuilt for MSVSphere 8.8
* Sun Jul 30 2023 Arkady L. Shane <ashejn@msvsphere.ru> - 9.2-1.4
- Create separate packages for Server and ARM
* 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