Advertisement
mkv

ever17 psp patcher

mkv
May 4th, 2017
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.02 KB | None | 0 0
  1. #!/bin/bash
  2. #######################################################################
  3. #
  4. #  linux patcher for ever17
  5. #  tested on xubuntu and alpine linux
  6. #  license for this script: http://www.wtfpl.net/
  7. #
  8. #######################################################################
  9.  
  10. # abort if something goes bad
  11. set -e
  12.  
  13. # fancy status messages
  14. function out() { printf "    $@\n"; }
  15. function msg() { printf   "\033[0;33m[*]\033[0m $@\n" "$@"; }
  16. function inf() { printf "\n\033[1;32m[+]\033[0m $@\n" "$@"; }
  17. function err() { printf "\n\033[1;31m[-]\033[0m $@\n" "$@"; }
  18. function ask() { printf "\n\033[1;37m[>]\033[0m "; read -u1 -r; echo; }
  19.  
  20. # say hi
  21. inf "Ever17 PSP English Patch Beta 2  (linux patcher v1)"
  22.  
  23.  
  24. msg "checking that all dependencies are installed"
  25. function have()
  26. {
  27.     which "$1" >/dev/null 2>/dev/null ||
  28.     {
  29.         err "the program '$1' is not installed"
  30.         out "please install $2"
  31.         echo
  32.         exit 1
  33.     }
  34. }
  35. have mkisofs "'cdrtools' or 'cdrkit'"
  36. have isoinfo "'cdrtools' or 'cdrkit'"
  37. have xdelta3 it
  38.  
  39.  
  40. msg "checking that your xdelta3 works"
  41. function xdelta3unusable()
  42. {
  43.     strings "$(which xdelta3)" |
  44.     grep LZMA |
  45.     grep -iq unavailable
  46. }
  47.  
  48. xdelta3unusable &&
  49. {
  50.     err "your xdelta3 is probably unusable:"
  51.     out "the translation patch uses LZMA compression,"
  52.     out "your xdelta3 seems to have LZMA disabled."
  53.     inf "that said, this MIGHT work after all... wanna try?"
  54.     echo
  55.     out "CTRL-C  to abort"
  56.     out "ENTER   to continue"
  57.     ask
  58. }
  59.  
  60.  
  61. msg "checking that your mkisofs works"
  62. strings "$(which mkisofs)" | grep -qE 'xorriso %d.%d' &&
  63. {
  64.     err "wrong version of mkisofs"
  65.     echo
  66.     out "you have xorriso installed,"
  67.     out "this conflicts with the real mkisofs from cdrkit."
  68.     out "please temporarily uninstall xorriso/libburn"
  69.     out "(usually pulled in by alpine-sdk)"
  70.     out "then reinstall cdrkit"
  71.     echo
  72.     exit 1
  73. }
  74.  
  75.  
  76. # need to make sure we are in the correct directory
  77. # (same directory as this script is in)
  78. self="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  79. oldpwd="$(pwd)"
  80. cd "$self"
  81. newpwd="$(pwd)"
  82. [[ "x$oldpwd" == "x$newpwd" ]] ||
  83.     msg "changing directory to $newpwd"
  84.  
  85.  
  86. msg "checking that you have enough disk space"
  87. free=$(
  88.     df -PBM . | tail -n 1 |
  89.     awk '{sub(/M$/, "", $4); print $4}' ||
  90.     echo 99999999
  91. )
  92. needed=3206
  93. needed=$((needed+128))
  94. [[ $free -lt $needed ]] &&
  95. {
  96.     err "not enough disk space"
  97.     err "in the folder where this script is located:"
  98.     out "you have $free MB free"
  99.     out " we need $needed MB free"
  100.     echo
  101.     msg "move the patch folder and try again"
  102.     exit 1
  103. }
  104.  
  105.  
  106. # read the iso filename
  107. arg="$1"
  108. [[ "x$arg" == "x" ]] &&
  109. {
  110.     err 'need mandatory argument 1:'
  111.     out 'path to the ever17 iso file'
  112.     echo
  113.     out "example:  $0  ~/games/ever17.iso"
  114.     echo
  115.     exit 1
  116. }
  117.  
  118.  
  119. msg "checking that the iso exists"
  120. iso="$arg"
  121.  
  122. [[ -s "$iso" ]] ||
  123.     # maybe it was a relative path
  124.     iso="$oldpwd/$arg"
  125.  
  126. [[ -s "$iso" ]] ||
  127. {
  128.     err 'could not read the iso file:'
  129.     out "$arg"
  130.     echo
  131.     exit 1
  132. }
  133.  
  134.  
  135. # all tests ok
  136. inf "unpacking iso"
  137. rm -rf ISO 2>/dev/null || true
  138.  
  139. # get a list of all the files in the iso
  140. isoinfo -i "$iso" -f |
  141.  
  142. # normalize the output, just in case some
  143. # versions of isoinfo should appear different
  144. sed -r 's@^/@@;s@^@ISO/@' |
  145. while read path
  146. do
  147.     dir="${path%/*}"
  148.     file="${path##*/}"
  149.    
  150.     # don't care about directories
  151.     [[ "$file" =~ \. ]] ||
  152.         continue
  153.    
  154.     msg "extracting  $dir/$file"
  155.     mkdir -p "$dir"
  156.    
  157.     # remove ISO from the start of the string
  158.     isoinfo -i "$iso" -x "${path:3}" > "$path"
  159.    
  160.     [[ -s "$path" ]] ||
  161.         # this version of isoinfo expects no leading slash
  162.         isoinfo -i "$iso" -x "${path:4}" > "$path"
  163.    
  164.     [[ -s "$path" ]] ||
  165.     {
  166.         err "failed to extract file from iso:"
  167.         out "$path"
  168.         echo
  169.         exit 1
  170.     }
  171. done
  172.  
  173.  
  174.  
  175. inf "patching files using xdelta3"
  176.  
  177. mv ISO/PSP_GAME/USRDIR/mac.afs ISO/PSP_GAME/USRDIR/mac.old
  178. mv ISO/PSP_GAME/USRDIR/init.bin ISO/PSP_GAME/USRDIR/init.old
  179.  
  180. msg "patching  USRDIR/mac.afs"
  181. xdelta3 -d -s \
  182.    ISO/PSP_GAME/USRDIR/mac.old \
  183.    patch/mac.delta \
  184.    ISO/PSP_GAME/USRDIR/mac.afs ||
  185. {
  186.     err "failed to patch file"
  187.     xdelta3unusable &&
  188.         out "you definitely need a better version of xdelta3 :(" ||
  189.         out "and i have no idea why... :("
  190.     echo
  191.     exit 1
  192. }
  193.  
  194. msg "patching  USRDIR/init.afs"
  195. xdelta3 -d -s \
  196.    ISO/PSP_GAME/USRDIR/init.old \
  197.    patch/init.delta \
  198.    ISO/PSP_GAME/USRDIR/init.bin
  199.  
  200. msg "cleanup"
  201. rm ISO/PSP_GAME/USRDIR/mac.old
  202. rm ISO/PSP_GAME/USRDIR/init.old
  203.  
  204. msg "copying   SYSDIR/EBOOT.BIN"
  205. cp patch/EBOOT.BIN ISO/PSP_GAME/SYSDIR/EBOOT.BIN
  206.  
  207.  
  208.  
  209. inf "creating new iso"
  210. outfile="ever17EN_Beta2.iso"
  211. rm "$outfile" 2>/dev/null || true
  212.  
  213. mkisofs -sort patch/filelist.txt \
  214.    -iso-level 4 -xa -A "PSP GAME" -V "Ever17" \
  215.    -sysid "PSP GAME" -volset "Ever17" \
  216.    -p "" -publisher "" -o "$outfile" ISO/ 2>&1 |
  217.  
  218. # make mkisofs output less verbose
  219. # by keeping all the progress stuff on one line
  220. sed -r "s/(.*% done.*)/$(printf '\033[A\\1\033[K')/"
  221.  
  222. #inf "done!  disk space used: $(du -sBM)"
  223. inf "done!"
  224. msg "this is your new iso:"
  225. out "$outfile"
  226. echo
  227.  
  228. rm -rf ISO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement