mirror of
https://wiilab.wiimart.org/wiimart/WiiMart-Patcher
synced 2025-09-04 04:21:19 +02:00
Add coloring to progress output
This commit is contained in:
parent
c597e8f17d
commit
b15a4059bf
1
go.mod
1
go.mod
@ -3,6 +3,7 @@ module github.com/OpenShopChannel/WSC-Patcher
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/logrusorgru/aurora/v3 v3.0.0
|
||||
github.com/wii-tools/GoNUSD v0.2.1
|
||||
github.com/wii-tools/arclib v1.0.0
|
||||
github.com/wii-tools/wadlib v0.3.0
|
||||
|
2
go.sum
2
go.sum
@ -1,3 +1,5 @@
|
||||
github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4=
|
||||
github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
|
||||
github.com/wii-tools/GoNUSD v0.2.1 h1:HW8vssrEiCdFjiugCx3cTTaPw9nlz1TWxzeCqXKqTnQ=
|
||||
github.com/wii-tools/GoNUSD v0.2.1/go.mod h1:jMYMU5X81Hp0R+bq6/0AxAOijGHXfexaG6dLRilgS2s=
|
||||
github.com/wii-tools/arclib v1.0.0 h1:OAmbL3NDUmlR0wa1VpJhxnKiIRFZz1CC40lTVPUm8Ms=
|
||||
|
14
main.go
14
main.go
@ -3,10 +3,12 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/logrusorgru/aurora/v3"
|
||||
"github.com/wii-tools/GoNUSD"
|
||||
"github.com/wii-tools/arclib"
|
||||
"github.com/wii-tools/wadlib"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
@ -20,6 +22,8 @@ var mainDol []byte
|
||||
// mainArc holds the main ARC - our content at index 2.
|
||||
var mainArc *arclib.ARC
|
||||
|
||||
// rootCertificate holds the public certificate, in DER form, to be patched in.
|
||||
var rootCertificate []byte
|
||||
|
||||
// filePresent returns whether the specified path is present on disk.
|
||||
func filePresent(path string) bool {
|
||||
@ -77,7 +81,7 @@ func main() {
|
||||
|
||||
// Determine whether a certificate authority was provided, or generated previously.
|
||||
if !filePresent("./output/root.cer") {
|
||||
log.Println("Generating root certificates...")
|
||||
fmt.Println(aurora.Green("Generating root certificates..."))
|
||||
rootCertificate = createCertificates()
|
||||
} else {
|
||||
rootCertificate, err = ioutil.ReadFile("./output/root.cer")
|
||||
@ -101,9 +105,11 @@ func main() {
|
||||
originalWad.TMD.AccessRightsFlags = 0x3
|
||||
|
||||
// Apply all DOL patches
|
||||
log.Println("Applying DOL patches...")
|
||||
fmt.Println(aurora.Green("Applying DOL patches..."))
|
||||
applyDefaultPatches()
|
||||
|
||||
ioutil.WriteFile("/Users/spot/Desktop/patched.app", mainDol, 0755)
|
||||
|
||||
// Load main ARC
|
||||
arcData, err := originalWad.GetContent(2)
|
||||
check(err)
|
||||
@ -111,7 +117,7 @@ func main() {
|
||||
check(err)
|
||||
|
||||
// Generate filter list and certificate store
|
||||
log.Println("Applying Opera patches...")
|
||||
fmt.Println(aurora.Green("Applying Opera patches..."))
|
||||
modifyAllowList()
|
||||
generateOperaCertStore()
|
||||
|
||||
@ -125,7 +131,7 @@ func main() {
|
||||
output, err := originalWad.GetWAD(wadlib.WADTypeCommon)
|
||||
check(err)
|
||||
|
||||
log.Println("Done! Install ./output/patched.wad, sit back, and enjoy.")
|
||||
fmt.Println(aurora.Green("Done! Install ./output/patched.wad, sit back, and enjoy."))
|
||||
writeOut("patched.wad", output)
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,8 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"log"
|
||||
"fmt"
|
||||
"github.com/logrusorgru/aurora/v3"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -35,7 +36,7 @@ type PatchSet []Patch
|
||||
func applyPatch(patch Patch) error {
|
||||
// Print name if present
|
||||
if patch.Name != "" {
|
||||
log.Println("Applying patch " + patch.Name)
|
||||
fmt.Println(" + Applying patch", aurora.Cyan(patch.Name))
|
||||
}
|
||||
|
||||
// Ensure consistency
|
||||
@ -63,7 +64,7 @@ func applyPatch(patch Patch) error {
|
||||
|
||||
// applyPatchSet iterates through all possible patches, noting their name.
|
||||
func applyPatchSet(setName string, set PatchSet) {
|
||||
log.Printf("Handling patch set \"%s\":", setName)
|
||||
fmt.Printf("Handling patch set \"%s\":\n", aurora.Yellow(setName))
|
||||
|
||||
for _, patch := range set {
|
||||
err := applyPatch(patch)
|
||||
|
Loading…
x
Reference in New Issue
Block a user