From 58c4f41ac78762cbb40c90a86043e8e6ac49f7c7 Mon Sep 17 00:00:00 2001 From: Marcelo Date: Tue, 2 Aug 2022 02:36:23 +0000 Subject: [PATCH] allow setting optional url for packages via envvar. (#5839) * allow setting optional url for packages via envvar. * clean up left over * simplify code as suggested by Bernard (thanks) * fix typo (envvar name should be all upper case) --- tools/menuconfig.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/menuconfig.py b/tools/menuconfig.py index 853e4fe7f8..82274fdbb5 100644 --- a/tools/menuconfig.py +++ b/tools/menuconfig.py @@ -30,6 +30,10 @@ import shutil import hashlib import operator +DEFAULT_RTT_PACKAGE_URL = 'https://github.com/RT-Thread/packages.git' +# you can change the package url by defining RTT_PACKAGE_URL, ex: +# export RTT_PACKAGE_URL=https://github.com/Varanda-Labs/packages.git + # make rtconfig.h from .config def is_pkg_special_config(config_str): @@ -146,6 +150,8 @@ def touch_env(): home_dir = os.environ['HOME'] else: home_dir = os.environ['USERPROFILE'] + + package_url = os.getenv('RTT_PACKAGE_URL') or DEFAULT_RTT_PACKAGE_URL env_dir = os.path.join(home_dir, '.env') if not os.path.exists(env_dir): @@ -158,7 +164,7 @@ def touch_env(): if not os.path.exists(os.path.join(env_dir, 'packages', 'packages')): try: - ret = os.system('git clone https://github.com/RT-Thread/packages.git %s' % os.path.join(env_dir, 'packages', 'packages')) + ret = os.system('git clone %s %s' % (package_url, os.path.join(env_dir, 'packages', 'packages'))) if ret != 0: shutil.rmtree(os.path.join(env_dir, 'packages', 'packages')) print("********************************************************************************\n"