Update scripts/stack_installers/install_rtorrent.py
This commit is contained in:
@@ -534,8 +534,7 @@ def build_rtorrent(base_dir, rtorrent_ref, libtorrent_install, rpc_backend, xmlr
|
||||
env["CFLAGS"] = f"{tinyxml2_cflags} " + env.get("CFLAGS", "")
|
||||
|
||||
if tinyxml2_libs:
|
||||
env["LIBS"] = f"{tinyxml2_libs} " + env.get("LIBS", "")
|
||||
env["LDFLAGS"] = f"{tinyxml2_libs} " + env.get("LDFLAGS", "")
|
||||
env["LIBS"] = f"-Wl,--no-as-needed {tinyxml2_libs} -Wl,--as-needed " + env.get("LIBS", "")
|
||||
|
||||
with Spinner("Preparing rTorrent build system", enabled=not 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"
|
||||
|
||||
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"""
|
||||
## https://git.linuxiarz.pl/gru/tools_scripts/_edit/master/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)
|
||||
checks = [("libtorrent", str(Path(libtorrent_install) / "lib"))]
|
||||
|
||||
if rpc_backend == "xmlrpc-c":
|
||||
checks.append(("xmlrpc", str(Path(xmlrpc_install) / "lib")))
|
||||
|
||||
for libname, expected in checks:
|
||||
lines = [line for line in linked.splitlines() if libname in line]
|
||||
print_link_lines(f"Linked {libname} lines:", 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}.")
|
||||
|
||||
if rpc_backend == "tinyxml2":
|
||||
tinyxml_lines = [line for line in linked.splitlines() if "tinyxml2" in line.lower()]
|
||||
print_link_lines("Linked tinyxml2 lines:", 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:
|
||||
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["LC_ALL"] = "C"
|
||||
env["TERM"] = env.get("TERM", "xterm")
|
||||
|
||||
ld_paths = [str(Path(libtorrent_install) / "lib")]
|
||||
|
||||
if rpc_backend == "xmlrpc-c" and xmlrpc_install:
|
||||
ld_paths.append(str(Path(xmlrpc_install) / "lib"))
|
||||
|
||||
if curl_install:
|
||||
ld_paths.append(str(Path(curl_install) / "lib"))
|
||||
|
||||
if cares_install:
|
||||
ld_paths.append(str(Path(cares_install) / "lib"))
|
||||
|
||||
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()
|
||||
|
||||
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:
|
||||
raise InstallError(
|
||||
"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."
|
||||
)
|
||||
|
||||
|
||||
def build_parser():
|
||||
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})")
|
||||
|
||||
Reference in New Issue
Block a user