Tamar 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,443 @@
1
+ #!/usr/bin/env lua
2
+ --- Simple LuaDist CLI interface
3
+ -- This script uses the exposed LuaDist APIs to provide commandline interface to LuaDist features.
4
+ -- Peter Kapec, Peter Drahoš LuaDist Project, 2010
5
+
6
+ local dist = require "dist"
7
+ local config = require "dist.config"
8
+ local sys = require "dist.sys"
9
+ local persist = require "dist.persist"
10
+
11
+ --- Display help
12
+ local function help()
13
+ print ([[
14
+ LuaDist ]] .. config.version .. [[ - Simple Lua Distribution and Module Deployment System
15
+ Usage: luadist (depldir) [command] (names) (-variables)
16
+
17
+ where [...] are required and (...) are optional:
18
+ depldir - Optional path to the deployment directory LuaDist will operate on.
19
+ command - Specifies the operation to be executed:
20
+ help - Display detailed help about command.
21
+ install - Install/Update Dists from repository.
22
+ remove - Remove deployed Dists.
23
+ pack - Pack deployed Dists.
24
+ search - Search repositories for Dists.
25
+ list - List deployed Dists.
26
+ info - Show details about Dist from repository.
27
+ manifest - Generate dist manifest file for repository.
28
+ make - Build and deploy dist from path and URL.
29
+ names - A list of names (case sensitive), each name can contain version constraints.
30
+ variables - Configuration options or CMake settings to be passed into the build process.
31
+ Examples:
32
+ installing luasocket and md5
33
+ > luadist install luasocket md5
34
+ installing Lua 5.1.4 to its own deployment directory.
35
+ > luadist ./example install lua-5.1.4
36
+ switch to newest LuaJIT 1.x
37
+ > luadist ./example remove lua
38
+ > luadist ./example install luajit<2
39
+ update luajit to latest version
40
+ > luadist ./example install luajit
41
+
42
+ For additional help invoke
43
+ >luadist help command
44
+ ]])
45
+ end
46
+
47
+ --- Commands the CLI provides
48
+ local commands
49
+ commands = {
50
+ -- Display help for any other command or luadist in general.
51
+ ["help"] = {
52
+ help = [[
53
+ Usage: luadist help (command)
54
+
55
+ This will show detailed description about (command).
56
+ ]],
57
+ run = function (_, cmds)
58
+ if #cmds == 0 then
59
+ help()
60
+ else
61
+ for i = 1, #cmds do
62
+ local command = cmds[i]
63
+ if commands[command] then
64
+ print(commands[command].help)
65
+ else
66
+ print("Unknown command: " .. command)
67
+ end
68
+ end
69
+ end
70
+ return 0
71
+ end
72
+ },
73
+ -- Install dist
74
+ ["install"] = {
75
+ help = [[
76
+ Usage: luadist (depldir) install (names) (-variables)
77
+
78
+ The install command can install and update dists by their (names), each name can contain additional version constraints.
79
+ When constraints are not specified then the newest found is installed.
80
+ The optional (depldir) path is used to specify deployment directory, by default dists install directly into LuaDist.
81
+ For source dists (-variables) can contain CMake arguments using CMake's -D format and must be properly quoted.
82
+ Updating all deployed dists is possible by supplying no names to install.
83
+ ]],
84
+ run = function (depldir, names, variables)
85
+ local ok, err = dist.install(names, depldir, manifest, variables)
86
+ if not ok then print (err) return 1 end
87
+ print("Installation succesfull.")
88
+ return 0
89
+ end
90
+ },
91
+ ["test"] = {
92
+ help = [[
93
+ Usage: luadist (report) test (names) (-variables)
94
+
95
+ The test command can test installation of by their (names), each name can contain additional version constraints.
96
+ When constraints are not specified then the newest found is installed.
97
+ The optional (report) file is used to specify what type of report to generate, by default test will not generate a report file and will only print to console.
98
+ For source dists (-variables) can contain CMake arguments using CMake's -D format and must be properly quoted.
99
+ When a report file is supplied LuaDist will also generate packed binary dists from the test deployment, this is usefull when generating multiple binary dists from source.
100
+ ]],
101
+ run = function (report, names, variables)
102
+ local function saveHtml(filename, reportTable)
103
+ local report = {}
104
+ -- beginning of HTML code
105
+ report[#report + 1] = [[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
106
+ <xhtml xmlns="http://www.w3.org/1999/xhtml">
107
+ <head>
108
+ <title>Report - building packages in LuaDist</title>
109
+ <style type="text/css">
110
+ body
111
+ {background-color: #d0e4fe;}
112
+ </style>
113
+ </head>
114
+ <body>
115
+ <p>
116
+ <u><h2>Results of building packages</h2></u>
117
+ </p>
118
+ ]]
119
+
120
+ for distName, distTable in pairs (reportTable) do
121
+ -- first add dist name
122
+ report[#report + 1] = "<ul>\n <li style=\"font-size:18px;font-weight:bold;\">"
123
+ report[#report + 1] = distName
124
+ report[#report + 1] = "</li>\n <ul>"
125
+
126
+ for archName, archTable in pairs (distTable) do
127
+ -- add architecture information
128
+ report[#report + 1] = "\n <li style=\"font-weight:bold\">"
129
+ report[#report + 1] = archName
130
+ report[#report + 1] = "</li>"
131
+ -- and for the architecture add results of test
132
+ report[#report + 1] = "\n <ul>\n <li>Installation result: "
133
+
134
+ -- if result is "FAILED ..." and not just "OK"
135
+ if #archTable.result > 2 then
136
+ report[#report + 1] = "<span style=\"color:red\">"
137
+ report[#report + 1] = archTable.result
138
+ report[#report + 1] = "</span>"
139
+ else
140
+ report[#report + 1] = archTable.result
141
+ end
142
+
143
+ -- add date of test to given architecture
144
+ report[#report + 1] = "</li>\n <li>Date of test: "
145
+ report[#report + 1] = os.date ("!%c", os.time (archTable.date))
146
+ report[#report + 1] = "</li>\n </ul>"
147
+ end
148
+
149
+ -- end of information about dist
150
+ report[#report + 1] = "\n </ul>\n</ul>\n<hr/>\n"
151
+ end
152
+
153
+ -- end of HTML code
154
+ report[#report + 1] = "</body>\n</xhtml>\n"
155
+
156
+ -- transform an array of strings into one long string
157
+ report = table.concat (report)
158
+
159
+ -- write the HTML code to a file
160
+ local output = io.open (filename, "w")
161
+ output:write (report)
162
+ output:close ()
163
+ return true
164
+ end
165
+
166
+ -- Suppress standard output in tests
167
+ config.message = nil
168
+
169
+ -- Get requested dists and repo manifest
170
+ local manifest = dist.filterManifest()
171
+ local dists, err = dist.findDists(names, manifest)
172
+ if not dists then print(err) return 1 end
173
+
174
+ -- Temporary deployment dir
175
+ local temp = sys.path(config.temp, "luadist-test")
176
+
177
+ print ("\nTest results for " .. config.arch .. "-" .. config.type .. ":\n===========================\n")
178
+
179
+ -- Generate the report
180
+ local archType = config.arch .. "-" .. config.type
181
+
182
+ local test = {}
183
+ for i = 1, #dists do
184
+ local info = dists[i]
185
+ local name = info.name .. "-" .. info.version
186
+ local depl = sys.path(temp, name)
187
+
188
+ local entry = {}
189
+ entry.date = os.date("!*t")
190
+
191
+ io.write("\t" .. name)
192
+ io.flush()
193
+ -- try to install the module
194
+ local ok, err = dist.install(name, depl, manifest, variables)
195
+ if not ok then
196
+ io.write(" FAILED: "..err.."\n")
197
+ entry.result = "FAILED: "..err
198
+ else
199
+ io.write(" OK.\n")
200
+ entry.result = "OK."
201
+ if report then dist.pack(name, depl) end
202
+ end
203
+ io.flush()
204
+
205
+ test[name] = {
206
+ [archType] = entry
207
+ }
208
+ end
209
+
210
+ -- Save report if needed
211
+ if report then
212
+ if report:match("html$") then
213
+ saveHtml(report, test)
214
+ else
215
+ persist.saveManifest(report, test)
216
+ end
217
+ end
218
+
219
+ -- Cleanup
220
+ sys.delete(sys.path(temp))
221
+
222
+ return 0
223
+ end
224
+ },
225
+ -- Update dist
226
+ ["remove"] = {
227
+ help = [[
228
+ Usage: luadist (depldir) remove (names)
229
+
230
+ The remove command will remove deployed dists specified by (names) from the deployment directory (depldir).
231
+ When (depldir) is not specified, then the dist will be removed from LuaDist.
232
+ When no names are supplied LuaDist will delete the deployment entirely.
233
+ NOTE: LuaDist does not do any dist dependency breakage tests on remove!
234
+ WARNING! Be careful when removing whole deployments. You may loose data and in worst case break your system.
235
+ ]],
236
+ run = function (depldir, names)
237
+ local ok, err = dist.remove(names, depldir)
238
+ if not ok then print (err) return 1 end
239
+ print("Removal succesfull.")
240
+ return 0
241
+ end
242
+ },
243
+ -- Pack dist
244
+ ["pack"] = {
245
+ help = [[
246
+ Usage: luadist (depldir) pack (names)
247
+
248
+ The pack command will pack installed dist identified by (names) from the deployment directory (depldir).
249
+ When (depldir) is not specified the dist will be packed from LuaDist.
250
+ The resulting dist files will beplaced into current directory.
251
+ When no names are supplied LuaDist will pack all dists in the deployment.
252
+ ]],
253
+ run = function (depldir, names)
254
+ local ok, err = dist.pack(names, depldir)
255
+ if not ok then print (err) return 1 end
256
+ print("Pack successful.")
257
+ return 0
258
+ end
259
+ },
260
+ -- Search for dist
261
+ ["search"] = {
262
+ help = [[
263
+ Usage: luadist search (names)
264
+
265
+ The search command will search repositories for all dists satisfing manes.
266
+ Wildcard character * can be used to search for.
267
+ When no search arguments are specified then all available dists will be listed.
268
+ Search results are filtered and display only dists that can be installed for the platform LuaDist is running on.
269
+ ]],
270
+ run = function (_, names)
271
+ local dists = dist.findDists(names)
272
+ if not dists then print("\nNo dists found!")return 1 end
273
+ print("\nSearch result:\n===============\n")
274
+ for i = 1, #dists do
275
+ local dist = dists[i]
276
+ print("\t" .. dist.name .. "-" .. dist.version, "(" .. dist.arch .. "-" .. dist.type .. ")")
277
+ end
278
+ return 0
279
+ end
280
+ },
281
+ -- List deployed dists
282
+ ["list"] = {
283
+ help = [[
284
+ Usage: luadist (depldir) list (names)
285
+
286
+ The list command will list deployed dists containing any occurance of a string from (strings) in their name.
287
+ When no list arguments are specified then all deployed dists will be listed.
288
+ ]],
289
+ run = function (depldir, names)
290
+ local dists = dist.findDists(names, dist.getDeployed(depldir))
291
+ print("\nDeployed dists:\n===============\n")
292
+ for i = 1, #dists do
293
+ local dist = dists[i]
294
+ if dist.provided then
295
+ print("\t" .. dist.name .. "-" .. dist.version, "( provided by: " .. dist.provided .. ")")
296
+ else
297
+ print("\t" .. dist.name .. "-" .. dist.version, "(" .. dist.arch .. "-" .. dist.type .. ")")
298
+ end
299
+ end
300
+ return 0
301
+ end
302
+ },
303
+ -- Generate manifest
304
+ ["manifest"] = {
305
+ help = [[
306
+ Usage: luadist (dir) manifest
307
+
308
+ The manifest command will create a dist.manifest file for the directory (dir) or current directory.
309
+ This file is used as generated static index of dists contained in remote URL repositories where LuaDist cannot fetch directory listings.
310
+ When you plan to make an online repository make sure it contains and up to date manifest.
311
+ ]],
312
+ run = function (dir)
313
+ local manifest, err = dist.getManifest(dir)
314
+ if not manifest then return nil, "Could not generate manifest: " .. err end
315
+ local ok, err = persist.saveManifest("dist.manifest", manifest)
316
+ if not ok then return nil, "Could not save manifest: " .. err end
317
+ print("Manifest generated.")
318
+ return 0
319
+ end
320
+ },
321
+ -- Build a unpacked dist directory
322
+ ["make"] = {
323
+ help = [[
324
+ Usage: luadist (depldir) make (paths) (variables)
325
+
326
+ The make command will make and deploy dists into (depldir) from local (paths) or current directory if no paths are specified.
327
+ This command is usefull for development of dists or in cases where you want to force deployment of dists.
328
+ Make sure (paths) contain valid dist.info files or point to .dist or .zip archives.
329
+ Optional CMake (variables) can be passed to the build process when dealing with source dists using -D[CMakeVariable]= format.
330
+ ]],
331
+ run = function (depldir, paths, variables)
332
+ local ok, err = dist.deploy(paths, depldir, variables)
333
+ if not ok then print(err) return 1 end
334
+ print("Make successful.")
335
+ return 0
336
+ end
337
+ },
338
+ -- Display info about dist
339
+ ["info"] = {
340
+ help = [[
341
+ Usage: luadist info (names)
342
+
343
+ Info command will print information about the dists identified by (name) from repository.
344
+ In case names are satisfied by multiple dist versions, only the most recent version will be displayed.
345
+ ]],
346
+ run = function (depldir, names)
347
+ local dists = dist.findDists(names)
348
+ if not dists then print("No dists found!") return 1 end
349
+ for i = 1, #dists do
350
+ local info = dists[i]
351
+ print("\n" .. info.name .. "-" .. info.version)
352
+ print("Description: " .. (info.desc or "not-available"))
353
+ print("Author: " .. (info.author or "not-available" ))
354
+ print("Maintainer: " .. (info.maintainer or "not-available" ))
355
+ print("Url: " .. (info.url or "not-available" ))
356
+ print("License: " .. (info.license or "not-available" ))
357
+ end
358
+ return 0
359
+ end
360
+ },
361
+ }
362
+
363
+ --- Handle commandline arguments
364
+ local n, dir, command, names, variables = nil, nil, nil, {}, {}
365
+
366
+ -- Determine deployment and command
367
+ if not commands[arg[1]] and commands[arg[2]] then
368
+ dir = arg[1]
369
+ command = arg[2]
370
+ n = 3
371
+ elseif commands[arg[1]] then
372
+ dir = dist.getDeployment()
373
+ command = arg[1]
374
+ n = 2
375
+ else
376
+ -- No Command, print help
377
+ help()
378
+ return 0
379
+ end
380
+
381
+ -- Helper split function for argument to table conversion
382
+ function split(str, pat)
383
+ local t, fpat, last_end = {}, "(.-)" .. pat, 1
384
+ local s, e, cap = str:find(fpat, 1)
385
+ while s do
386
+ if s ~= 1 or cap ~= "" then
387
+ table.insert(t,cap)
388
+ end
389
+ last_end = e+1
390
+ s, e, cap = str:find(fpat, last_end)
391
+ end
392
+ if last_end <= #str then
393
+ cap = str:sub(last_end)
394
+ table.insert(t, cap)
395
+ end
396
+ return t
397
+ end
398
+
399
+ -- Collect settings, names and variables
400
+ for i = n, #arg do
401
+ -- Collect names
402
+ if arg[i]:match("^%-") then
403
+ -- Arguments
404
+ if arg[i]:match("^%-D") then
405
+ local cvar, value = arg[i]:match("^%-D(.-)=(.*)")
406
+ variables[cvar] = value
407
+ elseif arg[i]:match("^%-") then
408
+ local var, value = arg[i]:match("^%-(.-)=(.*)")
409
+ -- Compare to variables from config.lua and change type accordingly
410
+ if config[var]~=nil then
411
+ -- Change to number
412
+ if type(config[var])=="number" then
413
+ value = tonumber(value)
414
+ end
415
+ -- If its a boolean, everything else but "false" counts as true.
416
+ if type(config[var])=="boolean" then
417
+ if value == "false" or value == "0" or value == "off" then value = false else value = true end
418
+ end
419
+ -- If its a table
420
+ if type(config[var])=="table" then
421
+ value = split( value, "," )
422
+ end
423
+ -- Set the value
424
+ config[var] = value
425
+ else
426
+ print("Invalid configuration option!", arg[i], "\n")
427
+ help()
428
+ return 1
429
+ end
430
+ else
431
+ print("Invalid argument!", arg[i], "\n")
432
+ help()
433
+ return 1
434
+ end
435
+ else
436
+ table.insert(names, arg[i])
437
+ end
438
+ end
439
+
440
+ -- Run command
441
+ commands[command].run(dir, names, variables)
442
+ return 0
443
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: Tamar
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.2
5
+ version: 0.7.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Evan Wies, David Love
@@ -122,6 +122,31 @@ files:
122
122
  - Rakefile
123
123
  - Tamar.gemspec
124
124
  - VERSION
125
+ - src/luadist/CMakeLists.txt
126
+ - src/luadist/COPYRIGHT
127
+ - src/luadist/README
128
+ - src/luadist/dist.cmake
129
+ - src/luadist/dist.info
130
+ - src/luadist/dist/config.lua.in
131
+ - src/luadist/dist/dep.lua
132
+ - src/luadist/dist/fetch.lua
133
+ - src/luadist/dist/init.lua
134
+ - src/luadist/dist/log.lua
135
+ - src/luadist/dist/manifest.lua
136
+ - src/luadist/dist/package.lua
137
+ - src/luadist/dist/persist.lua
138
+ - src/luadist/dist/sys.lua
139
+ - src/luadist/doc/index.html
140
+ - src/luadist/doc/luadoc.css
141
+ - src/luadist/doc/modules/dist.dep.html
142
+ - src/luadist/doc/modules/dist.fetch.html
143
+ - src/luadist/doc/modules/dist.html
144
+ - src/luadist/doc/modules/dist.log.html
145
+ - src/luadist/doc/modules/dist.manifest.html
146
+ - src/luadist/doc/modules/dist.package.html
147
+ - src/luadist/doc/modules/dist.persist.html
148
+ - src/luadist/doc/modules/dist.sys.html
149
+ - src/luadist/luadist
125
150
  has_rdoc: true
126
151
  homepage: http://rubyluabridge.rubyforge.org
127
152
  licenses:
@@ -136,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
161
  requirements:
137
162
  - - ">="
138
163
  - !ruby/object:Gem::Version
139
- hash: -2275393015427977805
164
+ hash: 2597924468305270284
140
165
  segments:
141
166
  - 0
142
167
  version: "0"