Blame lua-luarepl.spec

a8a9fa
#
a8a9fa
# spec file
a8a9fa
#
a8a9fa
# Copyright (c) 2022 SUSE LLC
a8a9fa
#
a8a9fa
# All modifications and additions to the file contributed by third parties
a8a9fa
# remain the property of their copyright owners, unless otherwise agreed
a8a9fa
# upon. The license for this file, and modifications and additions to the
a8a9fa
# file, is the same license as for the pristine package itself (unless the
a8a9fa
# license for the pristine package is not an Open Source License, in which
a8a9fa
# case the license is the MIT License). An "Open Source License" is a
a8a9fa
# license that conforms to the Open Source Definition (Version 1.9)
a8a9fa
# published by the Open Source Initiative.
a8a9fa
a8a9fa
# Please submit bugfixes or comments via https://bugs.opensuse.org/
a8a9fa
#
a8a9fa
a8a9fa
%bcond_without test
a8a9fa
%define flavor @BUILD_FLAVOR@
a8a9fa
%define mod_name luarepl
a8a9fa
%define lua_value  %(echo "%{flavor}" |sed -e 's:lua::')
a8a9fa
%define rock_version 0.10-1
a8a9fa
Version:        0.10
a8a9fa
Release:        0
a8a9fa
Summary:        A Lua REPL implemented in Lua for embedding in other programs
a8a9fa
License:        MIT
a8a9fa
Group:          Development/Languages/Other
a8a9fa
URL:            https://github.com/hoelzro/lua-repl
a8a9fa
Source:         lua-repl-%{version}.tar.xz
103345
BuildRequires:  lua-macros
a8a9fa
BuildRequires:  %{flavor}-luarocks
a8a9fa
BuildRequires:  %{flavor}-devel
a8a9fa
%if %{with test}
a8a9fa
BuildRequires:  perl
a8a9fa
BuildRequires:  %{flavor}-testmore
a8a9fa
%endif
a8a9fa
Requires:       %{flavor}
a8a9fa
Requires:       bash-sh
a8a9fa
# https://github.com/hoelzro/lua-repl#recommended-packages
a8a9fa
Recommends:     %{flavor}-linenoise
a8a9fa
# Enable filename_completion plugin
a8a9fa
Suggests:       %{flavor}-filesystem
a8a9fa
%lua_provides
a8a9fa
%if "%{flavor}" == ""
a8a9fa
Name:           lua-%{mod_name}
a8a9fa
ExclusiveArch:  do_not_build
a8a9fa
%else
a8a9fa
Name:           %{flavor}-%{mod_name}
a8a9fa
%endif
a8a9fa
BuildArch:      noarch
a8a9fa
Requires(post): update-alternatives
a8a9fa
Requires(postun):update-alternatives
a8a9fa
a8a9fa
%description
a8a9fa
This project has two uses:
a8a9fa
- An alternative to the standalone interpreter included with Lua, one that
a8a9fa
supports things like plugins, tab completion, and automatic insertion of
a8a9fa
return in front of expressions.
a8a9fa
- A REPL library you may embed in your application, to provide all of the
a8a9fa
niceties of the standalone interpreter included with Lua and then some.
a8a9fa
a8a9fa
%prep
a8a9fa
%autosetup -n lua-repl-%{version}
a8a9fa
# Fix the Lua shebang of rep.lua script
a8a9fa
sed -i -r '1s/env (lua)/\1%{lua_version}/' rep.lua
a8a9fa
a8a9fa
%build
a8a9fa
%luarocks_build "%{mod_name}-%{rock_version}.rockspec"
a8a9fa
a8a9fa
%install
a8a9fa
%luarocks_install *.rock
a8a9fa
a8a9fa
# Version the rep.lua file
a8a9fa
sed -i -r -e "s#%{buildroot}##" -e "s#(/bin/rep.lua)#\1-%{lua_version}#" \
a8a9fa
    "%{buildroot}/usr/bin/rep.lua"
a8a9fa
mv %{buildroot}%{_bindir}/rep.lua{,-%{lua_version}}
a8a9fa
a8a9fa
# update-alternatives
a8a9fa
mkdir -p %{buildroot}%{_sysconfdir}/alternatives/
a8a9fa
touch %{buildroot}%{_sysconfdir}/alternatives/rep.lua
a8a9fa
ln -sf %{_sysconfdir}/alternatives/rep.lua %{buildroot}%{_bindir}/rep.lua
a8a9fa
mkdir -p %{buildroot}%{luarocks_treedir}/%{mod_name}/%{rock_version}/bin
a8a9fa
touch %{buildroot}%{luarocks_treedir}/%{mod_name}/%{rock_version}/bin/rep.lua-%{lua_version}
a8a9fa
ln -sf %{luarocks_treedir}/%{mod_name}/%{rock_version}/bin/rep.lua \
a8a9fa
%{buildroot}%{luarocks_treedir}/%{mod_name}/%{rock_version}/bin/rep.lua-%{lua_version}
a8a9fa
a8a9fa
%post
a8a9fa
%{_sbindir}/update-alternatives --install %{_bindir}/rep.lua rep.lua %{_bindir}/rep.lua-%{lua_version} %{lua_value}
a8a9fa
a8a9fa
%postun
a8a9fa
if [ "$1" = 0 ] ; then
a8a9fa
 %{_sbindir}/update-alternatives --remove rep.lua %{_bindir}/rep.lua-%{lua_version}
a8a9fa
fi
a8a9fa
a8a9fa
%if %{with test}
a8a9fa
%check
a8a9fa
make test
a8a9fa
%endif
a8a9fa
a8a9fa
%files
a8a9fa
%license %{luarocks_treedir}/%{mod_name}/%{rock_version}/doc/COPYING
a8a9fa
%docdir %{luarocks_treedir}/%{mod_name}/%{rock_version}/doc
a8a9fa
%{lua_noarchdir}
a8a9fa
%{luarocks_treedir}/%{mod_name}
a8a9fa
%ghost %{_sysconfdir}/alternatives/rep.lua
a8a9fa
%{_bindir}/rep.lua
a8a9fa
%{_bindir}/rep.lua-%{lua_version}
a8a9fa
a8a9fa
%changelog