wsl-setup/wsl-setup.spec
Troy Dawson cac1fa2a3b Expand variations for default_name
Signed-off-by: Troy Dawson <tdawson@redhat.com>
2025-04-11 07:31:27 -07:00

87 lines
2.8 KiB
RPMSpec

%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
Version: 1.0.0
Release: %autorelease
Summary: Windows Subsystem for Linux setup script and configuration
License: MIT
URL: https://src.fedoraproject.org/rpms/wsl-setup
BuildArch: noarch
Source1: LICENSE
Source2: wsl.conf
Source3: wsl-distribution.conf
Source4: wsl-oobe.sh
Source5: firstboot-override.conf
Source6: wsl-setup-tmpfiles.conf
Source7: wsl-setup-user-tmpfiles.conf
BuildRequires: systemd-rpm-macros
# Needed for the distribution icon
Requires: system-logos
%description
Provides WSL specific configuration files and first-time setup script.
%prep
sed -i 's,$NAME,%{default_name},' %{SOURCE3}
%build
%install
install -pm 0644 %{SOURCE1} LICENSE
install -Dpm0644 -t %{buildroot}%{_sysconfdir}/ %{SOURCE2}
install -Dpm0644 -t %{buildroot}%{_prefix}/lib/ %{SOURCE3}
install -Dpm0755 -T %{SOURCE4} %{buildroot}%{_libexecdir}/wsl/oobe.sh
ln -s ..%{_prefix}/lib/wsl-distribution.conf %{buildroot}%{_sysconfdir}/wsl-distribution.conf
# WSL provides a socket for x11, but we need to ensure its linked to in /tmp.
# The official recommendation is to disable tmpfiles entirely, but it would be
# nice to work with it, instead.
# https://learn.microsoft.com/en-us/windows/wsl/build-custom-distro#systemd-recommendations
install -Dpm0644 %{SOURCE6} %{buildroot}%{_tmpfilesdir}/%{name}.conf
# WSL provides a Wayland and PulseAudio socket as well, which are expected to be in
# the user's runtime directory. This configuration sets up the links for each user.
install -Dpm0644 %{SOURCE7} %{buildroot}%{_user_tmpfilesdir}/%{name}.conf
# Currently systemd-firstboot hangs forever attempting to acquire the console; this is
# problematic since many other services wait for it to complete before starting, including
# things like the system D-Bus. Configure it to not run in WSL (a preset didn't seem to work)
# 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
%check
grep "defaultName = %{default_name}" %{buildroot}%{_sysconfdir}/wsl-distribution.conf
%files
%config(noreplace) %{_sysconfdir}/wsl.conf
%{_prefix}/lib/wsl-distribution.conf
%{_sysconfdir}/wsl-distribution.conf
%{_libexecdir}/wsl/oobe.sh
%{_tmpfilesdir}/%{name}.conf
%{_user_tmpfilesdir}/%{name}.conf
%{_unitdir}/systemd-firstboot.service.d/override.conf
%license LICENSE
%changelog
%autochangelog