-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathps3mfw_tasks.tcl
120 lines (100 loc) · 3.81 KB
/
ps3mfw_tasks.tcl
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
#!/usr/bin/tclsh
#
# ps3mfw -- PS3 MFW creator
#
# Copyright (C) Anonymous Developers (Code Monkeys)
#
# This software is distributed under the terms of the GNU General Public
# License ("GPL") version 3, as published by the Free Software Foundation.
#
proc ego {} {
puts "PS3MFW Creator v${::PS3MFW_VERSION}"
puts " Copyright (C) 2011 Project PS3MFW"
puts " This program comes with ABSOLUTELY NO WARRANTY;"
puts " This is free software, and you are welcome to redistribute it"
puts " under certain conditions; see COPYING for details."
puts ""
puts " Developed By :"
puts " Anonymous Developers"
puts ""
}
proc ego_gui {} {
log "PS3MFW Creator v${::PS3MFW_VERSION}"
log " Copyright (C) 2011 Project PS3MFW"
log " This program comes with ABSOLUTELY NO WARRANTY;"
log " This is free software, and you are welcome to redistribute it"
log " under certain conditions; see COPYING for details."
log ""
log " Developed By :"
log " Anonymous Developers"
log ""
}
proc clean_up {} {
log "Deleting output files"
catch_die {file delete -force -- ${::CUSTOM_PUP_DIR} ${::ORIGINAL_PUP_DIR} ${::OUT_FILE}} \
"Could not cleanup output files"
}
proc unpack_source_pup {pup dest} {
log "Unpacking source PUP [file tail ${pup}]"
catch_die {pup_extract ${pup} ${dest}} "Error extracting PUP file [file tail ${pup}]"
# Check for license.txt for people using older version of ps3tools
set license_txt [file join ${::CUSTOM_UPDATE_DIR} license.txt]
if {![file exists ${::CUSTOM_LICENSE_XML}] && [file exists ${license_txt}]} {
set ::CUSTOM_LICENSE_XML ${license_txt}
}
}
proc pack_custom_pup {dir pup} {
set build ${::PUP_BUILD}
set obuild [get_pup_build]
if {${build} == "" || ![string is integer ${build}] || ${build} == ${obuild}} {
set build ${obuild}
incr build
}
# create pup
log "Packing Modified PUP [file tail ${pup}]"
catch_die {pup_create ${dir} ${pup} $build} "Error packing PUP file [file tail ${pup}]"
}
proc build_mfw {input output tasks} {
global options
set ::selected_tasks [sort_tasks ${tasks}]
# print out ego info
ego_gui
if {${input} == "" || ${output} == ""} {
die "Must specify an input and output file"
}
if {![file exists ${input}]} {
die "Input file does not exist"
}
log "Selected tasks : ${::selected_tasks}"
if {[info exists ::env(HOME)]} {
debug "HOME=$::env(HOME)"
}
if {[info exists ::env(USERPROFILE)]} {
debug "USERPROFILE=$::env(USERPROFILE)"
}
if {[info exists ::env(PATH)]} {
debug "PATH=$::env(PATH)"
}
clean_up
# PREPARE PS3UPDAT.PUP for modification
unpack_source_pup ${input} ${::CUSTOM_PUP_DIR}
extract_tar ${::CUSTOM_UPDATE_TAR} ${::CUSTOM_UPDATE_DIR}
# copy original PUP to working dir
copy_file ${::CUSTOM_PUP_DIR} ${::ORIGINAL_PUP_DIR}
log "Unpacking all dev_flash files"
unpkg_devflash_all ${::CUSTOM_DEVFLASH_DIR}
# Execute tasks
foreach task ${::selected_tasks} {
log "******** Running task $task **********"
eval [string map {- _} ${task}::main]
}
log "******** Completed tasks **********"
# RECREATE PS3UPDAT.PUP
file delete -force ${::CUSTOM_DEVFLASH_DIR}
set files [lsort [glob -nocomplain -tails -directory ${::CUSTOM_UPDATE_DIR} *.pkg]]
eval lappend files [lsort [glob -nocomplain -tails -directory ${::CUSTOM_UPDATE_DIR} *.img]]
eval lappend files [lsort [glob -nocomplain -tails -directory ${::CUSTOM_UPDATE_DIR} dev_flash3_*]]
eval lappend files [lsort [glob -nocomplain -tails -directory ${::CUSTOM_UPDATE_DIR} dev_flash_*]]
create_tar ${::CUSTOM_UPDATE_TAR} ${::CUSTOM_UPDATE_DIR} ${files}
pack_custom_pup ${::CUSTOM_PUP_DIR} ${::OUT_FILE}
}