1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-03 22:52:20 +02:00
Rampant/make.rkt

138 lines
5.6 KiB
Racket
Raw Normal View History

2022-01-15 00:08:58 +02:00
;; 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/>.
2020-11-29 03:53:41 +02:00
(require file/zip)
(require json)
2020-11-29 03:53:41 +02:00
(define modFolder "/mnt/gallery/gameFiles/factorio/mods/")
2021-03-29 07:00:49 +02:00
(define serverModFolder "/home/veden/Downloads/factorio/mods/")
2020-11-29 03:53:41 +02:00
(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)))
2020-11-29 03:53:41 +02:00
(define (makeZip folder)
(let ((packagePath (string->path (string-append folder
packageName
2021-04-16 23:15:35 +02:00
".zip")))
(unzippedPath (string->path (string-append folder
packageName))))
(delete-directory/files unzippedPath)
2020-11-29 03:53:41 +02:00
(when (file-exists? packagePath)
(delete-file packagePath)))
2021-04-16 23:15:35 +02:00
2020-11-29 03:53:41 +02:00
(zip (string-append folder
packageName
".zip")
#:path-prefix packageName
(string->path "info.json")
(string->path "control.lua")
(string->path "data.lua")
(string->path "data-updates.lua")
(string->path "data-final-fixes.lua")
2022-01-17 19:35:04 +02:00
(string->path "COPYING")
2020-11-29 03:53:41 +02:00
(string->path "tests.lua")
(string->path "changelog.txt")
(string->path "Upgrade.lua")
(string->path "settings.lua")
(string->path "README.md")
(string->path "thumbnail.png")
2022-04-23 06:03:34 +02:00
(string->path "NOTICE")
2020-11-29 03:53:41 +02:00
(string->path "libs")
(string->path "sounds")
(string->path "migrations")
(string->path "locale")
(string->path "graphics")
(string->path "prototypes")))
2020-11-29 03:53:41 +02:00
(define (copyFile fileName modFolder)
(copy-file (string->path fileName)
(string->path (string-append modFolder
packageName
"/"
fileName))))
2020-11-29 03:53:41 +02:00
(define (copyDirectory directoryName modFolder)
(copy-directory/files (string->path directoryName)
(string->path (string-append modFolder
packageName
"/"
directoryName))))
2020-11-29 03:53:41 +02:00
(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)
2022-04-23 06:03:34 +02:00
(copyFile "COPYING" modFolder)
(copyFile "NOTICE" modFolder)
(copyFile "README.md" modFolder)
2020-11-29 03:53:41 +02:00
(copyFile "data-updates.lua" modFolder)
(copyFile "data-final-fixes.lua" modFolder)
(copyFile "settings.lua" modFolder)
(copyFile "changelog.txt" modFolder)
(copyFile "Upgrade.lua" modFolder)
(copyFile "tests.lua" modFolder)
2021-04-16 23:15:35 +02:00
(copyFile "thumbnail.png" modFolder)
2020-11-29 03:53:41 +02:00
(copyDirectory "libs" modFolder)
(copyDirectory "locale" modFolder)
(copyDirectory "migrations" modFolder)
(copyDirectory "sounds" modFolder)
(copyDirectory "graphics" modFolder)
(copyDirectory "prototypes" modFolder)))
2020-11-29 03:53:41 +02:00
(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)))
2018-09-26 07:14:13 +02:00
2020-11-29 03:53:41 +02:00
(print (string-append "copying " (hash-ref configuration 'name) (hash-ref configuration 'version)))
2021-03-29 07:00:49 +02:00
(copyFiles modFolder)
;; (copyFiles serverModFolder)
)
2020-04-13 00:41:45 +02:00
2020-11-29 03:53:41 +02:00
(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))
2018-09-26 07:14:13 +02:00
2020-11-29 03:53:41 +02:00
(define (runStart)
(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)))
(copyFiles modFolder)
(system*/exit-code "factorio"))