Skip to content

Commit

Permalink
Merge pull request #202 from h3xp/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mrludo001 authored Oct 12, 2023
2 parents f2f7f82 + 4f045a5 commit 20621c9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 34 additions & 1 deletion update.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,38 @@ def get_package_date(file: str):
return datetime.datetime.fromisoformat("1900-01-01T00:00:00")


def get_retropie_cores():
cores = []
found = False
val = subprocess.check_output(["/bin/bash", "-c", "sudo /home/pi/RetroPie-Setup/retropie_packages.sh | less"])
lines = val.decode("utf-8").split(str("\n"))
for line in lines:
if not found:
if line[0:10:] == "----------":
found = True
else:
parts = line.split(":")
if len(parts) == 3:
cores.append(parts[0].strip())

return cores


def install_emulators(directory):
if len(list(Path(directory).rglob('retropie.pkg'))) == 0:
return
# get official cores
cores = get_retropie_cores()
# check if retropie.pkg files exist
for package in Path(directory).rglob('retropie.pkg'):
package_dir = os.path.dirname(package)
if "/opt/retropie/libretrocores" in package_dir:
if os.path.basename(package_dir) not in cores:
# I took this out of check_root
if not os.path.isdir(f"/opt/retropie/libretrocores/{os.path.basename(package_dir)}"):
os.system(f"sudo mkdir /opt/retropie/libretrocores/{os.path.basename(package_dir)} > /tmp/test")
os.system(f"sudo chown -R pi:pi /opt/retropie/libretrocores/{os.path.basename(package_dir)} > /tmp/test")
return
os.system("sudo chown -R pi:pi {} > /tmp/test".format(os.path.dirname(package)))
local_package = str(package).replace(str(directory), "")
if os.path.isfile(local_package):
Expand Down Expand Up @@ -4075,7 +4104,9 @@ def check_root(directory):
for files in os.listdir(directory):
if os.path.exists(directory / "etc" / "emulationstation"):
return True

#if os.path.exists(directory / "opt" / "retropie" / "libretrocores"):
# return True

return False


Expand Down Expand Up @@ -4566,6 +4597,7 @@ def process_improvement(file: str, extracted: str, status=True, auto_clean=False
if check_root(extracted):
os.system("sudo chown -R pi:pi {} > /tmp/test".format(str(extracted)))
os.system("sudo chown -R pi:pi /etc/emulationstation/ > /tmp/test")
#os.system("sudo chown -R pi:pi /opt/retropie/libretrocores/ > /tmp/test")
update_config(extracted)
make_deletions(extracted)
install_emulators(extracted)
Expand All @@ -4579,6 +4611,7 @@ def process_improvement(file: str, extracted: str, status=True, auto_clean=False
if official:
if check_root(extracted):
os.system("sudo chown -R root:root /etc/emulationstation/")
os.system("sudo chown -R root:root /opt/retropie/libretrocores/")

try:
shutil.rmtree(extracted)
Expand Down
2 changes: 1 addition & 1 deletion update_tool.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[CONFIG_ITEMS]
tool_ver = 2.7.6
tool_ver = 2.7.7
home_dir = /home/pi/.update_tool
home_command = update.py
home_exe = python3
Expand Down

0 comments on commit 20621c9

Please sign in to comment.