Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions doc/parse_hdlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

def read_header(f):
"""Lit un header RPM depuis un flux"""
pos = f.tell()
magic = f.read(3)

if not magic or len(magic) < 3:
Expand All @@ -46,8 +45,8 @@ def read_header(f):
# Pas un header RPM, probablement le trailer
return None

version = f.read(1)
reserved = f.read(4)
_version = f.read(1)
_reserved = f.read(4)

nindex = struct.unpack('>I', f.read(4))[0]
hsize = struct.unpack('>I', f.read(4))[0]
Expand Down
3 changes: 1 addition & 2 deletions urpm/auth/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

import json
import logging
import os
import time
from pathlib import Path
from typing import Optional, List
from typing import List

from .context import AuthContext

Expand Down
1 change: 0 additions & 1 deletion urpm/auth/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pwd
from dataclasses import dataclass
from enum import Flag, auto
from typing import Optional


class Permission(Flag):
Expand Down
2 changes: 1 addition & 1 deletion urpm/auth/polkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""

import logging
from typing import Optional, Tuple
from typing import Tuple

from .context import AuthContext, Permission

Expand Down
3 changes: 1 addition & 2 deletions urpm/cli/commands/appstream.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""AppStream metadata command."""

import gzip
from datetime import datetime
from pathlib import Path
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -187,7 +186,7 @@ def cmd_appstream(args, db: 'PackageDatabase') -> int:
print(colors.ok(f"OS metainfo file created: {metainfo_file}"))
return 0
except PermissionError:
print(colors.error(f"Permission denied. Run with sudo."))
print(colors.error("Permission denied. Run with sudo."))
return 1
except Exception as e:
print(colors.error(f"Failed to create metainfo: {e}"))
Expand Down
47 changes: 23 additions & 24 deletions urpm/cli/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:
# Check if image already exists
if container.image_exists(tag):
print(colors.error(f"\nError: Image '{tag}' already exists."))
print(f"\nTo replace it, first remove the existing image:")
print("\nTo replace it, first remove the existing image:")
print(f" {runtime.name} rmi {tag}")
print(f"\nThen run mkimage again.")
print("\nThen run mkimage again.")
return 1

# Base packages for build image
Expand Down Expand Up @@ -160,7 +160,7 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:
if free_gb < MIN_SPACE_GB:
print(colors.error(f"Insufficient disk space in {workdir}"))
print(colors.error(f" Available: {free_gb:.1f} GB, required: {MIN_SPACE_GB} GB"))
print(colors.dim(f" Use --workdir to specify a different location"))
print(colors.dim(" Use --workdir to specify a different location"))
return 1
except OSError as e:
print(colors.warning(f"Could not check disk space: {e}"))
Expand Down Expand Up @@ -243,7 +243,7 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:
print(colors.dim(f" DEBUG: rpmdb.sqlite size: {rpmdb_sqlite.stat().st_size} bytes"))
else:
if DEBUG_MKIMAGE:
print(colors.error(f" DEBUG: RPM db dir does not exist!"))
print(colors.error(" DEBUG: RPM db dir does not exist!"))

check = subprocess.run(
['rpm', '--root', tmpdir, '-q', 'filesystem'],
Expand Down Expand Up @@ -272,10 +272,10 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:
print(colors.success(f" DEBUG: /bin is symlink -> {bin_path.resolve()}"))
elif bin_path.exists():
if DEBUG_MKIMAGE:
print(colors.error(f" DEBUG: /bin exists but is NOT a symlink!"))
print(colors.error(" DEBUG: /bin exists but is NOT a symlink!"))
else:
if DEBUG_MKIMAGE:
print(colors.error(f" DEBUG: /bin does not exist!"))
print(colors.error(" DEBUG: /bin does not exist!"))

# Now install remaining packages (filesystem already provides /bin -> usr/bin etc)
remaining_packages = [p for p in packages if p != 'filesystem']
Expand Down Expand Up @@ -396,7 +396,7 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:
)
ret = cmd_install(urpm_local_args, chroot_db)
if ret != 0:
print(colors.error(f"Failed to install urpm"))
print(colors.error("Failed to install urpm"))
return ret
print(colors.success(f" Installed {rpm_path.name}"))
else:
Expand Down Expand Up @@ -427,7 +427,7 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:
print(f" Chroot size: {size_mb:.1f} MB")
except Exception:
pass
print(f" Archiving and importing (this may take a moment)...", end='', flush=True)
print(" Archiving and importing (this may take a moment)...", end='', flush=True)
# Use podman unshare for import when not root (same UID/GID mapping as install)
if not container.import_from_dir(tmpdir, tag, use_unshare=use_noscripts):
print() # newline after "..."
Expand All @@ -440,11 +440,11 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:
size = images[0]['size'] if images else 'unknown'

print(colors.success(f"\n{'='*60}"))
print(colors.success(f"Image created successfully!"))
print(colors.success("Image created successfully!"))
print(colors.success(f"{'='*60}"))
print(f" Tag: {tag}")
print(f" Size: {size}")
print(f"\nUsage:")
print("\nUsage:")
print(f" {runtime.name} run -it {tag} /bin/bash")
print(f" urpm build --image {tag} ./package.src.rpm")

Expand All @@ -456,7 +456,7 @@ def cmd_mkimage(args, db: 'PackageDatabase') -> int:

finally:
if not keep_chroot:
print(f"\nCleaning up temporary directory...")
print("\nCleaning up temporary directory...")
shutil.rmtree(tmpdir, ignore_errors=True)
else:
print(f"\nChroot kept at: {tmpdir}")
Expand All @@ -469,7 +469,6 @@ def _cleanup_chroot_for_image(root: str):
"""
import glob

from .. import colors

cleanup_patterns = [
'var/cache/urpmi/*',
Expand Down Expand Up @@ -503,7 +502,7 @@ def _cleanup_chroot_for_image(root: str):
var_tmp = os.path.join(root, 'var', 'tmp')
if not os.path.exists(var_tmp):
os.makedirs(var_tmp, mode=0o1777, exist_ok=True)
print(f" Created /var/tmp")
print(" Created /var/tmp")

# Create /etc/machine-id if missing (required by systemd, dbus, etc.)
machine_id_path = os.path.join(root, 'etc', 'machine-id')
Expand All @@ -513,7 +512,7 @@ def _cleanup_chroot_for_image(root: str):
machine_id = uuid.uuid4().hex # 32 hex chars, no dashes
with open(machine_id_path, 'w') as f:
f.write(machine_id + '\n')
print(f" Created /etc/machine-id")
print(" Created /etc/machine-id")
except (IOError, OSError):
pass

Expand Down Expand Up @@ -560,7 +559,7 @@ def cmd_build(args, db: 'PackageDatabase') -> int:
valid_sources.append(source_path)
elif source_path.suffix == '.rpm':
print(colors.warning(f"Binary RPM cannot be built: {source}"))
print(colors.dim(f" Use a .src.rpm or .spec file instead"))
print(colors.dim(" Use a .src.rpm or .spec file instead"))
continue
else:
print(colors.warning(f"Unsupported source type: {source}"))
Expand Down Expand Up @@ -618,7 +617,7 @@ def build_one(source_path: Path) -> tuple:
print(f" Output: {output_dir}")

if fail_count > 0:
print(f"\nFailed packages:")
print("\nFailed packages:")
for source, success, msg in results:
if not success:
print(f" {colors.error('X')} {source.name}: {msg}")
Expand Down Expand Up @@ -705,14 +704,14 @@ def _build_single_package(
container.exec(cid, ['/bin/update-ca-trust', 'extract'])

# 3. Copy source into container
print(f" Copying source...")
print(" Copying source...")

if source_path.suffix == '.rpm' and '.src.' in source_path.name:
# Source RPM - install it to extract spec and sources
if not container.cp(str(source_path), f"{cid}:/root/rpmbuild/SRPMS/"):
return (source_path, False, "Failed to copy SRPM")

print(f" Installing SRPM...")
print(" Installing SRPM...")
result = container.exec(cid, [
'rpm', '-ivh', f'/root/rpmbuild/SRPMS/{source_path.name}'
])
Expand Down Expand Up @@ -741,37 +740,37 @@ def _build_single_package(
# Copy entire directory content at once
container.cp(f"{sources_dir}/.", f"{cid}:/root/rpmbuild/SOURCES/")
else:
print(colors.warning(f" Warning: No SOURCES directory found"))
print(colors.warning(" Warning: No SOURCES directory found"))

else:
return (source_path, False, f"Unsupported source type: {source_path.suffix}")

# 4. Install rpm-build (provides rpmbuild)
print(f" Installing rpm-build...")
print(" Installing rpm-build...")
ret = container.exec_stream(cid, [
'urpm', 'install', '--auto', '--sync', 'rpm-build'
])
if ret != 0:
return (source_path, False, "Failed to install rpm-build")

# 5. Install build dependencies
print(f" Installing BuildRequires...")
print(" Installing BuildRequires...")
ret = container.exec_stream(cid, [
'urpm', 'install', '--auto', '--sync', '--builddeps', spec_path
])
if ret != 0:
return (source_path, False, f"BuildRequires install failed")
return (source_path, False, "BuildRequires install failed")

# 6. Build the package
print(f" Building...")
print(" Building...")
result = container.exec_stream(cid, [
'rpmbuild', '-ba', spec_path
])
if result != 0:
return (source_path, False, "rpmbuild failed")

# 7. Copy results out
print(f" Retrieving results...")
print(" Retrieving results...")

# Determine output location
if is_spec_build and workspace:
Expand Down
4 changes: 2 additions & 2 deletions urpm/cli/commands/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def cmd_cache_rebuild_fts(args, db: 'PackageDatabase') -> int:
# Check current FTS state
stats = db.get_fts_stats()

print(f"\nFTS Index Status:")
print("\nFTS Index Status:")
print(f" Available: {'yes' if stats['available'] else 'no'}")
print(f" Current: {'yes' if stats['current'] else 'no'}")
print(f" Files in package_files: {stats['pf_count']:,}")
Expand All @@ -274,7 +274,7 @@ def cmd_cache_rebuild_fts(args, db: 'PackageDatabase') -> int:
rebuild_time = datetime.fromtimestamp(stats['last_rebuild'])
print(f" Last rebuild: {rebuild_time.strftime('%Y-%m-%d %H:%M:%S')}")

print(f"\nRebuilding FTS index...", flush=True)
print("\nRebuilding FTS index...", flush=True)

# Try to use urpmd API if running (avoids database lock issues)
port = DEV_PORT if is_dev_mode() else PROD_PORT
Expand Down
12 changes: 6 additions & 6 deletions urpm/cli/commands/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def cmd_autoremove(args, db: 'PackageDatabase') -> int:
# Check for previous background errors
prev_error = check_background_error()
if prev_error:
print(colors.warning(f"Warning: Previous background operation had an error:"))
print(colors.warning("Warning: Previous background operation had an error:"))
print(colors.warning(f" {prev_error}"))
print(colors.dim(" (This message will not appear again)"))
clear_background_error()
Expand Down Expand Up @@ -256,7 +256,7 @@ def queue_progress(op_id: str, name: str, current: int, total: int):
print(f"\r\033[K [{len(package_names)}/{len(package_names)}] done")

if not queue_result.success:
print(colors.error(f"\nRemoval failed:"))
print(colors.error("\nRemoval failed:"))
if queue_result.operations:
for err in queue_result.operations[0].errors[:3]:
print(f" {colors.error(err)}")
Expand All @@ -266,7 +266,7 @@ def queue_progress(op_id: str, name: str, current: int, total: int):
return 1

if interrupted[0]:
print(colors.warning(f"\n Autoremove interrupted"))
print(colors.warning("\n Autoremove interrupted"))
db.abort_transaction(transaction_id)
return 130

Expand All @@ -289,7 +289,7 @@ def queue_progress(op_id: str, name: str, current: int, total: int):

return 0

except Exception as e:
except Exception:
db.abort_transaction(transaction_id)
raise
finally:
Expand Down Expand Up @@ -611,7 +611,7 @@ def queue_progress(op_id: str, name: str, current: int, total: int):
print(f"\r\033[K [{len(packages_to_erase)}/{len(packages_to_erase)}] done")

if not queue_result.success:
print(colors.error(f"\nErase failed:"))
print(colors.error("\nErase failed:"))
if queue_result.operations:
for err in queue_result.operations[0].errors[:5]:
print(f" {colors.error(err)}")
Expand Down Expand Up @@ -647,7 +647,7 @@ def queue_progress(op_id: str, name: str, current: int, total: int):

return 0

except Exception as e:
except Exception:
db.abort_transaction(transaction_id)
raise
finally:
Expand Down
2 changes: 1 addition & 1 deletion urpm/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ...core.database import PackageDatabase
pass

from ..helpers.kernel import (
read_config as _read_config,
Expand Down
4 changes: 2 additions & 2 deletions urpm/cli/commands/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ def format_dep_type(dep_type: str, short: bool = False) -> str:

if not direct_rdeps:
print(f"{colors.bold(pkg_name)}: {colors.warning('orphan')} (nothing requires it)")
print(f"\nThis package can be removed with: urpm autoremove --orphans")
print("\nThis package can be removed with: urpm autoremove --orphans")
return 0

# For each direct rdep, find ALL paths to explicit packages using ONLY requires
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def format_dep_type(dep_type: str, short: bool = False) -> str:

if not explicit_branches:
print(f"{colors.bold(pkg_name)}: {colors.warning('orphan')} (no explicit package requires it)")
print(f"\nThis package can be removed with: urpm autoremove --orphans")
print("\nThis package can be removed with: urpm autoremove --orphans")
return 0

# Group by explicit package
Expand Down
2 changes: 1 addition & 1 deletion urpm/cli/commands/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def install_progress(op_id: str, name: str, current: int, total: int):
print(colors.success(f" {installed_count} packages reinstalled"))

elif not_found and not rpm_paths:
print(colors.warning(f" Could not reinstall: packages not found in repositories"))
print(colors.warning(" Could not reinstall: packages not found in repositories"))

if interrupted:
db.abort_transaction(undo_trans_id)
Expand Down
Loading