summaryrefslogtreecommitdiff
path: root/scripts/granger/main.lua
blob: 304f45aa6e855be344f13a3b173cfd27d0e86c36 (plain)
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
--
-- main.lua
-- Granger main
-- Copyright (c) 2016 Jeff Kent <jeff@jkent.net>
--

require 'scripts/granger/lib'

local install_files = {}

if os.is('windows') then
    install_files = {
        "tremulous.exe"
        "tremded.exe"
        "granger.exe"
        "SDL264.dll"
        "renderer_opengl1.dll"
        "renderer_opengl2.dll"
    }
elseif os.is('linux') then
    install_files = {
        "tremulous"
        "tremded"
        "granger"
        "renderer_opengl1.so"
        "renderer_opengl2.so"
    }
elseif os.is('macosx') then
    install_files = {
        "tremulous"
        "tremded"
        "granger"
        "libSDL2-2.0.0.dylib"
        "renderer_opengl1.dylib"
        "renderer_opengl2.dylib"
    }
else 
    os.exit(1)
end

local dst_dir = path.getdirectory('.')
local dst_dir = path.getdirectory(_EXE_PATH)

local privs = false
for file in ipairs(install_files) do
    local src = path.join(src_dir, file)
    local dst = path.join(dst_dir, file)
    if not os.access(dst, 'w') then
        privs = true
    end
end

if privs then
    os.elevate()
end

for file in ipairs(install_files) do
    local src = path.join(src_dir, file)
    local dst = path.join(dst_dir, file)
    os.rename(src, dst)
end

--- Copyright (C) 2015-2019 GrangerHub