File pie.spec of Package pie

%define bname pie
Name: %bname
Version: 1
Release: 9
Summary: Programmer's Interactive Editor
License: BSD-3-Clause
Group: Development/Tools/Other
URL: https://github.com/erlang-unicode/%bname
Source: %bname.tar.xz
Patch1: 0001-msc-replace-regexp-with-re.patch
Patch2: 0002-pie-replace-regexp-with-re.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: erlang-otp-base >= R16B01
BuildRequires: rebar erl_interface eslang-devel erlang-parsetools erlang-parsetools-devel

%description
Emacs-like Erlang editor fully written in Erlang with S-Lang driver.
It is refined with built-in sync and lager.
Pie codebase is very tiny, clean and extendable.


%prep
%setup -q -n %bname
%patch1 -p1
%patch2 -p1
sed -i \
	-e '/^-include_lib/s/^/%%/' \
	-e '/^do_change_size/,$s/^/%%/' \
	-e 's/do_\(change_size\)/disk_log:\1/g' \
	apps/msc/src/disk_log_h.erl
rm -f apps/{%bname/src/edit_{make,terminal_gterm},msc/src/syslog}.*


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
file:write_file("%bname.rebar.config", [[io_lib:print(E), ".\n"] || E <- lists:keydelete(deps, 1, L)], [raw]),
init:stop().'
ERL_COMPILER_OPTIONS='[inline,{i,"'"$PWD"'/apps"},verbose]' rebar %{?_smp_mflags} -C %bname.rebar.config compile -v


%install
install -d -m 0755 %buildroot%_bindir
for i in %bname msc; do
	install -d -m 0755 %buildroot%_otplibdir/$i-%version/ebin
	install -p -m 0644 apps/$i/ebin/* %buildroot%_otplibdir/$i-%version/ebin/
done
install -p -m 0644 sys.config %buildroot%_otplibdir/%bname-%version/
cat > %buildroot%_bindir/%bname <<"__EOF__"
#!/bin/sh
erl +A 100 -config %_otplibdir/%bname-%version/sys.config -s pie start $@
stty sane
__EOF__
chmod 0755 %buildroot%_bindir/%bname


%files
%defattr(-,root,root)
%doc README*
%_bindir/*
%_otplibdir/*


%changelog
* Sun Nov 12 2017 Led <ledest@gmail.com> 1-9
- fix build

* Sun Jul 26 2015 Led <ledest@gmail.com> 1-8
- remove syslog module

* Thu Jul 02 2015 Led <ledest@gmail.com> 1-7
- fix BuildRequires

* Sun Apr 12 2015 Led <ledest@gmail.com> 1-6
- clean ups
- update BuildRequires

* Tue Mar 03 2015 Led <ledest@gmail.com> 1-5
- add erl_opts

* Tue Mar 03 2015 Led <ledest@gmail.com> 1-4
- added patches:
  + 0001-msc-replace-regexp-with-re.patch
  + 0002-pie-replace-regexp-with-re.patch

* Tue Mar 03 2015 Led <ledest@gmail.com> 1-3
- remove unneeded module edit_make

* Tue Mar 03 2015 Led <ledest@gmail.com> 1-2
- remove unneeded module edit_terminal_gterm

* Tue Mar 03 2015 Led <ledest@gmail.com> 1-1
- initial build
openSUSE Build Service is sponsored by