#
# spec file for package xdg-terminal-exec
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%define make_macros prefix="%{buildroot}%{_prefix}" exec_prefix="%{buildroot}%{_prefix}" bindir="%{buildroot}%{_bindir}" datarootdir="%{buildroot}%{_datarootdir}" mandir="%{buildroot}%{_mandir}" man1dir="%{buildroot}%{_mandir}/man1"

# Based on OpenSUSE's 20240120+git.efc3517, which corresponds to version 0.9.0.
# Though, using actual version numbers in other distros.
%global rpmver 0.12.2
%global snap 20250303
%global commit 841a029

# Disable tests on distros lacking the bats program
%if "%{_vendor}" == "openmandriva" || "%{_vendor}" == "openEuler" || 0%{?centos}
%bcond_with    tests
%else
%bcond_without tests
%endif

%if 0%{!?mkrel:1}
%define mkrel(c) %{1}%{?dist}
%endif

Name:           xdg-terminal-exec
%if 0%{?suse_version}
Version:        %{snap}+git.%{commit}
%else
Version:        %{rpmver}
%endif
Release:        %mkrel 1
Group:          Terminals
Summary:        XDG terminal execution utility and default terminal specification
Summary(eo):    Plenumigas onian preferatan terminalon laÅ­ la inkluzivita specifo
License:        GPL-3.0-or-later
URL:            https://github.com/Vladimir-csp/xdg-terminal-exec/
Source:         https://github.com/Vladimir-csp/xdg-terminal-exec/archive/v%{rpmver}/%{name}-%{rpmver}.tar.gz
BuildRequires:  pkgconfig(scdoc)
BuildRequires:  make
%if %{with tests}
BuildRequires:  bats
%endif

BuildArch:      noarch

%description
Utility for XDG terminal execution and defining a systems default graphical terminal emulator.

Used by various GNOME utilities, among others.

%description -l eo
Utilaĵo por difini la aprioran grafikan terminalan imitilon de sistemo.

Uzata de diversaj iloj de GNOME, inter aliaj.

%prep
%autosetup -p1 -n %{name}-%{rpmver}

%build
%make_build %make_macros

%install
%make_install %make_macros

%if %{with tests}
%check
%__make test
%endif

%files
%doc README.md
%license LICENSE
%{_bindir}/xdg-terminal-exec
%{_mandir}/man1/%{name}.1*
%{_datarootdir}/%{name}/

%changelog
* Sat Jan 20 2024 mcepl@cepl.eu
- Update to version 20240120+git.efc3517:
  * Validate only entry ID part of paths, fixes #48
* Fri Jan 19 2024 mcepl@cepl.eu
- Update to version 20231218+git.a09da69:
  * Document cache behavior caveat
  * tests: Don't implicitly test found entry order
  * README: Document checking order of found entries
  * find_entry_paths: Only use a single `find` call
  * xdg-terminal-exec: Reverse entry data search order
  * Fix typo
  * xdg-terminal-exec: Simplify entry search
  * [Breaking] Drop xdg-terminals dirs, discard explicit exec arg
  * set umask when saving cache
  * update readme
  * cleanups
  * improve debug, comments
  * only validate entries from config, mass validate filenames with find
  * aliases are not propagated to subshells in bash, future-proofing for cache
  * xdg-terminal-exec: Introduce `error`
  * xdg-terminal-exec: Don't check for duplicates
  * xdg-terminal-exec: Fix matching <hyphen-minus>
  * cleanups
  * Fix undefined var
  * Add XDG_CURRENT_DESKTOP to cache
  * optimize contains(), case is awesome
  * repeat small things from cache branch
  * simplify id validator, relax config id pattern
  * Cache tweaks, stricter entry IDs from configs
  * wording sync
  * Update readme
  * save cmd late, invalidate cache by missing cmd early
  * drop cache on missing command
  * working cache
  * initial funcions
  * [Semi-Breaking] flexible directives
  * drop /usr/etc from readme
  * [Breaking] use stock applications by default
  * action test fix
  * formatting and debug
  * ignore *ShowIn checks for explicitly selected entries, better debug
  * change wording on non-conforming entry IDs
  * add ID string validator
  * Fix entry heirarchy precedence.
* Fri Nov 24 2023 mcepl@cepl.eu
- Update to version 20231124+git.fc8a6e0:
  * do not let alias chew on empty data
  * Support Desktop Actions, update docs
  * xdg-terminal-exec: Don't default to `xterm`
  * README: Reflect new `XTE_STOCK_TERMINALS` behaviour
  * xdg-terminal-exec: Convert all IDs in one `tr` call
  * xdg-terminal-exec: Map ID-path pairs using aliases
  * xdg-terminal-exec: Mask `IFS` inside functions
  * xdg-terminal-exec: Introduce `check_entry_key`
  * xdg-terminal-exec: Introduce `find_entry`
  * xdg-terminal-exec: Introduce `find_entry_paths`
  * xdg-terminal-exec: check `Categories` in `check_entry`
  * xdg-terminal-exec: Use `$XTE_STOCK_TERMINALS`
  * xdg-terminal-exec: Introduce `read_config_paths`
  * xdg-terminal-exec: Introduce `find_config_paths`
  * xdg-terminal-exec: Use `find -print`
  * xdg-terminal-exec: Make `find` call POSIX compliant
  * xdg-terminal-exec: match default paths with spec
  * xdg-terminal-exec: disable pathname expansion
* Thu Oct 26 2023 mcepl@cepl.eu
- Update to version 20231014+git.b6d2874:
  * update readme
  * WIP #28 internal list deduplicator, formatting
  * WIP #28 add stock applications controls to configs
  * check_bool function
  * WIP #28 filter terminals from applications
  * tr is faster than xargs -n1 on lots of lines
- Store only *.obscpio, the tarball is generated in buildtime.
* Sat Oct  7 2023 mcepl@cepl.eu
- Update to version 20231003+git.e5c20d0:
  * test/tests.bats: Add a TODO for additional tests
  * Add myself as a contributor
  * xdg-terminal-exec: Remove now unused code
  * xdg-terminal-exec: Move entry ID loops out to main
  * xdg-terminal-exec: Use globals set by `find*entry`
  * xdg-terminal-exec: Parse config file using `case`
  * xdg-terminal-exec: Check entries using `case`
  * xdg-terminal-exec: Parse entry file using `case`
  * xdg-terminal-exec: set `errexit` and `nounset`
  * README: Small fixes and changes
  * default debug value (fixes #24)
  * xdg-terminal-exec: Remove empty variable assignments
  * xdg-terminal-exec: Normalise printing
  * xdg-terminal-exec: Normalise string quotes
  * xdg-terminal-exec: Indent here documents
  * tests: Make `tests.bats` executable
  * xdg-terminal-exec: run `shfmt`
  * xdg-terminal-exec: don't use `find -printf`
* Mon Jul 31 2023 mcepl@suse.com
- Update to version 20230731+git.6426085:
  * fix shellcheck warnings, fixes #20
* Mon Jul 31 2023 mcepl@suse.com
- Update to version 20230725+git.97162b5:
  * Update xdg-terminal-exec
  * replace bloated xargs -0/IFS sorcery with more compact and
    clean eval/set magic
  * Use ASCII chars as candidates for delimiter, fixes #12
  * Fix errors during tests
  * xdg-terminal-exec: add missed $ to CHAR variable
  * Fixes for missing executable and empty data dirs
  * account for explicitly empty EXECARG, construct_argv
    function, update doc
- Enable tests.
* Thu Feb 23 2023 rbrown@suse.com
- Update to version 20230223+git.c70f178:
  * Add support for /usr/etc configurations
* Thu Feb 23 2023 Richard Brown <rbrown@suse.com>
- Initial Packaging, to be used by MicroOS Desktop and forks