a2qlinux 0.7.3__tar.gz → 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/CHANGELOG.md +21 -0
  2. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/PKG-INFO +1 -1
  3. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/_version.py +2 -2
  4. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/bin/questlog_ctl.exe +0 -0
  5. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/bin/version.dll +0 -0
  6. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/bin/wpcap.dll +0 -0
  7. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/launcher.py +32 -4
  8. a2qlinux-0.8.0/a2qlinux/questlog_versions.py +96 -0
  9. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/setup_desktop.py +10 -2
  10. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/tray.py +32 -4
  11. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/update.py +88 -8
  12. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/docs/ARCHITECTURE.md +116 -5
  13. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/docs/INSTALL.md +5 -2
  14. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/docs/RELEASE.md +8 -0
  15. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/docs/TROUBLESHOOTING.md +3 -2
  16. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/docs/UPDATING.md +49 -0
  17. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/docs/USING.md +9 -0
  18. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_launcher.py +35 -0
  19. a2qlinux-0.8.0/tests/test_questlog_watch.py +97 -0
  20. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_update.py +106 -3
  21. a2qlinux-0.8.0/tools/questlog_watch.py +151 -0
  22. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/.gitignore +0 -0
  23. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/LICENSE +0 -0
  24. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/README.md +0 -0
  25. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/__init__.py +0 -0
  26. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/config.py +0 -0
  27. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/desktop.py +0 -0
  28. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/diagnose.py +0 -0
  29. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/focus.py +0 -0
  30. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/kde_overlays.py +0 -0
  31. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/open_folders.py +0 -0
  32. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/pcap_bridge.py +0 -0
  33. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/a2qlinux/steam.py +0 -0
  34. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/build.sh +0 -0
  35. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/focus_hook.c +0 -0
  36. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/focus_hook.def +0 -0
  37. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/questlog_ctl.c +0 -0
  38. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/tests/bridge_client_test.c +0 -0
  39. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/tests/focus_hook_test.c +0 -0
  40. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/tests/run_focus_hook_test.py +0 -0
  41. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/tests/zorder_guard_test.c +0 -0
  42. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/bridge/wpcap_bridge.c +0 -0
  43. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/docs/README.md +0 -0
  44. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/pyproject.toml +0 -0
  45. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/__init__.py +0 -0
  46. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_config.py +0 -0
  47. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_desktop.py +0 -0
  48. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_diagnose.py +0 -0
  49. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_focus.py +0 -0
  50. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_kde_overlays.py +0 -0
  51. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_open_folders.py +0 -0
  52. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_pcap_bridge.py +0 -0
  53. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_replay_stream.py +0 -0
  54. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_setup_desktop.py +0 -0
  55. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_steam.py +0 -0
  56. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tests/test_version.py +0 -0
  57. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tools/__init__.py +0 -0
  58. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tools/foreground_probe.c +0 -0
  59. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tools/pcap2questlog.py +0 -0
  60. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tools/replay_stream.py +0 -0
  61. {a2qlinux-0.7.3 → a2qlinux-0.8.0}/tools/tcp_owner_probe.c +0 -0
@@ -3,6 +3,27 @@
3
3
  What changed for players, release by release. Technical details are in
4
4
  `docs/ARCHITECTURE.md`.
5
5
 
6
+ ## [0.8.0] — 2026-11-18
7
+
8
+ ### Added
9
+ - A newer Questlog that A2Qlinux cannot install yet no longer goes
10
+ unnoticed once its notification has gone: the tray icon's menu shows a
11
+ line such as "Questlog 0.1.56 not installed: does not fit yet" for as
12
+ long as that holds (hovering over it shows the reason), and
13
+ `a2qlinux-setup` names the installed Questlog and what is known about a
14
+ newer one. A version ready for the next start shows there too.
15
+ - When Questlog has just released a version A2Qlinux cannot work with yet,
16
+ `a2qlinux-setup` on a new machine no longer stops with an error: it
17
+ installs the newest earlier Questlog that works and says so; the newer
18
+ version follows by itself once A2Qlinux works with it.
19
+
20
+ ### Fixed
21
+ - Questlog 0.1.56 is installed again. A2Qlinux had refused it, as it had
22
+ 0.1.55 ("a second start no longer simply shows its window"), although
23
+ Open Questlog works with it as before. Players on 0.1.54 get the newest
24
+ version at the next update check after updating A2Qlinux, and a new
25
+ installation with `a2qlinux-setup` works again.
26
+
6
27
  ## [0.7.3] — 2026-11-14
7
28
 
8
29
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: a2qlinux
3
- Version: 0.7.3
3
+ Version: 0.8.0
4
4
  Summary: Questlog Desktop (AION 2 damage meter) on Linux under Proton, with live game traffic.
5
5
  Project-URL: homepage, https://github.com/raman78/A2Qlinux
6
6
  Project-URL: repository, https://github.com/raman78/A2Qlinux
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.7.3'
22
- __version_tuple__ = version_tuple = (0, 7, 3)
21
+ __version__ = version = '0.8.0'
22
+ __version_tuple__ = version_tuple = (0, 8, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -745,12 +745,18 @@ class Tray:
745
745
  It runs in its own session, so a Ctrl+C meant for this launcher does not
746
746
  reach it; it ends when its stdin closes. If it ends by itself, "tray-died"
747
747
  is put into requests so that Questlog's own icon can be shown again.
748
+
749
+ news: a callable giving update.update_news's (short, full) or None; sent
750
+ to the icon when it starts and on refresh(), so the menu carries a
751
+ refused or staged Questlog version for as long as that holds.
748
752
  """
749
753
 
750
- def __init__(self, requests):
754
+ def __init__(self, requests, news=lambda: None):
751
755
  self.requests = requests
756
+ self.news = news
752
757
  self.process = None
753
758
  self.stopping = False
759
+ self.writing = threading.Lock() # refresh() runs in the update thread
754
760
 
755
761
  def start(self):
756
762
  if self.process and self.process.poll() is None:
@@ -759,6 +765,26 @@ class Tray:
759
765
  self.process = subprocess.Popen([sys.executable, "-m", "a2qlinux.tray"], stdin=subprocess.PIPE,
760
766
  stdout=subprocess.PIPE, start_new_session=True)
761
767
  threading.Thread(target=self._read, args=(self.process,), daemon=True).start()
768
+ self.refresh()
769
+
770
+ def refresh(self):
771
+ """Send the current news to the icon (update.update_news); nothing when it does not run."""
772
+ try:
773
+ news = self.news()
774
+ except Exception as error: # the news must never stop the launcher; say why it is missing
775
+ log(f"Could not work out the update news for the tray icon: {error!r}")
776
+ return
777
+ line = "news" if not news else "news " + "\t".join(part.replace("\t", " ").replace("\n", " ")
778
+ for part in news)
779
+ with self.writing:
780
+ process = self.process
781
+ if not process or process.poll() is not None:
782
+ return
783
+ try:
784
+ process.stdin.write((line + "\n").encode())
785
+ process.stdin.flush()
786
+ except (OSError, ValueError):
787
+ pass # it is ending (stop() may have closed the pipe); _read reports that
762
788
 
763
789
  def _read(self, process):
764
790
  for line in process.stdout:
@@ -870,7 +896,7 @@ def notify_unless_playing(text):
870
896
  notify(text)
871
897
 
872
898
 
873
- def check_for_updates(questlog_dir, state_dir):
899
+ def check_for_updates(questlog_dir, state_dir, checked=lambda: None):
874
900
  """Thread body: stage new Questlog versions, 60 s after the start and then every UPDATE_CHECK_EVERY.
875
901
 
876
902
  Also while the game runs, with the download slowed (update_rate_limit):
@@ -881,6 +907,7 @@ def check_for_updates(questlog_dir, state_dir):
881
907
  while True:
882
908
  questlog_update.stage(questlog_dir, state_dir, log, notify, rate_limit=update_rate_limit,
883
909
  notify_ready=notify_unless_playing)
910
+ checked()
884
911
  time.sleep(UPDATE_CHECK_EVERY)
885
912
 
886
913
 
@@ -1453,7 +1480,7 @@ def main():
1453
1480
  "Start the game any time - its traffic then flows to Questlog.")
1454
1481
  log_path = state_dir / "questlog.log"
1455
1482
  start_questlog_log(log_path)
1456
- tray = Tray(requests)
1483
+ tray = Tray(requests, news=lambda: questlog_update.update_news(executable.parent, state_dir))
1457
1484
  quit_control = QuitControl()
1458
1485
 
1459
1486
  trial = {"until": 0.0} # end of a just-installed update's trial run
@@ -1478,7 +1505,8 @@ def main():
1478
1505
 
1479
1506
  questlog = start_questlog()
1480
1507
  if auto_update:
1481
- threading.Thread(target=check_for_updates, args=(executable.parent, state_dir), daemon=True).start()
1508
+ threading.Thread(target=check_for_updates, args=(executable.parent, state_dir, tray.refresh),
1509
+ daemon=True).start()
1482
1510
  told = False
1483
1511
  game_gone_since = None
1484
1512
  after_exit = None
@@ -0,0 +1,96 @@
1
+ """The register of Questlog versions and how A2Qlinux judged them (docs/ARCHITECTURE.md §12).
2
+
3
+ Questlog's feed (latest.yml) describes only its newest version. Older
4
+ installers stay on the CDN, but nothing there says how large they are, what
5
+ their SHA-512 is, or whether they fit A2Qlinux. The watch workflow
6
+ (.github/workflows/questlog-watch.yml, tools/questlog_watch.py) therefore
7
+ records every new version while it is the feed's newest: its size and
8
+ SHA-512 as the feed gives them, and the verdict of compatibility_problems.
9
+ a2qlinux-setup reads it (read, older_fitting) when the newest version does
10
+ not fit, to install the newest earlier one that does (update.install_fresh).
11
+ The register lives on the branch `questlog-versions` as one JSON file:
12
+
13
+ {"format": 1,
14
+ "versions": {"0.1.56": {"path": "questlog-setup-0.1.56.exe",
15
+ "size": 129748160, "sha512": "<base64>",
16
+ "sha512_from": "latest.yml",
17
+ "fits": true, "problems": [],
18
+ "checked_by": "0.7.4 (source checkout)",
19
+ "checked_at": "2026-11-18T12:00:00Z",
20
+ "issue": null}}}
21
+
22
+ sha512_from is "latest.yml" when the feed named the checksum, or
23
+ "computed" when it was worked out from the CDN's file after the feed had
24
+ moved on (the first entries only). issue is the GitHub issue opened for a
25
+ refusal, if any.
26
+ """
27
+
28
+ import json
29
+ from pathlib import Path
30
+ import re
31
+ import urllib.request
32
+
33
+ FORMAT = 1
34
+ FILE = "questlog-versions.json"
35
+ BRANCH = "questlog-versions"
36
+ # Where a2qlinux-setup reads the register (update.install_fresh).
37
+ URL = f"https://raw.githubusercontent.com/raman78/A2Qlinux/{BRANCH}/{FILE}"
38
+
39
+
40
+ def empty():
41
+ return {"format": FORMAT, "versions": {}}
42
+
43
+
44
+ def load(path):
45
+ """The register in `path`; an empty one if the file does not exist yet."""
46
+ path = Path(path)
47
+ if not path.exists():
48
+ return empty()
49
+ return _checked(json.loads(path.read_text()), path)
50
+
51
+
52
+ def _checked(register, where):
53
+ if register.get("format") != FORMAT or not isinstance(register.get("versions"), dict):
54
+ raise ValueError(f"{where} is not a register of format {FORMAT}")
55
+ return register
56
+
57
+
58
+ def read(url=URL, timeout=20):
59
+ """The register as published; raises OSError or ValueError."""
60
+ with urllib.request.urlopen(url, timeout=timeout) as response:
61
+ return _checked(json.loads(response.read().decode("utf-8")), url)
62
+
63
+
64
+ def older_fitting(register, below):
65
+ """Feed-like descriptions of the versions older than `below` the register says fit, newest first."""
66
+ found = []
67
+ for version, entry in register["versions"].items():
68
+ if not re.fullmatch(r"\d+(\.\d+)+", version) or version_key(version) >= version_key(below):
69
+ continue
70
+ if not entry.get("fits") or not re.fullmatch(r"[\w.-]+\.exe", str(entry.get("path", ""))):
71
+ continue
72
+ found.append({"version": version, "path": entry["path"], "size": entry["size"], "sha512": entry["sha512"]})
73
+ return sorted(found, key=lambda feed: version_key(feed["version"]), reverse=True)
74
+
75
+
76
+ def save(path, register):
77
+ Path(path).write_text(json.dumps(register, indent=1, sort_keys=True) + "\n")
78
+
79
+
80
+ def version_key(version):
81
+ """Sort key for Questlog's versions (0.1.9 < 0.1.10)."""
82
+ return tuple(int(part) for part in version.split("."))
83
+
84
+
85
+ def record(register, feed, problems, checked_by, checked_at, sha512_from="latest.yml"):
86
+ """Enter (or replace) the verdict on the feed's version; returns the entry.
87
+
88
+ An issue already opened for the version is kept, so a later verdict can
89
+ close it.
90
+ """
91
+ entry = {"path": feed["path"], "size": feed["size"], "sha512": feed["sha512"], "sha512_from": sha512_from,
92
+ "fits": not problems, "problems": list(problems), "checked_by": checked_by,
93
+ "checked_at": checked_at,
94
+ "issue": register["versions"].get(feed["version"], {}).get("issue")}
95
+ register["versions"][feed["version"]] = entry
96
+ return entry
@@ -14,7 +14,11 @@ What it does, in order:
14
14
  4. Checks that the Windows parts are present: shipped in the package, built
15
15
  by bridge/build.sh in a source checkout.
16
16
  5. Installs the newest Questlog when its folder has no Questlog.exe
17
- (update.install_fresh: the updater's download and checks).
17
+ (update.install_fresh: the updater's download and checks), or, when
18
+ the newest does not fit, the newest earlier one that does.
19
+ Names the installed version, and what the updater knows of a newer
20
+ one (update.update_news): refused and why, or installing at the next
21
+ start.
18
22
  6. Takes Questlog's icon from the installed Questlog (resources/icon.png in
19
23
  its app.asar) and colours its white Q red (a2qlinux_icon), so that
20
24
  A2Qlinux's entry and tray icon are told apart from Questlog's own - the
@@ -51,7 +55,7 @@ import sys
51
55
  from . import APP_NAME, ICON, config, shown_version
52
56
  from . import kde_overlays, open_folders
53
57
  from .desktop import TERMINALS, terminal_command
54
- from .update import install_fresh, read_asar_file
58
+ from .update import install_fresh, installed_version, read_asar_file, update_news
55
59
 
56
60
  BIN = Path(__file__).resolve().parent / "bin"
57
61
  ENTRY_ID = "questlog-aion2" # the file name from before the entry was called A2Qlinux; kept, so that
@@ -515,6 +519,10 @@ def main():
515
519
  except RuntimeError as error:
516
520
  problems.append(str(error))
517
521
  if (questlog_dir / "Questlog.exe").is_file():
522
+ print(f"Questlog: {installed_version(questlog_dir) or '(version unknown)'} in {questlog_dir}.")
523
+ news = update_news(questlog_dir, questlog_dir / "proton-stream")
524
+ if news:
525
+ print(f" {news[1]}")
518
526
  try:
519
527
  write_icon(questlog_dir)
520
528
  print(f"Icon: {ICON}")
@@ -13,6 +13,12 @@ This process only reports what was chosen, one word per line on stdout:
13
13
  the launcher (a2qlinux/launcher.py) does the rest. It ends when its stdin closes, i.e. when
14
14
  the launcher (a2qlinux/launcher.py) stops it or ends itself.
15
15
 
16
+ The launcher tells it, one line on stdin each:
17
+ news <short>\t<full> news about a newer Questlog (update.update_news): the
18
+ short text becomes a greyed-out menu line, the full one
19
+ its tooltip and part of the icon's tooltip
20
+ news no news any more; the line goes
21
+
16
22
  With --check it only tells whether it could run here: exit code 0 if Qt
17
23
  starts and the desktop has a system tray, otherwise 1 with the reason on
18
24
  stderr (Qt's own message when Qt cannot start). a2qlinux-setup runs it.
@@ -47,6 +53,10 @@ def main():
47
53
  tray.setToolTip(f"{version} — Questlog for AION 2")
48
54
  menu = QMenu()
49
55
  menu.addAction(version).setEnabled(False) # which A2Qlinux runs, for reports; not clickable
56
+ menu.setToolTipsVisible(True)
57
+ news = menu.addAction("") # update.update_news, while there is any; not clickable
58
+ news.setEnabled(False)
59
+ news.setVisible(False)
50
60
  menu.addSeparator()
51
61
  menu.addAction("Open Questlog").triggered.connect(lambda: report("open"))
52
62
  menu.addSeparator()
@@ -55,12 +65,30 @@ def main():
55
65
  tray.activated.connect(lambda reason: reason == QSystemTrayIcon.ActivationReason.Trigger and report("open"))
56
66
  tray.show()
57
67
 
58
- def parent_gone():
59
- if not sys.stdin.buffer.read1(4096):
60
- app.quit()
68
+ def show_news(line):
69
+ short, _, full = line.removeprefix("news").strip().partition("\t")
70
+ news.setText(short)
71
+ news.setToolTip(full or short)
72
+ news.setVisible(bool(short))
73
+ tray.setToolTip(f"{version} — Questlog for AION 2" + (f"\n{full or short}" if short else ""))
74
+
75
+ pending = bytearray()
76
+
77
+ def read_launcher():
78
+ data = sys.stdin.buffer.read1(4096)
79
+ if not data:
80
+ app.quit() # the launcher stopped us or ended
81
+ return
82
+ pending.extend(data)
83
+ while b"\n" in pending:
84
+ line, _, rest = bytes(pending).partition(b"\n")
85
+ pending[:] = rest
86
+ line = line.decode("utf-8", "replace")
87
+ if line == "news" or line.startswith("news "):
88
+ show_news(line)
61
89
 
62
90
  watcher = QSocketNotifier(sys.stdin.fileno(), QSocketNotifier.Type.Read)
63
- watcher.activated.connect(parent_gone)
91
+ watcher.activated.connect(read_launcher)
64
92
  return app.exec()
65
93
 
66
94
 
@@ -41,6 +41,8 @@ import threading
41
41
  import time
42
42
  import urllib.request
43
43
 
44
+ from . import questlog_versions
45
+
44
46
  FEED = "https://cdn.questlog.gg/desktop/latest.yml"
45
47
  DOWNLOADS = "https://cdn.questlog.gg/desktop/"
46
48
  # The libpcap calls bridge/wpcap_bridge.c implements.
@@ -168,7 +170,10 @@ def compatibility_problems(app_dir):
168
170
  problems.append(f"it uses Electron {electron.group(1).decode()}, not yet checked "
169
171
  f"(known: {', '.join(sorted(KNOWN_ELECTRON))}); its tray icon id and session end "
170
172
  "need reading in that version's source")
171
- if not re.search(r'on\(["`]second-instance["`],[A-Za-z0-9_$]+\.show\)', main):
173
+ # The handler is the window's show itself, or (since 0.1.56) a function whose first act is to call it;
174
+ # 0.1.56 then follows a questlog:// link from the arguments, which A2Qlinux's second start never passes.
175
+ if not re.search(r'on\(["`]second-instance["`],(?:[A-Za-z0-9_$]+\.show\)'
176
+ r'|\([^)]*\)=>\{?[A-Za-z0-9_$]+\.show\(\)[,;})])', main):
172
177
  problems.append("a second start no longer simply shows its window (Open Questlog relies on it)")
173
178
  if "focusable:!1" not in main:
174
179
  problems.append("its overlay windows are no longer non-activatable (the window-order guard relies on it)")
@@ -366,15 +371,80 @@ def _stage(questlog_dir, state_dir, log, notify, feed_url, downloads, rate_limit
366
371
  return state
367
372
 
368
373
 
374
+ def update_news(questlog_dir, state_dir):
375
+ """What the player should know about a newer Questlog, as (short, full); None when there is nothing.
376
+
377
+ From the updater's verdict (staged.json) against the installed version:
378
+ a newer version that does not fit (refused, or rolled back after it did
379
+ not start), or one that is staged and installs at the next start. Shown
380
+ by a2qlinux-setup and, for as long as it holds, in the tray icon's menu
381
+ (docs/ARCHITECTURE.md §6.6, "Telling the player"), so a refusal is more
382
+ than one notification that may have gone by unseen.
383
+ """
384
+ state, installed = read_state(state_dir), installed_version(questlog_dir)
385
+ version = state.get("version")
386
+ if not version or version == installed:
387
+ return None
388
+ if state.get("fits"):
389
+ return (f"Questlog {version} installs at the next start",
390
+ f"Questlog {version} is downloaded and checked; it is installed the next time Questlog starts.")
391
+ why = "; ".join(state.get("problems") or ["no reason recorded"])
392
+ again = (" It is checked again at the next update check, as another A2Qlinux judged it."
393
+ if refused_by_older_checks(state) else
394
+ " Check for a newer A2Qlinux: pipx upgrade a2qlinux.")
395
+ return (f"Questlog {version} not installed: does not fit yet",
396
+ f"Questlog {version} is out but does not fit this A2Qlinux yet, so Questlog {installed or '(unknown)'} "
397
+ f"stays. Why: {why}.{again}")
398
+
399
+
369
400
  # ------------------------------------------------------------- installation
370
401
 
371
- def install_fresh(questlog_dir, log, feed_url=FEED, downloads=DOWNLOADS):
372
- """Install the newest Questlog into a missing or empty folder; returns its version.
402
+ # How many older versions install_fresh downloads at most when the newest does not fit (130 MB each).
403
+ FALLBACK_TRIES = 2
404
+
405
+
406
+ def _older_that_fits(newest, work, downloads, register_url, log):
407
+ """For install_fresh: the newest older version that fits, as (app folder, version, None);
408
+ else (None, None, why not).
409
+
410
+ The register (questlog_versions, kept by the Questlog watch on GitHub)
411
+ names the candidates and their size and SHA-512, which Questlog's feed
412
+ gives for its newest version only; this A2Qlinux's own checks decide.
413
+ """
414
+ try:
415
+ candidates = questlog_versions.older_fitting(questlog_versions.read(register_url), newest)
416
+ except (OSError, ValueError) as error:
417
+ return None, None, f"the list of earlier versions that fit could not be read ({error})"
418
+ if not candidates:
419
+ return None, None, "no earlier version is known to fit"
420
+ tried = []
421
+ for feed in candidates[:FALLBACK_TRIES]:
422
+ log(f"Downloading Questlog {feed['version']} instead, the newest earlier version known to fit "
423
+ f"({feed['size'] / 1e6:.0f} MB) …")
424
+ try:
425
+ (work / feed["version"]).mkdir()
426
+ app, problems = _fetch(feed, work / feed["version"], downloads)
427
+ except (OSError, ValueError, RuntimeError) as error:
428
+ tried.append(f"{feed['version']} could not be installed: {error}")
429
+ log(f"Questlog {tried[-1]}.")
430
+ continue
431
+ if not problems:
432
+ return app, feed["version"], None
433
+ shutil.rmtree(app, ignore_errors=True)
434
+ tried.append(f"{feed['version']} does not fit either: " + "; ".join(problems))
435
+ log(f"Questlog {tried[-1]}.")
436
+ return None, None, "; ".join(tried)
437
+
438
+
439
+ def install_fresh(questlog_dir, log, feed_url=FEED, downloads=DOWNLOADS, register_url=None):
440
+ """Install the newest Questlog that fits into a missing or empty folder; returns its version.
373
441
 
374
442
  For a2qlinux-setup on a machine without Questlog: the same download,
375
443
  checksum, unpacking and compatibility checks as an update (_fetch), then
376
444
  the unpacked program is moved into place. The work folder is made next
377
- to the target, so the move is a rename on one file system.
445
+ to the target, so the move is a rename on one file system. When the
446
+ newest version does not fit, the newest earlier one that does is
447
+ installed instead (_older_that_fits), and the log says so and why.
378
448
 
379
449
  Raises RuntimeError with what went wrong and what to do; a folder that
380
450
  holds anything is never written into, and nothing is left behind.
@@ -388,7 +458,7 @@ def install_fresh(questlog_dir, log, feed_url=FEED, downloads=DOWNLOADS):
388
458
  except (OSError, ValueError) as error:
389
459
  raise RuntimeError(f"Questlog's download information could not be read ({error}); "
390
460
  "check the internet connection and run a2qlinux-setup again") from error
391
- version = feed["version"]
461
+ version = newest = feed["version"]
392
462
  log(f"Downloading Questlog {version} from its authors' server ({feed['size'] / 1e6:.0f} MB), "
393
463
  "checking and unpacking it …")
394
464
  try:
@@ -402,9 +472,15 @@ def install_fresh(questlog_dir, log, feed_url=FEED, downloads=DOWNLOADS):
402
472
  except (OSError, ValueError, RuntimeError) as error:
403
473
  raise RuntimeError(f"Questlog {version} could not be installed: {error}") from error
404
474
  if problems:
405
- raise RuntimeError(f"Questlog {version} does not fit this A2Qlinux yet: " + "; ".join(problems)
406
- + ". Update A2Qlinux (pipx upgrade a2qlinux), or install an earlier "
407
- "Questlog by hand (docs/UPDATING.md, 'Installing Questlog by hand')")
475
+ refused = f"Questlog {version} does not fit this A2Qlinux yet: " + "; ".join(problems)
476
+ shutil.rmtree(app, ignore_errors=True)
477
+ log(refused + ".")
478
+ app, version, why_not = _older_that_fits(version, work, downloads,
479
+ register_url or questlog_versions.URL, log)
480
+ if app is None:
481
+ raise RuntimeError(refused + f". No earlier version was installed instead: {why_not}. Update "
482
+ "A2Qlinux (pipx upgrade a2qlinux), or install an earlier Questlog by hand "
483
+ "(docs/UPDATING.md, 'Installing Questlog by hand')")
408
484
  try:
409
485
  if questlog_dir.exists():
410
486
  questlog_dir.rmdir()
@@ -414,6 +490,10 @@ def install_fresh(questlog_dir, log, feed_url=FEED, downloads=DOWNLOADS):
414
490
  finally:
415
491
  shutil.rmtree(work, ignore_errors=True)
416
492
  log(f"Installed Questlog {version} in {questlog_dir}.")
493
+ if newest != version:
494
+ log(f"Questlog {newest} does not fit this A2Qlinux yet, so {version} was installed instead. A2Qlinux "
495
+ f"updates it by itself once Questlog's newest version fits; a fix for {newest} comes with a newer "
496
+ "A2Qlinux (pipx upgrade a2qlinux).")
417
497
  return version
418
498
 
419
499