From: Moritz Warning Date: Sat, 23 May 2020 22:51:41 +0000 (+0200) Subject: collect.py: add option change image name prefix X-Git-Tag: v2.2.1~25 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e93f49725b46a65082d503ef2e71f1653f63514f;p=web%2Ffirmware-selector-openwrt-org.git collect.py: add option change image name prefix this is useful for custom image releases when the image files have been renamed afterwards --- diff --git a/misc/collect.py b/misc/collect.py index b95a746..f5f2556 100755 --- a/misc/collect.py +++ b/misc/collect.py @@ -13,11 +13,17 @@ parser.add_argument('--url', action="store", default="", help="Link to get the image from. May contain {target}, {version} and {commit}") parser.add_argument('--formatted', action="store_true", help="Output formatted JSON data.") +parser.add_argument('--change-prefix', + help="Change the openwrt- file name prefix.") args = parser.parse_args() SUPPORTED_METADATA_VERSION = 1 +def change_prefix(images, old_prefix, new_prefix): + for image in images: + if image['name'].startswith(old_prefix): + image['name'] = new_prefix + image['name'][len(old_prefix):] # OpenWrt JSON device files paths = [] @@ -65,6 +71,9 @@ for path in paths: for image in obj['images']: images.append({'name': image['name'], 'type': image['type']}) + if args.change_prefix: + change_prefix(images, 'openwrt-', args.change_prefix) + target = obj['target'] id = obj['id'] for title in obj['titles']: