File lua-tl.spec of Package lua-tl

#
# spec file for package lua-tl
#
# Copyright (c) 2022 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 flavor @BUILD_FLAVOR@
%define mod_name tl
Version:        0.14.1
Release:        0
Summary:        Compiler for Teal, a typed dialect of Lua
License:        MIT
Group:          Development/Libraries/Other
URL:            https://github.com/teal-language/tl
Source:         https://github.com/teal-language/tl/archive/v%{version}.tar.gz#/%{mod_name}-%{version}.tar.gz
BuildRequires:  %{flavor}-argparse
BuildRequires:  %{flavor}-busted
BuildRequires:  %{flavor}-compat-5.3
BuildRequires:  %{flavor}-devel
BuildRequires:  %{flavor}-dkjson
BuildRequires:  %{flavor}-luafilesystem
BuildRequires:  lua-macros
Requires:       %{flavor}
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch
%lua_provides
%if "%{flavor}" == ""
Name:           lua-%{mod_name}
ExclusiveArch:  do_not_build
%else
Name:           %{flavor}-%{mod_name}
%endif

%description
The compiler for Teal, a typed dialect of Lua.

The core compiler has no dependencies and is implemented as a single tl.lua
file which you can load into your projects. Running tl.loader() will add Teal
support to your package loader, meaning that require() will be able to run .tl
files.

%prep
%autosetup -p1 -n %{mod_name}-%{version}

%build
%make_build -j1
diff -u tl.lua tl.lua.2

%install
install -m 0755 -p -d %{buildroot}%{lua_noarchdir}
install -v -D -m 0644 -p -t %{buildroot}%{lua_noarchdir} %{mod_name}.lua
install -v -D -m 0644 -p -t %{buildroot}%{lua_noarchdir} %{mod_name}.tl
install -m 0755 -p -d %{buildroot}%{_bindir}
install -v -D -m 0755 -p -t %{buildroot}%{_bindir} %{mod_name}

# update-alternatives
cp %{buildroot}%{_bindir}/tl{,-%{lua_version}}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives/
touch %{buildroot}%{_sysconfdir}/alternatives/tl
ln -sf %{_sysconfdir}/alternatives/tl %{buildroot}%{_bindir}/tl

%check

%post
%{_sbindir}/update-alternatives --install %{_bindir}/tl tl %{_bindir}/tl-%{lua_version} %{lua_version_nodots} \
%postun
if [ "$1" = 0 ] ; then
	%{_sbindir}/update-alternatives --remove tl %{_bindir}/tl-%{lua_version}
fi

%files
%license LICENSE
%doc README.md CHANGELOG.md
%{lua_noarchdir}/%{mod_name}*
%ghost %{_sysconfdir}/alternatives/tl
%{_bindir}/tl
%{_bindir}/tl-%{lua_version}

%changelog
openSUSE Build Service is sponsored by