From 47d39f340ed96f0e9b0540718231f25a7a73ba3c Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sun, 21 Jan 2024 18:29:36 +0800 Subject: [PATCH 1/4] Update taptui path --- magefile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magefile.go b/magefile.go index 284d004a..9c67a7d8 100644 --- a/magefile.go +++ b/magefile.go @@ -63,7 +63,7 @@ var apps = []app{ bin: "tapto.sh", releaseId: "mrext/tapto", ldFlags: "-lnfc -lusb -lcurses", - releaseFiles: []string{filepath.Join(cwd, "scripts", "nfcui", "nfcui.sh")}, + releaseFiles: []string{filepath.Join(cwd, "scripts", "taptui", "taptui.sh")}, }, } From 1342a6fd06c7f18e828cbf68daff19d8e3019554 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sun, 21 Jan 2024 18:29:51 +0800 Subject: [PATCH 2/4] Generate single tapto repo --- scripts/generate_repo.py | 105 +++++---------------------------------- 1 file changed, 13 insertions(+), 92 deletions(-) diff --git a/scripts/generate_repo.py b/scripts/generate_repo.py index 4ff7decb..45fb1db8 100644 --- a/scripts/generate_repo.py +++ b/scripts/generate_repo.py @@ -9,30 +9,13 @@ from zipfile import ZipFile from typing import TypedDict, Union, Optional, List -APPS = ["lastplayed", "launchseq", "launchsync", "nfc", "playlog", "random", "remote", "search", "pocketbackup"] -FILES = { - "lastplayed": ["lastplayed.sh"], - "launchseq": ["launchseq.sh"], - "launchsync": ["launchsync.sh"], - "nfc": ["nfc.sh", "nfcui.sh"], - "playlog": ["playlog.sh"], - "random": ["random.sh"], - "remote": ["remote.sh"], - "search": ["search.sh"], - "pocketbackup": ["pocketbackup.sh"], -} -REBOOT = ["remote"] -EXTERNAL_FILES = [ - "releases/external/bgm.sh", - "releases/external/favorites.sh", - "releases/external/gamesmenu.sh", -] - -DB_ID = "mrext/{}" -RELEASES_FOLDER = "releases" +DB_ID = "mrext/tapto" +DL_URL = "https://github.com/wizzomafizzo/tapto/releases/download/{}" DL_FOLDER = "_bin/releases" -DL_URL = "https://github.com/wizzomafizzo/mrext/releases/download/{}" -EXTERNAL_URL = "https://github.com/wizzomafizzo/mrext/raw/main/releases/external/{}" +FILES = [ + "tapto.sh", + "taptui.sh", +] class RepoDbFilesItem(TypedDict): @@ -62,22 +45,14 @@ class RepoDb(TypedDict): base_files_url: Optional[str] -def create_app_db(app: str, tag: str) -> RepoDb: - if app not in APPS: - raise ValueError("Invalid app name") - +def create_tapto_db(tag: str) -> RepoDb: folders: RepoDbFolders = { "Scripts/": RepoDbFoldersItem(tags=None), } - dl_files = FILES[app] - reboot = app in REBOOT - files: RepoDbFiles = {} - for file in dl_files: - local_path = file - if "/" not in file: - local_path = os.path.join(DL_FOLDER, file) + for file in FILES: + local_path = os.path.join(DL_FOLDER, file) key = "Scripts/{}".format(os.path.basename(local_path)) size = os.stat(local_path).st_size @@ -85,61 +60,13 @@ def create_app_db(app: str, tag: str) -> RepoDb: url = "{}/{}".format(DL_URL.format(tag), os.path.basename(local_path)) file_entry = RepoDbFilesItem( - hash=md5, size=size, url=url, overwrite=None, reboot=reboot, tags=[Path(local_path).stem] - ) - - files[key] = file_entry - - return RepoDb( - db_id=DB_ID.format(app), - timestamp=int(time.time()), - files=files, - folders=folders, - base_files_url=None, - ) - - -def create_all_db(tag: str) -> RepoDb: - folders: RepoDbFolders = { - "Scripts/": RepoDbFoldersItem(tags=None), - } - files: RepoDbFiles = {} - - for app in APPS: - dl_files = FILES[app] - reboot = app in REBOOT - - for file in dl_files: - local_path = file - if "/" not in file: - local_path = os.path.join(DL_FOLDER, file) - - key = "Scripts/{}".format(os.path.basename(local_path)) - size = os.stat(local_path).st_size - md5 = hashlib.md5(open(local_path, "rb").read()).hexdigest() - url = "{}/{}".format(DL_URL.format(tag), os.path.basename(local_path)) - - file_entry = RepoDbFilesItem( - hash=md5, size=size, url=url, overwrite=None, reboot=reboot, tags=[Path(local_path).stem] - ) - - files[key] = file_entry - - for file in EXTERNAL_FILES: - local_path = file - key = "Scripts/{}".format(os.path.basename(local_path)) - size = os.stat(local_path).st_size - md5 = hashlib.md5(open(local_path, "rb").read()).hexdigest() - url = EXTERNAL_URL.format(os.path.basename(local_path)) - - file_entry = RepoDbFilesItem( - hash=md5, size=size, url=url, overwrite=None, reboot=False, tags=[Path(local_path).stem] + hash=md5, size=size, url=url, overwrite=None, reboot=None, tags=[Path(local_path).stem] ) files[key] = file_entry return RepoDb( - db_id=DB_ID.format("all"), + db_id=DB_ID, timestamp=int(time.time()), files=files, folders=folders, @@ -161,15 +88,9 @@ def generate_json(repo_db: RepoDb) -> str: def main(): tag = sys.argv[1] - for app in APPS: - repo_db = create_app_db(app, tag) - with open("{}/{}/{}.json".format(RELEASES_FOLDER, app, app), "w") as f: - f.write(generate_json(repo_db)) - - repo_db = create_all_db(tag) - with open("{}/all.json".format(RELEASES_FOLDER), "w") as f: + repo_db = create_tapto_db(tag) + with open("{}/tapto.json".format(DL_FOLDER), "w") as f: f.write(generate_json(repo_db)) - if __name__ == "__main__": main() From 7a646a30d16e7ea236db00152c98517209092706 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sun, 21 Jan 2024 18:52:16 +0800 Subject: [PATCH 3/4] Restructure mister scripts --- .gitignore | 2 +- magefile.go | 4 ++-- scripts/{misterbuild => mister/build}/Dockerfile | 0 scripts/{misterbuild => mister/build}/libnfc.sh | 0 .../build}/patches/acr122u-fix.patch | 0 scripts/{generate_repo.py => mister/repo/generate.py} | 7 ++++--- 6 files changed, 7 insertions(+), 6 deletions(-) rename scripts/{misterbuild => mister/build}/Dockerfile (100%) rename scripts/{misterbuild => mister/build}/libnfc.sh (100%) rename scripts/{misterbuild => mister/build}/patches/acr122u-fix.patch (100%) rename scripts/{generate_repo.py => mister/repo/generate.py} (91%) diff --git a/.gitignore b/.gitignore index 7808e8f0..7efff53a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ go.work /bin /_bin /out -scripts/misterbuild/_build +scripts/mister/build/_build .DS_Store diff --git a/magefile.go b/magefile.go index 9c67a7d8..b03887c4 100644 --- a/magefile.go +++ b/magefile.go @@ -39,8 +39,8 @@ var ( binReleasesDir = filepath.Join(binDir, "releases") upxBin = os.Getenv("UPX_BIN") // docker mister arm build - misterBuild = filepath.Join(cwd, "scripts", "misterbuild") - misterBuildImageName = "tapto/misterbuild" + misterBuild = filepath.Join(cwd, "scripts", "mister", "build") + misterBuildImageName = "tapto/mister-build" misterBuildCache = filepath.Join(os.TempDir(), "tapto-mister-buildcache") misterModCache = filepath.Join(os.TempDir(), "tapto-mister-modcache") ) diff --git a/scripts/misterbuild/Dockerfile b/scripts/mister/build/Dockerfile similarity index 100% rename from scripts/misterbuild/Dockerfile rename to scripts/mister/build/Dockerfile diff --git a/scripts/misterbuild/libnfc.sh b/scripts/mister/build/libnfc.sh similarity index 100% rename from scripts/misterbuild/libnfc.sh rename to scripts/mister/build/libnfc.sh diff --git a/scripts/misterbuild/patches/acr122u-fix.patch b/scripts/mister/build/patches/acr122u-fix.patch similarity index 100% rename from scripts/misterbuild/patches/acr122u-fix.patch rename to scripts/mister/build/patches/acr122u-fix.patch diff --git a/scripts/generate_repo.py b/scripts/mister/repo/generate.py similarity index 91% rename from scripts/generate_repo.py rename to scripts/mister/repo/generate.py index 45fb1db8..526defff 100644 --- a/scripts/generate_repo.py +++ b/scripts/mister/repo/generate.py @@ -11,7 +11,8 @@ DB_ID = "mrext/tapto" DL_URL = "https://github.com/wizzomafizzo/tapto/releases/download/{}" -DL_FOLDER = "_bin/releases" +RELEASES_FOLDER = "_bin/releases" +REPO_FOLDER = "scripts/mister/repo" FILES = [ "tapto.sh", "taptui.sh", @@ -52,7 +53,7 @@ def create_tapto_db(tag: str) -> RepoDb: files: RepoDbFiles = {} for file in FILES: - local_path = os.path.join(DL_FOLDER, file) + local_path = os.path.join(RELEASES_FOLDER, file) key = "Scripts/{}".format(os.path.basename(local_path)) size = os.stat(local_path).st_size @@ -89,7 +90,7 @@ def main(): tag = sys.argv[1] repo_db = create_tapto_db(tag) - with open("{}/tapto.json".format(DL_FOLDER), "w") as f: + with open("{}/tapto.json".format(REPO_FOLDER), "w") as f: f.write(generate_json(repo_db)) if __name__ == "__main__": From 253a160a934d48aab82cf00ea65f95887ed03308 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Sun, 21 Jan 2024 18:53:06 +0800 Subject: [PATCH 4/4] Create manual mister repo action --- .github/workflows/mister_repo.yml | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/mister_repo.yml diff --git a/.github/workflows/mister_repo.yml b/.github/workflows/mister_repo.yml new file mode 100644 index 00000000..b9763aca --- /dev/null +++ b/.github/workflows/mister_repo.yml @@ -0,0 +1,32 @@ +name: Generate MiSTer latest repo +on: + workflow_dispatch: + +permissions: write-all +jobs: + mister-repo: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + steps: + - uses: actions/checkout@v2 + - name: Get latest TapTo release + id: taptoreleaseinfo + uses: cardinalby/git-get-release-action@v1 + with: + latest: true + repo: wizzomafizzo/tapto + ref: main + - name: Download release files + run: | + DL_URL=https://github.com/wizzomafizzo/tapto/releases/download/${{ steps.taptoreleaseinfo.outputs.tag_name }} + mkdir -p _bin/releases + curl -L ${DL_URL}/tapto.sh -o _bin/releases/tapto.sh + curl -L ${DL_URL}/taptui.sh -o _bin/releases/taptui.sh + - name: Create databases + run: | + python scripts/mister/repo/generate.py ${{ steps.taptoreleaseinfo.outputs.tag_name }} + - name: Commit databases + uses: EndBug/add-and-commit@v9 + with: + add: scripts/mister/repo/tapto.json -f -A \ No newline at end of file