gamepkg/create_ps3.py

61 lines
1.4 KiB
Python
Raw Normal View History

2025-03-09 02:48:00 +01:00
#!/usr/bin/python
import sys
import os
def main():
if len(sys.argv) < 3:
print("Usage: script.py <output_path> <game_title>")
sys.exit(1)
out_path = sys.argv[1]
game_title = sys.argv[2]
game_desc = input("Enter game description: ")
safe_game_title = game_title.replace(" ", ".").lower()
print("Creating pkg structure")
root = os.path.join(out_path, "root")
os.makedirs(root, exist_ok=True)
os.makedirs(
os.path.join(root, "games", "rom", "ps3", safe_game_title)
,
exist_ok=True
)
os.makedirs(
os.path.join(root, "usr", "share", "icons", safe_game_title)
,
exist_ok=True
)
os.makedirs(
os.path.join(root, "usr", "share", "applications")
,
exist_ok=True
)
open(
os.path.join(root, "usr", "share", "applications", f"{game_title}.desktop"),
"w"
).write(
open("./examples/ps3/root/usr/share/applications/Game Title.desktop").read()
.replace("<GAME_TITLE>", game_title)
.replace("<GAME_DESC>", game_desc)
.replace("game.title", safe_game_title)
)
open(
os.path.join(out_path, "PKGBUILD"),
"w"
).write(
open("./examples/ps3/PKGBUILD").read()
.replace("<GAME_DESC>", game_desc)
.replace("game.title", safe_game_title)
)
if __name__ == "__main__":
main()