File sc-controller.spec of Package sc-controller-test

#
# spec file for package sc-controller
#

%{?sle15_python_module_pythons}

%define scc_version 0.5.5

Name:           sc-controller
Version:        2026.%{scc_version}
Release:        0
Summary:        User-mode driver and GTK3-based GUI for the Steam Controller
License:        GPL-2.0-only
Group:          Hardware/Joystick
URL:            https://github.com/C0rn3j/sc-controller
Source:         %{name}-%{scc_version}.tar.gz

BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  gobject-introspection
BuildRequires:  hicolor-icon-theme
BuildRequires:  pkgconfig
BuildRequires:  python3-setuptools
BuildRequires:  shared-mime-info
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(python3)
BuildRequires:  pkgconfig(udev)

BuildRequires:  regataos-python311
BuildRequires:  python311-setuptools
BuildRequires:  python311-devel
BuildRequires:  python311-gobject
BuildRequires:  python311-pytest-xdist
BuildRequires:  python311-pip
BuildRequires:  python311-setuptools
BuildRequires:  python311-wheel

Requires:       python311-vdf
Requires:       python311-evdev
Requires:       python311-gobject-Gdk
Requires:       python311-ioctl-opt
Requires:       python311-libusb1
Requires:       python311-pycairo
Requires:       python311-pylibacl
Requires:       python311-setuptools
Requires:       sc-controller-lang

%description
Application allowing to setup, configure and use the Steam Controller
without using the Steam client.

%lang_package

%prep
%setup -q -n sc-controller-%{scc_version}

%build
python3.11 setup.py build

%install
# IMPORTANT: use setup.py install to ensure scripts (/usr/bin/*) and the 'scc' package get installed
python3.11 setup.py install \
  --root=%{buildroot} \
  --prefix=%{_prefix} \
  --optimize=1

# ------------------------------------------------------------
# Instalar traduções (usa .mo pré-compilado se existir, senão compila .po)
# NOTA: NÃO usar msguniq — corrompe strings multiline!
# ------------------------------------------------------------
if [ -d locale ]; then
  for locale_dir in locale/*/LC_MESSAGES; do
    [ -d "$locale_dir" ] || continue
    lang=$(echo "$locale_dir" | cut -d/ -f2)
    
    install -d %{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES
    
    # Preferir .mo pré-compilado (mais seguro)
    if [ -f "${locale_dir}/sc-controller.mo" ]; then
      echo "Usando .mo pré-compilado para ${lang}"
      install -m 644 "${locale_dir}/sc-controller.mo" \
        %{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES/sc-controller.mo
    # Caso contrário, compilar do .po (SEM msguniq)
    elif [ -f "${locale_dir}/sc-controller.po" ]; then
      echo "Compilando .po para ${lang}"
      msgfmt -o %{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES/sc-controller.mo \
        "${locale_dir}/sc-controller.po"
    fi
  done
fi

%find_lang sc-controller
%fdupes %{buildroot}%{_prefix}

%files
%license LICENSE
%doc README.md ADDITIONAL-LICENSES TODO.md

# Binaries installed by the project
%{_bindir}/sc-controller
%{_bindir}/scc
%{_bindir}/scc-daemon
%{_bindir}/scc-osd-dialog
%{_bindir}/scc-osd-keyboard
%{_bindir}/scc-osd-launcher
%{_bindir}/scc-osd-menu
%{_bindir}/scc-osd-message
%{_bindir}/scc-osd-radial-menu
%{_bindir}/scc-osd-show-bindings

# Python package + extensions (x86_64 typically installs to sitearch: /usr/lib64/...)
%{python3_sitearch}/scc/
%{python3_sitearch}/libuinput*.so
%{python3_sitearch}/libcemuhook*.so
%{python3_sitearch}/libhiddrv*.so
%{python3_sitearch}/libsc_by_bt*.so
%{python3_sitearch}/libremotepad*.so
%{python3_sitearch}/sccontroller-*.egg-info/

# Desktop integration and data
%{_datadir}/applications/sc-controller.desktop
%{_datadir}/pixmaps/sc-controller.svg
%{_datadir}/scc/
%{_datadir}/mime/packages/scc-mime-types.xml
%{_datadir}/icons/hicolor/*/status/*.png

# udev rules
%{_udevrulesdir}/69-sc-controller.rules

%files lang -f sc-controller.lang

%changelog
openSUSE Build Service is sponsored by