(use_gitee=False)
| 103 | |
| 104 | |
| 105 | def touch_env(use_gitee=False): |
| 106 | if sys.platform != 'win32': |
| 107 | home_dir = os.environ['HOME'] |
| 108 | else: |
| 109 | home_dir = os.environ['USERPROFILE'] |
| 110 | |
| 111 | if use_gitee: |
| 112 | # "Install RT-Thread Environment from Gitee" |
| 113 | sdk_url = 'https://gitee.com/RT-Thread-Mirror/sdk.git' |
| 114 | pkg_url = 'https://gitee.com/RT-Thread-Mirror/packages.git' |
| 115 | env_url = 'https://gitee.com/RT-Thread-Mirror/env.git' |
| 116 | else: |
| 117 | pkg_url = 'https://github.com/RT-Thread/packages.git' |
| 118 | sdk_url = 'https://github.com/RT-Thread/sdk.git' |
| 119 | env_url = 'https://github.com/RT-Thread/env.git' |
| 120 | |
| 121 | pkg_url = os.getenv('RTT_PACKAGE_URL') or pkg_url |
| 122 | sdk_url = os.getenv('RTT_SDK_URL') or sdk_url |
| 123 | env_url = os.getenv('RTT_ENV_URL') or env_url |
| 124 | |
| 125 | # make .env and other directories |
| 126 | env_dir = os.path.join(home_dir, '.env') |
| 127 | if not os.path.exists(env_dir): |
| 128 | os.mkdir(env_dir) |
| 129 | os.mkdir(os.path.join(env_dir, 'local_pkgs')) |
| 130 | os.mkdir(os.path.join(env_dir, 'packages')) |
| 131 | os.mkdir(os.path.join(env_dir, 'tools')) |
| 132 | kconfig = open(os.path.join(env_dir, 'packages', 'Kconfig'), 'w') |
| 133 | kconfig.close() |
| 134 | |
| 135 | # git clone packages |
| 136 | if not os.path.exists(os.path.join(env_dir, 'packages', 'packages')): |
| 137 | try: |
| 138 | ret = os.system('git clone %s %s' % (pkg_url, os.path.join(env_dir, 'packages', 'packages'))) |
| 139 | if ret != 0: |
| 140 | shutil.rmtree(os.path.join(env_dir, 'packages', 'packages')) |
| 141 | print( |
| 142 | "********************************************************************************\n" |
| 143 | "* Warnning:\n" |
| 144 | "* Run command error for \"git clone https://github.com/RT-Thread/packages.git\".\n" |
| 145 | "* This error may have been caused by not found a git tool or network error.\n" |
| 146 | "* If the git tool is not installed, install the git tool first.\n" |
| 147 | "* If the git utility is installed, check whether the git command is added to \n" |
| 148 | "* the system PATH.\n" |
| 149 | "* This error may cause the RT-Thread packages to not work properly.\n" |
| 150 | "********************************************************************************\n" |
| 151 | ) |
| 152 | help_info() |
| 153 | else: |
| 154 | kconfig = open(os.path.join(env_dir, 'packages', 'Kconfig'), 'w') |
| 155 | kconfig.write('source "$PKGS_DIR/packages/Kconfig"') |
| 156 | kconfig.close() |
| 157 | except: |
| 158 | print( |
| 159 | "**********************************************************************************\n" |
| 160 | "* Warnning:\n" |
| 161 | "* Run command error for \"git clone https://github.com/RT-Thread/packages.git\". \n" |
| 162 | "* This error may have been caused by not found a git tool or git tool not in \n" |
no test coverage detected