-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b93b05
commit a7ad2da
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Build | ||
|
||
# Build on every branch push, tag push, and pull request change: | ||
on: [push, pull_request_target] | ||
|
||
jobs: | ||
build_repo: | ||
name: Build repo | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Install Python dependencies | ||
run: pip3 install -r requirements.txt | ||
|
||
- name: Get extra dependencies | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ secrets.SECRETREPO }} | ||
token: ${{ secrets.SECRETTOKEN }} | ||
path: deps_repo | ||
|
||
- name: Run repo tests | ||
run: python3 tests/check_recursive.py deps_repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: © 2023 Decompollaborate | ||
# SPDX-License-Identifier: MIT | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import ipl3checksum | ||
from pathlib import Path | ||
import struct | ||
|
||
|
||
print(f"Running ipl3checksum version {ipl3checksum.__version__}") | ||
|
||
def checkChecksum(romPath: Path) -> bool: | ||
print(romPath) | ||
|
||
print(" Reading...") | ||
romBytes = romPath.read_bytes() | ||
|
||
binChecksum = struct.unpack_from(f">II", romBytes, 0x10) | ||
|
||
print(f" Expected checksum is: 0x{binChecksum[0]:08X} 0x{binChecksum[1]:08X}") | ||
|
||
print(" Detecting CIC...") | ||
cicKind = ipl3checksum.detectCIC(romBytes) | ||
if cicKind is None: | ||
print(f" Not able to detect CIC for {romPath}") | ||
return False | ||
|
||
print(" Calculating checksum...") | ||
calculatedChecksum = ipl3checksum.calculateChecksum(romBytes, cicKind) | ||
if calculatedChecksum is None: | ||
print(f" Not able to calculate checksum for {romPath}") | ||
return False | ||
|
||
print(f" Calculated checksum is: 0x{calculatedChecksum[0]:08X} 0x{calculatedChecksum[1]:08X}") | ||
|
||
print(" Checking checksum...") | ||
if calculatedChecksum[0] != binChecksum[0] or calculatedChecksum[1] != binChecksum[1]: | ||
print(f" Wrong checksum for {romPath}") | ||
return False | ||
|
||
print(f" {romPath} OK") | ||
|
||
return True | ||
|
||
def recursePaths(folder: Path) -> int: | ||
errors = 0 | ||
|
||
for subpath in sorted(folder.iterdir()): | ||
if subpath.is_dir(): | ||
recursePaths(subpath) | ||
continue | ||
|
||
if subpath.parts[-2] == "drmario64" and subpath.name == "baserom.cn.z64": | ||
# iQue has a wrong checksum for some reason | ||
continue | ||
|
||
ok = checkChecksum(subpath) | ||
if not ok: | ||
errors += 1 | ||
|
||
print(f"Total errors: {errors}") | ||
|
||
return errors | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("path") | ||
|
||
args = parser.parse_args() | ||
|
||
exit(recursePaths(Path(args.path))) |