Skip to content

Commit

Permalink
add GPLv3
Browse files Browse the repository at this point in the history
  • Loading branch information
shinrax2 committed Jul 22, 2023
1 parent 67d6f35 commit 37c8dbc
Show file tree
Hide file tree
Showing 7 changed files with 788 additions and 41 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ future release (aka current master branch):
+ save git commit id at buildtime and show it in the main window
! proper handling of sonys weak certificate
+ faster search for new titledb versions
! add GPL3 license to this project
- fix update searching for games with no ps3_system_ver set like BCUS98132

v011:
- fix crash when proxy is enabled but no proper proxy settings are set
Expand Down
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions PS3GUD.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# PS3GameUpdateDownloader by shinrax2
#PS3GameUpdateDownloader downloads PS3 game updates from official Sony servers
#Copyright (C) 2023 shinrax2
#
#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/>.

#built-in
import urllib.parse
Expand Down Expand Up @@ -40,6 +47,7 @@ def __init__(self, window=None):
#handle sonys weak cert for their https server
self.https_session = requests.Session()
self.https_session.mount('https://a0.ww.np.dl.playstation.net', SonySSLContextAdapter())
self.pemfile = "./sony.pem"

self.useDefaultConfig = True
self.configDefaults = {}
Expand Down Expand Up @@ -200,7 +208,7 @@ def checkForUpdates(self, titleid):
updates = []
url = urllib.parse.urljoin(urllib.parse.urljoin("https://a0.ww.np.dl.playstation.net/tpl/np/", self.titleid+"/"), self.titleid+"-ver.xml")
try:
resp = self.https_session.get(url, verify="sony.pem", proxies=self.proxies)
resp = self.https_session.get(url, verify=self.pemfile, proxies=self.proxies)
except requests.exceptions.ConnectionError:
self.logger.log(self.loc.getKey("msg_metaNotAvailable"), "e")
if self.getConfig("use_proxy"):
Expand Down
112 changes: 77 additions & 35 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# build.py for PS3GameUpdateDownloader by shinrax2
#PS3GameUpdateDownloader downloads PS3 game updates from official Sony servers
#Copyright (C) 2023 shinrax2
#
#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/>.

#built-in
import argparse
Expand Down Expand Up @@ -77,13 +84,48 @@ def getJSONFiles():
jsonfiles = []
for root, dirs, files in os.walk(locdirbuildpath):
for file in files:
if os.path.isfile(os.path.join(root, file)):
if os.path.isfile(os.path.join(root, file)) and os.path.join(root, file).lower().endswith(".json"):
jsonfiles.append(os.path.join(root, file))
#other files
jsonfiles.append(os.path.join(builddir, "release.json"))
jsonfiles.append(os.path.join(builddir, "titledb.json"))
return jsonfiles

def copyData(builddir, locdirname, imagedirname, debug=False, source=False):
if debug == True: #debug specific files
shutil.copy2("titledb.debug.json", os.path.join(builddir, "titledb.json"))
shutil.copy2("release.debug.json", os.path.join(builddir, "release.json"))
else: #release specific files
shutil.copy2("LICENSE", os.path.join(builddir, "LICENSE"))
shutil.copy2("CHANGELOG", os.path.join(builddir, "CHANGELOG"))
shutil.copy2("release.json", os.path.join(builddir, "release.json"))
shutil.copy2("titledb.json", os.path.join(builddir, "titledb.json"))
copySource(builddir)
if source == True: # source specific files
shutil.copy2("requirements.txt", os.path.join(builddir, "requirements.txt"))
# general files
shutil.copy2("sony.pem", os.path.join(builddir, "sony.pem"))
shutil.copytree(locdirname, os.path.join(builddir, locdirname))
shutil.copytree(imagedirname, os.path.join(builddir, imagedirname), ignore=shutil.ignore_patterns("*.xcf"))

def copySource(builddir):
sourcedir = os.path.join(builddir, "src")
files = ["build.py", "buildrequirements.txt", "CHANGELOG", "gui.py", "LICENSE", "main.py", "missingstrings.py", "PS3GUD.py", "README.md", "release.debug.json", "release.debug.json", "release.json", "requirements.txt", "sony.pem", "titledb.json", "titledb.debug.json", "updater.py", "utils.py"]
dirs = {
"images": {
"ignore": []
},
"loc": {
"ignore": []
}
}
#copy files
os.mkdir(sourcedir)
for file in files:
shutil.copy2(file, os.path.join(sourcedir, file))
for dir, options in dirs.items():
shutil.copytree(dir, os.path.join(sourcedir, dir), ignore=shutil.ignore_patterns(*options["ignore"]))

class Upx():
def __init__(self, build_config="build_config.json"):
self.upx = {}
Expand Down Expand Up @@ -163,7 +205,6 @@ def __exit__(self, type, value, traceback):
parser.add_argument("-u", "--upx", action="store_true", help="use UPX to shrink executables")
parser.add_argument("-up", "--upxpath", action="store", help="path to upx directory")
args = parser.parse_args()

#constants
builddir = "dist/PS3GameUpdateDownloader"
buildlog = os.path.join(builddir, "build.log")
Expand All @@ -176,11 +217,13 @@ def __exit__(self, type, value, traceback):
#get data from release.json
with open("release.json", "r", encoding="utf8") as f:
release = json.loads(f.read())
release["commitid"] = None

#check parameters
action = ""
zip_check = False
upx_check = False
upx_pathstr = ""
if args.compiled == True and args.source == True:
print("You cant pass \"-c\" and \"-s\" to the buildscript.")
sys.exit()
Expand Down Expand Up @@ -209,6 +252,7 @@ def __exit__(self, type, value, traceback):
upx_paths = Upx()
if args.upxpath is not None and os.path.isdir(args.upxpath) == True:
upx_paths.set_upx_dir(args.upxpath)
upx_pathstr = ", "+upx_paths.get_upx_dir()

if args.zip == True:
zip_check = True
Expand All @@ -234,12 +278,16 @@ def __exit__(self, type, value, traceback):
arch = py + libc + ostype + bits

#get git commit id if git is found on path
gitver = "None"
if (shutil.which("git") is not None) == True:
call = shutil.which("git") + " rev-parse HEAD"
call = shutil.which("git") + " rev-parse --short HEAD"
call = call if platform.system() == "Windows" else shlex.split(call)
gitver = subprocess.Popen(call, stdout=subprocess.PIPE).communicate()[0].decode("ascii").replace("\n", "")
release["commitid"] = gitver
release["commitid"] = subprocess.Popen(call, stdout=subprocess.PIPE).communicate()[0].decode("ascii").replace("\n", "")

print("build script for PS3GameUpdateDownloader")
if action == "":
print("use '-h' for help")
else:
print(f"build options:\nmode: {action}\narch: {arch}\n git commit: {release['commitid']}\nupx: {upx_check}{upx_pathstr}\nzip: {zip_check}")

if action == "sourcerelease":
#release running from source
Expand All @@ -253,24 +301,21 @@ def __exit__(self, type, value, traceback):
#write header to buildlog
buildheader(release, buildlog)
#copy scripts
print(f"copying scripts to '{builddir}'")
shutil.copy2("main.py", os.path.join(builddir, "main.py"))
shutil.copy2("utils.py", os.path.join(builddir, "utils.py"))
shutil.copy2("updater.py", os.path.join(builddir, "updater.py"))
shutil.copy2("PS3GUD.py", os.path.join(builddir, "PS3GUD.py"))
shutil.copy2("gui.py", os.path.join(builddir, "gui.py"))
#copy data
shutil.copy2("CHANGELOG", os.path.join(builddir, "CHANGELOG"))
shutil.copy2("titledb.json", os.path.join(builddir, "titledb.json"))
shutil.copy2("requirements.txt", os.path.join(builddir, "requirements.txt"))
shutil.copy2("release.json", os.path.join(builddir, "release.json"))
shutil.copy2("sony.pem", os.path.join(builddir, "sony.pem"))
shutil.copytree(locdirname, os.path.join(builddir, locdirname))
shutil.copytree(imagedirname, os.path.join(builddir, imagedirname), ignore=shutil.ignore_patterns("*.xcf"))
print(f"copying data to '{builddir}'")
copyData(builddir, locdirname, imagedirname, source=True)
#save commitid
if release["commitid"] is not None:
with open(os.path.join(builddir, "release.json"), "w", encoding="utf8") as f:
f.write(json.dumps(release, sort_keys=True, ensure_ascii=False, indent=4))
#validate & minify json files
print("minifying & validating JSON files")
minifyJSON(getJSONFiles())
#build zip
if zip_check == True:
Expand All @@ -295,24 +340,21 @@ def __exit__(self, type, value, traceback):
#write header to buildlog
buildheader(release, buildlog)
#copy scripts
print(f"copying scripts to '{builddir}'")
shutil.copy2("main.py", os.path.join(builddir, "main.py"))
shutil.copy2("utils.py", os.path.join(builddir, "utils.py"))
shutil.copy2("updater.py", os.path.join(builddir, "updater.py"))
shutil.copy2("PS3GUD.py", os.path.join(builddir, "PS3GUD.py"))
shutil.copy2("gui.py", os.path.join(builddir, "gui.py"))
#copy data
shutil.copy2("CHANGELOG", os.path.join(builddir, "CHANGELOG"))
shutil.copy2("titledb.debug.json", os.path.join(builddir, "titledb.json"))
shutil.copy2("release.debug.json", os.path.join(builddir, "release.json"))
shutil.copy2("requirements.txt", os.path.join(builddir, "requirements.txt"))
shutil.copy2("sony.pem", os.path.join(builddir, "sony.pem"))
shutil.copytree(locdirname, os.path.join(builddir, locdirname))
shutil.copytree(imagedirname, os.path.join(builddir, imagedirname), ignore=shutil.ignore_patterns("*.xcf"))
print(f"copying data to '{builddir}'")
copyData(builddir, locdirname, imagedirname, source=True, debug=True)
#save commitid
if release["commitid"] is not None:
with open(os.path.join(builddir, "release.json"), "w", encoding="utf8") as f:
f.write(json.dumps(release, sort_keys=True, ensure_ascii=False, indent=4))
#validate json files
print("validating JSON files")
for file in getJSONFiles():
validateJSON(file)
#build zip
Expand All @@ -333,6 +375,7 @@ def __exit__(self, type, value, traceback):
else:
os.makedirs(builddir)
#build main executable
print("building main executable")
import PyInstaller.__main__
import PyInstaller.__init__
fh = logging.FileHandler(buildlog)
Expand All @@ -354,6 +397,7 @@ def __exit__(self, type, value, traceback):
arg_main.append("main.py")
PyInstaller.__main__.run(arg_main)
#build updater executable
print("building updater executable")
arg_updater = [
"--name=PS3GUDup",
"--clean",
Expand All @@ -368,22 +412,20 @@ def __exit__(self, type, value, traceback):
arg_updater.append("updater.py")
PyInstaller.__main__.run(arg_updater)
#move executables to buildir
print(f"copying executables to '{builddir}'")
shutil.move("dist/ps3gud"+suffix, os.path.join(builddir, "ps3gud"+suffix))
shutil.move("dist/PS3GUDup"+suffix, os.path.join(builddir, "PS3GUDup"+suffix))
#copy data
shutil.copy2("CHANGELOG", os.path.join(builddir, "CHANGELOG"))
shutil.copy2("titledb.json", os.path.join(builddir, "titledb.json"))
shutil.copy2("release.json", os.path.join(builddir, "release.json"))
shutil.copy2("sony.pem", os.path.join(builddir, "sony.pem"))
shutil.copytree(locdirname, os.path.join(builddir, locdirname))
shutil.copytree(imagedirname, os.path.join(builddir, imagedirname), ignore=shutil.ignore_patterns("*.xcf"))
print(f"copying data to '{builddir}'")
copyData(builddir, locdirname, imagedirname)
#write header to buildlog
buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__)
#save commitid
if release["commitid"] is not None:
with open(os.path.join(builddir, "release.json"), "w", encoding="utf8") as f:
f.write(json.dumps(release, sort_keys=True, ensure_ascii=False, indent=4))
#validate & minify json files
print("minifying & validating JSON files")
minifyJSON(getJSONFiles())
#build zip
if zip_check == True:
Expand Down Expand Up @@ -414,6 +456,7 @@ def __exit__(self, type, value, traceback):
log.addHandler(fh)

#build main executable
print("building main executable")
arg_main = [
"--name=ps3gud",
"--clean",
Expand All @@ -423,11 +466,12 @@ def __exit__(self, type, value, traceback):
]
if upx_check == True:
arg_main.append("--upx-dir="+upx_paths.get_upx_dir())
if platform.system() == "Windows": # fix for UPXed executeables not starting
if platform.system() == "Windows": # fix for UPXed executables not starting
arg_main.append("--upx-exclude=vcruntime140.dll")
arg_main.append("main.py")
PyInstaller.__main__.run(arg_main)
#build updater executable
print("building updater executable")
arg_updater = [
"--name=PS3GUDup",
"--clean",
Expand All @@ -437,27 +481,25 @@ def __exit__(self, type, value, traceback):
]
if upx_check == True:
arg_updater.append("--upx-dir="+upx_paths.get_upx_dir())
if platform.system() == "Windows": # fix for UPXed executeables not starting
if platform.system() == "Windows": # fix for UPXed executables not starting
arg_updater.append("--upx-exclude=vcruntime140.dll")
arg_updater.append("updater.py")
PyInstaller.__main__.run(arg_updater)
#move executables to buildir
print(f"copying executables to '{builddir}'")
shutil.move("dist/ps3gud"+suffix, os.path.join(builddir, "ps3gud"+suffix))
shutil.move("dist/PS3GUDup"+suffix, os.path.join(builddir, "PS3GUDup"+suffix))
#copy data
shutil.copy2("CHANGELOG", os.path.join(builddir, "CHANGELOG"))
shutil.copy2("titledb.debug.json", os.path.join(builddir, "titledb.json"))
shutil.copy2("release.debug.json", os.path.join(builddir, "release.json"))
shutil.copy2("sony.pem", os.path.join(builddir, "sony.pem"))
shutil.copytree(locdirname, os.path.join(builddir, locdirname))
shutil.copytree(imagedirname, os.path.join(builddir, imagedirname), ignore=shutil.ignore_patterns("*.xcf"))
print(f"copying data to '{builddir}'")
copyData(builddir, locdirname, imagedirname, debug=True)
#write header to buildlog
buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__)
#save commitid
if release["commitid"] is not None:
with open(os.path.join(builddir, "release.json"), "w", encoding="utf8") as f:
f.write(json.dumps(release, sort_keys=True, ensure_ascii=False, indent=4))
#validate json files
print("validating JSON files")
for file in getJSONFiles():
validateJSON(file)
#build zip
Expand Down
9 changes: 8 additions & 1 deletion gui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# PS3GameUpdateDownloader by shinrax2
#PS3GameUpdateDownloader downloads PS3 game updates from official Sony servers
#Copyright (C) 2023 shinrax2
#
#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/>.

#builtin
import webbrowser
Expand Down
10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# PS3GameUpdateDownloader by shinrax2
#PS3GameUpdateDownloader downloads PS3 game updates from official Sony servers
#Copyright (C) 2023 shinrax2
#
#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/>.


#local files
import gui
Expand Down
10 changes: 8 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# PS3GameUpdateDownloader by shinrax2

#PS3GameUpdateDownloader downloads PS3 game updates from official Sony servers
#Copyright (C) 2023 shinrax2
#
#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/>.

#built-in
import datetime
Expand Down

0 comments on commit 37c8dbc

Please sign in to comment.