Browse Source

Switch from zip to tar.zst plugin archives.

pull/785/head
Andrew Belt 3 years ago
parent
commit
e76395d59f
1 changed files with 12 additions and 8 deletions
  1. +12
    -8
      scripts/update.py

+ 12
- 8
scripts/update.py View File

@@ -3,8 +3,8 @@ import os
import glob import glob
import json import json
import time import time
import zipfile
import re import re
import tempfile


import common import common
import update_modulargrid import update_modulargrid
@@ -47,22 +47,26 @@ for plugin_path in plugin_paths:
continue continue
slug = manifest['slug'] slug = manifest['slug']
version = manifest['version'] version = manifest['version']
# TODO Extract manifest from .vcvplugin
elif plugin_ext == ".zip":
# Extract manifest from .vcvplugin
elif plugin_ext == ".vcvplugin":
m = re.match(r'^(.*)-(.*?)-(.*?)$', plugin_basename) m = re.match(r'^(.*)-(.*?)-(.*?)$', plugin_basename)
if not m:
raise Exception(f"Filename {plugin_path} invalid format")
slug = m[1] slug = m[1]
version = m[2] version = m[2]
arch = m[3] arch = m[3]
# Open ZIP # Open ZIP
z = zipfile.ZipFile(plugin_path)
tempdir = tempfile.mkdtemp()
common.system(f'zstd -d < "{plugin_path}" | tar -x -C "{tempdir}"')
# Unzip manifest # Unzip manifest
manifest_filename = f"{slug}/plugin.json"
with z.open(manifest_filename) as f:
manifest_filename = os.path.join(tempdir, slug, "plugin.json")
with open(manifest_filename) as f:
manifest = json.load(f) manifest = json.load(f)
if manifest['slug'] != slug: if manifest['slug'] != slug:
raise Exception(f"Manifest slug does not match filename slug {slug}") raise Exception(f"Manifest slug does not match filename slug {slug}")
if manifest['version'] != version: if manifest['version'] != version:
raise Exception(f"Manifest slug does not match filename slug {slug}")
raise Exception(f"Manifest version does not match filename version {version}")
common.system(f'rm -rf "{tempdir}"')
else: else:
raise Exception(f"Plugin {plugin_path} is not a valid format") raise Exception(f"Plugin {plugin_path} is not a valid format")


@@ -98,7 +102,7 @@ for plugin_path in plugin_paths:
# Open plugin issue thread # Open plugin issue thread
os.system(f"xdg-open 'https://github.com/VCVRack/library/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+in%3Atitle+{slug}' &") os.system(f"xdg-open 'https://github.com/VCVRack/library/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+in%3Atitle+{slug}' &")


elif plugin_ext == ".zip":
elif plugin_ext == ".vcvplugin":
# Review manifest for errors # Review manifest for errors
print(json.dumps(manifest, indent=" ")) print(json.dumps(manifest, indent=" "))
print("Press enter to approve manifest") print("Press enter to approve manifest")


Loading…
Cancel
Save