File lua-lmod.spec of Package lua-lmod

#
# spec file for package lua-lmod
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

%define lua_lmod_modulesdir %{_datarootdir}/lmod/modulefiles
%define lua_lmod_admin_modulesdir %{_datarootdir}/lmod/admin/modulefiles
%define lua_lmod_moduledeps %{_datarootdir}/lmod/moduledeps
%define lua_path ?.lua;?/?.lua;%{lua_noarchdir}/?.lua
%define lua_cpath ?.so;?/?.so;%{lua_archdir}/?.so

Name:      lua-lmod
Summary:   Lua based Environment Modules
Version:   6.0.24
Release:   0
License:   MIT
Group:     Development/Libraries/Other
Url:       https://github.com/TACC/Lmod
BuildArch: noarch

Source0:   https://github.com/TACC/Lmod/archive/%{version}.tar.gz#$/%{name}-%{version}.tar.gz
Patch1: lmod.consulting.patch
Patch2: lmod.site.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires: lua >= %{lua_version}
BuildRequires: lua-devel >= %{lua_version}
BuildRequires: lua-luafilesystem
BuildRequires: lua-luaposix
BuildRequires: lua-luaterm
BuildRequires: rsync
BuildRequires: tcl

Requires: lua >= %{lua_version}
Requires: lua-luafilesystem
Requires: lua-luaposix
Requires: lua-luaterm
Requires: tcl

%description
Lmod is an Environment Module System based on Lua, Reads TCL Modules,
Supports a Software Hierarchy.

%prep
%setup -q -n Lmod-%{version}
%patch1 -p1
%patch2 -p1

%build
export LUA_CPATH="%{lua_cpath}"
export LUA_PATH="%{lua_path}"
%configure --prefix=%{_datadir} \
    --with-module-root-path=%{lua_lmod_modulesdir} \
    --libdir=%{lua_archdir} \
    --datadir=%{lua_noarchdir} \
    --with-redirect=yes \
    --with-autoSwap=no
make 

%install
export LUA_CPATH="%{lua_cpath}"
export LUA_PATH="%{lua_path}"
make DESTDIR=%{buildroot} install

%{__mkdir_p} %{buildroot}%{_sysconfdir}/rpm
%{__cat} <<EOF > %{buildroot}%{_sysconfdir}/rpm/macros.lmod
%%lua_lmod_modulesdir %{lua_lmod_modulesdir}
%%lua_lmod_admin_modulesdir %{lua_lmod_admin_modulesdir}
%%lua_lmod_moduledeps %{lua_lmod_moduledeps}
EOF
%{__mkdir_p} %{buildroot}%{lua_lmod_modulesdir}
%{__mkdir_p} %{buildroot}%{lua_lmod_admin_modulesdir}
%{__mkdir_p} %{buildroot}%{lua_lmod_moduledeps}

# Fix exec warning
%{__chmod} u+x %{buildroot}%{_datadir}/lmod/%{version}/libexec/ignore_dirs_converter
# Fix file duplicates
%{__rm} -f %{buildroot}/%{_datadir}/lmod/%{version}/init/ksh
%{__ln_s} %{_datadir}/lmod/%{version}/init/sh  %{buildroot}/%{_datadir}/lmod/%{version}/init/ksh
%{__rm} -f %{buildroot}/%{_datadir}/lmod/%{version}/init/zsh
%{__ln_s} %{_datadir}/lmod/%{version}/init/bash  %{buildroot}/%{_datadir}/lmod/%{version}/init/zsh
%{__rm} -f %{buildroot}/%{_datadir}/lmod/%{version}/init/tcsh
%{__ln_s} %{_datadir}/lmod/%{version}/init/csh %{buildroot}/%{_datadir}/lmod/%{version}/init/tcsh
%{__rm} -f %{buildroot}/%{_datadir}/lmod/%{version}/settarg/Version.lua 
%{__ln_s} %{_datadir}/lmod/%{version}/libexec/Version.lua %{buildroot}/%{_datadir}/lmod/%{version}/settarg/Version.lua

%files
%defattr(-,root,root,-)
%config %{_sysconfdir}/rpm/macros.lmod
%dir %{_datadir}/lmod
%dir %{lua_lmod_modulesdir}
%dir %{lua_lmod_admin_modulesdir}
%dir %{lua_lmod_moduledeps}
%{_datadir}/lmod/*
%doc License
%doc README

%changelog
openSUSE Build Service is sponsored by