Publicerad källa
Ladda ner källa ZIP
CH-J Server Manager
Bläddra i kataloger och filer för en specifik programutgåva.
CH-J / Server Manager
193 filer
core-20261011T184039Z-4148710795d0
Tillagd: Datum inte noterat · Byggd:
1
#!/usr/bin/env python32
"""Pinned native HTTP runtime. Run with python3 scripts/native/build.py on macOS/Linux.3
Windows uses curl.se's reproducible, statically linked official curl-for-win release.4
No runtime downloads or system curl fallback. Build products stay outside source archives.5
"""6
import os,sys,json,hashlib,urllib.request,tarfile,zipfile,subprocess,platform,shutil7
from pathlib import Path8
here=Path(__file__).resolve().parent;app=here.parents[1]9
lock=json.loads((here/'dependencies.lock.json').read_text());system={'Darwin':'darwin','Linux':'linux','Windows':'win32'}[platform.system()];arch={'arm64':'arm64','aarch64':'arm64','x86_64':'x64','AMD64':'x64'}[platform.machine()]10
work=Path(os.environ.get('CHJ_NATIVE_WORK',str(app/'build'/'native-work'))).resolve();cache=work/'cache';prefix=work/'prefix';out=app/'build'/'native-runtime'/f'{system}-{arch}'11
for p in (cache,prefix,out):p.mkdir(parents=True,exist_ok=True)12
def run(args,**kw):13
print('+',' '.join(map(str,args)),flush=True);subprocess.run(list(map(str,args)),check=True,**kw)14
def fetch(p):15
f=cache/p['url'].split('/')[-1]16
if not f.exists():17
tmp=f.with_suffix(f.suffix+'.partial');urllib.request.urlretrieve(p['url'],tmp);tmp.replace(f)18
if hashlib.sha256(f.read_bytes()).hexdigest()!=p['sha256']:raise RuntimeError('Source checksum mismatch: '+p['name'])19
return f20
pins={p['name']:p for p in lock['sources']}21
licenses=out/'licenses';licenses.mkdir(exist_ok=True)22
if system=='win32':23
if arch!='x64':raise RuntimeError('Windows runtime supports x64 only')24
with zipfile.ZipFile(fetch(pins['curl-win'])) as z:25
for n in z.namelist():26
if n.endswith('/bin/curl.exe'): (out/'curl.exe').write_bytes(z.read(n))27
if not n.endswith('/') and (any(x in Path(n).name for x in ['COPYING','LICENSE']) or Path(n).name in ['BUILD-MANIFEST.txt','BUILD-HASHES.txt']):28
dst=licenses/('-'.join(Path(n).parts[1:]));dst.write_bytes(z.read(n))29
else:30
jobs=str(min(8,os.cpu_count() or 2));env=os.environ.copy();env['PKG_CONFIG_PATH']=str(prefix/'lib/pkgconfig');env['CMAKE_PREFIX_PATH']=str(prefix)31
def source(name):32
p=pins[name];d=work/(name+'-'+p['version'])33
if not d.exists():34
with tarfile.open(fetch(p)) as t:t.extractall(work,filter='data') if sys.version_info>=(3,12) else t.extractall(work)35
for n in ['COPYING','LICENSE','LICENSE.txt','COPYING.MIT']:36
if (d/n).exists():shutil.copy2(d/n,licenses/(name+'-'+n))37
return d38
ssl=source('openssl')39
if not (prefix/'lib/libssl.a').exists():40
run(['perl',ssl/'Configure','darwin64-arm64-cc' if system=='darwin' else 'linux-x86_64','no-shared','no-tests','no-module','--prefix='+str(prefix),'--libdir=lib'],cwd=ssl,env=env)41
run(['make','-j'+jobs],cwd=ssl,env=env);run(['make','install_sw'],cwd=ssl,env=env)42
def cmake(name,flags):43
src=source(name);b=work/(name+'-build')44
run(['cmake','-S',src,'-B',b,'-G','Ninja','-DCMAKE_BUILD_TYPE=Release','-DCMAKE_INSTALL_PREFIX='+str(prefix),'-DCMAKE_INSTALL_LIBDIR=lib','-DCMAKE_PREFIX_PATH='+str(prefix),'-DCMAKE_POSITION_INDEPENDENT_CODE=ON','-DBUILD_SHARED_LIBS=OFF','-DBUILD_STATIC_LIBS=ON','-DBUILD_TESTING=OFF',*flags],env=env)45
run(['cmake','--build',b,'--parallel',jobs],env=env);run(['cmake','--install',b],env=env)46
cmake('nghttp2',['-DENABLE_LIB_ONLY=ON','-DENABLE_STATIC_LIB=ON','-DENABLE_SHARED_LIB=OFF'])47
cmake('nghttp3',['-DENABLE_LIB_ONLY=ON','-DENABLE_STATIC_LIB=ON','-DENABLE_SHARED_LIB=OFF'])48
cmake('ngtcp2',['-DENABLE_LIB_ONLY=ON','-DENABLE_STATIC_LIB=ON','-DENABLE_SHARED_LIB=OFF','-DENABLE_OPENSSL=ON','-DOPENSSL_ROOT_DIR='+str(prefix),'-DOPENSSL_USE_STATIC_LIBS=TRUE','-DENABLE_GNUTLS=OFF','-DENABLE_BORINGSSL=OFF'])49
cmake('curl',['-DBUILD_CURL_EXE=ON','-DBUILD_STATIC_LIBS=ON','-DCURL_USE_OPENSSL=ON','-DOPENSSL_ROOT_DIR='+str(prefix),'-DOPENSSL_USE_STATIC_LIBS=TRUE','-DUSE_NGHTTP2=ON','-DUSE_NGHTTP3=ON','-DUSE_NGTCP2=ON','-DCURL_USE_LIBPSL=OFF','-DCURL_ZLIB=OFF','-DCURL_BROTLI=OFF','-DCURL_ZSTD=OFF','-DCURL_USE_LIBSSH2=OFF','-DCURL_USE_LIBSSH=OFF','-DCURL_DISABLE_LDAP=ON','-DCURL_DISABLE_LDAPS=ON','-DCURL_CA_BUNDLE=none','-DCURL_CA_PATH=none'])50
shutil.copy2(prefix/'bin/curl',out/'curl');(out/'curl').chmod(0o755)51
exe=out/('curl.exe' if system=='win32' else 'curl')52
version=subprocess.check_output([str(exe),'--disable','--version'],text=True)53
if not all(x in version.split('Features:')[-1].split() for x in ['HTTP2','HTTP3','SSL']):raise RuntimeError('Native client lacks required HTTP/2, HTTP/3 or TLS: '+version)54
# Identical pinned trust store on every platform.55
ca=(here/'ca-bundle.pem').read_bytes()56
if hashlib.sha256(ca).hexdigest()!=lock['ca']['sha256']:raise RuntimeError('CA checksum mismatch')57
(out/'ca-bundle.pem').write_bytes(ca)58
files={str(p.relative_to(out)).replace('\\','/'):hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(out.rglob('*')) if p.is_file() and p.name!='manifest.json'}59
(out/'manifest.json').write_text(json.dumps({'schema':1,'platform':system,'arch':arch,'version':version.strip(),'files':files,'sources':lock['sources'],'caSource':lock['ca']['source']},indent=2)+'\n')60
print(version);print('Verified runtime:',out)SHA-256
5932a89e953b69b440c68f19d9c2e01f6b6e994bed90cefbea9e3b80a65fba84CH-J Proprietary Software License 1.14 · Källan finns under CH-J Proprietary Software License 1.14. Dess tillgänglighet ändrar inte licensvillkoren eller ger ytterligare rättigheter.
Arkiv SHA-256
5a8ea02d06a5643cf2330fe9f54b8767a06c1c59d36527705e536fa9dbca7614