Skip to content

Commit 1506f62

Browse files
committed
【添加】:通过镜像更新 Env 功能脚本和软件包列表功能
1 parent 4972c5c commit 1506f62

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

cmds/cmd_package.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -939,40 +939,65 @@ def package_wizard():
939939

940940
def upgrade_packages_index():
941941
"""Update the package repository index."""
942+
env_root = Import('env_root')
942943

943-
packages_root = os.path.join(Import('env_root'), 'packages')
944-
git_repo = 'https://github.com/RT-Thread/packages.git'
944+
env_kconfig_path = os.path.join(env_root, 'tools\scripts\cmds')
945+
env_config_file = os.path.join(env_kconfig_path, '.config')
946+
if os.path.isfile(env_config_file) and find_macro_in_config(env_config_file, 'SYS_PKGS_DOWNLOAD_ACCELERATE'):
947+
git_repo = 'https://gitee.com/RT-Thread-Mirror/packages.git'
948+
else:
949+
git_repo = 'https://github.com/RT-Thread/packages.git'
950+
951+
packages_root = os.path.join(env_root, 'packages')
945952
pkgs_path = os.path.join(packages_root, 'packages')
946953

947954
if not os.path.isdir(pkgs_path):
948955
cmd = 'git clone ' + git_repo + ' ' + pkgs_path
949956
os.system(cmd)
950957
print ("upgrade from :%s" % (git_repo))
958+
else:
959+
print("Begin to upgrade env packages.")
960+
cmd = r'git pull ' + git_repo
961+
execute_command(cmd, cwd=pkgs_path)
962+
print("==============================> Env packages upgrade done \n")
951963

952964
for filename in os.listdir(packages_root):
953965
package_path = os.path.join(packages_root, filename)
954966
if os.path.isdir(package_path):
967+
968+
if package_path == pkgs_path:
969+
continue
970+
955971
if os.path.isdir(os.path.join(package_path, '.git')):
972+
print("Begin to upgrade %s." % filename)
956973
cmd = r'git pull'
957974
execute_command(cmd, cwd=package_path)
958-
print("==============================> Env %s update done \n" % filename)
975+
print(
976+
"==============================> Env %s update done \n" % filename)
959977

960978

961979
def upgrade_env_script():
962980
"""Update env function scripts."""
963981

964-
env_scripts_root = os.path.join(Import('env_root'), 'tools', 'scripts')
965-
env_scripts_repo = 'https://github.com/RT-Thread/env.git'
982+
print("Begin to upgrade env scripts.")
983+
env_root = Import('env_root')
984+
env_kconfig_path = os.path.join(env_root, 'tools\scripts\cmds')
985+
env_config_file = os.path.join(env_kconfig_path, '.config')
986+
if os.path.isfile(env_config_file) and find_macro_in_config(env_config_file, 'SYS_PKGS_DOWNLOAD_ACCELERATE'):
987+
env_scripts_repo = 'https://gitee.com/RT-Thread-Mirror/env.git'
988+
else:
989+
env_scripts_repo = 'https://github.com/RT-Thread/env.git'
990+
991+
env_scripts_root = os.path.join(env_root, 'tools', 'scripts')
966992

967993
cmd = r'git pull ' + env_scripts_repo
968994
execute_command(cmd, cwd=env_scripts_root)
969-
970-
print("==============================> Env scripts update done \n")
995+
print("==============================> Env scripts upgrade done \n")
971996

972997

973998
def package_upgrade():
974999
"""Update the package repository directory and env function scripts."""
975-
1000+
9761001
upgrade_packages_index()
9771002
upgrade_env_script()
9781003

0 commit comments

Comments
 (0)