diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/grindem.sh | 40 | ||||
-rwxr-xr-x | bin/killem.sh | 21 | ||||
-rwxr-xr-x | bin/unpacker.lua | 105 |
3 files changed, 166 insertions, 0 deletions
diff --git a/bin/grindem.sh b/bin/grindem.sh new file mode 100755 index 0000000..96edc5d --- /dev/null +++ b/bin/grindem.sh | |||
@@ -0,0 +1,40 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Memory checker, and the default tool. | ||
4 | # --tool=memcheck --leak-check=full | ||
5 | # --track-origins=yes | ||
6 | |||
7 | # Cache and branch prediction profiler, analyse speed issues. | ||
8 | # --tool=cachegrind | ||
9 | # --branch-sim=yes | ||
10 | |||
11 | # Heap profiler, check memory sizes. | ||
12 | # --tool=massif | ||
13 | |||
14 | # Heap profiler. | ||
15 | # --tool=dhat | ||
16 | |||
17 | # "Call-graph generating cache profiler", complements cachegrind. | ||
18 | # --tool=callgrind | ||
19 | |||
20 | # Thread error detector. | ||
21 | # --tool=helgrind | ||
22 | |||
23 | # Thread error detector. | ||
24 | # --tool=drd | ||
25 | |||
26 | # "experimental tool that can detect overruns of stack and global arrays" | ||
27 | # --tool=sgcheck | ||
28 | |||
29 | tool="memcheck" | ||
30 | #tool="helgrind" | ||
31 | #tool="drd" | ||
32 | #extra="" | ||
33 | extra="--leak-check=full" | ||
34 | |||
35 | valgrind --tool=$tool --time-stamp=yes --log-file=valgrind_LuaSL.log $extra ./LuaSL & | ||
36 | sleep 3 | ||
37 | valgrind --tool=$tool --time-stamp=yes --log-file=valgrind_love.log $extra ./love & | ||
38 | sleep 3 | ||
39 | valgrind --tool=$tool --time-stamp=yes --log-file=valgrind_extantz.log $extra ./extantz | ||
40 | |||
diff --git a/bin/killem.sh b/bin/killem.sh new file mode 100755 index 0000000..7b4d3a2 --- /dev/null +++ b/bin/killem.sh | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # TODO - Deal with the valgrind left overs, by scanning the output of the following lines, picking out the PIDs, then "kill -KILL pid" | ||
4 | ps aux | grep love | ||
5 | ps aux | grep LuaSL | ||
6 | |||
7 | killall -TERM love | ||
8 | sleep 1 | ||
9 | killall -TERM LuaSL | ||
10 | sleep 1 | ||
11 | |||
12 | ps aux | grep love | ||
13 | ps aux | grep LuaSL | ||
14 | |||
15 | killall -KILL love | ||
16 | sleep 1 | ||
17 | killall -KILL LuaSL | ||
18 | sleep 1 | ||
19 | |||
20 | ps aux | grep love | ||
21 | ps aux | grep LuaSL | ||
diff --git a/bin/unpacker.lua b/bin/unpacker.lua new file mode 100755 index 0000000..c60ef30 --- /dev/null +++ b/bin/unpacker.lua | |||
@@ -0,0 +1,105 @@ | |||
1 | #!/usr/bin/env luajit | ||
2 | |||
3 | local args = ... | ||
4 | local tmpFile = os.tmpname() | ||
5 | |||
6 | readCommand = function (command) | ||
7 | os.execute(command .. ' >' .. tmpFile) | ||
8 | local tf = io.open(tmpFile, 'r') | ||
9 | local result = tf:read() | ||
10 | tf:close() | ||
11 | return result | ||
12 | end | ||
13 | |||
14 | function scanDir(directory) | ||
15 | local i, t, popen = 0, {}, io.popen | ||
16 | -- for filename in popen('dir "'..directory..'" /b'):lines() do | ||
17 | for filename in popen('ls -AF "'..directory..'"'):lines() do | ||
18 | i = i + 1 | ||
19 | t[i] = filename | ||
20 | end | ||
21 | return t | ||
22 | end | ||
23 | |||
24 | |||
25 | --workingDir = readCommand('pwd') | ||
26 | --baseDir = workingDir | ||
27 | --baseDir = string.gsub(baseDir, '(.*)/.-$', '%1') | ||
28 | |||
29 | --bin_d = baseDir .. '' | ||
30 | --lib_d = baseDir .. '/lib' | ||
31 | --data_d = baseDir .. '/media' | ||
32 | --locale_d = baseDir .. '/locale' | ||
33 | home_d = readCommand('echo "$HOME"') | ||
34 | |||
35 | |||
36 | unpackers = | ||
37 | { | ||
38 | iar = function (src, dst) return('tar -xzf ' .. src .. ' -C ' .. dst) end, | ||
39 | oar = function (src, dst) return('tar -xzf ' .. src .. ' -C ' .. dst) end, | ||
40 | rar = function (src, dst) return('unrar x ' .. src .. ' ' .. dst) end, | ||
41 | tar_bz2 = function (src, dst) return('tar -xzf ' .. src .. ' -C ' .. dst) end, | ||
42 | tar_gz = function (src, dst) return('tar -xzf ' .. src .. ' -C ' .. dst) end, | ||
43 | tgz = function (src, dst) return('tar -xzf ' .. src .. ' -C ' .. dst) end, | ||
44 | zip = function (src, dst) return('unzip ' .. src .. ' -d ' .. dst) end, | ||
45 | } | ||
46 | |||
47 | --[[ TODO | ||
48 | Make it accept arguments - file dir | ||
49 | file = archive file, or directory to scan | ||
50 | dir = output directory | ||
51 | |||
52 | If it's an OAR, or other sim defining format, or a model format, then create .omg files, stuff into .cache/converted/ or inventory/converted. | ||
53 | Or should conversion be a separate tool? | ||
54 | The problem is that we need to link back to the original archive, or carry other info like the archive type with us from here. | ||
55 | So might as well start the process by creating basic .omg files, with the info we have here, before we lose that info. | ||
56 | |||
57 | ]] | ||
58 | |||
59 | print('Searching for archives in ' .. home_d .. '/.SledjHamr', ' -> ', ' unpack into ' .. home_d .. '/.SledjHamr/.cache/unpacked/') | ||
60 | |||
61 | for k, v in pairs(scanDir(home_d .. '/.SledjHamr')) do | ||
62 | |||
63 | -- First find if there's one of the special flags at the end, and strip it off. | ||
64 | t = string.sub(v, -1, -1) | ||
65 | v = string.sub(v, 1, -2) | ||
66 | f = true | ||
67 | if '@' == t then t = t | ||
68 | elseif '*' == t then t = t | ||
69 | elseif '/' == t then f = false | ||
70 | elseif '=' == t then t = t | ||
71 | elseif '>' == t then t = t | ||
72 | elseif '|' == t then t = t | ||
73 | else v = v .. t; t = ' '; | ||
74 | end | ||
75 | |||
76 | -- Figure out what sort of file it is. | ||
77 | name, ext = string.match(v, "(.*)%.(.*)$") | ||
78 | if f and nil ~= ext then | ||
79 | name1, tar = string.match(name, "(.*)%.(.*)$") | ||
80 | if 'tar' == tar then | ||
81 | name = name1 | ||
82 | ext = tar .. '_' .. ext | ||
83 | end | ||
84 | |||
85 | ext = string.lower(ext) | ||
86 | u = unpackers[ext] | ||
87 | if nil ~= u then | ||
88 | src = home_d .. '/.SledjHamr/' .. v | ||
89 | dst = home_d .. '/.SledjHamr/.cache/unpacked/' .. name | ||
90 | |||
91 | os.execute('rm -fr ' .. dst) | ||
92 | os.execute('mkdir -p ' .. dst) | ||
93 | print('un' .. string.upper(ext) .. 'ing ', '"' .. v .. '"', ' -> ', '"' .. name .. '"') | ||
94 | if '@' == t then print(' ' .. v, ' is a soft link.') | ||
95 | elseif '*' == t then print(' ' .. v, ' is an executable.') | ||
96 | elseif '/' == t then print(' ' .. v, ' is a directory.'); | ||
97 | elseif '=' == t then print(' ' .. v, ' is a socket.') | ||
98 | elseif '>' == t then print(' ' .. v, ' is a door.') | ||
99 | elseif '|' == t then print(' ' .. v, ' is a FIFO.') | ||
100 | -- else print(' ' .. v, ' is an ordinary file.') | ||
101 | end | ||
102 | os.execute(u(src, dst) .. ' >/dev/null') | ||
103 | end | ||
104 | end | ||
105 | end | ||