-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_rockspec.lua
executable file
·89 lines (82 loc) · 2.81 KB
/
update_rockspec.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env lua
print("enter a new version:")
version = string.match(io.read(), "v?([%d]+.[%d]+-[%d]+)")
assert(version ~= nil)
rockspec = {
package = "chronos",
version = version,
source = {
url = "https://github.com/ldrumm/chronos/archive/v" .. version .. ".zip",
dir= "chronos-" .. version,
tag = "v" .. version
},
description = {
summary = "High resolution monotonic timers",
detailed = [[
Wrappers around a number of platform-specific monotonic timers. The
highest resolution timer on each platform is used. This is typically
clock_gettime, gettimeofday, QueryPerformanceCounter, or similar
depending on the capabilities of the host. On a modern Linux system,
nanosecond precision is achievable.
]],
homepage = "https://github.com/ldrumm/chronos",
license = "MIT/X11"
},
dependencies = {
"lua >= 5.1"
},
build = {
platforms = {
unix = {
modules = {
chronos = {
sources = "src/chronos.c",
libraries = {"rt"},
},
},
},
macosx = {
modules = {
chronos = "src/chronos.c",
}
},
},
type = "builtin",
modules = {
chronos = "src/chronos.c",
}
}
}
do
local function writerockspec(file, rockspec, indent)
local comma = indent and "," or ""
indent = indent or 0
for k, v in pairs(rockspec) do
if type(v) == "table" then
file:write("\n")
file:write(string.rep("\t", indent) .. string.format("%s = {\n", k))
writerockspec(file, v, indent + 1)
file:write(string.rep("\t", indent) .. string.format("}%s\n", comma))
else
if(type(k) == "string") then
file:write(string.rep("\t", indent) .. string.format("%s = %q%s\n", k, v, comma))
elseif(type(k) == "number") then
file:write(string.rep("\t", indent) .. string.format("%q%s\n", v, comma))
else
file:write("rockspec can't contain key of type:" .. type(k))
end
end
end
end
local update_git
while update_git == nil do
print(string.format("Do 'git add . && commit -a && git tag v%s'?[yes/NO]", version))
update_git = io.read() == "yes"
end
local out = io.open(string.format("rockspecs/%s-%s.rockspec", rockspec.package, version ), "w")
writerockspec(out, rockspec)
out:flush()
if update_git then
os.execute(string.format('git add . && git commit -a && git tag v%s', version))
end
end