Commit 680e49c
0
plików
+0
dodanych
-0
usuniętych
@@ -55,7 +55,7 @@ import threading, itertools
55
55
import uuid # serialNumber SBOM (CycloneDX)
56
56
57
57
# Wersja klienta – do porównania z repo.json["pag_version"] (self-update)
58
-PAG_VERSION = "3.3.12"
58
+PAG_VERSION = "3.3.13"
59
59
from urllib.error import URLError, HTTPError
60
60
61
61
# =============================================================================
@@ -274,6 +274,8 @@ T = {
274
274
"repo_added": "Added repository: {}",
275
275
"repo_exists": "Repository already exists: {}",
276
276
"updated_done": "Index refresh complete. {} packages cached.",
277
+ "indexes_refreshed": "Indexes refreshed.",
278
+ "updates_available": "⚠ {} packages have updates – run: pag update",
277
279
"upgrading": "Upgrading: {} packages",
278
280
"all_up_to_date": "All packages are up to date.",
279
281
"removing": "Removing",
@@ -354,6 +356,8 @@ T = {
354
356
"repo_added": "Dodano repozytorium: {}",
355
357
"repo_exists": "Repozytorium już istnieje: {}",
356
358
"updated_done": "Odświeżanie zakończone. {} pakietów w cache.",
359
+ "indexes_refreshed": "Indeksy odświeżone.",
360
+ "updates_available": "⚠ jest {} pakietów do zaktualizowania – wpisz: pag update",
357
361
"upgrading": "Aktualizacje: {} pakietów",
358
362
"all_up_to_date": "Wszystkie pakiety są aktualne.",
359
363
"removing": "Usuwanie",
@@ -2697,10 +2701,25 @@ def cmd_self_update():
2697
2701
return 0
2698
2702
2699
2703
2700
-def cmd_update():
2701
- # `pag update` / `pag sync` to JAWNE odświeżenie indeksów – pomijamy
2702
- # cache TTL (inaczej nowe pakiety/aktualizacje są niewidoczne nawet
2703
- # przez godzinę). Pełne pobranie + weryfikacja GPG przy każdym update.
2704
+def _pending_updates() -> List[str]:
2705
+ """Zainstalowane pakiety z nowszą wersją w repo (bez przypiętych)."""
2706
+ installed = load_json(INSTALLED_DB)
2707
+ pinned = load_json(PINNED_FILE)
2708
+ repo = fetch_all_packages()
2709
+ if not repo:
2710
+ return []
2711
+ return [n for n, i in installed.items()
2712
+ if n not in pinned and (rp := repo.get(n)) and _version_newer(rp.version, i["version"])]
2713
+
2714
+def cmd_update(do_upgrade: bool = False):
2715
+ """`pag sync` / `pag update` – odświeżenie indeksów + raport aktualizacji.
2716
+
2717
+ sync → tylko odświeżenie indeksów + info: „jest X pakietów do
2718
+ zaktualizowania – wpisz: pag update".
2719
+ update → odświeżenie indeksów + AKTUALIZACJA PAKIETÓW (pakiety, nie system).
2720
+ Pomijamy cache TTL (inaczej nowe pakiety/aktualizacje są niewidoczne nawet
2721
+ przez godzinę). Pełne pobranie + weryfikacja GPG przy każdym odświeżeniu.
2722
+ """
2704
2723
force = True
2705
2724
print("🔄 Refreshing indexes...")
2706
2725
for repo_url in get_repos():
@@ -2708,15 +2727,7 @@ def cmd_update():
2708
2727
cp = _repo_cache_path(repo_url)
2709
2728
has_sig = os.path.exists(cp + ".sig")
2710
2729
print(f" {'✅' if pkgs is not None else '❌'} {repo_url}: {len(pkgs or [])} pkgs {'🔐' if has_sig else '⚠'}")
2711
- total = 0
2712
- for r in get_repos():
2713
- cp = _repo_cache_path(r)
2714
- if os.path.exists(cp):
2715
- try:
2716
- total += len(json.load(open(cp)).get("packages", []))
2717
- except Exception:
2718
- pass
2719
- print(f"✅ {_('updated_done', total)}")
2730
+ print(f"✅ {_('indexes_refreshed')}")
2720
2731
2721
2732
# Powiadomienie o nowszej wersji pag (repo.json["pag_version"])
2722
2733
try:
@@ -2730,24 +2741,49 @@ def cmd_update():
2730
2741
except Exception:
2731
2742
pass
2732
2743
2733
-def cmd_upgrade():
2734
- ensure_dirs()
2744
+ # Raport: pakiety do aktualizacji
2745
+ pending = _pending_updates()
2746
+ if not pending:
2747
+ print(f"✅ {_('all_up_to_date')}")
2748
+ return 0
2749
+ print(f"{_('updates_available', len(pending))}")
2735
2750
installed = load_json(INSTALLED_DB)
2736
- pinned = load_json(PINNED_FILE)
2737
2751
repo = fetch_all_packages()
2738
- if not repo:
2739
- print(f"❌ {_('no_index')}")
2740
- return 1
2741
- upgrades = [n for n, i in installed.items()
2742
- if n not in pinned and (rp := repo.get(n)) and _version_newer(rp.version, i["version"])]
2743
- if not upgrades:
2744
- print(f"✅ {_('all_up_to_date')}"); return 0
2745
- print(f"📦 {_('upgrading', len(upgrades))}")
2746
- for n in upgrades:
2747
- print(f" {n}: {installed[n]['version']} → {repo[n].version}")
2752
+ for n in pending:
2753
+ print(f" {n}: {installed.get(n, {}).get('version', '?')} → {repo[n].version}")
2754
+ if not do_upgrade:
2755
+ return 0 # sync: tylko informacja
2748
2756
if not _ask_confirm():
2749
2757
return 0
2750
- return cmd_install(upgrades, upgrade=True)
2758
+ return cmd_install(pending, upgrade=True)
2759
+
2760
+def _initramfs_stale() -> bool:
2761
+ """Czy initramfs jest starszy niż najnowsze jądro (wymaga przebudowy)."""
2762
+ try:
2763
+ kernels = [k for k in os.listdir("/boot") if k.startswith("vmlinuz-")] if os.path.isdir("/boot") else []
2764
+ if not kernels:
2765
+ return False
2766
+ newest = max(os.path.getmtime(os.path.join("/boot", k)) for k in kernels)
2767
+ initrd = "/boot/initramfs.img"
2768
+ return (not os.path.exists(initrd)) or os.path.getmtime(initrd) < newest
2769
+ except Exception:
2770
+ return False
2771
+
2772
+def cmd_upgrade():
2773
+ """`pag upgrade` – aktualizacja SYSTEMU: pakiety + kernel/initramfs/GRUB."""
2774
+ rc = cmd_update(do_upgrade=True)
2775
+ if rc != 0:
2776
+ return rc
2777
+ # System: dopilnuj initramfs (gdyby kernel był nowszy) + GRUB (immutable)
2778
+ if _initramfs_stale():
2779
+ print(" 🐧 Przebudowa initramfs (nowsze jądro)...")
2780
+ _rebuild_initramfs()
2781
+ try:
2782
+ if _load_deployments():
2783
+ _update_grub_config()
2784
+ except Exception:
2785
+ pass
2786
+ return 0
2751
2787
2752
2788
def cmd_list(installed_only=False):
2753
2789
if installed_only:
@@ -4473,9 +4509,9 @@ USAGE_EN = """pag v3 – Pagan Linux Package Manager
4473
4509
BASIC:
4474
4510
pag install <pkg>... Install packages
4475
4511
pag remove <pkg>... Remove packages
4476
- pag update [--force] Refresh repo indexes
4477
- pag sync Refresh repo indexes (alias for update)
4478
- pag upgrade Upgrade all packages
4512
+ pag update Update PACKAGES (refreshes indexes first)
4513
+ pag sync Refresh indexes + show pending package updates
4514
+ pag upgrade Update SYSTEM (packages + kernel/initramfs/GRUB)
4479
4515
pag list [--installed] List available / installed
4480
4516
pag search <query> Search packages
4481
4517
pag info <pkg> Package details
@@ -4528,9 +4564,9 @@ USAGE_PL = """pag v3 – Pagan Linux Package Manager
4528
4564
PODSTAWOWE:
4529
4565
pag install <pkg>... Instalacja pakietów
4530
4566
pag remove <pkg>... Usuwanie pakietów
4531
- pag update [--force] Odśwież indeksy repozytoriów
4532
- pag sync Odśwież indeksy repozytoriów (alias dla update)
4533
- pag upgrade Aktualizacja wszystkich pakietów
4567
+ pag update Aktualizacja PAKIETÓW (odświeża indeksy)
4568
+ pag sync Odśwież indeksy + info o aktualizacjach
4569
+ pag upgrade Aktualizacja SYSTEMU (pakiety + kernel/initramfs/GRUB)
4534
4570
pag list [--installed] Lista dostępnych / zainstalowanych
4535
4571
pag search <query> Szukaj pakietów
4536
4572
pag info <pkg> Szczegóły pakietu
@@ -4659,8 +4695,8 @@ def main():
4659
4695
WRITE_COMMANDS = {
4660
4696
"install": lambda: cmd_install(args),
4661
4697
"remove": lambda: cmd_remove(args),
4662
- "update": cmd_update,
4663
- "sync": cmd_update,
4698
+ "update": lambda: cmd_update(do_upgrade=True),
4699
+ "sync": lambda: cmd_update(do_upgrade=False),
4664
4700
"upgrade": cmd_upgrade,
4665
4701
"clean": cmd_clean,
4666
4702
"download": lambda: cmd_download(args),