From e93f49725b46a65082d503ef2e71f1653f63514f Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Sun, 24 May 2020 00:51:41 +0200 Subject: [PATCH] collect.py: add option change image name prefix this is useful for custom image releases when the image files have been renamed afterwards --- misc/collect.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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']: -- 2.30.2