-
Notifications
You must be signed in to change notification settings - Fork 194
/
install-info.lua
74 lines (62 loc) · 2.03 KB
/
install-info.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
-- Log installation info to install-info.txt
--[====[
install-info
============
Saves information about the current DFHack installation to ``install-info.txt``
in the current DF folder. Useful for bug reports.
]====]
local utils = require 'utils'
local f = io.open(dfhack.getDFPath() .. '/install-info.txt', 'w')
function log(...)
local text = table.concat({...}, '')
if not f then
print(text)
else
f:write(text .. '\n')
end
end
log('DFHack ', dfhack.getDFHackVersion(), ' on ', dfhack.getOSType(),
'/', dfhack.getArchitectureName())
log('\nVersion information:')
function log_version(text, func_name)
log(' ', text, ': ', tostring(dfhack[func_name]()))
end
log_version('DF version', 'getDFVersion')
log_version('DFHack version', 'getDFHackVersion')
log_version('DFHack release', 'getDFHackRelease')
log_version('DFHack build ID', 'getDFHackBuildID')
log_version('Compiled DF version', 'getCompiledDFVersion')
log_version('Git description', 'getGitDescription')
log_version('Git commit', 'getGitCommit')
log_version('Git XML commit', 'getGitXmlCommit')
log_version('Git XML expected commit', 'getGitXmlExpectedCommit')
log_version('Git XML match', 'gitXmlMatch')
log_version('Is release', 'isRelease')
log_version('Is prerelease', 'isPrerelease')
log_version('Is world loaded', 'isWorldLoaded')
log_version('Is map loaded', 'isMapLoaded')
function log_command(cmd)
log('\nOutput of "' .. cmd .. '":')
local output = select(1, dfhack.run_command_silent(cmd))
for _, line in pairs(output:split('\n')) do
log(' ' .. line)
end
end
log_command('devel/save-version')
log_command('plug')
log('Tweak log entries:')
if not pcall(function()
for line in io.lines('stderr.log') do
if line:match('tweak') then
log(' ' .. line)
end
end
end) then
log('Failed to read stderr.log')
end
if not f then
qerror('Could not write to install-info.txt.\nCopy the above text instead.')
else
f:close()
print('Saved to:\n' .. dfhack.getDFPath() .. '/install-info.txt')
end