gl-infra-builder-FUjr/patches-wlan-ap-5.4/openwrt/0003-gen_config-add-version-info.patch
Jianhui Zhao 34774a1a41 ax1800/axt1800: add kernel 5.4 support
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
2022-05-24 16:39:22 +08:00

63 lines
2.1 KiB
Diff

From e5f0506332d157189a0ff42f7fe6b6b64e7d121e Mon Sep 17 00:00:00 2001
From: Jianhui Zhao <jianhui.zhao@gl-inet.com>
Date: Tue, 24 May 2022 11:54:35 +0800
Subject: [PATCH 3/3] gen_config: add version info
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
---
scripts/gen_config.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/scripts/gen_config.py b/scripts/gen_config.py
index 01c3f4050d..ec273446fe 100755
--- a/scripts/gen_config.py
+++ b/scripts/gen_config.py
@@ -4,6 +4,8 @@ from os import getenv
from pathlib import Path
from shutil import rmtree, which
from subprocess import run
+from subprocess import call
+import time
import sys
import yaml
@@ -61,6 +63,27 @@ def process_host_dependency(dependecy: dict, profile: dict):
else:
die("Can't continue without dependency and no `fallback_diffconfig` set")
+def load_metadata():
+ try:
+ with open("gl_metadata.yaml", "r") as stream:
+ metadata=yaml.safe_load(stream)
+ version = metadata["version"]
+ call("echo %s > %s" % (version, "files/etc/glversion"), shell=True)
+ call("echo %s > %s" % (version, "release"), shell=True)
+ version_type = metadata["type"]
+ call("echo %s > %s" % (version_type, "files/etc/version.type"), shell=True)
+ print("firmware version: " +version)
+ print("firmware type: " +version_type)
+ except:
+ pass
+
+def generate_files(profile):
+ if run(["mkdir", "-p", "files/etc"]).returncode:
+ die(f"Error create files")
+
+ compile_time = time.strftime('%Y-%m-%d %k:%M:%S', time.localtime(time.time()))
+ call("echo %s > %s" % (compile_time, "files/etc/version.date"), shell=True)
+ load_metadata()
def load_yaml(fname: str, profile: dict, include=True):
profile_file = (profile_folder / fname).with_suffix(".yml")
@@ -225,6 +248,7 @@ if __name__ == "__main__":
clean_tree()
setup_feeds(profile)
generate_config(profile)
+ generate_files(profile)
run(["rm", "-rf", "tmp/"])
print("Running make defconfig")
if run(["make", "defconfig"]).returncode:
--
2.25.1