rufus-lua-win 5.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (459) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +69 -0
  6. data/Rakefile +1 -0
  7. data/lib/rufus/lua/win.rb +18 -0
  8. data/lib/rufus/lua/win/version.rb +7 -0
  9. data/rufus-lua-win.gemspec +23 -0
  10. data/vendor/lua/bin/liblua.dll +0 -0
  11. data/vendor/lua/lib/lua/LuaXml.lua +119 -0
  12. data/vendor/lua/lib/lua/alien.lua +250 -0
  13. data/vendor/lua/lib/lua/alien/core.dll +0 -0
  14. data/vendor/lua/lib/lua/alien/struct.dll +0 -0
  15. data/vendor/lua/lib/lua/base.lua +536 -0
  16. data/vendor/lua/lib/lua/bin.lua +20 -0
  17. data/vendor/lua/lib/lua/bit.dll +0 -0
  18. data/vendor/lua/lib/lua/cdlua.dll +0 -0
  19. data/vendor/lua/lib/lua/cdluacontextplus.dll +0 -0
  20. data/vendor/lua/lib/lua/cdluagl.dll +0 -0
  21. data/vendor/lua/lib/lua/cdluaim.dll +0 -0
  22. data/vendor/lua/lib/lua/cdluapdf.dll +0 -0
  23. data/vendor/lua/lib/lua/copas.lua +543 -0
  24. data/vendor/lua/lib/lua/coxpcall.lua +57 -0
  25. data/vendor/lua/lib/lua/date.lua +745 -0
  26. data/vendor/lua/lib/lua/debug_ext.lua +84 -0
  27. data/vendor/lua/lib/lua/debug_init.lua +2 -0
  28. data/vendor/lua/lib/lua/des56.dll +0 -0
  29. data/vendor/lua/lib/lua/dist/config.lua +109 -0
  30. data/vendor/lua/lib/lua/dist/constraints.lua +271 -0
  31. data/vendor/lua/lib/lua/dist/depends.lua +601 -0
  32. data/vendor/lua/lib/lua/dist/git.lua +307 -0
  33. data/vendor/lua/lib/lua/dist/init.lua +278 -0
  34. data/vendor/lua/lib/lua/dist/manifest.lua +225 -0
  35. data/vendor/lua/lib/lua/dist/package.lua +583 -0
  36. data/vendor/lua/lib/lua/dist/sys.lua +367 -0
  37. data/vendor/lua/lib/lua/dist/utils.lua +130 -0
  38. data/vendor/lua/lib/lua/ex.dll +0 -0
  39. data/vendor/lua/lib/lua/fstable.lua +116 -0
  40. data/vendor/lua/lib/lua/getopt.lua +273 -0
  41. data/vendor/lua/lib/lua/git.lua +5 -0
  42. data/vendor/lua/lib/lua/git/core.dll +0 -0
  43. data/vendor/lua/lib/lua/git/objects.lua +121 -0
  44. data/vendor/lua/lib/lua/git/pack.lua +316 -0
  45. data/vendor/lua/lib/lua/git/protocol.lua +188 -0
  46. data/vendor/lua/lib/lua/git/repo.lua +283 -0
  47. data/vendor/lua/lib/lua/git/util.lua +233 -0
  48. data/vendor/lua/lib/lua/gzio.dll +0 -0
  49. data/vendor/lua/lib/lua/gzip.lua +81 -0
  50. data/vendor/lua/lib/lua/iconv.dll +0 -0
  51. data/vendor/lua/lib/lua/imlua.dll +0 -0
  52. data/vendor/lua/lib/lua/imlua_fftw.dll +0 -0
  53. data/vendor/lua/lib/lua/imlua_jp2.dll +0 -0
  54. data/vendor/lua/lib/lua/imlua_process.dll +0 -0
  55. data/vendor/lua/lib/lua/imlua_process_omp.dll +0 -0
  56. data/vendor/lua/lib/lua/io_ext.lua +115 -0
  57. data/vendor/lua/lib/lua/iuplua.dll +0 -0
  58. data/vendor/lua/lib/lua/iuplua_mglplot.dll +0 -0
  59. data/vendor/lua/lib/lua/iuplua_pplot.dll +0 -0
  60. data/vendor/lua/lib/lua/iupluacd.dll +0 -0
  61. data/vendor/lua/lib/lua/iupluacontrols.dll +0 -0
  62. data/vendor/lua/lib/lua/iupluagl.dll +0 -0
  63. data/vendor/lua/lib/lua/iupluaim.dll +0 -0
  64. data/vendor/lua/lib/lua/iupluaimglib.dll +0 -0
  65. data/vendor/lua/lib/lua/iupluatuio.dll +0 -0
  66. data/vendor/lua/lib/lua/lanes-keeper.lua +302 -0
  67. data/vendor/lua/lib/lua/lanes.lua +591 -0
  68. data/vendor/lua/lib/lua/lanes/core.dll +0 -0
  69. data/vendor/lua/lib/lua/lcs.lua +55 -0
  70. data/vendor/lua/lib/lua/lemock.lua +659 -0
  71. data/vendor/lua/lib/lua/lfs.dll +0 -0
  72. data/vendor/lua/lib/lua/list.lua +375 -0
  73. data/vendor/lua/lib/lua/logging.lua +189 -0
  74. data/vendor/lua/lib/lua/logging/console.lua +22 -0
  75. data/vendor/lua/lib/lua/logging/email.lua +44 -0
  76. data/vendor/lua/lib/lua/logging/file.lua +55 -0
  77. data/vendor/lua/lib/lua/logging/rolling_file.lua +81 -0
  78. data/vendor/lua/lib/lua/logging/socket.lua +35 -0
  79. data/vendor/lua/lib/lua/logging/sql.lua +64 -0
  80. data/vendor/lua/lib/lua/loop/base.lua +68 -0
  81. data/vendor/lua/lib/lua/loop/cached.lua +312 -0
  82. data/vendor/lua/lib/lua/loop/collection/MapWithArrayOfKeys.lua +64 -0
  83. data/vendor/lua/lib/lua/loop/collection/ObjectCache.lua +39 -0
  84. data/vendor/lua/lib/lua/loop/collection/OrderedSet.lua +164 -0
  85. data/vendor/lua/lib/lua/loop/collection/PriorityQueue.lua +86 -0
  86. data/vendor/lua/lib/lua/loop/collection/UnorderedArray.lua +32 -0
  87. data/vendor/lua/lib/lua/loop/collection/UnorderedArraySet.lua +56 -0
  88. data/vendor/lua/lib/lua/loop/compiler/Arguments.lua +108 -0
  89. data/vendor/lua/lib/lua/loop/compiler/Conditional.lua +50 -0
  90. data/vendor/lua/lib/lua/loop/compiler/Expression.lua +215 -0
  91. data/vendor/lua/lib/lua/loop/component/base.lua +221 -0
  92. data/vendor/lua/lib/lua/loop/component/contained.lua +71 -0
  93. data/vendor/lua/lib/lua/loop/component/dynamic.lua +223 -0
  94. data/vendor/lua/lib/lua/loop/component/intercepted.lua +354 -0
  95. data/vendor/lua/lib/lua/loop/component/wrapped.lua +195 -0
  96. data/vendor/lua/lib/lua/loop/debug/Inspector.lua +521 -0
  97. data/vendor/lua/lib/lua/loop/debug/Matcher.lua +192 -0
  98. data/vendor/lua/lib/lua/loop/debug/Verbose.lua +266 -0
  99. data/vendor/lua/lib/lua/loop/debug/Viewer.lua +200 -0
  100. data/vendor/lua/lib/lua/loop/multiple.lua +105 -0
  101. data/vendor/lua/lib/lua/loop/object/Exception.lua +57 -0
  102. data/vendor/lua/lib/lua/loop/object/Publisher.lua +43 -0
  103. data/vendor/lua/lib/lua/loop/object/Wrapper.lua +39 -0
  104. data/vendor/lua/lib/lua/loop/scoped.lua +585 -0
  105. data/vendor/lua/lib/lua/loop/serial/FileStream.lua +48 -0
  106. data/vendor/lua/lib/lua/loop/serial/Serializer.lua +291 -0
  107. data/vendor/lua/lib/lua/loop/serial/SocketStream.lua +51 -0
  108. data/vendor/lua/lib/lua/loop/serial/StringStream.lua +47 -0
  109. data/vendor/lua/lib/lua/loop/simple.lua +75 -0
  110. data/vendor/lua/lib/lua/loop/table.lua +71 -0
  111. data/vendor/lua/lib/lua/loop/thread/CoSocket.lua +416 -0
  112. data/vendor/lua/lib/lua/loop/thread/IOScheduler.lua +170 -0
  113. data/vendor/lua/lib/lua/loop/thread/Scheduler.lua +327 -0
  114. data/vendor/lua/lib/lua/loop/thread/SocketScheduler.lua +88 -0
  115. data/vendor/lua/lib/lua/loop/thread/Timer.lua +54 -0
  116. data/vendor/lua/lib/lua/lpeg.dll +0 -0
  117. data/vendor/lua/lib/lua/ltn12.lua +292 -0
  118. data/vendor/lua/lib/lua/luaXML_lib.dll +0 -0
  119. data/vendor/lua/lib/lua/luacurl.dll +0 -0
  120. data/vendor/lua/lib/lua/luadoc/config.lua +34 -0
  121. data/vendor/lua/lib/lua/luadoc/doclet/debug.lua +46 -0
  122. data/vendor/lua/lib/lua/luadoc/doclet/formatter.lua +84 -0
  123. data/vendor/lua/lib/lua/luadoc/doclet/html.lua +289 -0
  124. data/vendor/lua/lib/lua/luadoc/doclet/html/file.lp +113 -0
  125. data/vendor/lua/lib/lua/luadoc/doclet/html/function.lp +64 -0
  126. data/vendor/lua/lib/lua/luadoc/doclet/html/index.lp +70 -0
  127. data/vendor/lua/lib/lua/luadoc/doclet/html/luadoc.css +286 -0
  128. data/vendor/lua/lib/lua/luadoc/doclet/html/menu.lp +55 -0
  129. data/vendor/lua/lib/lua/luadoc/doclet/html/module.lp +109 -0
  130. data/vendor/lua/lib/lua/luadoc/doclet/html/table.lp +15 -0
  131. data/vendor/lua/lib/lua/luadoc/doclet/raw.lua +12 -0
  132. data/vendor/lua/lib/lua/luadoc/init.lua +58 -0
  133. data/vendor/lua/lib/lua/luadoc/lp.lua +130 -0
  134. data/vendor/lua/lib/lua/luadoc/taglet/standard.lua +495 -0
  135. data/vendor/lua/lib/lua/luadoc/taglet/standard/tags.lua +171 -0
  136. data/vendor/lua/lib/lua/luadoc/util.lua +233 -0
  137. data/vendor/lua/lib/lua/luagl.dll +0 -0
  138. data/vendor/lua/lib/lua/luaglu.dll +0 -0
  139. data/vendor/lua/lib/lua/luaidl.lua +113 -0
  140. data/vendor/lua/lib/lua/luaidl/lex.lua +793 -0
  141. data/vendor/lua/lib/lua/luaidl/pre.lua +149 -0
  142. data/vendor/lua/lib/lua/luaidl/sin.lua +3631 -0
  143. data/vendor/lua/lib/lua/luarocks/add.lua +108 -0
  144. data/vendor/lua/lib/lua/luarocks/admin_remove.lua +87 -0
  145. data/vendor/lua/lib/lua/luarocks/build.lua +330 -0
  146. data/vendor/lua/lib/lua/luarocks/build/builtin.lua +253 -0
  147. data/vendor/lua/lib/lua/luarocks/build/cmake.lua +54 -0
  148. data/vendor/lua/lib/lua/luarocks/build/command.lua +32 -0
  149. data/vendor/lua/lib/lua/luarocks/build/make.lua +92 -0
  150. data/vendor/lua/lib/lua/luarocks/cache.lua +85 -0
  151. data/vendor/lua/lib/lua/luarocks/cfg.lua +449 -0
  152. data/vendor/lua/lib/lua/luarocks/command_line.lua +163 -0
  153. data/vendor/lua/lib/lua/luarocks/deps.lua +654 -0
  154. data/vendor/lua/lib/lua/luarocks/dir.lua +69 -0
  155. data/vendor/lua/lib/lua/luarocks/download.lua +90 -0
  156. data/vendor/lua/lib/lua/luarocks/fetch.lua +321 -0
  157. data/vendor/lua/lib/lua/luarocks/fetch/cvs.lua +44 -0
  158. data/vendor/lua/lib/lua/luarocks/fetch/git.lua +81 -0
  159. data/vendor/lua/lib/lua/luarocks/fetch/git_file.lua +17 -0
  160. data/vendor/lua/lib/lua/luarocks/fetch/hg.lua +54 -0
  161. data/vendor/lua/lib/lua/luarocks/fetch/sscm.lua +42 -0
  162. data/vendor/lua/lib/lua/luarocks/fetch/svn.lua +53 -0
  163. data/vendor/lua/lib/lua/luarocks/fs.lua +40 -0
  164. data/vendor/lua/lib/lua/luarocks/fs/lua.lua +676 -0
  165. data/vendor/lua/lib/lua/luarocks/fs/unix.lua +88 -0
  166. data/vendor/lua/lib/lua/luarocks/fs/unix/tools.lua +325 -0
  167. data/vendor/lua/lib/lua/luarocks/fs/win32.lua +107 -0
  168. data/vendor/lua/lib/lua/luarocks/fs/win32/tools.lua +334 -0
  169. data/vendor/lua/lib/lua/luarocks/help.lua +101 -0
  170. data/vendor/lua/lib/lua/luarocks/index.lua +172 -0
  171. data/vendor/lua/lib/lua/luarocks/install.lua +151 -0
  172. data/vendor/lua/lib/lua/luarocks/list.lua +35 -0
  173. data/vendor/lua/lib/lua/luarocks/loader.lua +228 -0
  174. data/vendor/lua/lib/lua/luarocks/make.lua +71 -0
  175. data/vendor/lua/lib/lua/luarocks/make_manifest.lua +34 -0
  176. data/vendor/lua/lib/lua/luarocks/manif.lua +360 -0
  177. data/vendor/lua/lib/lua/luarocks/manif_core.lua +75 -0
  178. data/vendor/lua/lib/lua/luarocks/new_version.lua +141 -0
  179. data/vendor/lua/lib/lua/luarocks/pack.lua +205 -0
  180. data/vendor/lua/lib/lua/luarocks/path.lua +315 -0
  181. data/vendor/lua/lib/lua/luarocks/persist.lua +173 -0
  182. data/vendor/lua/lib/lua/luarocks/refresh_cache.lua +30 -0
  183. data/vendor/lua/lib/lua/luarocks/remove.lua +135 -0
  184. data/vendor/lua/lib/lua/luarocks/rep.lua +313 -0
  185. data/vendor/lua/lib/lua/luarocks/require.lua +6 -0
  186. data/vendor/lua/lib/lua/luarocks/search.lua +399 -0
  187. data/vendor/lua/lib/lua/luarocks/show.lua +138 -0
  188. data/vendor/lua/lib/lua/luarocks/site_config.lua +23 -0
  189. data/vendor/lua/lib/lua/luarocks/tools/patch.lua +712 -0
  190. data/vendor/lua/lib/lua/luarocks/tools/tar.lua +144 -0
  191. data/vendor/lua/lib/lua/luarocks/tools/zip.lua +245 -0
  192. data/vendor/lua/lib/lua/luarocks/type_check.lua +267 -0
  193. data/vendor/lua/lib/lua/luarocks/unpack.lua +151 -0
  194. data/vendor/lua/lib/lua/luarocks/util.lua +420 -0
  195. data/vendor/lua/lib/lua/luarocks/validate.lua +164 -0
  196. data/vendor/lua/lib/lua/luars232.dll +0 -0
  197. data/vendor/lua/lib/lua/luasql/mysql.dll +0 -0
  198. data/vendor/lua/lib/lua/luasql/postgres.dll +0 -0
  199. data/vendor/lua/lib/lua/luasql/sqlite3.dll +0 -0
  200. data/vendor/lua/lib/lua/luaunit.lua +601 -0
  201. data/vendor/lua/lib/lua/lxp.dll +0 -0
  202. data/vendor/lua/lib/lua/lxp/lom.lua +60 -0
  203. data/vendor/lua/lib/lua/math_ext.lua +27 -0
  204. data/vendor/lua/lib/lua/mbox.lua +53 -0
  205. data/vendor/lua/lib/lua/md5.lua +19 -0
  206. data/vendor/lua/lib/lua/md5/core.dll +0 -0
  207. data/vendor/lua/lib/lua/metalua.lua +0 -0
  208. data/vendor/lua/lib/lua/metalua/ast_to_string.mlua +553 -0
  209. data/vendor/lua/lib/lua/metalua/base.lua +104 -0
  210. data/vendor/lua/lib/lua/metalua/bytecode.lua +0 -0
  211. data/vendor/lua/lib/lua/metalua/clopts.mlua +204 -0
  212. data/vendor/lua/lib/lua/metalua/compiler.lua +3 -0
  213. data/vendor/lua/lib/lua/metalua/dollar.mlua +24 -0
  214. data/vendor/lua/lib/lua/metalua/extension/H-runtime.mlua +216 -0
  215. data/vendor/lua/lib/lua/metalua/extension/H.mlua +22 -0
  216. data/vendor/lua/lib/lua/metalua/extension/anaphoric.mlua +54 -0
  217. data/vendor/lua/lib/lua/metalua/extension/clist.mlua +149 -0
  218. data/vendor/lua/lib/lua/metalua/extension/continue.mlua +53 -0
  219. data/vendor/lua/lib/lua/metalua/extension/localin.mlua +2 -0
  220. data/vendor/lua/lib/lua/metalua/extension/log.mlua +39 -0
  221. data/vendor/lua/lib/lua/metalua/extension/match.mlua +374 -0
  222. data/vendor/lua/lib/lua/metalua/extension/ternary.mlua +10 -0
  223. data/vendor/lua/lib/lua/metalua/extension/trycatch.mlua +189 -0
  224. data/vendor/lua/lib/lua/metalua/extension/types-runtime.mlua +159 -0
  225. data/vendor/lua/lib/lua/metalua/extension/types.mlua +352 -0
  226. data/vendor/lua/lib/lua/metalua/extension/withdo.mlua +30 -0
  227. data/vendor/lua/lib/lua/metalua/extension/xglobal-runtime.lua +41 -0
  228. data/vendor/lua/lib/lua/metalua/extension/xglobal.mlua +20 -0
  229. data/vendor/lua/lib/lua/metalua/extension/xloop.mlua +100 -0
  230. data/vendor/lua/lib/lua/metalua/extension/xmatch.mlua +216 -0
  231. data/vendor/lua/lib/lua/metalua/metaloop.mlua +76 -0
  232. data/vendor/lua/lib/lua/metalua/mlc.lua +0 -0
  233. data/vendor/lua/lib/lua/metalua/mlc_xcall.lua +119 -0
  234. data/vendor/lua/lib/lua/metalua/mlp.lua +0 -0
  235. data/vendor/lua/lib/lua/metalua/package2.lua +101 -0
  236. data/vendor/lua/lib/lua/metalua/runtime.lua +3 -0
  237. data/vendor/lua/lib/lua/metalua/string2.lua +44 -0
  238. data/vendor/lua/lib/lua/metalua/table2.lua +372 -0
  239. data/vendor/lua/lib/lua/metalua/walk.mlua +304 -0
  240. data/vendor/lua/lib/lua/metalua/walk/bindings.mlua +41 -0
  241. data/vendor/lua/lib/lua/metalua/walk/id.mlua +186 -0
  242. data/vendor/lua/lib/lua/metalua/walk/scope.lua +54 -0
  243. data/vendor/lua/lib/lua/mime.lua +87 -0
  244. data/vendor/lua/lib/lua/mime/core.dll +0 -0
  245. data/vendor/lua/lib/lua/mobdebug.lua +1484 -0
  246. data/vendor/lua/lib/lua/modules.lua +16 -0
  247. data/vendor/lua/lib/lua/object.lua +56 -0
  248. data/vendor/lua/lib/lua/oil/Exception.lua +26 -0
  249. data/vendor/lua/lib/lua/oil/arch.lua +27 -0
  250. data/vendor/lua/lib/lua/oil/arch/basic/client.lua +29 -0
  251. data/vendor/lua/lib/lua/oil/arch/basic/common.lua +13 -0
  252. data/vendor/lua/lib/lua/oil/arch/basic/server.lua +27 -0
  253. data/vendor/lua/lib/lua/oil/arch/cooperative/common.lua +10 -0
  254. data/vendor/lua/lib/lua/oil/arch/cooperative/server.lua +16 -0
  255. data/vendor/lua/lib/lua/oil/arch/corba/client.lua +39 -0
  256. data/vendor/lua/lib/lua/oil/arch/corba/common.lua +58 -0
  257. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/client.lua +9 -0
  258. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/server.lua +9 -0
  259. data/vendor/lua/lib/lua/oil/arch/corba/server.lua +35 -0
  260. data/vendor/lua/lib/lua/oil/arch/ludo/byref.lua +18 -0
  261. data/vendor/lua/lib/lua/oil/arch/ludo/client.lua +19 -0
  262. data/vendor/lua/lib/lua/oil/arch/ludo/common.lua +18 -0
  263. data/vendor/lua/lib/lua/oil/arch/ludo/server.lua +19 -0
  264. data/vendor/lua/lib/lua/oil/arch/typed/client.lua +27 -0
  265. data/vendor/lua/lib/lua/oil/arch/typed/common.lua +9 -0
  266. data/vendor/lua/lib/lua/oil/arch/typed/server.lua +18 -0
  267. data/vendor/lua/lib/lua/oil/assert.lua +87 -0
  268. data/vendor/lua/lib/lua/oil/builder.lua +45 -0
  269. data/vendor/lua/lib/lua/oil/builder/basic/client.lua +31 -0
  270. data/vendor/lua/lib/lua/oil/builder/basic/common.lua +11 -0
  271. data/vendor/lua/lib/lua/oil/builder/basic/server.lua +13 -0
  272. data/vendor/lua/lib/lua/oil/builder/cooperative/common.lua +11 -0
  273. data/vendor/lua/lib/lua/oil/builder/cooperative/server.lua +11 -0
  274. data/vendor/lua/lib/lua/oil/builder/corba/client.lua +13 -0
  275. data/vendor/lua/lib/lua/oil/builder/corba/common.lua +24 -0
  276. data/vendor/lua/lib/lua/oil/builder/corba/gencode.lua +13 -0
  277. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/client.lua +11 -0
  278. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/server.lua +11 -0
  279. data/vendor/lua/lib/lua/oil/builder/corba/server.lua +13 -0
  280. data/vendor/lua/lib/lua/oil/builder/lua/client.lua +11 -0
  281. data/vendor/lua/lib/lua/oil/builder/lua/server.lua +12 -0
  282. data/vendor/lua/lib/lua/oil/builder/ludo/byref.lua +13 -0
  283. data/vendor/lua/lib/lua/oil/builder/ludo/client.lua +13 -0
  284. data/vendor/lua/lib/lua/oil/builder/ludo/common.lua +14 -0
  285. data/vendor/lua/lib/lua/oil/builder/ludo/server.lua +13 -0
  286. data/vendor/lua/lib/lua/oil/builder/typed/client.lua +16 -0
  287. data/vendor/lua/lib/lua/oil/builder/typed/server.lua +12 -0
  288. data/vendor/lua/lib/lua/oil/compat.lua +846 -0
  289. data/vendor/lua/lib/lua/oil/component.lua +1 -0
  290. data/vendor/lua/lib/lua/oil/corba/giop.lua +301 -0
  291. data/vendor/lua/lib/lua/oil/corba/giop/Codec.lua +1568 -0
  292. data/vendor/lua/lib/lua/oil/corba/giop/CodecGen.lua +589 -0
  293. data/vendor/lua/lib/lua/oil/corba/giop/Exception.lua +25 -0
  294. data/vendor/lua/lib/lua/oil/corba/giop/Indexer.lua +63 -0
  295. data/vendor/lua/lib/lua/oil/corba/giop/Listener.lua +343 -0
  296. data/vendor/lua/lib/lua/oil/corba/giop/Messenger.lua +228 -0
  297. data/vendor/lua/lib/lua/oil/corba/giop/Referrer.lua +180 -0
  298. data/vendor/lua/lib/lua/oil/corba/giop/Requester.lua +462 -0
  299. data/vendor/lua/lib/lua/oil/corba/idl.lua +597 -0
  300. data/vendor/lua/lib/lua/oil/corba/idl/Compiler.lua +133 -0
  301. data/vendor/lua/lib/lua/oil/corba/idl/Importer.lua +235 -0
  302. data/vendor/lua/lib/lua/oil/corba/idl/Indexer.lua +95 -0
  303. data/vendor/lua/lib/lua/oil/corba/idl/Registry.lua +1821 -0
  304. data/vendor/lua/lib/lua/oil/corba/idl/ir.lua +847 -0
  305. data/vendor/lua/lib/lua/oil/corba/idl/sysex.lua +21 -0
  306. data/vendor/lua/lib/lua/oil/corba/iiop/Profiler.lua +200 -0
  307. data/vendor/lua/lib/lua/oil/corba/intercepted/Listener.lua +158 -0
  308. data/vendor/lua/lib/lua/oil/corba/intercepted/Requester.lua +181 -0
  309. data/vendor/lua/lib/lua/oil/corba/services/event.lua +126 -0
  310. data/vendor/lua/lib/lua/oil/corba/services/event/ConsumerAdmin.lua +50 -0
  311. data/vendor/lua/lib/lua/oil/corba/services/event/EventFactory.lua +15 -0
  312. data/vendor/lua/lib/lua/oil/corba/services/event/EventQueue.lua +37 -0
  313. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushConsumer.lua +75 -0
  314. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushSupplier.lua +62 -0
  315. data/vendor/lua/lib/lua/oil/corba/services/event/SingleDeferredDispatcher.lua +60 -0
  316. data/vendor/lua/lib/lua/oil/corba/services/event/SingleSynchronousDispatcher.lua +39 -0
  317. data/vendor/lua/lib/lua/oil/corba/services/event/SupplierAdmin.lua +50 -0
  318. data/vendor/lua/lib/lua/oil/corba/services/naming.lua +436 -0
  319. data/vendor/lua/lib/lua/oil/kernel/base/Acceptor.lua +268 -0
  320. data/vendor/lua/lib/lua/oil/kernel/base/Channels.lua +121 -0
  321. data/vendor/lua/lib/lua/oil/kernel/base/Connector.lua +147 -0
  322. data/vendor/lua/lib/lua/oil/kernel/base/Dispatcher.lua +99 -0
  323. data/vendor/lua/lib/lua/oil/kernel/base/Proxies.lua +86 -0
  324. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/asynchronous.lua +56 -0
  325. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/protected.lua +17 -0
  326. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/synchronous.lua +17 -0
  327. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/utils.lua +29 -0
  328. data/vendor/lua/lib/lua/oil/kernel/base/Receiver.lua +110 -0
  329. data/vendor/lua/lib/lua/oil/kernel/base/Servants.lua +207 -0
  330. data/vendor/lua/lib/lua/oil/kernel/base/Sockets.lua +44 -0
  331. data/vendor/lua/lib/lua/oil/kernel/cooperative/Receiver.lua +139 -0
  332. data/vendor/lua/lib/lua/oil/kernel/intercepted/Listener.lua +47 -0
  333. data/vendor/lua/lib/lua/oil/kernel/intercepted/Requester.lua +58 -0
  334. data/vendor/lua/lib/lua/oil/kernel/lua/Dispatcher.lua +76 -0
  335. data/vendor/lua/lib/lua/oil/kernel/lua/Proxies.lua +69 -0
  336. data/vendor/lua/lib/lua/oil/kernel/typed/Dispatcher.lua +91 -0
  337. data/vendor/lua/lib/lua/oil/kernel/typed/Proxies.lua +153 -0
  338. data/vendor/lua/lib/lua/oil/kernel/typed/Servants.lua +137 -0
  339. data/vendor/lua/lib/lua/oil/ludo/Codec.lua +66 -0
  340. data/vendor/lua/lib/lua/oil/ludo/CodecByRef.lua +103 -0
  341. data/vendor/lua/lib/lua/oil/ludo/Listener.lua +151 -0
  342. data/vendor/lua/lib/lua/oil/ludo/Referrer.lua +72 -0
  343. data/vendor/lua/lib/lua/oil/ludo/Requester.lua +107 -0
  344. data/vendor/lua/lib/lua/oil/oo.lua +1 -0
  345. data/vendor/lua/lib/lua/oil/port.lua +1 -0
  346. data/vendor/lua/lib/lua/oil/properties.lua +57 -0
  347. data/vendor/lua/lib/lua/oil/verbose.lua +133 -0
  348. data/vendor/lua/lib/lua/package_ext.lua +15 -0
  349. data/vendor/lua/lib/lua/parser.lua +268 -0
  350. data/vendor/lua/lib/lua/pl/Date.lua +555 -0
  351. data/vendor/lua/lib/lua/pl/List.lua +613 -0
  352. data/vendor/lua/lib/lua/pl/Map.lua +113 -0
  353. data/vendor/lua/lib/lua/pl/MultiMap.lua +62 -0
  354. data/vendor/lua/lib/lua/pl/OrderedMap.lua +151 -0
  355. data/vendor/lua/lib/lua/pl/Set.lua +153 -0
  356. data/vendor/lua/lib/lua/pl/app.lua +165 -0
  357. data/vendor/lua/lib/lua/pl/array2d.lua +501 -0
  358. data/vendor/lua/lib/lua/pl/class.lua +180 -0
  359. data/vendor/lua/lib/lua/pl/comprehension.lua +286 -0
  360. data/vendor/lua/lib/lua/pl/config.lua +176 -0
  361. data/vendor/lua/lib/lua/pl/data.lua +606 -0
  362. data/vendor/lua/lib/lua/pl/dir.lua +475 -0
  363. data/vendor/lua/lib/lua/pl/file.lua +70 -0
  364. data/vendor/lua/lib/lua/pl/func.lua +376 -0
  365. data/vendor/lua/lib/lua/pl/init.lua +68 -0
  366. data/vendor/lua/lib/lua/pl/input.lua +173 -0
  367. data/vendor/lua/lib/lua/pl/lapp.lua +407 -0
  368. data/vendor/lua/lib/lua/pl/lexer.lua +456 -0
  369. data/vendor/lua/lib/lua/pl/luabalanced.lua +264 -0
  370. data/vendor/lua/lib/lua/pl/operator.lua +201 -0
  371. data/vendor/lua/lib/lua/pl/path.lua +398 -0
  372. data/vendor/lua/lib/lua/pl/permute.lua +63 -0
  373. data/vendor/lua/lib/lua/pl/platf/luajava.lua +101 -0
  374. data/vendor/lua/lib/lua/pl/pretty.lua +285 -0
  375. data/vendor/lua/lib/lua/pl/seq.lua +551 -0
  376. data/vendor/lua/lib/lua/pl/sip.lua +344 -0
  377. data/vendor/lua/lib/lua/pl/strict.lua +70 -0
  378. data/vendor/lua/lib/lua/pl/stringio.lua +158 -0
  379. data/vendor/lua/lib/lua/pl/stringx.lua +440 -0
  380. data/vendor/lua/lib/lua/pl/tablex.lua +817 -0
  381. data/vendor/lua/lib/lua/pl/template.lua +103 -0
  382. data/vendor/lua/lib/lua/pl/test.lua +135 -0
  383. data/vendor/lua/lib/lua/pl/text.lua +243 -0
  384. data/vendor/lua/lib/lua/pl/utils.lua +550 -0
  385. data/vendor/lua/lib/lua/pl/xml.lua +689 -0
  386. data/vendor/lua/lib/lua/profiler.dll +0 -0
  387. data/vendor/lua/lib/lua/re.lua +248 -0
  388. data/vendor/lua/lib/lua/rex_onig.dll +0 -0
  389. data/vendor/lua/lib/lua/rex_pcre.dll +0 -0
  390. data/vendor/lua/lib/lua/rex_posix.dll +0 -0
  391. data/vendor/lua/lib/lua/rings.dll +0 -0
  392. data/vendor/lua/lib/lua/serialize.lua +193 -0
  393. data/vendor/lua/lib/lua/set.lua +149 -0
  394. data/vendor/lua/lib/lua/socket.lua +133 -0
  395. data/vendor/lua/lib/lua/socket/core.dll +0 -0
  396. data/vendor/lua/lib/lua/socket/ftp.lua +281 -0
  397. data/vendor/lua/lib/lua/socket/http.lua +350 -0
  398. data/vendor/lua/lib/lua/socket/smtp.lua +251 -0
  399. data/vendor/lua/lib/lua/socket/tp.lua +123 -0
  400. data/vendor/lua/lib/lua/socket/url.lua +297 -0
  401. data/vendor/lua/lib/lua/ssl.dll +0 -0
  402. data/vendor/lua/lib/lua/ssl.lua +93 -0
  403. data/vendor/lua/lib/lua/ssl/https.lua +138 -0
  404. data/vendor/lua/lib/lua/stable.lua +28 -0
  405. data/vendor/lua/lib/lua/std.lua +16 -0
  406. data/vendor/lua/lib/lua/strbuf.lua +32 -0
  407. data/vendor/lua/lib/lua/strict.lua +45 -0
  408. data/vendor/lua/lib/lua/string_ext.lua +274 -0
  409. data/vendor/lua/lib/lua/table_ext.lua +117 -0
  410. data/vendor/lua/lib/lua/tar.lua +262 -0
  411. data/vendor/lua/lib/lua/task.dll +0 -0
  412. data/vendor/lua/lib/lua/tree.lua +81 -0
  413. data/vendor/lua/lib/lua/unicode.dll +0 -0
  414. data/vendor/lua/lib/lua/verbose_require.lua +11 -0
  415. data/vendor/lua/lib/lua/vstruct.lua +86 -0
  416. data/vendor/lua/lib/lua/vstruct/ast.lua +192 -0
  417. data/vendor/lua/lib/lua/vstruct/ast/Bitpack.lua +33 -0
  418. data/vendor/lua/lib/lua/vstruct/ast/Generator.lua +174 -0
  419. data/vendor/lua/lib/lua/vstruct/ast/IO.lua +45 -0
  420. data/vendor/lua/lib/lua/vstruct/ast/List.lua +56 -0
  421. data/vendor/lua/lib/lua/vstruct/ast/Name.lua +20 -0
  422. data/vendor/lua/lib/lua/vstruct/ast/Repeat.lua +23 -0
  423. data/vendor/lua/lib/lua/vstruct/ast/Root.lua +19 -0
  424. data/vendor/lua/lib/lua/vstruct/ast/Table.lua +65 -0
  425. data/vendor/lua/lib/lua/vstruct/cursor.lua +81 -0
  426. data/vendor/lua/lib/lua/vstruct/io.lua +45 -0
  427. data/vendor/lua/lib/lua/vstruct/io/a.lua +24 -0
  428. data/vendor/lua/lib/lua/vstruct/io/b.lua +28 -0
  429. data/vendor/lua/lib/lua/vstruct/io/bigendian.lua +21 -0
  430. data/vendor/lua/lib/lua/vstruct/io/c.lua +25 -0
  431. data/vendor/lua/lib/lua/vstruct/io/defaults.lua +24 -0
  432. data/vendor/lua/lib/lua/vstruct/io/endianness.lua +41 -0
  433. data/vendor/lua/lib/lua/vstruct/io/f.lua +129 -0
  434. data/vendor/lua/lib/lua/vstruct/io/hostendian.lua +21 -0
  435. data/vendor/lua/lib/lua/vstruct/io/i.lua +42 -0
  436. data/vendor/lua/lib/lua/vstruct/io/littleendian.lua +21 -0
  437. data/vendor/lua/lib/lua/vstruct/io/m.lua +62 -0
  438. data/vendor/lua/lib/lua/vstruct/io/p.lua +23 -0
  439. data/vendor/lua/lib/lua/vstruct/io/s.lua +27 -0
  440. data/vendor/lua/lib/lua/vstruct/io/seekb.lua +18 -0
  441. data/vendor/lua/lib/lua/vstruct/io/seekf.lua +18 -0
  442. data/vendor/lua/lib/lua/vstruct/io/seekto.lua +18 -0
  443. data/vendor/lua/lib/lua/vstruct/io/u.lua +54 -0
  444. data/vendor/lua/lib/lua/vstruct/io/x.lua +34 -0
  445. data/vendor/lua/lib/lua/vstruct/io/z.lua +63 -0
  446. data/vendor/lua/lib/lua/vstruct/lexer.lua +100 -0
  447. data/vendor/lua/lib/lua/vstruct/pack.lua +142 -0
  448. data/vendor/lua/lib/lua/vstruct/test.lua +47 -0
  449. data/vendor/lua/lib/lua/vstruct/test/basic.lua +73 -0
  450. data/vendor/lua/lib/lua/vstruct/test/common.lua +100 -0
  451. data/vendor/lua/lib/lua/vstruct/test/fp-bigendian.lua +56 -0
  452. data/vendor/lua/lib/lua/vstruct/test/fp-littleendian.lua +56 -0
  453. data/vendor/lua/lib/lua/vstruct/test/struct-test-gen.lua +1230 -0
  454. data/vendor/lua/lib/lua/vstruct/unpack.lua +126 -0
  455. data/vendor/lua/lib/lua/wx.dll +0 -0
  456. data/vendor/lua/lib/lua/xml.lua +75 -0
  457. data/vendor/lua/lib/lua/zip.dll +0 -0
  458. data/vendor/lua/lib/lua/zlib.dll +0 -0
  459. metadata +529 -0
@@ -0,0 +1,44 @@
1
+
2
+ --- Fetch back-end for retrieving sources from CVS.
3
+ module("luarocks.fetch.cvs", package.seeall)
4
+
5
+ local fs = require("luarocks.fs")
6
+ local dir = require("luarocks.dir")
7
+ local util = require("luarocks.util")
8
+
9
+ --- Download sources for building a rock, using CVS.
10
+ -- @param rockspec table: The rockspec table
11
+ -- @param extract boolean: Unused in this module (required for API purposes.)
12
+ -- @param dest_dir string or nil: If set, will extract to the given directory.
13
+ -- @return (string, string) or (nil, string): The absolute pathname of
14
+ -- the fetched source tarball and the temporary directory created to
15
+ -- store it; or nil and an error message.
16
+ function get_sources(rockspec, extract, dest_dir)
17
+ assert(type(rockspec) == "table")
18
+ assert(type(dest_dir) == "string" or not dest_dir)
19
+
20
+ local name_version = rockspec.name .. "-" .. rockspec.version
21
+ local module = rockspec.source.module or dir.base_name(rockspec.source.url)
22
+ local command = {rockspec.variables.CVS, "-d"..rockspec.source.pathname, "export", module}
23
+ if rockspec.source.tag then
24
+ table.insert(command, 4, "-r")
25
+ table.insert(command, 5, rockspec.source.tag)
26
+ end
27
+ local store_dir
28
+ if not dest_dir then
29
+ store_dir = fs.make_temp_dir(name_version)
30
+ if not store_dir then
31
+ return nil, "Failed creating temporary directory."
32
+ end
33
+ util.schedule_function(fs.delete, store_dir)
34
+ else
35
+ store_dir = dest_dir
36
+ end
37
+ fs.change_dir(store_dir)
38
+ if not fs.execute(unpack(command)) then
39
+ return nil, "Failed fetching files from CVS."
40
+ end
41
+ fs.pop_dir()
42
+ return module, store_dir
43
+ end
44
+
@@ -0,0 +1,81 @@
1
+
2
+ --- Fetch back-end for retrieving sources from GIT.
3
+ module("luarocks.fetch.git", package.seeall)
4
+
5
+ local fs = require("luarocks.fs")
6
+ local dir = require("luarocks.dir")
7
+ local util = require("luarocks.util")
8
+
9
+ --- Git >= 1.7.10 can clone a branch **or tag**, < 1.7.10 by branch only. We
10
+ -- need to know this in order to build the appropriate command; if we can't
11
+ -- clone by tag then we'll have to issue a subsequent command to check out the
12
+ -- given tag.
13
+ -- @return boolean: Whether Git can clone by tag.
14
+ local function git_can_clone_by_tag()
15
+ local version_string = io.popen('git --version'):read()
16
+ local major, minor, tiny = version_string:match('(%d-)%.(%d+)%.?(%d*)')
17
+ major, minor, tiny = tonumber(major), tonumber(minor), tonumber(tiny) or 0
18
+ local value = major > 1 or (major == 1 and (minor > 7 or (minor == 7 and tiny >= 10)))
19
+ git_can_clone_by_tag = function() return value end
20
+ return git_can_clone_by_tag()
21
+ end
22
+
23
+ --- Download sources for building a rock, using git.
24
+ -- @param rockspec table: The rockspec table
25
+ -- @param extract boolean: Unused in this module (required for API purposes.)
26
+ -- @param dest_dir string or nil: If set, will extract to the given directory.
27
+ -- @return (string, string) or (nil, string): The absolute pathname of
28
+ -- the fetched source tarball and the temporary directory created to
29
+ -- store it; or nil and an error message.
30
+ function get_sources(rockspec, extract, dest_dir)
31
+ assert(type(rockspec) == "table")
32
+ assert(type(dest_dir) == "string" or not dest_dir)
33
+
34
+ local git_cmd = rockspec.variables.GIT
35
+ local name_version = rockspec.name .. "-" .. rockspec.version
36
+ local module = dir.base_name(rockspec.source.url)
37
+ -- Strip off .git from base name if present
38
+ module = module:gsub("%.git$", "")
39
+
40
+ local store_dir
41
+ if not dest_dir then
42
+ store_dir = fs.make_temp_dir(name_version)
43
+ if not store_dir then
44
+ return nil, "Failed creating temporary directory."
45
+ end
46
+ util.schedule_function(fs.delete, store_dir)
47
+ else
48
+ store_dir = dest_dir
49
+ end
50
+ store_dir = fs.absolute_name(store_dir)
51
+ fs.change_dir(store_dir)
52
+
53
+ local command = {git_cmd, "clone", "--depth=1", rockspec.source.url, module}
54
+ local tag_or_branch = rockspec.source.tag or rockspec.source.branch
55
+ -- If the tag or branch is explicitly set to "master" in the rockspec, then
56
+ -- we can avoid passing it to Git since it's the default.
57
+ if tag_or_branch == "master" then tag_or_branch = nil end
58
+ if tag_or_branch then
59
+ if git_can_clone_by_tag() then
60
+ -- The argument to `--branch` can actually be a branch or a tag as of
61
+ -- Git 1.7.10.
62
+ table.insert(command, 4, "--branch=" .. tag_or_branch)
63
+ end
64
+ end
65
+ if not fs.execute(unpack(command)) then
66
+ return nil, "Failed cloning git repository."
67
+ end
68
+ fs.change_dir(module)
69
+ if tag_or_branch and not git_can_clone_by_tag() then
70
+ local checkout_command = {git_cmd, "checkout", tag_or_branch}
71
+ if not fs.execute(unpack(checkout_command)) then
72
+ return nil, 'Failed to check out the "' .. tag_or_branch ..'" tag or branch.'
73
+ end
74
+ end
75
+
76
+ fs.delete(dir.path(store_dir, module, ".git"))
77
+ fs.delete(dir.path(store_dir, module, ".gitignore"))
78
+ fs.pop_dir()
79
+ fs.pop_dir()
80
+ return module, store_dir
81
+ end
@@ -0,0 +1,17 @@
1
+
2
+ --- Fetch back-end for retrieving sources from local Git repositories.
3
+ module("luarocks.fetch.git_file", package.seeall)
4
+
5
+ local git = require("luarocks.fetch.git")
6
+
7
+ --- Fetch sources for building a rock from a local Git repository.
8
+ -- @param rockspec table: The rockspec table
9
+ -- @param extract boolean: Unused in this module (required for API purposes.)
10
+ -- @param dest_dir string or nil: If set, will extract to the given directory.
11
+ -- @return (string, string) or (nil, string): The absolute pathname of
12
+ -- the fetched source tarball and the temporary directory created to
13
+ -- store it; or nil and an error message.
14
+ function get_sources(rockspec, extract, dest_dir)
15
+ rockspec.source.url = rockspec.source.url:gsub("^git.file://", "")
16
+ return git.get_sources(rockspec, extract, dest_dir)
17
+ end
@@ -0,0 +1,54 @@
1
+
2
+ --- Fetch back-end for retrieving sources from HG.
3
+ module("luarocks.fetch.hg", package.seeall)
4
+
5
+ local fs = require("luarocks.fs")
6
+ local dir = require("luarocks.dir")
7
+ local util = require("luarocks.util")
8
+
9
+ --- Download sources for building a rock, using hg.
10
+ -- @param rockspec table: The rockspec table
11
+ -- @param extract boolean: Unused in this module (required for API purposes.)
12
+ -- @param dest_dir string or nil: If set, will extract to the given directory.
13
+ -- @return (string, string) or (nil, string): The absolute pathname of
14
+ -- the fetched source tarball and the temporary directory created to
15
+ -- store it; or nil and an error message.
16
+ function get_sources(rockspec, extract, dest_dir)
17
+ assert(type(rockspec) == "table")
18
+ assert(type(dest_dir) == "string" or not dest_dir)
19
+
20
+ local hg_cmd = rockspec.variables.HG
21
+ local name_version = rockspec.name .. "-" .. rockspec.version
22
+ -- Strip off special hg:// protocol type
23
+ local url = rockspec.source.url:gsub("^hg://", "")
24
+
25
+ local module = dir.base_name(url)
26
+
27
+ local command = {hg_cmd, "clone", url, module}
28
+ local tag_or_branch = rockspec.source.tag or rockspec.source.branch
29
+ if tag_or_branch then
30
+ command = {hg_cmd, "clone", "--rev", url, module}
31
+ end
32
+ local store_dir
33
+ if not dest_dir then
34
+ store_dir = fs.make_temp_dir(name_version)
35
+ if not store_dir then
36
+ return nil, "Failed creating temporary directory."
37
+ end
38
+ util.schedule_function(fs.delete, store_dir)
39
+ else
40
+ store_dir = dest_dir
41
+ end
42
+ fs.change_dir(store_dir)
43
+ if not fs.execute(unpack(command)) then
44
+ return nil, "Failed cloning hg repository."
45
+ end
46
+ fs.change_dir(module)
47
+
48
+ fs.delete(dir.path(store_dir, module, ".hg"))
49
+ fs.delete(dir.path(store_dir, module, ".hgignore"))
50
+ fs.pop_dir()
51
+ fs.pop_dir()
52
+ return module, store_dir
53
+ end
54
+
@@ -0,0 +1,42 @@
1
+
2
+ --- Fetch back-end for retrieving sources from Surround SCM Server
3
+ module("luarocks.fetch.sscm", package.seeall)
4
+
5
+ local fs = require("luarocks.fs")
6
+ local dir = require("luarocks.dir")
7
+
8
+ --- Download sources via Surround SCM Server for building a rock.
9
+ -- @param rockspec table: The rockspec table
10
+ -- @param extract boolean: Unused in this module (required for API purposes.)
11
+ -- @param dest_dir string or nil: If set, will extract to the given directory.
12
+ -- @return (string, string) or (nil, string): The absolute pathname of
13
+ -- the fetched source tarball and the temporary directory created to
14
+ -- store it; or nil and an error message.
15
+ function get_sources(rockspec, extract, dest_dir)
16
+ assert(type(rockspec) == "table")
17
+ assert(type(dest_dir) == "string" or not dest_dir)
18
+
19
+ local sscm_cmd = rockspec.variables.SSCM
20
+ local module = rockspec.source.module or dir.base_name(rockspec.source.url)
21
+ local branch, repository = string.match(rockspec.source.pathname, "^([^/]*)/(.*)")
22
+ if not branch or not repository then
23
+ return nil, "Error retrieving branch and repository from rockspec."
24
+ end
25
+ -- Search for working directory.
26
+ local working_dir
27
+ local tmp = io.popen(string.format(sscm_cmd..[[ property "/" -d -b%s -p%s]], branch, repository))
28
+ for line in tmp:lines() do
29
+ --%c because a chr(13) comes in the end.
30
+ working_dir = string.match(line, "Working directory:[%s]*(.*)%c$")
31
+ if working_dir then break end
32
+ end
33
+ tmp:close()
34
+ if not working_dir then
35
+ return nil, "Error retrieving working directory from SSCM."
36
+ end
37
+ if not fs.execute(sscm_cmd, "get", "*", "-e" , "-r", "-b"..branch, "-p"..repository, "-tmodify", "-wreplace") then
38
+ return nil, "Failed fetching files from SSCM."
39
+ end
40
+ -- FIXME: This function does not honor the dest_dir parameter.
41
+ return module, working_dir
42
+ end
@@ -0,0 +1,53 @@
1
+
2
+ --- Fetch back-end for retrieving sources from Subversion.
3
+ module("luarocks.fetch.svn", package.seeall)
4
+
5
+ local fs = require("luarocks.fs")
6
+ local dir = require("luarocks.dir")
7
+ local util = require("luarocks.util")
8
+
9
+ --- Download sources for building a rock, using Subversion.
10
+ -- @param rockspec table: The rockspec table
11
+ -- @param extract boolean: Unused in this module (required for API purposes.)
12
+ -- @param dest_dir string or nil: If set, will extract to the given directory.
13
+ -- @return (string, string) or (nil, string): The absolute pathname of
14
+ -- the fetched source tarball and the temporary directory created to
15
+ -- store it; or nil and an error message.
16
+ function get_sources(rockspec, extract, dest_dir)
17
+ assert(type(rockspec) == "table")
18
+ assert(type(dest_dir) == "string" or not dest_dir)
19
+
20
+ local svn_cmd = rockspec.variables.SVN
21
+ local name_version = rockspec.name .. "-" .. rockspec.version
22
+ local module = rockspec.source.module or dir.base_name(rockspec.source.url)
23
+ local url = rockspec.source.url:gsub("^svn://", "")
24
+ local command = {svn_cmd, "checkout", url, module}
25
+ if rockspec.source.tag then
26
+ table.insert(command, 5, "-r")
27
+ table.insert(command, 6, rockspec.source.tag)
28
+ end
29
+ local store_dir
30
+ if not dest_dir then
31
+ store_dir = fs.make_temp_dir(name_version)
32
+ if not store_dir then
33
+ return nil, "Failed creating temporary directory."
34
+ end
35
+ util.schedule_function(fs.delete, store_dir)
36
+ else
37
+ store_dir = dest_dir
38
+ end
39
+ fs.change_dir(store_dir)
40
+ if not fs.execute(unpack(command)) then
41
+ return nil, "Failed fetching files from Subversion."
42
+ end
43
+ fs.change_dir(module)
44
+ for _, d in ipairs(fs.find(".")) do
45
+ if dir.base_name(d) == ".svn" then
46
+ fs.delete(dir.path(store_dir, module, d))
47
+ end
48
+ end
49
+ fs.pop_dir()
50
+ fs.pop_dir()
51
+ return module, store_dir
52
+ end
53
+
@@ -0,0 +1,40 @@
1
+
2
+ --- Proxy module for filesystem and platform abstractions.
3
+ -- All code using "fs" code should require "luarocks.fs",
4
+ -- and not the various platform-specific implementations.
5
+ -- However, see the documentation of the implementation
6
+ -- for the API reference.
7
+
8
+ local pairs = pairs
9
+
10
+ module("luarocks.fs", package.seeall)
11
+
12
+ local cfg = require("luarocks.cfg")
13
+
14
+ local function load_fns(fs_table)
15
+ for name, fn in pairs(fs_table) do
16
+ if not _M[name] then
17
+ _M[name] = fn
18
+ end
19
+ end
20
+ end
21
+
22
+ -- Load platform-specific functions
23
+ local loaded_platform = nil
24
+ for _, platform in ipairs(cfg.platforms) do
25
+ local ok, fs_plat = pcall(require, "luarocks.fs."..platform)
26
+ if ok and fs_plat then
27
+ loaded_platform = platform
28
+ load_fns(fs_plat)
29
+ break
30
+ end
31
+ end
32
+
33
+ -- Load platform-independent pure-Lua functionality
34
+ local fs_lua = require("luarocks.fs.lua")
35
+ load_fns(fs_lua)
36
+
37
+ -- Load platform-specific fallbacks for missing Lua modules
38
+ local ok, fs_plat_tools = pcall(require, "luarocks.fs."..loaded_platform..".tools")
39
+ if ok and fs_plat_tools then load_fns(fs_plat_tools) end
40
+
@@ -0,0 +1,676 @@
1
+
2
+ --- Native Lua implementation of filesystem and platform abstractions,
3
+ -- using LuaFileSystem, LZLib, MD5 and LuaCurl.
4
+ module("luarocks.fs.lua", package.seeall)
5
+
6
+ local fs = require("luarocks.fs")
7
+
8
+ local cfg = require("luarocks.cfg")
9
+ local dir = require("luarocks.dir")
10
+ local util = require("luarocks.util")
11
+ local path = require("luarocks.path")
12
+
13
+ local socket_ok, http = pcall(require, "socket.http")
14
+ local _, ftp = pcall(require, "socket.ftp")
15
+ local zip_ok, lrzip = pcall(require, "luarocks.tools.zip")
16
+ local unzip_ok, luazip = pcall(require, "zip"); _G.zip = nil
17
+ local lfs_ok, lfs = pcall(require, "lfs")
18
+ local md5_ok, md5 = pcall(require, "md5")
19
+ local posix_ok, posix = pcall(require, "posix")
20
+
21
+ local tar = require("luarocks.tools.tar")
22
+ local patch = require("luarocks.tools.patch")
23
+
24
+ local dir_stack = {}
25
+
26
+ math.randomseed(os.time())
27
+
28
+ dir_separator = "/"
29
+
30
+ --- Quote argument for shell processing.
31
+ -- Adds single quotes and escapes.
32
+ -- @param arg string: Unquoted argument.
33
+ -- @return string: Quoted argument.
34
+ function Q(arg)
35
+ assert(type(arg) == "string")
36
+
37
+ -- FIXME Unix-specific
38
+ return "'" .. arg:gsub("\\", "\\\\"):gsub("'", "'\\''") .. "'"
39
+ end
40
+
41
+ local function normalize(name)
42
+ return name:gsub("\\", "/"):gsub("/$", "")
43
+ end
44
+
45
+ --- Test is file/dir is writable.
46
+ -- Warning: testing if a file/dir is writable does not guarantee
47
+ -- that it will remain writable and therefore it is no replacement
48
+ -- for checking the result of subsequent operations.
49
+ -- @param file string: filename to test
50
+ -- @return boolean: true if file exists, false otherwise.
51
+ function is_writable(file)
52
+ assert(file)
53
+ file = normalize(file)
54
+ local result
55
+ if fs.is_dir(file) then
56
+ local file2 = dir.path(file, '.tmpluarockstestwritable')
57
+ local fh = io.open(file2, 'wb')
58
+ result = fh ~= nil
59
+ if fh then fh:close() end
60
+ os.remove(file2)
61
+ else
62
+ local fh = io.open(file, 'r+b')
63
+ result = fh ~= nil
64
+ if fh then fh:close() end
65
+ end
66
+ return result
67
+ end
68
+
69
+ --- Create a temporary directory.
70
+ -- @param name string: name pattern to use for avoiding conflicts
71
+ -- when creating temporary directory.
72
+ -- @return string or nil: name of temporary directory or nil on failure.
73
+ function make_temp_dir(name)
74
+ assert(type(name) == "string")
75
+ name = normalize(name)
76
+
77
+ local temp_dir = (os.getenv("TMP") or "/tmp") .. "/luarocks_" .. name:gsub(dir.separator, "_") .. "-" .. tostring(math.floor(math.random() * 10000))
78
+ if fs.make_dir(temp_dir) then
79
+ return temp_dir
80
+ else
81
+ return nil
82
+ end
83
+ end
84
+
85
+ --- Run the given command, quoting its arguments.
86
+ -- The command is executed in the current directory in the dir stack.
87
+ -- @param command string: The command to be executed. No quoting/escaping
88
+ -- is applied.
89
+ -- @param ... Strings containing additional arguments, which are quoted.
90
+ -- @return boolean: true if command succeeds (status code 0), false
91
+ -- otherwise.
92
+ function execute(command, ...)
93
+ assert(type(command) == "string")
94
+
95
+ for _, arg in ipairs({...}) do
96
+ assert(type(arg) == "string")
97
+ command = command .. " " .. fs.Q(arg)
98
+ end
99
+ return fs.execute_string(command)
100
+ end
101
+
102
+ --- Check the MD5 checksum for a file.
103
+ -- @param file string: The file to be checked.
104
+ -- @param md5sum string: The string with the expected MD5 checksum.
105
+ -- @return boolean: true if the MD5 checksum for 'file' equals 'md5sum', false if not
106
+ -- or if it could not perform the check for any reason.
107
+ function check_md5(file, md5sum)
108
+ file = normalize(file)
109
+ local computed = fs.get_md5(file)
110
+ if not computed then
111
+ return false
112
+ end
113
+ if computed:match("^"..md5sum) then
114
+ return true
115
+ else
116
+ return false
117
+ end
118
+ end
119
+
120
+ ---------------------------------------------------------------------
121
+ -- LuaFileSystem functions
122
+ ---------------------------------------------------------------------
123
+
124
+ if lfs_ok then
125
+
126
+ --- Run the given command.
127
+ -- The command is executed in the current directory in the dir stack.
128
+ -- @param cmd string: No quoting/escaping is applied to the command.
129
+ -- @return boolean: true if command succeeds (status code 0), false
130
+ -- otherwise.
131
+ function execute_string(cmd)
132
+ local code = os.execute(cmd)
133
+ if code == 0 or code == true then
134
+ return true
135
+ else
136
+ return false
137
+ end
138
+ end
139
+
140
+ --- Obtain current directory.
141
+ -- Uses the module's internal dir stack.
142
+ -- @return string: the absolute pathname of the current directory.
143
+ function current_dir()
144
+ return lfs.currentdir()
145
+ end
146
+
147
+ --- Change the current directory.
148
+ -- Uses the module's internal dir stack. This does not have exact
149
+ -- semantics of chdir, as it does not handle errors the same way,
150
+ -- but works well for our purposes for now.
151
+ -- @param d string: The directory to switch to.
152
+ function change_dir(d)
153
+ table.insert(dir_stack, lfs.currentdir())
154
+ d = normalize(d)
155
+ lfs.chdir(d)
156
+ end
157
+
158
+ --- Change directory to root.
159
+ -- Allows leaving a directory (e.g. for deleting it) in
160
+ -- a crossplatform way.
161
+ function change_dir_to_root()
162
+ table.insert(dir_stack, lfs.currentdir())
163
+ lfs.chdir("/") -- works on Windows too
164
+ end
165
+
166
+ --- Change working directory to the previous in the dir stack.
167
+ -- @return true if a pop ocurred, false if the stack was empty.
168
+ function pop_dir()
169
+ local d = table.remove(dir_stack)
170
+ if d then
171
+ lfs.chdir(d)
172
+ return true
173
+ else
174
+ return false
175
+ end
176
+ end
177
+
178
+ --- Create a directory if it does not already exist.
179
+ -- If any of the higher levels in the path name does not exist
180
+ -- too, they are created as well.
181
+ -- @param directory string: pathname of directory to create.
182
+ -- @return boolean: true on success, false on failure.
183
+ function make_dir(directory)
184
+ assert(type(directory) == "string")
185
+ directory = normalize(directory)
186
+ local path = nil
187
+ if directory:sub(2, 2) == ":" then
188
+ path = directory:sub(1, 2)
189
+ directory = directory:sub(4)
190
+ else
191
+ if directory:match("^/") then
192
+ path = ""
193
+ end
194
+ end
195
+ for d in directory:gmatch("([^"..dir.separator.."]+)"..dir.separator.."*") do
196
+ path = path and path .. dir.separator .. d or d
197
+ local mode = lfs.attributes(path, "mode")
198
+ if not mode then
199
+ if not lfs.mkdir(path) then
200
+ return false
201
+ end
202
+ elseif mode ~= "directory" then
203
+ return false
204
+ end
205
+ end
206
+ return true
207
+ end
208
+
209
+ --- Remove a directory if it is empty.
210
+ -- Does not return errors (for example, if directory is not empty or
211
+ -- if already does not exist)
212
+ -- @param d string: pathname of directory to remove.
213
+ function remove_dir_if_empty(d)
214
+ assert(d)
215
+ d = normalize(d)
216
+ lfs.rmdir(d)
217
+ end
218
+
219
+ --- Remove a directory if it is empty.
220
+ -- Does not return errors (for example, if directory is not empty or
221
+ -- if already does not exist)
222
+ -- @param d string: pathname of directory to remove.
223
+ function remove_dir_tree_if_empty(d)
224
+ assert(d)
225
+ d = normalize(d)
226
+ for i=1,10 do
227
+ lfs.rmdir(d)
228
+ d = dir.dir_name(d)
229
+ end
230
+ end
231
+
232
+ --- Copy a file.
233
+ -- @param src string: Pathname of source
234
+ -- @param dest string: Pathname of destination
235
+ -- @param perms string or nil: Permissions for destination file,
236
+ -- or nil to use the source filename permissions
237
+ -- @return boolean or (boolean, string): true on success, false on failure,
238
+ -- plus an error message.
239
+ function copy(src, dest, perms)
240
+ assert(src and dest)
241
+ src = normalize(src)
242
+ dest = normalize(dest)
243
+ local destmode = lfs.attributes(dest, "mode")
244
+ if destmode == "directory" then
245
+ dest = dir.path(dest, dir.base_name(src))
246
+ end
247
+ if not perms then perms = fs.get_permissions(src) end
248
+ local src_h, err = io.open(src, "rb")
249
+ if not src_h then return nil, err end
250
+ local dest_h, err = io.open(dest, "w+b")
251
+ if not dest_h then src_h:close() return nil, err end
252
+ while true do
253
+ local block = src_h:read(8192)
254
+ if not block then break end
255
+ dest_h:write(block)
256
+ end
257
+ src_h:close()
258
+ dest_h:close()
259
+ fs.chmod(dest, perms)
260
+ return true
261
+ end
262
+
263
+ --- Implementation function for recursive copy of directory contents.
264
+ -- Assumes paths are normalized.
265
+ -- @param src string: Pathname of source
266
+ -- @param dest string: Pathname of destination
267
+ -- @return boolean or (boolean, string): true on success, false on failure
268
+ local function recursive_copy(src, dest)
269
+ local srcmode = lfs.attributes(src, "mode")
270
+
271
+ if srcmode == "file" then
272
+ local ok = fs.copy(src, dest)
273
+ if not ok then return false end
274
+ elseif srcmode == "directory" then
275
+ local subdir = dir.path(dest, dir.base_name(src))
276
+ fs.make_dir(subdir)
277
+ for file in lfs.dir(src) do
278
+ if file ~= "." and file ~= ".." then
279
+ local ok = recursive_copy(dir.path(src, file), subdir)
280
+ if not ok then return false end
281
+ end
282
+ end
283
+ end
284
+ return true
285
+ end
286
+
287
+ --- Recursively copy the contents of a directory.
288
+ -- @param src string: Pathname of source
289
+ -- @param dest string: Pathname of destination
290
+ -- @return boolean or (boolean, string): true on success, false on failure,
291
+ -- plus an error message.
292
+ function copy_contents(src, dest)
293
+ assert(src and dest)
294
+ src = normalize(src)
295
+ dest = normalize(dest)
296
+ assert(lfs.attributes(src, "mode") == "directory")
297
+
298
+ for file in lfs.dir(src) do
299
+ if file ~= "." and file ~= ".." then
300
+ local ok = recursive_copy(dir.path(src, file), dest)
301
+ if not ok then
302
+ return false, "Failed copying "..src.." to "..dest
303
+ end
304
+ end
305
+ end
306
+ return true
307
+ end
308
+
309
+ --- Implementation function for recursive removal of directories.
310
+ -- Assumes paths are normalized.
311
+ -- @param name string: Pathname of file
312
+ -- @return boolean or (boolean, string): true on success,
313
+ -- or nil and an error message on failure.
314
+ local function recursive_delete(name)
315
+ local mode = lfs.attributes(name, "mode")
316
+
317
+ if mode == "file" then
318
+ return os.remove(name)
319
+ elseif mode == "directory" then
320
+ for file in lfs.dir(name) do
321
+ if file ~= "." and file ~= ".." then
322
+ local ok, err = recursive_delete(dir.path(name, file))
323
+ if not ok then return nil, err end
324
+ end
325
+ end
326
+ local ok, err = lfs.rmdir(name)
327
+ if not ok then return nil, err end
328
+ end
329
+ return true
330
+ end
331
+
332
+ --- Delete a file or a directory and all its contents.
333
+ -- @param name string: Pathname of source
334
+ -- @return boolean: true on success, false on failure.
335
+ function delete(name)
336
+ name = normalize(name)
337
+ return recursive_delete(name) or false
338
+ end
339
+
340
+ --- List the contents of a directory.
341
+ -- @param at string or nil: directory to list (will be the current
342
+ -- directory if none is given).
343
+ -- @return table: an array of strings with the filenames representing
344
+ -- the contents of a directory.
345
+ function list_dir(at)
346
+ assert(type(at) == "string" or not at)
347
+ if not at then
348
+ at = fs.current_dir()
349
+ end
350
+ at = normalize(at)
351
+ if not fs.is_dir(at) then
352
+ return {}
353
+ end
354
+ local result = {}
355
+ for file in lfs.dir(at) do
356
+ if file ~= "." and file ~= ".." then
357
+ table.insert(result, file)
358
+ end
359
+ end
360
+ return result
361
+ end
362
+
363
+ --- Implementation function for recursive find.
364
+ -- Assumes paths are normalized.
365
+ -- @param cwd string: Current working directory in recursion.
366
+ -- @param prefix string: Auxiliary prefix string to form pathname.
367
+ -- @param result table: Array of strings where results are collected.
368
+ local function recursive_find(cwd, prefix, result)
369
+ for file in lfs.dir(cwd) do
370
+ if file ~= "." and file ~= ".." then
371
+ local item = prefix .. file
372
+ table.insert(result, item)
373
+ local pathname = dir.path(cwd, file)
374
+ if lfs.attributes(pathname, "mode") == "directory" then
375
+ recursive_find(pathname, item..dir_separator, result)
376
+ end
377
+ end
378
+ end
379
+ end
380
+
381
+ --- Recursively scan the contents of a directory.
382
+ -- @param at string or nil: directory to scan (will be the current
383
+ -- directory if none is given).
384
+ -- @return table: an array of strings with the filenames representing
385
+ -- the contents of a directory.
386
+ function find(at)
387
+ assert(type(at) == "string" or not at)
388
+ if not at then
389
+ at = fs.current_dir()
390
+ end
391
+ at = normalize(at)
392
+ if not fs.is_dir(at) then
393
+ return {}
394
+ end
395
+ local result = {}
396
+ recursive_find(at, "", result)
397
+ return result
398
+ end
399
+
400
+ --- Test for existance of a file.
401
+ -- @param file string: filename to test
402
+ -- @return boolean: true if file exists, false otherwise.
403
+ function exists(file)
404
+ assert(file)
405
+ file = normalize(file)
406
+ return type(lfs.attributes(file)) == "table"
407
+ end
408
+
409
+ --- Test is pathname is a directory.
410
+ -- @param file string: pathname to test
411
+ -- @return boolean: true if it is a directory, false otherwise.
412
+ function is_dir(file)
413
+ assert(file)
414
+ file = normalize(file)
415
+ return lfs.attributes(file, "mode") == "directory"
416
+ end
417
+
418
+ --- Test is pathname is a regular file.
419
+ -- @param file string: pathname to test
420
+ -- @return boolean: true if it is a file, false otherwise.
421
+ function is_file(file)
422
+ assert(file)
423
+ file = normalize(file)
424
+ return lfs.attributes(file, "mode") == "file"
425
+ end
426
+
427
+ function set_time(file, time)
428
+ file = normalize(file)
429
+ return lfs.touch(file, time)
430
+ end
431
+
432
+ end
433
+
434
+ ---------------------------------------------------------------------
435
+ -- LuaZip functions
436
+ ---------------------------------------------------------------------
437
+
438
+ if zip_ok then
439
+
440
+ function zip(zipfile, ...)
441
+ return lrzip.zip(zipfile, ...)
442
+ end
443
+
444
+ end
445
+
446
+ if unzip_ok then
447
+ --- Uncompress files from a .zip archive.
448
+ -- @param zipfile string: pathname of .zip archive to be extracted.
449
+ -- @return boolean: true on success, false on failure.
450
+ function unzip(zipfile)
451
+ local zipfile, err = luazip.open(zipfile)
452
+ if not zipfile then return nil, err end
453
+ local files = zipfile:files()
454
+ local file = files()
455
+ repeat
456
+ if file.filename:sub(#file.filename) == "/" then
457
+ fs.make_dir(dir.path(fs.current_dir(), file.filename))
458
+ else
459
+ local rf, err = zipfile:open(file.filename)
460
+ if not rf then zipfile:close(); return nil, err end
461
+ local contents = rf:read("*a")
462
+ rf:close()
463
+ local wf, err = io.open(dir.path(fs.current_dir(), file.filename), "wb")
464
+ if not wf then zipfile:close(); return nil, err end
465
+ wf:write(contents)
466
+ wf:close()
467
+ end
468
+ file = files()
469
+ until not file
470
+ zipfile:close()
471
+ return true
472
+ end
473
+
474
+ end
475
+
476
+ ---------------------------------------------------------------------
477
+ -- LuaSocket functions
478
+ ---------------------------------------------------------------------
479
+
480
+ if socket_ok then
481
+
482
+ local ltn12 = require("ltn12")
483
+ local luasec_ok, https = pcall(require, "ssl.https")
484
+ local redirect_protocols = {
485
+ http = http,
486
+ https = luasec_ok and https,
487
+ }
488
+
489
+ local function http_request(url, http, loop_control)
490
+ local result = {}
491
+ local res, status, headers, err = http.request { url = url, proxy = cfg.proxy, redirect = false, sink = ltn12.sink.table(result) }
492
+ if not res then
493
+ return nil, status
494
+ elseif status == 301 or status == 302 then
495
+ local location = headers.location
496
+ if location then
497
+ local protocol, rest = dir.split_url(location)
498
+ if redirect_protocols[protocol] then
499
+ if not loop_control then
500
+ loop_control = {}
501
+ elseif loop_control[location] then
502
+ return nil, "Redirection loop -- broken URL?"
503
+ end
504
+ loop_control[url] = true
505
+ return http_request(location, redirect_protocols[protocol], loop_control)
506
+ else
507
+ return nil, "URL redirected to unsupported protocol - install luasec to get HTTPS support."
508
+ end
509
+ end
510
+ return nil, err
511
+ elseif status ~= 200 then
512
+ return nil, err
513
+ else
514
+ return table.concat(result)
515
+ end
516
+ end
517
+
518
+ --- Download a remote file.
519
+ -- @param url string: URL to be fetched.
520
+ -- @param filename string or nil: this function attempts to detect the
521
+ -- resulting local filename of the remote file as the basename of the URL;
522
+ -- if that is not correct (due to a redirection, for example), the local
523
+ -- filename can be given explicitly as this second argument.
524
+ -- @return boolean: true on success, false on failure.
525
+ function download(url, filename)
526
+ assert(type(url) == "string")
527
+ assert(type(filename) == "string" or not filename)
528
+
529
+ filename = dir.path(fs.current_dir(), filename or dir.base_name(url))
530
+
531
+ local content, err
532
+ if util.starts_with(url, "http:") then
533
+ content, err = http_request(url, http)
534
+ elseif util.starts_with(url, "ftp:") then
535
+ content, err = ftp.get(url)
536
+ elseif util.starts_with(url, "https:") then
537
+ if luasec_ok then
538
+ content, err = http_request(url, https)
539
+ else
540
+ err = "Unsupported protocol - install luasec to get HTTPS support."
541
+ end
542
+ else
543
+ err = "Unsupported protocol"
544
+ end
545
+ if not content then
546
+ return false, tostring(err)
547
+ end
548
+ local file = io.open(filename, "wb")
549
+ if not file then return false end
550
+ file:write(content)
551
+ file:close()
552
+ return true
553
+ end
554
+
555
+ end
556
+ ---------------------------------------------------------------------
557
+ -- MD5 functions
558
+ ---------------------------------------------------------------------
559
+
560
+ if md5_ok then
561
+
562
+ --- Get the MD5 checksum for a file.
563
+ -- @param file string: The file to be computed.
564
+ -- @return string: The MD5 checksum
565
+ function get_md5(file)
566
+ file = fs.absolute_name(file)
567
+ local file = io.open(file, "rb")
568
+ if not file then return false end
569
+ local computed = md5.sumhexa(file:read("*a"))
570
+ file:close()
571
+ return computed
572
+ end
573
+
574
+ end
575
+
576
+ ---------------------------------------------------------------------
577
+ -- POSIX functions
578
+ ---------------------------------------------------------------------
579
+
580
+ if posix_ok then
581
+
582
+ local octal_to_rwx = {
583
+ ["0"] = "---",
584
+ ["1"] = "--x",
585
+ ["2"] = "-w-",
586
+ ["3"] = "-wx",
587
+ ["4"] = "r--",
588
+ ["5"] = "r-x",
589
+ ["6"] = "rw-",
590
+ ["7"] = "rwx",
591
+ }
592
+
593
+ function chmod(file, mode)
594
+ -- LuaPosix (as of 5.1.15) does not support octal notation...
595
+ if mode:sub(1,1) == "0" then
596
+ local new_mode = {}
597
+ for c in mode:sub(2):gmatch(".") do
598
+ table.insert(new_mode, octal_to_rwx[c])
599
+ end
600
+ mode = table.concat(new_mode)
601
+ end
602
+ local err = posix.chmod(file, mode)
603
+ return err == 0
604
+ end
605
+
606
+ function get_permissions(file)
607
+ return posix.stat(file, "mode")
608
+ end
609
+
610
+ end
611
+
612
+ ---------------------------------------------------------------------
613
+ -- Other functions
614
+ ---------------------------------------------------------------------
615
+
616
+ --- Apply a patch.
617
+ -- @param patchname string: The filename of the patch.
618
+ -- @param patchdata string or nil: The actual patch as a string.
619
+ function apply_patch(patchname, patchdata)
620
+ local p, all_ok = patch.read_patch(patchname, patchdata)
621
+ if not all_ok then
622
+ return nil, "Failed reading patch "..patchname
623
+ end
624
+ if p then
625
+ return patch.apply_patch(p, 1)
626
+ end
627
+ end
628
+
629
+ --- Move a file.
630
+ -- @param src string: Pathname of source
631
+ -- @param dest string: Pathname of destination
632
+ -- @return boolean or (boolean, string): true on success, false on failure,
633
+ -- plus an error message.
634
+ function move(src, dest)
635
+ assert(src and dest)
636
+ if fs.exists(dest) and not fs.is_dir(dest) then
637
+ return false, "File already exists: "..dest
638
+ end
639
+ local ok, err = fs.copy(src, dest)
640
+ if not ok then
641
+ return false, err
642
+ end
643
+ ok = fs.delete(src)
644
+ if not ok then
645
+ return false, "Failed move: could not delete "..src.." after copy."
646
+ end
647
+ return true
648
+ end
649
+
650
+ --- Check if user has write permissions for the command.
651
+ -- Assumes the configuration variables under cfg have been previously set up.
652
+ -- @param flags table: the flags table passed to run() drivers.
653
+ -- @return boolean or (boolean, string): true on success, false on failure,
654
+ -- plus an error message.
655
+ function check_command_permissions(flags)
656
+ local root_dir = path.root_dir(cfg.rocks_dir)
657
+ local ok = true
658
+ local err = ""
659
+ for _, dir in ipairs { cfg.rocks_dir, root_dir, dir.dir_name(root_dir) } do
660
+ if fs.exists(dir) and not fs.is_writable(dir) then
661
+ ok = false
662
+ err = "Your user does not have write permissions in " .. dir
663
+ break
664
+ end
665
+ end
666
+ if ok then
667
+ return true
668
+ else
669
+ if flags["local"] then
670
+ err = err .. " \n-- please check your permissions."
671
+ else
672
+ err = err .. " \n-- you may want to run as a privileged user or use your local tree with --local."
673
+ end
674
+ return nil, err
675
+ end
676
+ end