-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmake.rkt
121 lines (106 loc) · 4.97 KB
/
make.rkt
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
;; Copyright (C) 2022 veden
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(require file/zip)
(require json)
(define modFolder "/mnt/gallery/gameFiles/factorio/mods/")
(define zipModFolder "/data/games/factorio/mods/")
(define configuration (call-with-input-file "info.json"
(lambda (port)
(string->jsexpr (port->string port)))))
(define packageName (string-append (string-replace (hash-ref configuration 'name) " " "_")
"_"
(hash-ref configuration 'version)))
(define (makeZip folder)
(let ((packagePath (string->path (string-append folder
packageName
".zip"))))
(delete-directory/files (string->path (string-append folder
packageName)))
(when (file-exists? packagePath)
(delete-file packagePath)))
(zip (string-append folder
packageName
".zip")
#:path-prefix packageName
(string->path "info.json")
(string->path "control.lua")
(string->path "data.lua")
(string->path "thumbnail.png")
(string->path "data-updates.lua")
(string->path "data-final-fixes.lua")
(string->path "changelog.txt")
(string->path "COPYING")
(string->path "settings.lua")
(string->path "README.md")
(string->path "NOTICE")
(string->path "libs")
(string->path "migrations")
(string->path "locale")
(string->path "graphics")
(string->path "prototypes")))
(define (copyFile fileName modFolder)
(copy-file (string->path fileName)
(string->path (string-append modFolder
packageName
"/"
fileName))))
(define (copyDirectory directoryName modFolder)
(copy-directory/files (string->path directoryName)
(string->path (string-append modFolder
packageName
"/"
directoryName))))
(define (copyFiles modFolder)
(let ((packagePath (string->path (string-append modFolder
packageName))))
(when (directory-exists? packagePath)
(delete-directory/files packagePath))
(sleep 0.1)
(make-directory packagePath)
(copyFile "control.lua" modFolder)
(copyFile "info.json" modFolder)
(copyFile "data.lua" modFolder)
(copyFile "data-updates.lua" modFolder)
(copyFile "data-final-fixes.lua" modFolder)
(copyFile "COPYING" modFolder)
(copyFile "thumbnail.png" modFolder)
(copyFile "changelog.txt" modFolder)
(copyFile "settings.lua" modFolder)
(copyFile "NOTICE" modFolder)
(copyDirectory "libs" modFolder)
(copyDirectory "migrations" modFolder)
(copyDirectory "locale" modFolder)
(copyDirectory "graphics" modFolder)
(copyDirectory "prototypes" modFolder)))
(define (copy)
(set! configuration (call-with-input-file "info.json"
(lambda (port)
(string->jsexpr (port->string port)))))
(set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_")
"_"
(hash-ref configuration 'version)))
(print (string-append "copying " (hash-ref configuration 'name) (hash-ref configuration 'version)))
(copyFiles modFolder))
(define (zipIt)
(set! configuration (call-with-input-file "info.json"
(lambda (port)
(string->jsexpr (port->string port)))))
(set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_")
"_"
(hash-ref configuration 'version)))
(print (string-append "zipping " (hash-ref configuration 'name) (hash-ref configuration 'version)))
(makeZip modFolder))
(define (runStart)
;; (copyFiles modFolder)
;;(copyFiles zipModFolder)
(makeZip modFolder)
(system*/exit-code "factorio"))