diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cd2b46347e..09e6beaca8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -92,6 +92,7 @@ jobs: python3 tools/build_data.py python3 tools/build_release.py "${{steps.date.outputs.date}}" rm -fv releases/.gitignore + rm -fv releases/port_stats_raw.json - name: "Prepare Release" uses: ncipollo/release-action@v1 diff --git a/SOURCE_SETUP.txt b/SOURCE_SETUP.txt index e837c57fa8..cc18bc11dd 100644 --- a/SOURCE_SETUP.txt +++ b/SOURCE_SETUP.txt @@ -11,5 +11,8 @@ REPO_NAME="PortMaster New Repo." # For example "xmpl" REPO_PREFIX="pm" +SPLIT_IMAGES="Y" + ## This is only required by PortMaster-New Repo. +## --DEPRECATED-- PMGUI_RELEASE="8.6.1_0556" diff --git a/releases/.gitignore b/releases/.gitignore index 7626b537c0..93677cee62 100644 --- a/releases/.gitignore +++ b/releases/.gitignore @@ -8,3 +8,4 @@ ports_status.json manifest.json ports.json gameinfo_status.json +port_stats_raw.json diff --git a/tools/build_release.py b/tools/build_release.py index e60fd23860..15e1708c7a 100644 --- a/tools/build_release.py +++ b/tools/build_release.py @@ -58,18 +58,19 @@ ROOT_DIR = Path('.') -CACHE_FILE = ROOT_DIR / '.hash_cache' -RELEASE_DIR = ROOT_DIR / 'releases' -RUNTIMES_DIR = ROOT_DIR / 'runtimes' -MANIFEST_FILE = RELEASE_DIR / 'manifest.json' -STATUS_FILE = RELEASE_DIR / 'ports_status.json' -PORTS_DIR = ROOT_DIR / 'ports' +CACHE_FILE = ROOT_DIR / '.hash_cache' +RELEASE_DIR = ROOT_DIR / 'releases' +RUNTIMES_DIR = ROOT_DIR / 'runtimes' +MANIFEST_FILE = RELEASE_DIR / 'manifest.json' +STATUS_FILE = RELEASE_DIR / 'ports_status.json' +PORTS_DIR = ROOT_DIR / 'ports' +PORT_STAT_RAW_FILE = RELEASE_DIR / 'port_stats_raw.json' -SPLIT_IMAGES = True +SPLIT_IMAGES = False -GITHUB_RUN = (ROOT_DIR / '.github_check').is_file() +GITHUB_RUN = (ROOT_DIR / '.github_check').is_file() -LARGEST_FILE = (1024 * 1024 * 90) +LARGEST_FILE = (1024 * 1024 * 90) ############################################################################# """ @@ -115,6 +116,7 @@ 'RELEASE_REPO': None, 'REPO_NAME': None, 'REPO_PREFIX': None, + 'SPLIT_IMAGES': "N", } with open('SOURCE_SETUP.txt', 'r') as fh: @@ -148,6 +150,45 @@ ############################################################################# +PORT_STAT_RAW_DATA = None +def get_historial_added_date(port_name, default=None): + """ + Uses port_stats_raw.json to get a historial release date if it is not found. + + This is used to keep info sane when moving ports between github repos. + """ + global PORT_STAT_RAW_DATA + + if PORT_STAT_RAW_DATA is None: + if not PORT_STAT_RAW_FILE.is_file(): + return default + + try: + with PORT_STAT_RAW_FILE.open('r') as fh: + PORT_STAT_RAW_DATA = json.load(fh) + + if not isinstance(PORT_STAT_RAW_DATA, dict): + return default + + except json.decoder.JSONDecodeError as err: + printf(f"Unable to load {str(PORT_STAT_RAW_FILE)}: {err}") + PORT_STAT_RAW_DATA = None + return default + + if port_name not in PORT_STAT_RAW_DATA.get('ports', {}): + print(f"- {port_name} --> {default} (DEFAULT)") + return default + + for release_id in sorted(PORT_STAT_RAW_DATA.get('releases', [])): + if port_name in PORT_STAT_RAW_DATA.get('release_data', {}).get(release_id, []): + added_date = release_id.split('_', 1)[0] + print(f"- {port_name} --> {added_date}") + return added_date + + print(f"- {port_name} --> {default} (DEFAULT)") + return default + + def current_release_url(release_id): if release_id == 'latest': return f"https://github.com/{REPO_CONFIG['RELEASE_ORG']}/{REPO_CONFIG['RELEASE_REPO']}/releases/latest/download/" @@ -251,7 +292,7 @@ def load_port(port_dir, manifest, registered, port_status, quick_build=False, ha port_data['files'][port_file.name] = port_file_type if port_data['name'] not in port_status: - port_date = TODAY + port_date = get_historial_added_date(port_data['name'], TODAY) else: port_date = port_status[port_data['name']]['date_added'] @@ -783,6 +824,7 @@ def port_info(file_name, ports_json, ports_status): } if clean_name not in ports_status: + default_status['date_added'] = get_historial_added_date(clean_name, TODAY) ports_status[clean_name] = default_status elif ports_status[clean_name]['md5'] != file_md5: @@ -946,7 +988,7 @@ def generate_ports_json(all_ports, port_status, old_manifest, new_manifest): ) ## Jank :| - if SPLIT_IMAGES: + if REPO_CONFIG.get('SPLIT_IMAGES', "N") == "Y": build_new_images_zip(old_manifest, new_manifest, port_status) utils = [] diff --git a/tools/prepare_repo.sh b/tools/prepare_repo.sh index f298ac9dc0..5cadc1052c 100755 --- a/tools/prepare_repo.sh +++ b/tools/prepare_repo.sh @@ -14,6 +14,7 @@ wget "https://github.com/${RELEASE_ORG}/${RELEASE_REPO}/releases/latest/download wget "https://github.com/${RELEASE_ORG}/${RELEASE_REPO}/releases/latest/download/ports_status.json" wget "https://github.com/${RELEASE_ORG}/${RELEASE_REPO}/releases/latest/download/manifest.json" wget "https://github.com/${RELEASE_ORG}/${RELEASE_REPO}/releases/latest/download/images.zip" +wget "https://raw.githubusercontent.com/PortsMaster/PortMaster-Info/refs/heads/main/port_stats_raw.json" cd .. python3 tools/build_data.py