def _locate_lib_path(self): _path = os.path.join(self.PATH_PYTHON_ROOT, 'lib', 'python{}'.format(ctx.py_dot_ver)) if os.path.exists(os.path.join(_path, 'ctypes', 'wintypes.py')): return _path cc.e('\ncan not locate python lib path at [{}]'.format(_path)) raise RuntimeError()
def _locate_dll_path(self): _path = os.path.join(self.PY_STATIC_PATH, 'lib', 'python3.4', 'lib-dynload') if os.path.exists(_path): return _path cc.e('\ncan not locate python DLLs path at [{}]'.format(_path)) raise RuntimeError()
def _prepare_python(self): cc.n('prepare python header files ...', end='') if os.path.exists( os.path.join(PATH_EXTERNAL, 'python', 'include', 'Python.h')): cc.w('already exists, skip.') return cc.v('') # if os.path.exists(os.path.join(env.path_py_inc, 'Python.h')): # cc.e('can not locate python development include path, make sure miniconda installed.') # return # cc.v('') # utils.copy_ex(env.path_py_inc, os.path.join(PATH_EXTERNAL, 'python', 'include')) _header_path = None for p in sys.path: if os.path.exists(os.path.join(p, 'include', 'Python.h')): _header_path = os.path.join(p, 'include') if _header_path is None: cc.e('\ncan not locate python development include path in:') for p in sys.path: cc.e(' ', p) raise RuntimeError() utils.copy_ex(_header_path, os.path.join(PATH_EXTERNAL, 'python', 'include'))
def _locate_dll_path(self): _path = os.path.join(self.PATH_PYTHON_ROOT, 'lib', 'python{}'.format(ctx.py_dot_ver), 'lib-dynload') if os.path.exists(_path): return _path cc.e('\ncan not locate python DLLs path at [{}]'.format(_path)) raise RuntimeError()
def _build_openssl(self, file_name): cc.n('prepare OpenSSL pre-built package ... ', end='') if os.path.exists(self.OPENSSL_PATH_SRC): cc.w('already exists, skip.') return cc.v('') _alt_ver = '_'.join(env.ver_ossl.split('.')) file_name = 'Win32OpenSSL-{}.msi'.format(_alt_ver) installer = os.path.join(PATH_DOWNLOAD, file_name) if not os.path.exists(installer): if not utils.download_file( 'openssl installer', 'http://slproweb.com/download/{}'.format(filename), PATH_DOWNLOAD, file_name): cc.e('can not download pre-built installer of OpenSSL.') return utils.ensure_file_exists(installer) cc.w('On Windows, we use pre-built package of OpenSSL.') cc.w('The installer have been downloaded at "{}".'.format(installer)) cc.w('please install OpenSSL into "{}".'.format(self.OPENSSL_PATH_SRC)) cc.w( '\nOnce the OpenSSL installed, press Enter to continue or Q to quit...', end='') try: x = env.input() except EOFError: x = 'q' if x == 'q': return
def _prompt_choice(message, choices): cc.v('{} ['.format(message), end='') def_choice = '' for i in range(len(choices)): if i > 0: cc.v('/', end='') msg = choices[i][0] idx = choices[i][1] if choices[i][2]: msg = msg.upper() def_choice = msg[idx] cc.v(msg[:idx], end='') cc.e(msg[idx], end='') cc.v(msg[idx + 1:], end='') else: msg = msg.lower() cc.v(msg[:idx], end='') cc.e(msg[idx], end='') cc.v(msg[idx + 1:], end='') cc.v(']: ', end='') try: x = input().strip() if len(x) == 0: x = def_choice except EOFError: x = def_choice return x.lower()
def _build_openssl(self, file_name): _alt_ver = '_'.join(env.ver_ossl.split('.')) if not utils.download_file('openssl source tarball', 'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.format(_alt_ver), PATH_DOWNLOAD, file_name): cc.e("can not download openssl source tarball.") return False else: return True
def _locate_lib_path(self): _path = os.path.join(self.PY_STATIC_PATH, 'lib', 'python3.4') if os.path.exists(os.path.join(_path, 'ctypes', 'wintypes.py')): return _path cc.e('\ncan not locate python lib path at [{}]'.format(_path)) raise RuntimeError()
def _locate_dll_path(self): for p in sys.path: if os.path.exists(os.path.join(p, 'DLLs', '_ctypes.pyd')): return os.path.join(p, 'DLLs') cc.e('\nCan not locate python DLLs path in:') for p in sys.path: cc.e(' ', p) raise RuntimeError()
def _locate_lib_path(self): for p in sys.path: if os.path.exists(os.path.join(p, 'Lib', 'ctypes', 'wintypes.py')): return os.path.join(p, 'Lib') cc.e('\nCan not locate python lib path in:') for p in sys.path: cc.e(' ', p) raise RuntimeError()
def _locate_dev_inc_path(self): for p in sys.path: if os.path.exists(os.path.join(p, 'include', 'pyctype.h')): return os.path.join(p, 'include') cc.e('\ncan not locate python development include path in:') for p in sys.path: cc.e(' ', p) raise RuntimeError()
def _build_mbedtls(self, file_name): if not os.path.exists(self.MBEDTLS_PATH_SRC): # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, PATH_TMP)) os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) cc.n('build mbedtls...', end='') if os.path.exists( os.path.join(self.PATH_RELEASE, 'lib', 'libmbedtls.a')): cc.w('already exists, skip.') return cc.v('') # fix the Makefile mkfile = os.path.join(self.MBEDTLS_PATH_SRC, 'Makefile') f = open(mkfile) fl = f.readlines() f.close() fixed = False for i in range(len(fl)): x = fl[i].split('=') if x[0] == 'DESTDIR': fl[i] = 'DESTDIR={}\n'.format(self.PATH_RELEASE) fixed = True break if not fixed: cc.e('can not fix Makefile of mbedtls.') return f = open(mkfile, 'w') f.writelines(fl) f.close() # fix source file utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls', 'config.h')) utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls'), os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls'), 'config.h') utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library', 'rsa.c')) utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library'), os.path.join(self.MBEDTLS_PATH_SRC, 'library'), 'rsa.c') old_p = os.getcwd() os.chdir(self.MBEDTLS_PATH_SRC) os.system('make CFLAGS="-fPIC" lib') os.system('make install') os.chdir(old_p)
def _build_openssl(self, file_name): _alt_ver = '_'.join(env.ver_ossl.split('.')) if not utils.download_file( 'openssl source tarball', 'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'. format(_alt_ver), PATH_DOWNLOAD, file_name): cc.e("can not download openssl source tarball.") return False else: return True
def _build_openssl(self, file_name): cc.n('prepare OpenSSL pre-built package ... ', end='') if os.path.exists(self.OPENSSL_PATH_SRC): cc.w('already exists, skip.') return cc.v('') _alt_ver = '_'.join(env.ver_ossl.split('.')) file_name = 'Win32OpenSSL-{}.msi'.format(_alt_ver) installer = os.path.join(PATH_DOWNLOAD, file_name) if not os.path.exists(installer): if not utils.download_file( 'openssl installer', 'http://slproweb.com/download/{}'.format(filename), PATH_DOWNLOAD, file_name): cc.e('can not download pre-built installer of OpenSSL.') return utils.ensure_file_exists(installer) cc.w('On Windows, we use pre-built package of OpenSSL.') cc.w('The installer have been downloaded at "{}".'.format(installer)) cc.w('please install OpenSSL into "{}".'.format(self.OPENSSL_PATH_SRC)) cc.w( '\nOnce the OpenSSL installed, press Enter to continue or Q to quit...', end='') try: x = input() except EOFError: x = 'q' if x == 'q': return _chk_output = [ os.path.join(self.OPENSSL_PATH_SRC, 'include', 'openssl', 'aes.h'), os.path.join(self.OPENSSL_PATH_SRC, 'include', 'openssl', 'opensslv.h'), os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'libcrypto32MT.lib'), os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'libeay32MT.lib'), os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'ssleay32MT.lib'), os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'static', 'libcrypto32MT.lib'), os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'static', 'libeay32MT.lib'), os.path.join(self.OPENSSL_PATH_SRC, 'lib', 'VC', 'static', 'ssleay32MT.lib'), ] for f in _chk_output: if not os.path.exists(f): raise RuntimeError( 'build openssl static library from source code failed.')
def _check_service(self): cc.o(' - check teleport core service status ... ', end='') _err, _o = utils.sys_exec(r'sc query "{}"'.format(self._core_service_name)) if _err == 1060 or _err == 0: cc.i('[running]') else: cc.e('[not running]') cc.o(' - check teleport web service status ... ', end='') _err, _o = utils.sys_exec(r'sc query "{}"'.format(self._web_service_name)) if _err == 1060 or _err == 0: cc.i('[running]') else: cc.e('[not running]')
def _uninstall_service(self): _check_service_name = [self._old_core_service_name, self._old_web_service_name, self._core_service_name, self._web_service_name] for _service_name in _check_service_name: cc.o(' - remove service [{}] ... '.format(_service_name), end='') _err, _ = utils.sys_exec(r'sc delete "{}"'.format(_service_name)) if _err == 1060 or _err == 0: cc.i('[done]') elif _err == 1072: cc.e('[failed]') raise RuntimeError('can not remove service [{}]. please close Service Manager and try again.'.format(_service_name)) else: cc.e('[failed]') raise RuntimeError('can not remove service [{}].'.format(_service_name))
def main(): try: _main() cc.v('\n--==[ ALL DONE ]==--\n') return 0 except KeyboardInterrupt: return 1 except RuntimeError as err: cc.v('') cc.v('') cc.e(err.__str__()) cc.v('') return 2 except: cc.f('got exception.') return 3
def _check_service(self): cc.o(' - check teleport core service status ... ', end='') _err, _o = utils.sys_exec(r'sc query "{}"'.format( self._core_service_name)) if _err == 1060 or _err == 0: cc.i('[running]') else: cc.e('[not running]') cc.o(' - check teleport web service status ... ', end='') _err, _o = utils.sys_exec(r'sc query "{}"'.format( self._web_service_name)) if _err == 1060 or _err == 0: cc.i('[running]') else: cc.e('[not running]')
def _start_service(self): cc.o(' - start teleport core service ... ', end='') _err, _o = utils.sys_exec(r'sc start "{}"'.format(self._core_service_name)) # print('start core', _err, _o) if _err == 0: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError('Can not start core service.') cc.o(' - start teleport web service ...', end='') _err, _ = utils.sys_exec(r'sc start "{}"'.format(self._web_service_name)) if _err == 0: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError('Can not start web service.')
def _start_service(self): cc.o(' - start teleport core service ... ', end='') _err, _o = utils.sys_exec(r'sc start "{}"'.format( self._core_service_name)) # print('start core', _err, _o) if _err == 0: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError('Can not start core service.') cc.o(' - start teleport web service ...', end='') _err, _ = utils.sys_exec(r'sc start "{}"'.format( self._web_service_name)) if _err == 0: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError('Can not start web service.')
def _prepare_python(self): cc.n('prepare python header files ...', end='') if os.path.exists(os.path.join(PATH_EXTERNAL, 'python', 'include', 'Python.h')): cc.w('already exists, skip.') return cc.v('') _header_path = None for p in sys.path: if os.path.exists(os.path.join(p, 'include', 'Python.h')): _header_path = os.path.join(p, 'include') if _header_path is None: cc.e('\ncan not locate python development include path in:') for p in sys.path: cc.e(' ', p) raise RuntimeError() utils.copy_ex(_header_path, os.path.join(PATH_EXTERNAL, 'python', 'include'))
def _build_mbedtls(self, file_name): if not os.path.exists(self.MBEDTLS_PATH_SRC): os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) cc.n('build mbedtls...', end='') if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libmbedtls.a')): cc.w('already exists, skip.') return cc.v('') # fix the Makefile mkfile = os.path.join(self.MBEDTLS_PATH_SRC, 'Makefile') f = open(mkfile) fl = f.readlines() f.close() fixed = False for i in range(len(fl)): x = fl[i].split('=') if x[0] == 'DESTDIR': fl[i] = 'DESTDIR={}\n'.format(self.PATH_RELEASE) fixed = True break if not fixed: cc.e('can not fix Makefile of mbedtls.') return f = open(mkfile, 'w') f.writelines(fl) f.close() # fix source file utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls', 'config.h')) utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls'), os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls'), 'config.h') # utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library', 'rsa.c')) # utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library'), os.path.join(self.MBEDTLS_PATH_SRC, 'library'), 'rsa.c') old_p = os.getcwd() os.chdir(self.MBEDTLS_PATH_SRC) os.system('make CFLAGS="-fPIC" lib') os.system('make install') os.chdir(old_p)
def _install_service(self): cc.o(' - install teleport core service ... ', end='') _core = os.path.join(self._install_path, 'bin', 'tp_core.exe') _err, _ = utils.sys_exec(r'"{}" -i'.format(_core)) if _err == 0 or _err == 1: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError('Install core service failed. error code: {}'.format(_err)) cc.o(' - install teleport web service ... ', end='') _core = os.path.join(self._install_path, 'bin', 'tp_web.exe') _err, _ = utils.sys_exec(r'"{}" -i'.format(_core)) if _err == 0 or _err == 1: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError('Install web service failed. error code: {}'.format(_err)) return True
def _uninstall_service(self): _check_service_name = [ self._old_core_service_name, self._old_web_service_name, self._core_service_name, self._web_service_name ] for _service_name in _check_service_name: cc.o(' - remove service [{}] ... '.format(_service_name), end='') _err, _ = utils.sys_exec(r'sc delete "{}"'.format(_service_name)) if _err == 1060 or _err == 0: cc.i('[done]') elif _err == 1072: cc.e('[failed]') raise RuntimeError( 'can not remove service [{}]. please close Service Manager and try again.' .format(_service_name)) else: cc.e('[failed]') raise RuntimeError( 'can not remove service [{}].'.format(_service_name))
def _check_installation_ver(self): if not self._is_installed: return # try to get the installed version from www/teleport/app/eom_ver.py cc.o(' - check installed version ... ', end='') ver_file = os.path.join(self._install_path, 'www', 'teleport', 'webroot', 'app', 'app_ver.py') try: with open(ver_file) as f: x = f.readlines() for i in x: s = i.split('=', 1) if 'TP_SERVER_VER' == s[0].strip(): self._installed_ver_str = s[1].strip()[1:-1] cc.i('[{}]'.format(self._installed_ver_str)) # self._installed_ver = self._ver_str_to_ver(self._installed_ver_str) break except FileNotFoundError: cc.e('[failed]') cc.e(' the installation maybe broken')
def _prepare_python_header(self): cc.n('prepare python header files ...', end='') if os.path.exists( os.path.join(PATH_EXTERNAL, 'python', 'include', 'pyctype.h')): cc.w('already exists, skip.') return cc.v('') _header_path = None for p in sys.path: if os.path.exists(os.path.join(p, 'include', 'pyctype.h')): _header_path = os.path.join(p, 'include') if _header_path is None: cc.e('\ncan not locate python development include path in:') for p in sys.path: cc.e(' ', p) raise RuntimeError() utils.copy_ex(_header_path, os.path.join(PATH_EXTERNAL, 'python', 'include'))
def _install_service(self): cc.o(' - install teleport core service ... ', end='') _core = os.path.join(self._install_path, 'bin', 'tp_core.exe') _err, _ = utils.sys_exec(r'"{}" -i'.format(_core)) if _err == 0 or _err == 1: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError( 'Install core service failed. error code: {}'.format(_err)) cc.o(' - install teleport web service ... ', end='') _core = os.path.join(self._install_path, 'bin', 'tp_web.exe') _err, _ = utils.sys_exec(r'"{}" -i'.format(_core)) if _err == 0 or _err == 1: cc.i('[done]') else: cc.e('[failed]') raise RuntimeError( 'Install web service failed. error code: {}'.format(_err)) return True
def _build_sqlite(self, file_name): cc.e("this is a pure-virtual function.")
def _build_libssh(self, file_name): cc.e("this is a pure-virtual function.")
def build_installer(self): cc.e('not support linux.')
def _build_libssh(self, file_name): if not self._download_libssh(file_name): return cc.n('build libssh library from source code... ', end='') if not os.path.exists(self.LIBSSH_PATH_SRC): cc.v('') utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL) os.rename( os.path.join(PATH_EXTERNAL, 'libssh-{}'.format(env.ver_libssh)), self.LIBSSH_PATH_SRC) cc.n('fix libssh source code... ', end='') s_name = 'libssh-{}'.format(env.ver_libssh) utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'session.c')) # # utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto.c')) # utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto-compat.c')) utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'session.c') # ## utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto.c') # # utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto-compat.c') out_file_lib = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.lib') out_file_dll = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.dll') if os.path.exists(out_file_lib) and os.path.exists(out_file_dll): cc.w('already exists, skip.') return cc.v('') build_path = os.path.join(self.LIBSSH_PATH_SRC, 'build') if not os.path.exists(build_path): utils.makedirs(build_path) openssl_path = os.path.join(PATH_EXTERNAL, 'OpenSSL') cmake_define = ' -DOPENSSL_INCLUDE_DIR={path_release}\include' \ ' -DOPENSSL_LIBRARIES={path_release}\lib\VC\static' \ ' -DWITH_SFTP=ON' \ ' -DWITH_SERVER=ON' \ ' -DWITH_GSSAPI=OFF' \ ' -DWITH_ZLIB=OFF' \ ' -DWITH_PCAP=OFF' \ ' -DWITH_STATIC_LIB=ON' \ ' -DUNIT_TESTING=OFF' \ ' -DWITH_EXAMPLES=OFF' \ ' -DWITH_BENCHMARKS=OFF' \ ' -DWITH_NACL=OFF' \ ''.format(path_release=openssl_path) # ' -DCMAKE_INSTALL_PREFIX={path_release}' # ' -DWITH_STATIC_LIB=ON' # ' -DBUILD_SHARED_LIBS=OFF' old_p = os.getcwd() try: os.chdir(build_path) utils.cmake(build_path, 'Release', False, cmake_define=cmake_define) os.chdir(build_path) # utils.sys_exec('make install') except: cc.e('can not make') raise os.chdir(old_p) # cc.w('On Windows, when build libssh, need you use cmake-gui.exe to generate solution file') # cc.w('for Visual Studio 2017. Visit https://docs.tp4a.com for more details.') # cc.w('\nOnce the libssh.sln generated, press Enter to continue or Q to quit...', end='') # try: # x = env.input() # except EOFError: # x = 'q' # if x == 'q': # return cc.i('build libssh...') sln_file = os.path.join(self.LIBSSH_PATH_SRC, 'build', 'libssh.sln') utils.msvc_build(sln_file, 'ssh_shared', ctx.target_path, 'win32', False) utils.ensure_file_exists( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path, 'ssh.lib')) utils.ensure_file_exists( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path, 'ssh.dll')) utils.copy_file( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path), os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path), 'ssh.lib') utils.copy_file( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path), os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path), 'ssh.dll') utils.ensure_file_exists(out_file_lib) utils.ensure_file_exists(out_file_dll)
def _build_mbedtls(self, file_name): if not os.path.exists(self.MBEDTLS_PATH_SRC): # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, PATH_TMP)) os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) cc.n('build mbedtls...', end='') if os.path.exists( os.path.join(self.PATH_RELEASE, 'lib', 'libmbedtls.a')): cc.w('already exists, skip.') return cc.v('') # fix the Makefile mkfile = os.path.join(self.MBEDTLS_PATH_SRC, 'Makefile') f = open(mkfile) fl = f.readlines() f.close() fixed = False for i in range(len(fl)): x = fl[i].split('=') if x[0] == 'DESTDIR': fl[i] = 'DESTDIR={}\n'.format(self.PATH_RELEASE) fixed = True break if not fixed: cc.e('can not fix Makefile of mbedtls.') return f = open(mkfile, 'w') f.writelines(fl) f.close() # # fix config.h # mkfile = os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls', 'config.h') # f = open(mkfile) # fl = f.readlines() # f.close() # # for i in range(len(fl)): # if fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED') >= 0: # fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED\n' # elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED') >= 0: # fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED\n' # elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED') >= 0: # fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED\n' # elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED') >= 0: # fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED\n' # elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED') >= 0: # fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED\n' # elif fl[i].find('#define MBEDTLS_SELF_TEST') >= 0: # fl[i] = '//#define MBEDTLS_SELF_TEST\n' # elif fl[i].find('#define MBEDTLS_SSL_RENEGOTIATION') >= 0: # fl[i] = '//#define MBEDTLS_SSL_RENEGOTIATION\n' # elif fl[i].find('#define MBEDTLS_ECDH_C') >= 0: # fl[i] = '//#define MBEDTLS_ECDH_C\n' # elif fl[i].find('#define MBEDTLS_ECDSA_C') >= 0: # fl[i] = '//#define MBEDTLS_ECDSA_C\n' # elif fl[i].find('#define MBEDTLS_ECP_C') >= 0: # fl[i] = '//#define MBEDTLS_ECP_C\n' # elif fl[i].find('#define MBEDTLS_NET_C') >= 0: # fl[i] = '//#define MBEDTLS_NET_C\n' # # elif fl[i].find('#define MBEDTLS_RSA_NO_CRT') >= 0: # fl[i] = '#define MBEDTLS_RSA_NO_CRT\n' # elif fl[i].find('#define MBEDTLS_SSL_PROTO_SSL3') >= 0: # fl[i] = '#define MBEDTLS_SSL_PROTO_SSL3\n' # # f = open(mkfile, 'w') # f.writelines(fl) # f.close() # fix source file utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls', 'config.h')) utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls'), os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls'), 'config.h') utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library', 'rsa.c')) utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library'), os.path.join(self.MBEDTLS_PATH_SRC, 'library'), 'rsa.c') old_p = os.getcwd() os.chdir(self.MBEDTLS_PATH_SRC) os.system('make CFLAGS="-fPIC" lib') os.system('make install') os.chdir(old_p)
def _build_mongoose(self, file_name): cc.e("this is a pure-virtual function.")
def _build_openssl(self, file_name): cc.e("this is a pure-virtual function.")
def _build_jsoncpp(self, file_name): cc.e("this is a pure-virtual function.")
def _init_path(self): cc.e("this is a pure-virtual function.")
def _prepare_python(self): cc.e("this is a pure-virtual function.")
def build_exe(self): cc.e('not support linux.')
def _build_mbedtls(self, file_name): cc.e("this is a pure-virtual function.")
lines[x] = '\t<string>{ver}</string>\n'.format(ver=ver) bOK = True if bOK: cc.v(' update {}...'.format(plist_file)) wrcFile = codecs.open(plist_file, 'w', 'utf8') wrcFile.writelines(lines) wrcFile.close() except IOError: raise RuntimeError('can not process plist file.') def main(): if not env.init(): return builder = Builder() builder.build() if __name__ == '__main__': try: main() except KeyboardInterrupt: pass except RuntimeError as e: cc.e(e.__str__()) except: cc.f('got exception.')
ctx.set_bits(BITS_32) elif 'x64' == argv[i]: ctx.set_bits(BITS_64) elif argv[i] in ctx.dist_all: builder = gen_builder(argv[i]) if builder is None: builder = gen_builder(ctx.host_os) builder.prepare_python() builder.build_jsoncpp() builder.build_mongoose() builder.build_openssl() builder.build_libuv() builder.build_mbedtls() builder.build_libssh() builder.fix_output() if __name__ == '__main__': try: main() except KeyboardInterrupt: pass except RuntimeError as e: cc.e(e.__str__()) except: cc.f('got exception.')