Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Bundle static curl for Linux AppImage downloads
Bowen Xue72f969429cc8
diff --git a/freevideo_engine/comfy_environment.py b/freevideo_engine/comfy_environment.pyindex 4b0ea9e..f3d1625 100644--- a/freevideo_engine/comfy_environment.py+++ b/freevideo_engine/comfy_environment.py@@ -35,4 +35,7 @@ def isolated_environment(root, source, environ=None):env.update(FREEVIDEO_HOME=str(root), FREEVIDEO_PROXY_MODE=proxy_mode, PYTHONPATH=str(source), PYTHONNOUSERSITE='1',PYTHONUTF8='1', PYTHONIOENCODING='utf-8', NO_COLOR='1', FREEVIDEO_UI_EVENTS='1')from .triton_compat import temporary_environment- return temporary_environment(root, env)+ # Pruning sys.prefix above also prunes the frozen launcher's static curl.+ # Restore its fallback for managed Python after isolating Python packages.+ from .linux_bundle import child_environment+ return temporary_environment(root, child_environment(env))diff --git a/freevideo_engine/diagnostics.py b/freevideo_engine/diagnostics.pyindex 9f15bc4..29e08a0 100644--- a/freevideo_engine/diagnostics.py+++ b/freevideo_engine/diagnostics.py@@ -42,7 +42,11 @@ ABSOLUTE_PATH = re.compile(# The preceding character guard prevents URL slashes from being treated# as local paths while still matching a drive path after prose such as# ``at C:\\Users\\...`` or a quoted traceback location.- r'''(?<![A-Za-z0-9_:/])(?:(?:[A-Za-z]:[\\/])|(?:\\\\[^\\/\s"'<>]+[\\/])|/(?!/))[^"'<>;\r\n,\)\]}]*''')+ # Consume explicit relative paths too, spaces included, so an interior+ # slash (after e.g. a hyphen) cannot subsequently be mistaken for an+ # absolute path. Only our own ``./setup.sh`` command stays as written.+ r'''(?<![A-Za-z0-9_:/])(?:(?P<command>\./setup\.sh(?![\w/\\-]|\.\w))|\.{1,2}/[^"'<>;\r\n,\)\]}]*|'''+ r'''(?:(?:[A-Za-z]:[\\/])|(?:\\\\[^\\/\s"'<>]+[\\/])|/(?!/))[^"'<>;\r\n,\)\]}]*)''')class Redactor:@@ -97,6 +101,8 @@ class Redactor:@classmethoddef _path_match(cls, match):value = match.group(0)+ if match.group('command') is not None:+ return value# Text is often redacted again (a worker's log inside a report, the# launcher terminal). The ``/name`` after an earlier ``<PATH>`` is that# pass's own output, unless it still has a directory in it.diff --git a/freevideo_engine/failure_details.py b/freevideo_engine/failure_details.pyindex 5ebbfda..7a5a3c2 100644--- a/freevideo_engine/failure_details.py+++ b/freevideo_engine/failure_details.py@@ -148,7 +148,17 @@ def display_launcher_error(value, *, zh=False, replacements=()):from .offline_errors import alias_failure, guidanceif alias_failure(value):return guidance('runtime-alias', zh)- return redacted_launcher_error(value, replacements)+ text = redacted_launcher_error(value, replacements)+ if zh:+ text = re.sub(r'Missing curl, needed for downloads and proxy connections\. '+ r'(In a terminal, run: ([^\r\n]+?), then check again\.|'+ r'Ask your administrator to install curl, then check again\.)'+ r'( You can also run \./setup\.sh in the source folder\.)?',+ lambda match: '缺少 curl,下载和代理连接需要它。' ++ ('请在终端运行:' + match.group(2) + ',然后重新检查。' if match.group(2) else+ '请管理员安装 curl,然后重新检查。') ++ ('也可以在源码目录运行 ./setup.sh。' if match.group(3) else ''), text)+ return textdef setup_command_failure(label, log, exit_code):diff --git a/freevideo_engine/linux_bundle.py b/freevideo_engine/linux_bundle.pyindex bca5a1c..10fb1ea 100644--- a/freevideo_engine/linux_bundle.py+++ b/freevideo_engine/linux_bundle.py@@ -61,6 +61,21 @@ def child_environment(environ=None):env.pop(name)elif name in QT_VARIABLES and inside_bundle(env[name]):env.pop(name)+ # Setup also runs through bash and a managed, non-frozen Python. Carry the+ # selected fallback on PATH so those workers use system.curl_executable()+ # just like the GUI. Append it: existing system tools keep priority.+ from .system import curl_executable, curl_ca_arguments+ bundled = bundle_directory() / 'curl/curl'+ curl = curl_executable(env) if bundled.is_file() else None+ if curl is not None and Path(curl) == bundled:+ folder = str(Path(curl).parent)+ path = env.get('PATH', os.defpath)+ if folder not in path.split(os.pathsep):+ env['PATH'] = path + os.pathsep + folder if path else folder+ certificates = curl_ca_arguments(curl, env)+ if certificates:+ # curl reads no variable for proxy roots; curl_command and setup pass this one on.+ env['CURL_CA_BUNDLE'] = env['FREEVIDEO_CURL_PROXY_CA'] = certificates[1]return envdiff --git a/freevideo_engine/modern_launcher.py b/freevideo_engine/modern_launcher.pyindex fac5388..60a0512 100644--- a/freevideo_engine/modern_launcher.py+++ b/freevideo_engine/modern_launcher.py@@ -426,6 +426,16 @@ def smoke_test(app, engine, window, bridge, destination):try:payload = check_launcher_payload(session.source, destination)payload['reopen'] = check_launcher_reopen(destination)+ from .linux_bundle import frozen_linux, child_environment+ if frozen_linux():+ import subprocess+ from .network import curl_command+ command = curl_command(5)+ version = subprocess.run([command[0], '--version'], env=child_environment(),+ capture_output=True, text=True, timeout=10, check=True).stdout+ if 'https' not in version:+ raise RuntimeError('Packaged curl lacks HTTPS support')+ payload['curl'] = dict(executable=command[0], version=version.splitlines()[0])from PySide6.QtQuick import QQuickItemfor page in ('comfy', 'models', 'progress', 'launcher'):session.page = pagediff --git a/freevideo_engine/network.py b/freevideo_engine/network.pyindex 30c379a..ea3000a 100644--- a/freevideo_engine/network.py+++ b/freevideo_engine/network.py@@ -25,7 +25,7 @@ import timefrom urllib.parse import quote, unquote, urlencode, urljoin, urlsplitfrom . import proxyfrom .long_paths import io_path, is_windows, path_chars, plain, plain_errors-from .system import curl_executable, missing_curl_message, windows+from .system import curl_executable, curl_ca_arguments, missing_curl_message, windowsSOURCES = {@@ -156,6 +156,9 @@ def curl_command(timeout, env=None):command = [executable, '--config', '-', '--silent', '--show-error', '--no-location-trusted', '--location','--max-redirs', '5', '--fail', '--proto', '=https,http', '--proto-redir', '=https,http','--connect-timeout', str(timeout), '--user-agent', 'FreeVideo-Setup/1']+ command += curl_ca_arguments(executable, env)+ if '--proxy-cacert' not in command and (env or {}).get('FREEVIDEO_CURL_PROXY_CA'):+ command += ['--proxy-cacert', env['FREEVIDEO_CURL_PROXY_CA']]if (env or {}).get('FREEVIDEO_PROXY_ROUTE') == 'direct':command += ['--proxy', '', '--noproxy', '*']return command@@ -579,8 +582,11 @@ def _package_failure(error):value = re.sub(r'(?i)(\b[\w-]{0,64}(?:token|password|secret|api[_-]?key)\s*[=:]\s*)[^\s,;&]+',r'\1<REDACTED>', value)# Keep a stable path marker without exposing usernames, drives or mounts.- value = re.sub(r'(?<![A-Za-z0-9_:/])(?:[A-Za-z]:[\\/]|/)([^\s"\'<>;,)\]}]*)',- lambda match: '<PATH>/' + re.split(r'[\\/]', match.group(1).rstrip('\\/'))[-1], value)+ value = re.sub(r'(?<![A-Za-z0-9_:/])(?:(?P<relative>\.{1,2}/[^\s"\'<>;,)\]}]*)|'+ r'(?:[A-Za-z]:[\\/]|/)([^\s"\'<>;,)\]}]*))',+ lambda match: match.group('relative') if match.group('relative') is not None+ and not re.search(r'[\\/]', match.group('relative').split('/', 1)[1]) else+ '<PATH>/' + re.split(r'[\\/]', match.group(0).rstrip('\\/'))[-1], value)lines = [line.strip() for line in value.splitlines() if line.strip()]detail = '\n'.join(lines[-12:])[-4096:] if lines else 'no package-manager output'summary = next((line for line in lines if line), detail).strip()[:320]diff --git a/freevideo_engine/system.py b/freevideo_engine/system.pyindex 95a8d60..4173395 100644--- a/freevideo_engine/system.py+++ b/freevideo_engine/system.py@@ -17,7 +17,36 @@ def curl_executable(env=None):from .curl_windows import inspectreturn inspect(env)['selected']found = shutil.which('curl', path=env.get('PATH', os.defpath))- return str(Path(found).absolute()) if found else None+ if found:+ return str(Path(found).absolute())+ from .linux_bundle import frozen_linux, bundle_directory+ if frozen_linux():+ bundled = bundle_directory() / 'curl/curl'+ if bundled.is_file() and os.access(bundled, os.X_OK):+ return str(bundled)+ return None+++def curl_ca_arguments(executable, env=None):+ """Use desktop trust roots for bundled curl, with its embedded Mozilla CA fallback.++ Leave system curl and explicit certificate settings alone. In particular,+ corporate proxy roots installed by the administrator must remain usable.+ The static binary needs neither libssl nor LD_LIBRARY_PATH from the bundle.+ """+ from .linux_bundle import frozen_linux, bundle_directory+ if not frozen_linux() or Path(executable) != bundle_directory() / 'curl/curl':+ return []+ env = os.environ if env is None else env+ if any(env.get(name) for name in ('CURL_CA_BUNDLE', 'SSL_CERT_FILE', 'SSL_CERT_DIR')):+ return []+ for name in ('/etc/ssl/certs/ca-certificates.crt', # Debian / Ubuntu+ '/etc/pki/tls/certs/ca-bundle.crt', # Fedora / RHEL+ '/etc/ssl/ca-bundle.pem'): # openSUSE+ if Path(name).is_file():+ # An https:// proxy is verified separately from the target server.+ return ['--cacert', name, '--proxy-cacert', name]+ return [] # curl 8.22.0's verified, embedded CA bundle.def missing_curl_message(env=None):@@ -26,7 +55,14 @@ def missing_curl_message(env=None):return failure_message(inspect(env))if platform.system() == 'Darwin':return 'macOS curl was not found. Check /usr/bin/curl and reopen FreeVideo with curl available in PATH.'- return 'Missing curl for bounded downloads and HTTP/SOCKS proxy support. Run ./setup.sh to install it.'+ env = os.environ if env is None else env+ command = linux_tools_command(['curl'], which=lambda name: shutil.which(name, path=env.get('PATH', os.defpath)))+ message = 'Missing curl, needed for downloads and proxy connections. %s, then check again.' % (+ 'In a terminal, run: ' + command if command else 'Ask your administrator to install curl')+ source = source_root()+ if source is not None and Path.cwd().resolve() == source and (source / 'setup.sh').is_file():+ message += ' You can also run ./setup.sh in the source folder.'+ return messagedef linux_tools_command(names, which=shutil.which, root=None):diff --git a/scripts/bootstrap_linux.sh b/scripts/bootstrap_linux.shindex 32bcc15..6257f83 100644--- a/scripts/bootstrap_linux.sh+++ b/scripts/bootstrap_linux.sh@@ -217,7 +217,7 @@ fv_download_uv() {[[ "$url" != *$'\n'* && "$url" != *$'\r'* && "$url" != *'"'* && "$url" != *"\\"* ]] || { fv_fail 'Invalid mirror URL.'; return 1; }part="$archive.partial.$(date +%s).$$.$attempt"if printf 'url = "%s"\n' "$url" | fv_with_route "$route" curl --disable --config - --fail --location --silent --show-error \- --connect-timeout 5 --max-time 120 --speed-limit 1024 --speed-time 20 --retry 1 \+ ${FREEVIDEO_CURL_PROXY_CA:+--proxy-cacert "$FREEVIDEO_CURL_PROXY_CA"} --connect-timeout 5 --max-time 120 --speed-limit 1024 --speed-time 20 --retry 1 \--retry-max-time 130 --output "$part" >>"$FREEVIDEO_BOOTSTRAP_ROOT/bootstrap.log" 2>&1; thenif printf '%s %s\n' "$FV_UV_SHA256" "$part" | sha256sum --check --status; thenmv -- "$part" "$archive"diff --git a/scripts/build_linux.py b/scripts/build_linux.pyindex 9712256..ac0573c 100644--- a/scripts/build_linux.py+++ b/scripts/build_linux.py@@ -18,6 +18,7 @@ import shutilimport subprocessimport sysimport sysconfig+import tarfileimport urllib.requestROOT = Path(__file__).resolve().parents[1]@@ -33,6 +34,14 @@ from scripts.deduplicate_bundle_data import deduplicate_bundle_data, write_data_APP_ID = 'org.flashml.FreeVideo'NAME = RELEASE_ASSETS[LINUX_CHANNEL][0]TOOLS = {+ # stunnel/static-curl 8.22.0, x86_64 musl: fully static, HTTPS + HTTP/SOCKS+ # proxies, with embedded Mozilla roots. The dev archive supplies the original+ # licenses for curl AND its linked components; headers/libraries are not shipped.+ 'curl': dict(version='8.22.0',+ url='https://github.com/stunnel/static-curl/releases/download/8.22.0/curl-linux-x86_64-dev-8.22.0.tar.xz',+ sha256='93a928c9bab36604ff646e7de31c9d4b789145acf8c7cda75e7da2e1221c5cc7',+ binary_sha256='b7443db66d622a27ef2152bb2032d6ada9fb29a8917f22b9521a993f8e61cd7f',+ ca_sha256='f66dff1bdf8f96060b8177976f8b7d9254bc89bc4db933d769f7384d28480bc9'),'appimagetool': dict(url='https://github.com/AppImage/appimagetool/releases/download/1.9.1/appimagetool-x86_64.AppImage',sha256='ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3cb384eb0'),'runtime': dict(url='https://github.com/AppImage/type2-runtime/releases/download/20251108/runtime-x86_64',@@ -90,11 +99,43 @@ def tool(cache, name):stage.replace(path)if hashlib.sha256(path.read_bytes()).hexdigest() != spec['sha256']:raise SystemExit('Pinned %s does not match its checksum: %s' % (name, path))- if not name.startswith('font'):+ if name in ('appimagetool', 'runtime'):path.chmod(0o755)return path+def bundle_curl(cache, destination, notices):+ """Stage only the verified static executable and its original license texts."""+ spec = TOOLS['curl']+ destination.mkdir(parents=True, exist_ok=True)+ licenses = notices / 'curl'+ licenses.mkdir(parents=True, exist_ok=True)+ with tarfile.open(tool(cache, 'curl'), 'r:xz') as archive:+ # Read exact members, never extract archive paths or follow archive links.+ member = archive.getmember('curl-x86_64/bin/curl')+ if not member.isfile():+ raise ValueError('Bundled curl must be a regular file')+ data = archive.extractfile(member).read()+ if hashlib.sha256(data).hexdigest() != spec['binary_sha256']:+ raise ValueError('Bundled curl binary does not match its checksum')+ executable = destination / 'curl'+ executable.write_bytes(data)+ executable.chmod(0o755)+ copied = []+ for member in archive.getmembers():+ path = Path(member.name)+ if path.parent == Path('curl-x86_64/licenses') and member.isfile():+ (licenses / (path.name + '.txt')).write_bytes(archive.extractfile(member).read())+ copied.append(path.name)+ if not {'curl', 'ca-bundle', 'openssl'} <= set(copied):+ raise ValueError('Bundled curl licenses are missing')+ (licenses / 'SOURCE.txt').write_text(+ 'Static curl %s (Linux x86_64 musl)\n%s\nArchive SHA256: %s\nBinary SHA256: %s\n'+ 'Build sources: https://github.com/stunnel/static-curl/tree/%s\n' %+ (spec['version'], spec['url'], spec['sha256'], spec['binary_sha256'], spec['version']), encoding='utf-8')+ return executable++def launcher_characters(root):text = ''for path in [*(root / 'freevideo_engine').rglob('*.py'), *(root / 'freevideo_engine').rglob('*.qml'),@@ -206,6 +247,7 @@ def main():stamp = stamp_source(staged, build)notices = staged / 'freevideo_engine/launcher/licenses/bundled'collect_notices(ROOT, notices)+ curl = bundle_curl(tools, out / 'curl', notices)fonts = out / 'fonts'glyphs = make_fonts(ROOT, tools, fonts)shutil.copyfile(fonts / 'OFL.txt', notices / 'Noto-Sans-CJK-SC-OFL.txt')@@ -227,6 +269,7 @@ def main():from scripts.source_build import run_pyinstaller# These files are added after PyInstaller; they belong to the same base key.extra_runtime = {'appimage-runtime': str(runtime), 'appimagetool': str(appimagetool)}+ extra_runtime['curl'] = str(curl)for name in SYSTEM_LIBRARIES:path = system_library(name, args.libraries.resolve() if args.libraries else None)if path is not None:@@ -235,6 +278,9 @@ def main():dist = out / 'dist' / 'FreeVideo'write_prune_report(out, prune_qt_bundle(dist))bundled = bundle_libraries(dist / '_internal', args.libraries.resolve() if args.libraries else None)+ # Copy after PyInstaller: a static ELF must not be rewritten or analyzed as+ # a shared library. The base manifest above still binds its exact bytes.+ shutil.copytree(curl.parent, dist / '_internal/curl')folder = appdir(out, dist, ROOT / 'freevideo_engine/assets/icon.png')# copytree expands hardlinks: deduplicate the final AppDir, after copying.write_data_report(out, deduplicate_bundle_data(folder))diff --git a/web/error_panel.js b/web/error_panel.jsindex 77124c8..e1d8a33 100644--- a/web/error_panel.js+++ b/web/error_panel.js@@ -229,7 +229,8 @@ function reportRedactor(detail, context) {.replace(/\b(?:\d{1,3}\.){3}\d{1,3}\b/g, '<ADDRESS REMOVED>');// Keep traceback source basenames and line numbers, never drive names,// home directories or private media filenames. Spaces in paths count.- text = text.replace(/(^|[^A-Za-z0-9_:/<>])((?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?![\/\s]))[^\r\n"'<>;,\)\]]+)/gm, (_, prefix, path) => {+ text = text.replace(/(^|[^A-Za-z0-9_:/<>])(\.\/setup\.sh(?![\w\/\\-]|\.\w)|\.{1,2}\/[^\r\n"'<>;,\)\]]*|(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?![\/\s]))[^\r\n"'<>;,\)\]]+)/gm, (_, prefix, path) => {+ if (path === './setup.sh') return prefix + path;const source = path.replace(/\\/g, '/').match(/\/([A-Za-z0-9_.-]+\.(?:py|js|ts|mjs))(?=[:\s]|$)/);return prefix + (source ? '<PATH>/' + source[1] + path.slice(path.indexOf(source[1]) + source[1].length) : '<PATH REMOVED>');});