feat: release v2.0.0 with tab completion, package filtering, db health checks, flatpak and logrotate
Build and Publish Release / Build Packages and Publish (push) Successful in 27s

This commit is contained in:
soda64 committed 2026-10-03 08:31:00 +02:00
1 parent 8d4157b42d
commit 8bec4ed932
27 files changed
+1053 -69

No files matched your search

+105 -6
View File
@@ -2,6 +2,7 @@ import argparse
import json
import os
from pathlib import Path
import shutil
import sys
from typing import List, Optional
@@ -116,9 +117,25 @@ Examples:
metavar="PACKAGE",
help="Selectively update only the specified package(s) instead of the entire system.",
)
update_parser.add_argument(
"--exclude",
nargs="+",
metavar="PATTERN",
help="Exclude package(s) or glob patterns (e.g. 'kernel*', 'nginx') from update.",
)
update_parser.add_argument(
"--security",
action="store_true",
help="Apply only security-related updates (supported on RHEL/Fedora/Debian/Ubuntu).",
)
update_parser.add_argument(
"--flatpak",
action="store_true",
help="Also update Flatpak packages if flatpak is installed.",
)
# Subcommand: check
subparsers.add_parser(
check_parser = subparsers.add_parser(
"check",
parents=[common],
help="Check system health and list available updates without making modifications.",
@@ -128,8 +145,21 @@ Examples:
Examples:
linux-updater check
linux-updater check --json
linux-updater check --security
linux-updater check --exclude kernel*
""",
)
check_parser.add_argument(
"--exclude",
nargs="+",
metavar="PATTERN",
help="Exclude package(s) or glob patterns from check.",
)
check_parser.add_argument(
"--security",
action="store_true",
help="Check only security-related updates.",
)
# Subcommand: release-upgrade
release_parser = subparsers.add_parser(
@@ -193,6 +223,33 @@ Examples:
""",
)
# Subcommand: completion
completion_parser = subparsers.add_parser(
"completion",
help="Generate shell autocompletion script (bash or zsh).",
formatter_class=argparse.RawDescriptionHelpFormatter,
description="Generate shell autocompletion script for Bash or Zsh.",
epilog="""
Installation Examples:
# Bash (current session)
source <(linux-updater completion bash)
# Bash (system-wide)
sudo linux-updater completion bash > /usr/share/bash-completion/completions/linux-updater
# Zsh (current session)
source <(linux-updater completion zsh)
# Zsh (system-wide)
sudo linux-updater completion zsh > /usr/share/zsh/site-functions/_linux-updater
""",
)
completion_parser.add_argument(
"shell",
choices=["bash", "zsh"],
help="Shell to generate autocompletion script for.",
)
return parser
@@ -262,6 +319,16 @@ def main(argv: Optional[List[str]] = None) -> int:
parser = create_parser()
args = parser.parse_args(argv)
if args.command == "completion":
from linux_updater.core.completion import get_bash_completion, get_zsh_completion
shell = getattr(args, "shell", "bash")
if shell == "zsh":
sys.stdout.write(get_zsh_completion())
else:
sys.stdout.write(get_bash_completion())
sys.stdout.flush()
return 0
if args.command is None:
args.command = "update"
@@ -444,16 +511,24 @@ def _run(
# 4. Check Command
if args.command == "check":
exclude = getattr(args, "exclude", None) or config.exclude_packages
security_only = getattr(args, "security", False) or config.security_only
if not json_output:
print("Checking for available package updates...")
updates = manager.check_updates()
if security_only:
print("Checking for available security updates...")
else:
print("Checking for available package updates...")
updates = manager.check_updates(exclude=exclude, security_only=security_only)
if json_output:
print(json.dumps({
"updates_count": len(updates),
"security_only": security_only,
"exclude": exclude,
"updates": [{"package": u.package, "current_version": u.current_version, "new_version": u.new_version, "repo": u.repo} for u in updates]
}, indent=2))
else:
print(f"\nAvailable Updates ({len(updates)}):")
label = "Security Updates" if security_only else "Available Updates"
print(f"\n{label} ({len(updates)}):")
print("-" * 65)
for u in updates:
print(f"• {u.package:<30} {u.current_version} -> {u.new_version}")
@@ -463,22 +538,28 @@ def _run(
# 5. Update Command
if args.command == "update":
packages = getattr(args, "packages", None)
exclude = getattr(args, "exclude", None) or config.exclude_packages
security_only = getattr(args, "security", False) or config.security_only
if not json_output:
if packages:
print(f"Preparing to update specific packages: {', '.join(packages)}")
elif security_only:
print("Checking available security updates...")
else:
print("Checking available updates...")
# If not selective, query updates for preview in interactive mode
updates = []
if not packages and not config.non_interactive:
updates = manager.check_updates()
updates = manager.check_updates(exclude=exclude, security_only=security_only)
if not updates:
if not json_output:
print("System is already up to date. No updates needed.")
return 0
if not json_output:
print(f"\nAvailable Updates ({len(updates)}):")
label = "Available Security Updates" if security_only else "Available Updates"
print(f"\n{label} ({len(updates)}):")
print("-" * 65)
for u in updates[:20]:
print(f"• {u.package:<30} {u.current_version} -> {u.new_version}")
@@ -498,6 +579,8 @@ def _run(
res = manager.apply_updates(
packages=packages,
exclude=exclude,
security_only=security_only,
dry_run=dry_run,
non_interactive=config.non_interactive,
)
@@ -509,6 +592,22 @@ def _run(
print(json.dumps({"success": False, "result": res.to_dict()}, indent=2))
return 1
# Flatpak updates if requested
flatpak_requested = getattr(args, "flatpak", False) or config.update_flatpak
if flatpak_requested:
flatpak_bin = shutil.which("flatpak")
if flatpak_bin:
if dry_run:
if not json_output:
print("[dry-run] Would execute: flatpak update -y")
else:
if not json_output:
print("\nUpdating Flatpak packages...")
runner.run(["flatpak", "update", "-y"])
elif getattr(args, "flatpak", False):
if not json_output:
print("Warning: flatpak binary not found, skipping Flatpak updates.", file=sys.stderr)
if config.clean_after_update:
if not json_output:
print("Cleaning orphan packages...")