luaはじめました。で、luarocksをrpm導入(rpmbuild編)。
冷やし中華ではなく、luaはじめました。
ストレスたまると、新しい言語さわりたくなりますよねぇーwww
ちょっといろいろ今後のこともあり、luaをはじめました。自分の中では、一番しっくり来てます。
で、Perlでいう、CPAN、PHPでいう、PEAR?、Pythonだと、easy_install(今だとpip?)のように
luaでもluarocksというパッケージ管理システムからluaのモジュールを自動で検索してインストールや
アップデートしてくれるツールがあります。 http://luarocks.org/
通常は、ソースコンパイルでの導入なんですが、Redhat系ならRPMで導入だよねぇーということで、
EPELとかでもなくて、ちょこっと探して導入したので、そのメモです。
-
-
-
- -
-
-
※追記 epel-release-6-7.noarch.rpm には、luarocks入っているのでそっち使った方がイイよ!!
-
-
-
- -
-
-
SPECがネットで公開されていますので、それを使いました。
http://thomas.duboucher.free.fr/luarocks.spec
以下、上記の引用で今だと、バージョンが2.0.8なので、それに合わせました。
ちなみに環境は、Kororaa release 16です。
vim wget /root/rpmbuild/luarocks.spec
Name: luarocks Version: 2.0.8 Release: 1%{?dist} Summary: Package management system for Lua modules and Libraries Group: Development/System License: MIT URL: http://www.luarocks.org/ Source0: http://luarocks.org/releases/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %define luaver 5.1 #LuaRocks is _not_ arch-independant, due to toolchain differences ExclusiveArch: x86, x86_64 #BuildArchitectures: noarch # Untested architectures: ARM, IA64, Parisc, ppc, ppc64, S390, SPARC BuildRequires: lua-devel >= %{luaver} BuildRequires: luadoc Requires: lua >= %{luaver} Requires: wget Requires: zip # LuaRocks is arch-dependant, however there's no debug-info since it's pure Lua %global debug_package %{nil} %define prefix /usr %define downloader wget %define md5checker md5sum %define manifest /%{prefix}/lib/luarocks/rocks/manifest %description This package contains LuaRocks, a command-line tool for managing Lua rocks. A rock is a compressed folder containing a Lua module and metadata mandatory for the compilation and installation process. It can be either written in C, Lua or both at the same time. LuaRocks manages fetching, installing and removing rocks and handles dependencies between rocks. Rocks are installed system-wide so that they can be used by any Lua application. This package also provides the admin tool to manage a LuaRocks repository, along with the LuaRocks documentation Note that most rocks require to have lua-devel installed on your system. # ### ### ### ### # Prep # ### ### ### ### %prep %setup -q -n %{name}-%{version} #Make sure COPYING is in utf8 iconv -f ISO-8859-1 -t UTF-8 -o COPYING.new COPYING && \ touch -r COPYING COPYING.new && \ mv COPYING.new COPYING # ### ### ### ### # Build # ### ### ### ### %build # ### ### ### ### ## pt1 - Executable # ### ### ### ### # Can't use configure macro here since configure script fails with unsupported # options ./configure \ --prefix="%{prefix}" \ --sysconfdir="%{_sysconfdir}/%{name}/" \ --with-lua="%{prefix}" \ --with-lua-include="%{_includedir}" \ --with-lua-lib="%{_libdir}" \ --with-downloader="%{downloader}" \ --with-md5-checker="%{md5checker}" \ --force-config="%{prefix}" make # Generate an empty manifest, since luarocks no longer provides one touch manifest echo 'modules = {}' >> manifest echo 'commands = {}' >> manifest echo 'repository = {}' >> manifest # ### ### ### ### ## pt2 - Documentation # ### ### ### ### # Builds HTML documentation make luadoc # Generates manpages since luarocks doesn't provide any #cd src && \ #help2man bin/%{name} -N > ../%{name}.1 && \ #help2man bin/%{name}-admin -N > ../%{name}-admin.1 && \ #cd .. && \ #gzip -9 %{name}.1 && \ #gzip -9 %{name}-admin.1 # ### ### ### ### # Install # ### ### ### ### %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} %{__mkdir} -p %{buildroot}/%{prefix}/lib/luarocks/rocks cp -pr manifest %{buildroot}/%{manifest} %{__mkdir} -p %{buildroot}/%{_defaultdocdir}/%{name}-%{version} #%{__mkdir} -p %{buildroot}/%{_mandir}/man1 #cp -pr *.1.gz %{buildroot}/%{_mandir}/man1 # LuaRocks always install rocks into /usr/lib, so we add a symlink for x86_64 %ifarch x86_64 %{__mkdir} -p %{buildroot}/%{prefix}/lib/lua/ %{__mkdir} -p %{buildroot}/%{_libdir}/lua/%{luaver} ln -s %{_libdir}/lua/%{luaver} %{buildroot}/%{prefix}/lib/lua/ %endif # ### ### ### ### # Clean # ### ### ### ### %clean rm -rf %{buildroot} # ### ### ### ### # Files # ### ### ### ### %files %defattr(644, root, root, 755) %attr(755, root, root) %{_bindir}/%{name} %attr(755, root, root) %{_bindir}/%{name}-admin %dir %{_sysconfdir}/%{name} %config(noreplace) %{_sysconfdir}/%{name}/config.lua %{manifest} %doc COPYING doc/luadoc %dir %{_datadir}/lua/5.1/%{name} %{_datadir}/lua/5.1/%{name}/* #%{_mandir}/man1/* %ifarch x86_64 %dir %{prefix}/lib/lua/ %{prefix}/lib/lua/%{luaver} %endif %changelog * Sun Mar 07 2010 Duboucher Thomas <thomas@duboucher.eu> - 2.0.1-1 - Initial packaging
あとは、
wget http://luarocks.org/releases/luarocks-2.0.8.tar.gz -P /root/rpmbuild/SOURCES
とかで、
rpmbuild -ba /root/rpmbuild/SPECS/luarocks.spec
とかしちゃって、 yum localinstall --nogpgcheck とかして導入してください。
あとは、以下を参照して環境変数の追加をします。
http://siguniang.wordpress.com/2012/04/14/lualuarocks-suck/
$ lua -lmd5 -e 'print(md5.sumhexa(""))' lua: module 'md5' not found: no field package.preload['md5'] no file '/usr/share/lua/5.1/:/usr/local/share/lua/5.1/' no file './md5.so' no file '/usr/lib64/lua/5.1/md5.so' no file '/usr/lib64/lua/5.1/loadall.so' stack traceback: [C]: ? [C]: ?
うん確かにPATH違うからダメだな。
毎回exportとかやってられないので、bash_profileに書きました。
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH export LUA_PATH="/usr/local/lib/lua/5.1/?.lua;/usr/local/share/lua/5.1/?.lua;;" export LUA_CPATH="/usr/local/lib/lua/5.1/?.so;;"
で確認すると、
lua -lmd5 -e 'print(md5.sumhexa(""))' d41d8cd98f00b204e9800998ecf8427e
これでおっけぇ〜 (∩´∀`)∩ワーイ