What's New in Luarocks
Total Page:16
File Type:pdf, Size:1020Kb
What's new in LuaRocks Hisham Muhammad [email protected] Lua Workshop 2014 Moscow, Russia What is LuaRocks Packa e manager... !ike dpkg (apt#get), RPM, etc. !ike Ru%&'ems, P&thon e s, npm, CP)*, etc. ...for Lua modu!es written in Lua (.lua files$ or binary modules (.so-.d!! ,les$ What does it do .he usual tasks o+ a language-oriented package manager Insta!! ...and make sure that Lua wi!l ,nd the module Remo0e ...and make sure things don't %!ow up 1eri+& dependencies ...when insta!!ing and remo0ing (ompile ...%ecause Lua modules ma& %e written in Lua or ( "or an& other language, %ut typica!!& ($ How does it work (ommand-!ine too!s luarocks and luarocks-admin Packagin ru!es specification +ormat .rockspec ,!es Package +ormat .rock ,!es 2er0in packaged modu!es rocks ser0er 3p and runnin in one s!ide4 ~$ wget http://lua.org/ftp/lua-5.2.3.tar.gz ~$ tar zxvpf lua-5.2.3.tar.gz ~$ cd lua-5.2.3 ~$ make linux; sudo make install; cd .. ~$ wget http://luarocks.org/releases/luarocks-2.2.0.tar.gz ~$ tar zxvpf luarocks-2.2.0.tar.gz ~$ cd luarocks-2.2.0 ~$ ./configure; sudo make bootstrap; cd .. ~$ sudo luarocks install luasocket ~$ lua Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio > require "socket" .he rockspec +ormat package = "midialsa"; version = "1.21-0" source = { url = "http://www.pjb.com.au/comp/lua/midialsa-1.21.tar.gz", md5 = "072844348e66c04cee42a5b489784453" } description = { summary = "Provides access to the ALSA sequencer", detailed = "...", homepage = "http://www.pjb.com.au/comp/lua/midialsa.html", license = "MIT/X11" } dependencies = { "lua >= 5.1" } external_dependencies = { ALSA = { header = "alsa/asoundlib.h", library = "asound" } } build = { type = "builtin", modules = { ["midialsa"] = "midialsa.lua", ["C-midialsa"] = { sources = { "C-midialsa.c" }, libraries = { "asound" }, incdirs = { "$(ALSA_INCDIR)" }, libdirs = { "$(ALSA_LIBDIR)" }, } }, copy_directories = { "doc", "test" } } Rocks ) rock contains modu!es and the rockspec Ma& contain binaries or source code package-version-revision.type.rock luafilesystem-1.5.0-2.src.rock lpeg-0.10-2.win32-x86.rock lxsh-0.8.6-1.all.rock /t's 5ust a zip ,!e with standard contents: Rockspec and rock_manifest at the root 2u%directories7 lua/, lib/, bin/... Rocks ser0er ) location containing .rock-.rockspec ,les 8irectory with rocks and a manifest inde9 ,!e 'enerate: luarocks-admin make-manifest dirname ) set o+ rocks instal!ed !ocal!& is ca!!ed a :rocks tree: ~$ luarocks install luasocket \ --from=http://example.com/my_repository/ ~$ luarocks install luasocket --from=/usr/local/myrocks/ ~$ luarocks install ./foo-1.0-1.rockspec ~$ luarocks install http://example.com/foo-1.0-1.rockspec ) ;uick !ook %ack at !ast &ear's ta!k :LuaRocks # past, present and +uture: Part I// # The +uture <uture o+ the rocks server7 curation and scala%i!ity Lua8ist and Lua +or Windows /mpro0ing the interp!a& with distros <urther de0e!opment More e9tensi%i!ity LuaRocks as a li%rar& What has chan ed this &ear LuaRocks 2.1.2 luarocks doc foo impro0ements on Windows rocks_provided so &ou can preload dependencies LuaRocks 2.2.0 pre!iminary support +or Lua 5.> luarocks upload foo-1.0-1.rockspec new de+au!t rocks ser0er4 !uarocks doc 8ocumentation +or modu!es7 it's important we a!l want it Like in man& aspects o+ the Lua wor!d, there are no standards 2omethin is %etter than nothin , so I came up with some heuristics /s there a doc director&? docs? @[email protected]...} 3se the system %rowser or print it in stdout When in doubt, just list the a0aila%!e docs rocksCpro0ided ) ta%!e in the con,guration ,!e with rocks that are considered :insta!!ed: e0en if the& are not in the rocks tree bit32 in Lua =.2, luabitop in LuaD/., utf8 in Lua =.>... *ot sure how to specif& ffi there This cou!d e0o!0e into something to %e used b& distros Let them auto#register Lua modu!es insta!!ed outside o+ LuaRocks .he %i chan e in the ecos&stem MoonRocks is now the de+ault rocks server %& Lea+ (orcoran # http7--rocks.moonscript.or )n&one can up!oad rocks And host their own ser0er7 ~$ luarocks install luasocket \ --from=http://rocks.moonscript.org/manifests/user Rocks &ou own o into the root mani+est, immediate!& a0ai!a%!e +or e0er&one !uarocks up!oad 3ploads rocks to MoonRocks 'o to MoonRocks, create an account 'o to Settings, generate an API ke& ~$ luarocks upload ./foo-1.0-1.rockspec \ --api-key=i5c02i3slkcrbd2if2sicd2rf289i23ndck2 /t packs a .src.rock ,!e and uploads both the .rockspec and .src.rock to MoonRocks AP/ ke& is sa0ed in &our home, no need to reenter it e0ery time 'rowth o+ the repositor& 600 500 400 300 200 100 0 'March 2013 'September 2013 'March 2014 'September 2014 Rockspec +ormat Limitations o+ the rockspec +ormat are we!!#known :%ui!tin: build mode compi!es only C89, can't pass custom compi!er Ga s (an't use plat+orm#speci,c detection +or dependencies (pk #con,g, etc.) *o separation between bui!d-runtime dependencies etc. /nstead o+ a big redesi n and another +ree6e, let's make it rea!!& extensi%!e LuaRocks add#ons The plan7 *ew kind o+ dependency that loads LuaRocks add#ons )dd#ons ma& add entries to the rockspec t&pechecker (new tables, new fields$ Hooks in bui!d-instal! steps +or add#ons to run Possi%i!ities: tests, generate docs, etc. Let users guide de0e!opment Rou h proposa! *amespace: luarocks.addon.youraddon Usin 7 using={"foo"} loads luarocks.addon.foo Lots o+ details to decide, %ut now LuaRocks can up rade itse!+ so we can e0o!0e the rockspec_format .he +uture cou!d look !ike this: rockspec_format = "3.0" using = { "build_dependencies", -- adds support for build-only dependencies "busted", -- ensures Busted is installed, runs tests "ldoc", -- generates docs using LDoc "build.ext >= 2.0", -- example build type extending builtin } build_dependencies = { "bin2c >= 1.2" } build = { type = "ext", modules = { ["foo"] = { language = "c99", sources = "foo.c" } }, } doc = { --[[ ldoc specific flags ]] } :LuaRocks as a !i%rar&: Hmbeda%i!ity Make LuaRocks +ul!& reentrant (remo0e al! g!o%al state$ This wi!l re;uire a major re+actoring .&ped Lua is coming +or the rescue4 Let's make LuaRocks extensi%!e and embedda%!e, !ike Lua4 .hank &ou4 http7--!uarocks.or (ontact: http7--hisham.hm/ [email protected] @hishamChm )%out these s!ides <ee! +ree to share this presentation and to use parts o+ it in &our own materia! Licensed under the Creati0e Commons CC BY 4.0: https:/-creati0ecommons.or -!icenses/%&-4.0/ .