jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
2.21k stars 112 forks source link

Feature request: RPM SPEC file #1171

Open Thulium-Drake opened 2 months ago

Thulium-Drake commented 2 months ago

Is your feature request related to a problem? Please describe.

To make the tool easier to install/update, I'd really like to have an RPM for Fedora. So I wrote a RPM SPEC file

Feedback to the file appreciated :)

Describe the solution you'd like.

Name:           kanata
Version:        %{version}
Release:        1%{?dist}
Summary:        Improve keyboard comfort and usability with advanced customization
BuildArch:      x86_64
License:        LGPL-3.0
%undefine _disable_source_fetch
Source0:        https://github.com/jtroo/kanata/archive/refs/tags/v%{version}.tar.gz
BuildRequires: rustup
BuildRequires: gcc

%description
This is a cross-platform software keyboard remapper for Linux, macOS and Windows. A short summary of the features:

*  multiple layers of key functionality
*  advanced key behaviour customization (e.g. tap-hold, macros, unicode)
*  cross-platform human readable configuration file

%prep
%autosetup -n %{name}-%{version}

%build
rustup-init -y
. "$HOME/.cargo/env"
rustup update stable
cargo update -p time  # needs to be updated for some reason
cargo build --release

%install
# Install binary
mkdir -p %{buildroot}/%{_bindir}
cp %{_builddir}/%{name}-%{version}/target/release/%{name} %{buildroot}/%{_bindir}

# Install config examples, systemd user unit and README
mkdir -p %{buildroot}/%{_docdir}/%{name}
cp -r %{_builddir}/%{name}-%{version}/cfg_samples %{buildroot}/%{_docdir}/%{name}
cp %{_builddir}/%{name}-%{version}/README.md %{buildroot}/%{_docdir}/%{name}

%{__cat} << EOF > %{buildroot}/%{_docdir}/%{name}/%{name}.service
[Unit]
Description=Kanata keyboard remapper
Documentation=https://github.com/jtroo/kanata

[Service]
Environment=DISPLAY=:0
Type=simple
ExecStart=/usr/bin/kanata --cfg ${HOME}/.config/kanata/config.kbd
Restart=no

[Install]
WantedBy=default.target
EOF

# Install udev rule
mkdir -p %{buildroot}/%{_sysconfdir}/udev/rules.d
%{__cat} << EOF > %{buildroot}/%{_sysconfdir}/udev/rules.d/90-kanata-uinput.rules
KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput"
EOF

%clean
rm -rf %{buildroot}

%pre
/usr/bin/getent group uinput || /usr/sbin/groupadd -r uinput

%postun
/usr/sbin/groupdel uinput

%files
%{_bindir}/%{name}
%{_docdir}/%{name}/README.md
%{_docdir}/%{name}/%{name}.service
%{_docdir}/%{name}/cfg_samples/*
%{_sysconfdir}/udev/rules.d/90-kanata-uinput.rules

%changelog
* Mon Jan 29 2024 Jeffrey van Pelt <jeff@vanpelt.one> - 0.0.1
- Initial RPM package

Once you've set up rpmbuild, you can build it with:

dnf builddep -D 'version 1.0' -y SPECS/kanata.spec  # version doesn't matter for this command
rpmbuild -bb -D '%version 1.6.1' SPECS/kanata.spec

Describe alternatives you've considered.

-

Additional context

No response

newsve commented 2 months ago

Remember it's just one guy maintaining it and there would be just too many distros/package managers to support on each build. I'd like to let him focus on what matters, and a git clone/pull + cargo build isn't a too big ask and done in few secs.

jtroo commented 2 months ago

If the steps to make an RPM can be added as a part of the Linux build steps in the top-level justfile, and it can be made simple to run, then I'd be happy to accept a PR for this. I don't have the expertise to review an rpm SPEC file though.