diff options
author | jaseg <git@jaseg.de> | 2023-10-24 17:03:58 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-10-24 17:08:15 +0200 |
commit | 35c4ef587c5cea6d75948dddba98f628f11348be (patch) | |
tree | d74719034f7d72c3c53dfebef4af97a5f816e247 | |
parent | f5c40093ff3a2b550ab6f273049d169046421a33 (diff) | |
download | kimesh-35c4ef587c5cea6d75948dddba98f628f11348be.tar.gz kimesh-35c4ef587c5cea6d75948dddba98f628f11348be.tar.bz2 kimesh-35c4ef587c5cea6d75948dddba98f628f11348be.zip |
Fix packaging script for the repo format's peculiarities
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | de.jaseg.kimesh.footprints-repo-metadata.json | 31 | ||||
-rw-r--r-- | de.jaseg.kimesh.footprints-v1.0.0.zip | bin | 822342 -> 0 bytes | |||
-rw-r--r-- | de.jaseg.kimesh.plugin-repo-metadata.json | 31 | ||||
-rw-r--r-- | de.jaseg.kimesh.plugin-v1.0.0.zip | bin | 12895 -> 0 bytes | |||
-rw-r--r-- | package.py | 23 |
6 files changed, 81 insertions, 6 deletions
@@ -1,2 +1,4 @@ de.jaseg.kimesh.footprints/footprints +de.jaseg.kimesh.footprints/metadata.json +de.jaseg.kimesh.plugin/metadata.json __pycache__ diff --git a/de.jaseg.kimesh.footprints-repo-metadata.json b/de.jaseg.kimesh.footprints-repo-metadata.json new file mode 100644 index 0000000..b6fdd9a --- /dev/null +++ b/de.jaseg.kimesh.footprints-repo-metadata.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://go.kicad.org/pcm/schemas/v1", + "name": "KiMesh", + "description": "A security mesh generator for KiCad", + "description_full": "This is the footprint package for the KiMesh security mesh generator.", + "identifier": "de.jaseg.kimesh.footprints", + "type": "library", + "author": { + "name": "jaseg", + "contact": { + "web": "https://jaseg.de/" + } + }, + "license": "CERN-OHL", + "resources": { + "homepage": "https://jaseg.de/projects/kimesh", + "git": "https://git.jaseg.de/kimesh.git", + "issues": "https://github.com/jaseg/kimesh/issues" + }, + "versions": [ + { + "version": "1.0.0", + "status": "stable", + "kicad_version": "7.99", + "download_sha256": "e0c1a2752090def465afa6f6c38baeb74a6544e79e87de3019087c41a3f2790e", + "download_size": 822342, + "download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kimesh.footprints-v1.0.0.zip?h=v1.0.0", + "install_size": 4803868 + } + ] +} diff --git a/de.jaseg.kimesh.footprints-v1.0.0.zip b/de.jaseg.kimesh.footprints-v1.0.0.zip Binary files differdeleted file mode 100644 index 064bf1c..0000000 --- a/de.jaseg.kimesh.footprints-v1.0.0.zip +++ /dev/null diff --git a/de.jaseg.kimesh.plugin-repo-metadata.json b/de.jaseg.kimesh.plugin-repo-metadata.json new file mode 100644 index 0000000..ad8da7c --- /dev/null +++ b/de.jaseg.kimesh.plugin-repo-metadata.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://go.kicad.org/pcm/schemas/v1", + "name": "KiMesh", + "description": "A security mesh generator for KiCad", + "description_full": "KiMesh automatically generates security meshes for you. A security mesh is a set of PCB traces that cover an area to detect physical tampering. KiMesh can cover arbitrary areas with two or more traces. Note: The KiMesh footprints Add-On must be installed alongside KiMesh. For detailed usage instructions, please have a look at the KiMesh website linked in the add-on information.", + "identifier": "de.jaseg.kimesh.plugin", + "type": "plugin", + "author": { + "name": "jaseg", + "contact": { + "web": "https://jaseg.de/" + } + }, + "license": "GPL-3.0", + "resources": { + "homepage": "https://jaseg.de/projects/kimesh", + "git": "https://git.jaseg.de/kimesh.git", + "issues": "https://github.com/jaseg/kimesh/issues" + }, + "versions": [ + { + "version": "1.0.0", + "status": "stable", + "kicad_version": "7.99", + "download_sha256": "59da3a8a13be001fb6f5eee9e1d346f4beee6c0d736856b2da205db290ad21a6", + "download_size": 12895, + "download_url": "https://git.jaseg.de/kimesh.git/plain/de.jaseg.kimesh.plugin-v1.0.0.zip?h=v1.0.0", + "install_size": 45166 + } + ] +} diff --git a/de.jaseg.kimesh.plugin-v1.0.0.zip b/de.jaseg.kimesh.plugin-v1.0.0.zip Binary files differdeleted file mode 100644 index eb2e9aa..0000000 --- a/de.jaseg.kimesh.plugin-v1.0.0.zip +++ /dev/null @@ -53,33 +53,44 @@ def do_release(version, increment): for path in res.stdout.splitlines(): if re.fullmatch(r'de\.jaseg\.kimesh\.[^/]*-v[.0-9]*\.zip', path.strip()): print(f'Removing old release zip {path} from git index.') - subprocess.run(['git', 'rm', '--cached', path], check=True, capture_output=True) + subprocess.run(['git', 'rm', path], check=True, capture_output=True) for pkg_dir in Path('de.jaseg.kimesh.plugin'), Path('de.jaseg.kimesh.footprints'): - meta_path = pkg_dir / 'metadata.json' + # NOTE: metadata.json appears twice. In what I believe is a sub-optimal design choice, the variant in the + # archive is only allowed to contain the current version in its version list without its zip file metadata, + # while the variant in the repository index is supposed to contain all past versions including their zip file + # metadata. AFAICT they are the same otherwise. + meta_path = Path(f'{pkg_dir}-repo-metadata.json') + print(f'Updating metadata file {meta_path}') - meta_file = json.loads(meta_path.read_text()) - subprocess.run(['git', 'add', str(meta_path)], check=True, capture_output=True) ver_dict = { 'version': version, 'status': 'stable', 'kicad_version': '7.99', } - meta_file['versions'].append(ver_dict) - meta_path.write_text(json.dumps(meta_file, indent=4)) + + # Include just the version metadata in the metadata for the archive + meta_file = json.loads(meta_path.read_text()) + meta_file['versions'] = [ver_dict] + (pkg_dir / 'metadata.json').write_text(json.dumps(meta_file, indent=4)) zip_fn = Path(shutil.make_archive(f'{pkg_dir.name}-v{version}', 'zip', pkg_dir, '.')) print(f'Adding new release zip {zip_fn} to git index.') subprocess.run(['git', 'add', str(zip_fn)], check=True, capture_output=True) + # Add the zip's metadata to the metadata for the repository ver_dict['download_sha256'] = hashlib.sha256(zip_fn.read_bytes()).hexdigest() ver_dict['download_size'] = zip_fn.stat().st_size ver_dict['download_url'] = f'https://git.jaseg.de/kimesh.git/plain/{zip_fn.name}?h=v{version}' ver_dict['install_size'] = tree_size(pkg_dir) + + meta_file = json.loads(meta_path.read_text()) + meta_file['versions'].append(ver_dict) meta_path.write_text(json.dumps(meta_file, indent=4)) print(f'Adding updated metadata file {meta_path} to git index') subprocess.run(['git', 'add', str(meta_path)], check=True, capture_output=True) + print('Create git commit') subprocess.run(['git', 'commit', '-m', f'Version {version}', '--no-edit'], check=True, capture_output=True) res = subprocess.run('git rev-parse --short HEAD'.split(), check=True, capture_output=True, text=True) |