Dynamically set DefaultName on package install

Signed-off-by: Troy Dawson <tdawson@redhat.com>
This commit is contained in:
Troy Dawson 2025-04-15 10:32:51 -07:00
parent cac1fa2a3b
commit 3c2b79527f
2 changed files with 7 additions and 17 deletions

View File

@ -16,7 +16,7 @@ defaultUid = 1000
# Default name the distribution is registered under. # Default name the distribution is registered under.
# This is used when the user double-clicks to install, or uses # This is used when the user double-clicks to install, or uses
# wsl --install --from-file ./Fedora.wsl # wsl --install --from-file ./Fedora.wsl
defaultName = $NAME defaultName = DEFAULT_NAME
[shortcut] [shortcut]
enabled = true enabled = true

View File

@ -1,16 +1,3 @@
%if %{defined eln}
%global default_name ELN
%elif %{defined epel} && %{defined centos}
%global default_name CentosStream-EPEL-%{?centos}
%elif %{defined centos}
%global default_name CentosStream-%{?centos}
%elif %{defined fedora}
%global default_name Fedora-%{?fedora}
%else
%global default_name Fedora
%endif
Name: wsl-setup Name: wsl-setup
Version: 1.0.0 Version: 1.0.0
Release: %autorelease Release: %autorelease
@ -38,7 +25,6 @@ Provides WSL specific configuration files and first-time setup script.
%prep %prep
sed -i 's,$NAME,%{default_name},' %{SOURCE3}
%build %build
@ -67,8 +53,12 @@ install -Dpm0644 %{SOURCE7} %{buildroot}%{_user_tmpfilesdir}/%{name}.conf
# until we can see about adjusting either WSL or systemd to make it behave. # until we can see about adjusting either WSL or systemd to make it behave.
install -Dpm0644 %{SOURCE5} %{buildroot}%{_unitdir}/systemd-firstboot.service.d/override.conf install -Dpm0644 %{SOURCE5} %{buildroot}%{_unitdir}/systemd-firstboot.service.d/override.conf
%check
grep "defaultName = %{default_name}" %{buildroot}%{_sysconfdir}/wsl-distribution.conf %post
# generate the "auto" naming
. %{_sysconfdir}/os-release
DYNAMIC_NAME="${NAME// /}-${VERSION_ID%.*}"
sed -i "s,DEFAULT_NAME,${DYNAMIC_NAME}," %{_sysconfdir}/wsl-distribution.conf
%files %files