forked from Razish/japp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.lua
65 lines (55 loc) · 1.6 KB
/
package.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
--[[
JA++ Binaries Package Script
by Raz0r
Requires lua 5.1, lua-filesystem, 7zip
--]]
require "lfs" -- lua filesystem
if lfs == nil then
error( 'lua-filesystem not available for this version of lua (' .. _VERSION .. ')' )
end
local linux = true and package.config:find( '/' ) or false
local bits = (arg[1] == '64bit') and 64 or 32
local extension = linux and '.zip' or '.pk3'
local suffix = (linux and 'linux' or 'win') .. tostring( bits )
local libExt = linux and '.so' or '.dll'
local arch = ''
if linux then
arch = (bits == 32) and 'i386' or 'x86_64'
else
arch = (bits == 32) and 'x86' or 'x64'
end
local paks = {
['cl'] = {
['bins'] = { 'cgame' .. arch .. libExt, 'ui' .. arch .. libExt },
-- pdb for windows?
},
['sv'] = {
['bins'] = { 'jampgame' .. arch .. libExt },
-- pdb for windows?
}
}
for prefix,pak in pairs( paks ) do
for pakname,files in pairs( pak ) do
local filelist = ''
for _,file in pairs( files ) do
if lfs.touch( file ) == nil then
error( 'Missing file ' .. file )
else
filelist = filelist .. ' ' .. file -- append file name
end
end
filelist = string.sub( filelist, 2 ) -- remove the leading space
local outname = prefix .. '_' .. pakname .. '_' .. suffix .. extension
-- remove existing pak
if lfs.touch( outname ) ~= nil then
print( 'removing existing pak "' .. outname .. '"' )
os.remove( outname )
end
print( 'creating "' .. outname .. '"' )
if linux then
os.execute( '7z a -tzip -y ' .. outname .. ' ' .. filelist .. ' >/dev/null 2>&1' )
else
os.execute( '7z a -tzip -y ' .. outname .. ' ' .. filelist .. ' >nul 2>&1' )
end
end
end