Update scripts/stack_installers/install_rtorrent.py

This commit is contained in:
gru
2026-06-13 17:00:46 +02:00
parent 8bc2924bea
commit d0ec2fe820
+42 -6
View File
@@ -534,8 +534,7 @@ def build_rtorrent(base_dir, rtorrent_ref, libtorrent_install, rpc_backend, xmlr
env["CFLAGS"] = f"{tinyxml2_cflags} " + env.get("CFLAGS", "") env["CFLAGS"] = f"{tinyxml2_cflags} " + env.get("CFLAGS", "")
if tinyxml2_libs: if tinyxml2_libs:
env["LIBS"] = f"{tinyxml2_libs} " + env.get("LIBS", "") env["LIBS"] = f"-Wl,--no-as-needed {tinyxml2_libs} -Wl,--as-needed " + env.get("LIBS", "")
env["LDFLAGS"] = f"{tinyxml2_libs} " + env.get("LDFLAGS", "")
with Spinner("Preparing rTorrent build system", enabled=not debug): with Spinner("Preparing rTorrent build system", enabled=not debug):
run(["autoreconf", "-i"], cwd=str(source_dir), env=env, debug=debug) run(["autoreconf", "-i"], cwd=str(source_dir), env=env, debug=debug)
@@ -657,7 +656,11 @@ def rtorrent_bind_address_directive(rtorrent_ref, rtorrent_version=None):
return "network.bind_address.ipv4.set" return "network.bind_address.ipv4.set"
def build_rtorrent_config_content(username, scgi_port, torrent_port, bind_address_directive, scgi_unix_socket=None): def build_rtorrent_config_content(username, scgi_port, torrent_port, bind_address_directive, scgi_unix_socket=None):
scgi_line = f"network.scgi.open_local = {scgi_unix_socket}" if scgi_unix_socket else f"{scgi_line}" if scgi_unix_socket:
scgi_line = f"network.scgi.open_local = {scgi_unix_socket}"
else:
scgi_line = f"network.scgi.open_port = 127.0.0.1:{scgi_port}"
return f""" return f"""
## https://git.linuxiarz.pl/gru/tools_scripts/_edit/master/install_rtorrent.py ## https://git.linuxiarz.pl/gru/tools_scripts/_edit/master/install_rtorrent.py
# Generated by install_rtorrent.py # Generated by install_rtorrent.py
@@ -836,18 +839,36 @@ def verify_install(base_dir, rtorrent_install, libtorrent_install, rpc_backend,
linked = capture(["ldd", str(rtorrent_bin)], check=True, debug=debug) linked = capture(["ldd", str(rtorrent_bin)], check=True, debug=debug)
checks = [("libtorrent", str(Path(libtorrent_install) / "lib"))] checks = [("libtorrent", str(Path(libtorrent_install) / "lib"))]
if rpc_backend == "xmlrpc-c": if rpc_backend == "xmlrpc-c":
checks.append(("xmlrpc", str(Path(xmlrpc_install) / "lib"))) checks.append(("xmlrpc", str(Path(xmlrpc_install) / "lib")))
for libname, expected in checks: for libname, expected in checks:
lines = [line for line in linked.splitlines() if libname in line] lines = [line for line in linked.splitlines() if libname in line]
print_link_lines(f"Linked {libname} lines:", lines) print_link_lines(f"Linked {libname} lines:", lines)
if not any(expected in line for line in lines): if not any(expected in line for line in lines):
raise InstallError(f"rtorrent does not appear to be linked against the compiled {libname} from {expected}.") raise InstallError(f"rtorrent does not appear to be linked against the compiled {libname} from {expected}.")
if rpc_backend == "tinyxml2": if rpc_backend == "tinyxml2":
tinyxml_lines = [line for line in linked.splitlines() if "tinyxml2" in line.lower()] tinyxml_lines = [line for line in linked.splitlines() if "tinyxml2" in line.lower()]
print_link_lines("Linked tinyxml2 lines:", tinyxml_lines) print_link_lines("Linked tinyxml2 lines:", tinyxml_lines)
if not tinyxml_lines: if not tinyxml_lines:
raise InstallError("rTorrent does not appear to be linked against tinyxml2.") config_log = Path(base_dir) / "rtorrent" / "config.log"
config_text = config_log.read_text(errors="ignore").lower() if config_log.exists() else ""
tinyxml2_evidence = (
"with-xmlrpc-tinyxml2" in config_text
or "xmlrpc-tinyxml2" in config_text
or "tinyxml2" in config_text
)
if tinyxml2_evidence:
print("tinyxml2 is not visible in ldd; accepting config.log evidence of tinyxml2/XML-RPC build.")
else:
raise InstallError(
"rTorrent does not expose tinyxml2 in ldd, and config.log does not show tinyxml2/XML-RPC support."
)
if curl_install: if curl_install:
verify_libtorrent_curl_integration(base_dir, libtorrent_install, curl_install, cares_install, debug=debug) verify_libtorrent_curl_integration(base_dir, libtorrent_install, curl_install, cares_install, debug=debug)
@@ -856,24 +877,39 @@ def verify_install(base_dir, rtorrent_install, libtorrent_install, rpc_backend,
env["LANG"] = "C" env["LANG"] = "C"
env["LC_ALL"] = "C" env["LC_ALL"] = "C"
env["TERM"] = env.get("TERM", "xterm") env["TERM"] = env.get("TERM", "xterm")
ld_paths = [str(Path(libtorrent_install) / "lib")] ld_paths = [str(Path(libtorrent_install) / "lib")]
if rpc_backend == "xmlrpc-c" and xmlrpc_install: if rpc_backend == "xmlrpc-c" and xmlrpc_install:
ld_paths.append(str(Path(xmlrpc_install) / "lib")) ld_paths.append(str(Path(xmlrpc_install) / "lib"))
if curl_install: if curl_install:
ld_paths.append(str(Path(curl_install) / "lib")) ld_paths.append(str(Path(curl_install) / "lib"))
if cares_install: if cares_install:
ld_paths.append(str(Path(cares_install) / "lib")) ld_paths.append(str(Path(cares_install) / "lib"))
env["LD_LIBRARY_PATH"] = ":".join(ld_paths) env["LD_LIBRARY_PATH"] = ":".join(ld_paths)
probe = subprocess.run([str(rtorrent_bin), "-h"], env=env, check=False, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) probe = subprocess.run(
[str(rtorrent_bin), "-h"],
env=env,
check=False,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
help_output = ((probe.stdout or "") + "\n" + (probe.stderr or "")).lower() help_output = ((probe.stdout or "") + "\n" + (probe.stderr or "")).lower()
if probe.returncode != 0:
raise InstallError("Compiled rTorrent binary exists but cannot run with the generated runtime environment.")
if "xmlrpc-c" in help_output and "i8" in help_output: if "xmlrpc-c" in help_output and "i8" in help_output:
raise InstallError( raise InstallError(
"rTorrent was built against an xmlrpc-c library without i8 support. " "rTorrent was built against an xmlrpc-c library without i8 support. "
"Make sure the custom xmlrpc-c build is used and that no older local installation shadows it." "Make sure the custom xmlrpc-c build is used and that no older local installation shadows it."
) )
def build_parser(): def build_parser():
parser = argparse.ArgumentParser(description="Installer for libtorrent + rTorrent under /opt. RPC defaults to tinyxml2; xmlrpc-c is optional.") parser = argparse.ArgumentParser(description="Installer for libtorrent + rTorrent under /opt. RPC defaults to tinyxml2; xmlrpc-c is optional.")
parser.add_argument("--base-dir", default=DEFAULT_BASE_DIR, help=f"Base build/install directory (default: {DEFAULT_BASE_DIR})") parser.add_argument("--base-dir", default=DEFAULT_BASE_DIR, help=f"Base build/install directory (default: {DEFAULT_BASE_DIR})")