From a54877e82ae0b6d338b630573800cad73b85f3cb Mon Sep 17 00:00:00 2001 From: ThomasVon2021 <1767893964@qq.com> Date: Mon, 9 Sep 2024 13:36:06 +0800 Subject: [PATCH] chore: add update specify version --- script/update.py | 36 +++++++++++++++++++++++------------- web_src/web_client | 2 +- web_src/web_server | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/script/update.py b/script/update.py index bfc6595..c5148b9 100755 --- a/script/update.py +++ b/script/update.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 # -*- coding:utf8 -*- -# eg: python3 update.py alpha +# eg: python3 update.py alpha v1.4.2 import json import os import sys @@ -124,7 +124,10 @@ def main(): make_path = sh_path + '/src' is_alpha = len(sys.argv) > 1 and sys.argv[1].lower() == "alpha" - + specified_version = None + # Check if a version has been passed as an argument + if len(sys.argv) > 2: + specified_version = sys.argv[2] # Remove/clear download directory cmd = "rm -rf /tmp/kvm_update" output = subprocess.check_output(cmd, shell = True, cwd=sh_path ) @@ -141,16 +144,22 @@ def main(): while(a>0): latest_version = '' run_version = '' - # get latest tag - url = "https://api.github.com/repos/{owner}/{repo}/releases/latest" - response = requests.get(url.format(owner="ThomasVon2021", repo="blikvm")) - json_response = response.json() - if "tag_name" in json_response: - latest_version = json_response["tag_name"] - print("The latest release tag for blikvm is ", latest_version) + if specified_version: + # Use the specified version + latest_version = specified_version + print(f"Specified version: {latest_version}") else: - print("Cannot find the latest release tag") - return + # Get the latest tag from GitHub if no version is specified + url = "https://api.github.com/repos/{owner}/{repo}/releases/latest" + response = requests.get(url.format(owner=code_owner, repo=code_repo)) + json_response = response.json() + if "tag_name" in json_response: + latest_version = json_response["tag_name"] + print("The latest release tag for blikvm is ", latest_version) + else: + print("Cannot find the latest release tag") + return + # get local tag run_json = '/usr/bin/blikvm/package.json' if not os.path.exists(run_json): @@ -181,7 +190,7 @@ def main(): except subprocess.CalledProcessError as e: print("Download release package failed, check network") break - print("Download release package success, start to install, please wait...", flush=True) + print("Download release package success, start to install, please wait 60s...", flush=True) release_tar = download_path + file_name if os.path.exists(release_tar): cmd = "tar -zxvf " + file_name @@ -192,7 +201,8 @@ def main(): else: cmd = "python3 install_release.py" - output = subprocess.check_output(cmd, shell = True, cwd=install_path) + output = subprocess.check_output(cmd, shell = True, cwd=install_path) + print(output) update_result = True print("Upgrade successful!", flush=True) else: diff --git a/web_src/web_client b/web_src/web_client index 3a752f1..0a25b72 160000 --- a/web_src/web_client +++ b/web_src/web_client @@ -1 +1 @@ -Subproject commit 3a752f14d2538d78e89718cee37c190b4dcb477e +Subproject commit 0a25b7207cb7c183cf10b5463efa8c4bedb2e58e diff --git a/web_src/web_server b/web_src/web_server index c507d37..da038de 160000 --- a/web_src/web_server +++ b/web_src/web_server @@ -1 +1 @@ -Subproject commit c507d3793a220055b693444da182ce953f6d8629 +Subproject commit da038de20e4241c2fa88e7c4839ced366f8d6e70