feat: implement proper build script
This commit is contained in:
parent
2e0e5a7ac5
commit
459b283f98
6 changed files with 304 additions and 58 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
|||
build
|
||||
.mpt
|
||||
|
|
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Notex 4 - LordMZTE's fork
|
||||
This is a fork of the Notex 4 pack with some tweaks and a proper build system.
|
||||
|
||||
## Building
|
||||
Dependencies:
|
||||
- a Racket toolchain
|
||||
- `json` (`raco pkg install json`)
|
||||
- `aria2c` or `wget`
|
112
build.rkt
Executable file
112
build.rkt
Executable file
|
@ -0,0 +1,112 @@
|
|||
#!/usr/bin/env racket
|
||||
#lang racket
|
||||
(require net/url
|
||||
json
|
||||
(prefix-in pack: "src/pack.rkt"))
|
||||
|
||||
(provide mod
|
||||
mod/cf)
|
||||
|
||||
(current-print void)
|
||||
(define do-clean (make-parameter #f))
|
||||
(command-line #:program "build.rkt"
|
||||
#:once-any [("-c" "--clean") "Delete build output instead of building"
|
||||
(do-clean #t)])
|
||||
|
||||
;; This is the API key used by the CurseForge launcher.
|
||||
;; Fuck you, CurseForge!
|
||||
(define cf-launcher-api-key "$2a$10$bL4bIL5pUWqfcO7KQtnMReakwtfHbNKh6v1uTpKlzhwoueEJQnPnm")
|
||||
|
||||
;; TODO: Find a HTTP lib for racket that works with CF's broken URL encoding implementation
|
||||
(define download-urls
|
||||
(match (find-executable-path "aria2c")
|
||||
[#f (match (find-executable-path "wget")
|
||||
[#f (raise-user-error "WGet or Aria2 is required!")]
|
||||
[wget-exe (λ (urls) (parameterize ([current-directory mods-dir])
|
||||
(apply system* #:set-pwd? #t wget-exe "--no-verbose" urls)))])]
|
||||
[aria-exe
|
||||
(λ (urls)
|
||||
(parameterize ([current-directory mods-dir])
|
||||
(match-let ([(list #f #f _ #f control)
|
||||
(process*/ports (current-output-port)
|
||||
(open-input-string (string-join urls "\n"))
|
||||
(current-error-port)
|
||||
#:set-pwd? #t
|
||||
aria-exe
|
||||
;; CF idiotically thinks they can block aria2 by detecting this header.
|
||||
"--no-want-digest-header"
|
||||
"--auto-file-renaming" "false"
|
||||
"--allow-overwrite" "true"
|
||||
"-i" "-"
|
||||
"-j" "8")])
|
||||
(control 'wait))))]))
|
||||
|
||||
;; Mods are collected in this list.
|
||||
(define mods '())
|
||||
|
||||
(define (mod url)
|
||||
(set! mods (cons url mods)))
|
||||
|
||||
(define (mod/cf pid fid)
|
||||
(printf "resolve CF: ~a:~a\n" pid fid)
|
||||
(let* ([url (string->url (format "https://api.curseforge.com/v1/mods/~a/files/~a/download-url" pid fid))]
|
||||
[response (call/input-url url get-pure-port read-json (list (format "x-api-key: ~a" cf-launcher-api-key)))]
|
||||
[mod-url (hash-ref response 'data)])
|
||||
(mod mod-url)))
|
||||
|
||||
|
||||
(define build-dir (build-path "build" pack:name))
|
||||
(when (do-clean)
|
||||
(when (directory-exists? build-dir)
|
||||
(delete-directory/files build-dir))
|
||||
(exit))
|
||||
|
||||
(define mods-dir (build-path build-dir "minecraft" "mods"))
|
||||
(make-directory* mods-dir)
|
||||
|
||||
(displayln "creating manifests")
|
||||
(with-output-to-file (build-path build-dir "instance.cfg") #:exists 'truncate/replace
|
||||
(λ ()
|
||||
(displayln "InstanceType=OneSix")
|
||||
(printf "name=~a\n" pack:name)
|
||||
(printf "ManagedPackName=~a\n" pack:name)
|
||||
(printf "ManagedPackVersionName=~a\n" pack:version)))
|
||||
|
||||
(let* ([components
|
||||
(list #hasheq((cachedName . "LWJGL 3")
|
||||
(cachedVersion . "3.2.2")
|
||||
(version . "3.2.2")
|
||||
(cachedVolatile . #t)
|
||||
(dependencyOnly . #t)
|
||||
(uid . "org.lwjgl3"))
|
||||
(hasheq 'cachedName "Minecraft"
|
||||
'cachedRequires '(#hasheq((suggests . "3.2.2")
|
||||
(uid . "org.lwjgl3")))
|
||||
'uid "net.minecraft"
|
||||
'cachedVersion pack:mc-version
|
||||
'version pack:mc-version
|
||||
'important #t)
|
||||
(hasheq 'cachedName "Forge"
|
||||
'cachedRequires (list (hasheq 'uid "net.minecraft"
|
||||
'equals pack:mc-version))
|
||||
'uid "net.minecraftforge"
|
||||
'cachedVersion pack:forge-version
|
||||
'version pack:forge-version))]
|
||||
[manifest (hasheq 'components components 'formatVersion 1)])
|
||||
(with-output-to-file (build-path build-dir "mmc-pack.json") #:exists 'truncate/replace
|
||||
(λ () (write-json manifest))))
|
||||
|
||||
(pack:mods)
|
||||
(printf "=== downloading the following URLs ===\n")
|
||||
(pretty-print mods)
|
||||
(download-urls mods)
|
||||
|
||||
(displayln "installing overrides")
|
||||
(let loop ([src "src/overrides"] [dest (build-path build-dir "minecraft")])
|
||||
(cond [(directory-exists? src)
|
||||
(unless (directory-exists? dest) (make-directory dest))
|
||||
(for ([subp (directory-list src)])
|
||||
(loop (build-path src subp) (build-path dest subp)))]
|
||||
[(file-exists? src)
|
||||
(copy-file src dest #:exists-ok? #t)]))
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
[Locations]
|
||||
#The location of the twitch manifest file (will be replaced with addonscript in later versions)
|
||||
manifestFile = "src/twitch/manifest.json"
|
||||
#The location of the source
|
||||
src = "src"
|
||||
#The location used to store temporary files
|
||||
tempDir = ".mpt"
|
||||
[Local]
|
||||
selectedVersion = -1
|
||||
[Downloads]
|
||||
#The maximum number of threads that will be used for downloads
|
||||
maxThreads = 5
|
||||
#The timeout of http requests in ms
|
||||
httpTimeout = 2147483647
|
43
mpt
43
mpt
|
@ -1,43 +0,0 @@
|
|||
#!/bin/sh
|
||||
cd "$(dirname "$0")" || exit
|
||||
case $1 in
|
||||
install)
|
||||
if ! [ -d "$HOME/.mpt" ];
|
||||
then mkdir $HOME/.mpt
|
||||
fi
|
||||
if ! [ -f "$HOME/.mpt/mpt.jar" ];
|
||||
then
|
||||
dl=$(curl https://data.tilera.xyz/api/mpt.php/latest)
|
||||
echo Downloading $dl ...
|
||||
curl $dl --output $HOME/.mpt/mpt.jar
|
||||
fi
|
||||
;;
|
||||
update)
|
||||
dl=$(curl https://data.tilera.xyz/api/mpt.php/latest)
|
||||
echo Downloading $dl ...
|
||||
if [ -f ".mpt/mpt.jar" ]
|
||||
then
|
||||
curl $dl --output .mpt/mpt.jar
|
||||
else
|
||||
curl $dl --output $HOME/.mpt/mpt.jar
|
||||
fi
|
||||
echo Updating Script
|
||||
curl https://data.tilera.xyz/api/mpt.php/script > mpt
|
||||
;;
|
||||
*)
|
||||
if ! [ -d ".mpt" ];
|
||||
then mkdir .mpt
|
||||
fi
|
||||
if [ -f ".mpt/mpt.jar" ];
|
||||
then jar=.mpt/mpt.jar
|
||||
elif [ -f "$HOME.mpt/mpt.jar" ];
|
||||
then jar=$HOME.mpt/mpt.jar
|
||||
else
|
||||
dl=$(curl https://data.tilera.xyz/api/mpt.php/latest)
|
||||
echo Downloading $dl ...
|
||||
curl $dl --output .mpt/mpt.jar
|
||||
jar=.mpt/mpt.jar
|
||||
fi
|
||||
java -jar $jar $*
|
||||
;;
|
||||
esac
|
184
src/pack.rkt
Normal file
184
src/pack.rkt
Normal file
|
@ -0,0 +1,184 @@
|
|||
#lang racket
|
||||
(require racket/lazy-require)
|
||||
(lazy-require ["../build.rkt" (mod mod/cf)])
|
||||
|
||||
(provide name
|
||||
version
|
||||
mc-version
|
||||
forge-version
|
||||
mods)
|
||||
|
||||
(define name "Notex 4")
|
||||
(define version "1.0.0")
|
||||
(define mc-version "1.18.2")
|
||||
(define forge-version "40.2.10")
|
||||
|
||||
(define (mods)
|
||||
(mod/cf 245506 4649325)
|
||||
(mod/cf 231382 4426917)
|
||||
(mod/cf 386134 4216216)
|
||||
(mod/cf 459929 4071160)
|
||||
(mod/cf 335673 4430268)
|
||||
(mod/cf 240950 4468504)
|
||||
(mod/cf 342543 4632805)
|
||||
(mod/cf 388172 4181370)
|
||||
(mod/cf 74924 4509007)
|
||||
(mod/cf 559313 3787188)
|
||||
(mod/cf 404468 4579981)
|
||||
(mod/cf 282001 4630521)
|
||||
(mod/cf 348521 4633387)
|
||||
(mod/cf 522992 4399032)
|
||||
(mod/cf 312353 4614546)
|
||||
(mod/cf 631923 4592311)
|
||||
(mod/cf 258426 4607606)
|
||||
(mod/cf 268566 3875978)
|
||||
(mod/cf 283644 4500363)
|
||||
(mod/cf 345425 3875980)
|
||||
(mod/cf 269024 4554183)
|
||||
(mod/cf 223565 4418000)
|
||||
(mod/cf 840734 4684881)
|
||||
(mod/cf 583345 4552152)
|
||||
(mod/cf 322896 3928750)
|
||||
(mod/cf 419699 4521465)
|
||||
(mod/cf 331936 3783096)
|
||||
(mod/cf 222880 4382339)
|
||||
(mod/cf 223622 3873885)
|
||||
(mod/cf 445385 4446200)
|
||||
(mod/cf 293752 3796423)
|
||||
(mod/cf 478939 4660563)
|
||||
(mod/cf 227443 4391159)
|
||||
(mod/cf 514923 3912758)
|
||||
(mod/cf 223852 3807626)
|
||||
(mod/cf 238222 4593548)
|
||||
(mod/cf 233105 4277564)
|
||||
(mod/cf 313970 4634636)
|
||||
(mod/cf 240630 4445746)
|
||||
(mod/cf 326041 4373521)
|
||||
(mod/cf 404360 3928749)
|
||||
(mod/cf 416089 4690551)
|
||||
(mod/cf 630092 3951871)
|
||||
(mod/cf 441647 4567924)
|
||||
(mod/cf 231484 4065856)
|
||||
(mod/cf 248619 3807867)
|
||||
(mod/cf 251389 4631540)
|
||||
(mod/cf 228525 4556713)
|
||||
(mod/cf 633483 4525198)
|
||||
(mod/cf 351748 4056696)
|
||||
(mod/cf 228702 4660558)
|
||||
(mod/cf 340666 4238585)
|
||||
(mod/cf 569849 4074347)
|
||||
(mod/cf 426386 3786356)
|
||||
(mod/cf 602059 4484352)
|
||||
(mod/cf 438784 3796950)
|
||||
(mod/cf 439890 4605624)
|
||||
(mod/cf 229049 4660560)
|
||||
(mod/cf 250231 3813964)
|
||||
(mod/cf 314906 4494633)
|
||||
(mod/cf 74072 4509008)
|
||||
(mod/cf 535933 3859302)
|
||||
(mod/cf 233398 4379418)
|
||||
(mod/cf 298187 4412996)
|
||||
(mod/cf 406360 4285099)
|
||||
(mod/cf 250577 3740180)
|
||||
(mod/cf 293426 4655485)
|
||||
(mod/cf 268560 3875976)
|
||||
(mod/cf 563928 3957976)
|
||||
(mod/cf 475335 4105519)
|
||||
(mod/cf 351264 4513187)
|
||||
(mod/cf 867328 4691908)
|
||||
(mod/cf 355440 4659835)
|
||||
(mod/cf 548599 3906977)
|
||||
(mod/cf 527361 4285040)
|
||||
(mod/cf 869316 4692543)
|
||||
(mod/cf 316867 3928753)
|
||||
(mod/cf 70496 3734491)
|
||||
(mod/cf 626708 4382885)
|
||||
(mod/cf 401955 4543053)
|
||||
(mod/cf 621711 3922792)
|
||||
(mod/cf 560323 3669114)
|
||||
(mod/cf 597824 3831430)
|
||||
(mod/cf 237333 4555761)
|
||||
(mod/cf 610632 4489732)
|
||||
(mod/cf 823046 4613500)
|
||||
(mod/cf 290209 4087998)
|
||||
(mod/cf 400954 3887446)
|
||||
(mod/cf 242195 4569313)
|
||||
(mod/cf 377448 3807783)
|
||||
(mod/cf 247007 4391353)
|
||||
(mod/cf 266784 3738448)
|
||||
(mod/cf 232758 4578150)
|
||||
(mod/cf 388282 3949460)
|
||||
(mod/cf 574300 3968835)
|
||||
(mod/cf 416294 4069880)
|
||||
(mod/cf 250363 3642382)
|
||||
(mod/cf 60089 3578801)
|
||||
(mod/cf 596879 3707321)
|
||||
(mod/cf 229048 4660559)
|
||||
(mod/cf 233780 3788395)
|
||||
(mod/cf 224218 3905502)
|
||||
(mod/cf 306770 3846086)
|
||||
(mod/cf 738663 4745202)
|
||||
(mod/cf 318646 3928751)
|
||||
(mod/cf 226410 3722831)
|
||||
(mod/cf 268567 3875979)
|
||||
(mod/cf 69163 4382343)
|
||||
(mod/cf 531761 4442615)
|
||||
(mod/cf 250294 3776175)
|
||||
(mod/cf 271835 4382340)
|
||||
(mod/cf 574856 4494903)
|
||||
(mod/cf 378609 4649845)
|
||||
(mod/cf 250398 4555742)
|
||||
(mod/cf 289712 4029100)
|
||||
(mod/cf 69162 4385215)
|
||||
(mod/cf 293425 4655617)
|
||||
(mod/cf 426558 3853078)
|
||||
(mod/cf 236307 4646705)
|
||||
(mod/cf 539097 4033023)
|
||||
(mod/cf 320926 4059979)
|
||||
(mod/cf 247921 4571447)
|
||||
(mod/cf 626839 4066820)
|
||||
(mod/cf 229045 4660562)
|
||||
(mod/cf 347706 4515002)
|
||||
(mod/cf 324717 4575623)
|
||||
(mod/cf 303278 3907553)
|
||||
(mod/cf 399558 4393837)
|
||||
(mod/cf 404465 4396792)
|
||||
(mod/cf 241665 4478796)
|
||||
(mod/cf 224791 3953207)
|
||||
(mod/cf 342466 4380977)
|
||||
(mod/cf 271740 3929072)
|
||||
(mod/cf 489843 4145521)
|
||||
(mod/cf 266515 4401654)
|
||||
(mod/cf 247560 4036050)
|
||||
(mod/cf 231095 4119191)
|
||||
(mod/cf 406959 4382347)
|
||||
(mod/cf 250763 4379832)
|
||||
(mod/cf 309927 4590652)
|
||||
(mod/cf 225643 3936568)
|
||||
(mod/cf 242830 3962438)
|
||||
(mod/cf 362479 3810570)
|
||||
(mod/cf 465066 3678612)
|
||||
(mod/cf 314515 4411032)
|
||||
(mod/cf 287342 4484519)
|
||||
(mod/cf 248020 4095061)
|
||||
(mod/cf 566563 3816078)
|
||||
(mod/cf 351914 3788376)
|
||||
(mod/cf 291737 4382344)
|
||||
(mod/cf 306935 3812852)
|
||||
(mod/cf 245174 3951068)
|
||||
(mod/cf 229046 4660561)
|
||||
(mod/cf 295319 3597135)
|
||||
(mod/cf 457570 4462832)
|
||||
(mod/cf 350006 4069708)
|
||||
(mod/cf 549381 4626919)
|
||||
(mod/cf 242818 4607274)
|
||||
(mod/cf 298744 3909656)
|
||||
(mod/cf 456171 4171033)
|
||||
(mod/cf 495509 3931224)
|
||||
(mod "https://maven.tilera.xyz/com/simibubi/create/create-1.18.2/0.5.1.c/create-1.18.2-0.5.1.c-all.jar")
|
||||
(mod "https://maven.tilera.xyz/com/teammoeg/steampowered/1.18.2-2.0.4-alpha/steampowered-1.18.2-2.0.4-alpha.jar")
|
||||
(mod "https://cdn.modrinth.com/data/XxWD5pD3/versions/qf2Yz73T/appliedenergistics2-forge-11.7.4.jar")
|
||||
(mod "https://cdn.modrinth.com/data/ncAcdgk7/versions/S69uHAZo/pneumaticcraft-repressurized-1.18.2-3.6.0-19.jar")
|
||||
(mod "https://cdn.modrinth.com/data/HmLJoQ1K/versions/A9UPRxAS/IntegratedTerminals-1.18.2-1.4.9.jar")
|
||||
(mod "https://maven.tilera.xyz/net/anvilcraft/anvillib-18-forge/0.2.1/anvillib-18-forge-0.2.1.jar")
|
||||
(mod "https://maven.tilera.xyz/com/cursedcauldron/wildbackport-forge/2.0.0/wildbackport-forge-2.0.0.jar"))
|
Loading…
Reference in a new issue