gl-infra-builder-FUjr/patches-19.x/0104-fix-change-metadata-src-from-yaml.patch
2021-08-17 10:47:24 +08:00

166 lines
4.8 KiB
Diff

From 7ee05c70dc3a6a4855505db527774bd26c1e9738 Mon Sep 17 00:00:00 2001
From: gl-tanqi <qi.tan@gl-inet.com>
Date: Tue, 17 Aug 2021 10:39:13 +0800
Subject: [PATCH] fix: change metadata src from yaml
---
gl_metadata.mk | 17 ----------
gl_metadata.yaml | 12 +++++++
include/image-commands.mk | 68 +--------------------------------------
make_gl_metadata.py | 13 ++++++++
4 files changed, 26 insertions(+), 84 deletions(-)
delete mode 100644 gl_metadata.mk
create mode 100644 gl_metadata.yaml
create mode 100755 make_gl_metadata.py
diff --git a/gl_metadata.mk b/gl_metadata.mk
deleted file mode 100644
index 0ea276262f..0000000000
--- a/gl_metadata.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-gl_not_keep_config_version := 4.003
-gl_not_keep_config_description := xxx
-gl_supported_version := 4.001
-
-gl_user := general
-
-gl_config_ssids := solve the ssids problem
-gl_config_wireless := solve the wireless problem
-gl_config_ddns := solve the ddns problem
-#gl_config_dhcp := solve the xxx problem
-#gl_config_firewall := solve the xxx problem
-#gl_config_openvpn := solve the xxx problem
-#gl_config_rtty := solve the xxx problem
-#gl_config_glconfig := solve the xxx problem
-#gl_config_system := solve the xxx problem
-#gl_config_mwan3 := solve the xxx problem
-#gl_config_network := solve the xxx problem
\ No newline at end of file
diff --git a/gl_metadata.yaml b/gl_metadata.yaml
new file mode 100644
index 0000000000..0c5557faff
--- /dev/null
+++ b/gl_metadata.yaml
@@ -0,0 +1,12 @@
+not_keep_config:
+ version: 4.003
+ description: Solve the xxx problem
+supported_version: 4.001
+not_keep_config_part:
+ -
+ path: /etc/config/ssids
+ description: Solve the ssids problem
+ -
+ path: /etc/config/dns
+ description: is dns problem
+user: general
diff --git a/include/image-commands.mk b/include/image-commands.mk
index d2637b178b..bcf871f679 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -384,52 +384,6 @@ define Build/append-metadata
}
endef
-include $(TOPDIR)/gl_metadata.mk
-
-ifdef gl_config_ssids
- CONFIG_GL_SSIDS={"path":"/etc/config/ssids","description":"$(gl_config_ssids)"},
-endif
-
-ifdef gl_config_wireless
- CONFIG_GL_WIRELESS={"path":"/etc/config/wireless","description":"$(gl_config_wireless)"},
-endif
-
-ifdef gl_config_ddns
- CONFIG_GL_DDNS={"path":"/etc/config/ddns","description":"$(gl_config_ddns)"},
-endif
-
-ifdef gl_config_dhcp
- CONFIG_GL_DHCP={"path":"/etc/config/dhcp","description":"$(gl_config_dhcp)"},
-endif
-
-ifdef gl_config_firewall
- CONFIG_GL_FIREWALL={"path":"/etc/config/firewall","description":"$(gl_config_firewall)"},
-endif
-
-ifdef gl_config_openvpn
- CONFIG_GL_OPENVPN={"path":"/etc/config/openvpn","description":"$(gl_config_openvpn)"},
-endif
-
-ifdef gl_config_rtty
- CONFIG_GL_RTTY={"path":"/etc/config/rtty","description":"$(gl_config_rtty)"},
-endif
-
-ifdef gl_config_glconfig
- CONFIG_GL_GLCONFIG={"path":"/etc/config/glconfig","description":"$(gl_config_glconfig)"},
-endif
-
-ifdef gl_config_system
- CONFIG_GL_SYSTEM={"path":"/etc/config/system","description":"$(gl_config_system)"},
-endif
-
-ifdef gl_config_mwan3
- CONFIG_GL_MWAN3={"path":"/etc/config/mwan3","description":"$(gl_config_mwan3)"},
-endif
-
-ifdef gl_config_network
- CONFIG_GL_NETWORK={"path":"/etc/config/network","description":"$(gl_config_network)"},
-endif
-
metadata_gl_json = \
'{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
"metadata_version": "1.0", \
@@ -443,27 +397,7 @@ metadata_gl_json = \
"target": "$(call json_quote,$(TARGETID))", \
"board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
}, \
- "upgrade_control":{ \
- "not_keep_config":{ \
- "version":"$(gl_not_keep_config_version)", \
- "description":"$(gl_not_keep_config_description)" \
- }, \
- "supported_version":"$(gl_supported_version)", \
- "not_keep_config_part":[ \
- $(CONFIG_GL_SSIDS)\
- $(CONFIG_GL_WIRELESS)\
- $(CONFIG_GL_DDNS)\
- $(CONFIG_GL_DHCP)\
- $(CONFIG_GL_FIREWALL)\
- $(CONFIG_GL_OPENVPN)\
- $(CONFIG_GL_RTTY)\
- $(CONFIG_GL_GLCONFIG)\
- $(CONFIG_GL_SYSTEM)\
- $(CONFIG_GL_MWAN3)\
- $(CONFIG_GL_NETWORK)\
- ], \
- "user":"$(gl_user)" \
- }, \
+ "upgrade_control":$(shell python3 $(TOPDIR)/make_gl_metadata.py), \
"release_note":"$(shell cat $(TOPDIR)/gl_release_note)" \
}'
diff --git a/make_gl_metadata.py b/make_gl_metadata.py
new file mode 100755
index 0000000000..a7f294664e
--- /dev/null
+++ b/make_gl_metadata.py
@@ -0,0 +1,13 @@
+import sys
+import os
+import yaml
+import json
+
+pyfilePath = os.path.split(os.path.realpath(__file__))[0]
+yamlPath = os.path.join(pyfilePath, 'gl_metadata.yaml')
+
+f = open(yamlPath, 'r', encoding='utf-8')
+cont = f.read()
+x = yaml.load(cont)
+
+print(json.dumps(x))
--
2.17.1