Skip to content

Commit

Permalink
sync my fork with original one
Browse files Browse the repository at this point in the history
* disk: move ENC_IDENTIFIER (archlinux#3034)

* general: remove unspecified exception handling (archlinux#3035)

* chore(deps): update pre-commit hook pre-commit/mirrors-mypy to v1.14.0 (archlinux#3037)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency mypy to v1.14.0 (archlinux#3036)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* disk: change from_partition() parameters (archlinux#3039)

* Rework profiles path (archlinux#3040)

* Rework mount point argument (archlinux#3041)

* Use Path.chmod() (archlinux#3051)

* audio: remove incorrect use of dataclass (archlinux#3058)

* chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.8.5 (archlinux#3063)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update pre-commit hook pre-commit/mirrors-mypy to v1.14.1 (archlinux#3062)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency pylint to v3.3.3 (archlinux#3046)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update dependency mypy to v1.14.1 (archlinux#3057)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* audio: capitalize enums (archlinux#3067)

* fix(deps): update dependency ruff to v0.8.5 (archlinux#3064)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

---------

Co-authored-by: codefiles <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 5, 2025
1 parent b0379f3 commit 409f4af
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
args: [--config=.flake8]
fail_fast: true
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.1
hooks:
- id: mypy
args: [
Expand All @@ -47,7 +47,7 @@ repos:
- pydantic-settings
- pytest
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
rev: v0.8.5
hooks:
- id: ruff
- repo: local
Expand Down
4 changes: 1 addition & 3 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def define_arguments() -> None:
parser.add_argument("--dry-run", "--dry_run", action="store_true",
help="Generates a configuration file and then exits instead of performing an installation")
parser.add_argument("--script", default="guided", nargs="?", help="Script to run for installation", type=str)
parser.add_argument("--mount-point", "--mount_point", nargs="?", type=str,
parser.add_argument("--mount-point", "--mount_point", default=Path("/mnt/archinstall"), nargs="?", type=Path,
help="Define an alternate mount point for installation")
parser.add_argument("--skip-ntp", action="store_true", help="Disables NTP checks during installation", default=False)
parser.add_argument("--debug", action="store_true", default=False, help="Adds debug info into the log")
Expand Down Expand Up @@ -266,8 +266,6 @@ def load_config() -> None:

def post_process_arguments(args: dict[str, Any]) -> None:
storage['arguments'] = args
if mountpoint := args.get('mount_point', None):
storage['MOUNT_POINT'] = Path(mountpoint)

if args.get('debug', False):
warn(f"Warning: --debug mode will write certain credentials to {storage['LOG_PATH']}/{storage['LOG_FILE']}!")
Expand Down
3 changes: 0 additions & 3 deletions archinstall/lib/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ def _parse_args(self) -> Arguments:
if args.config is None:
args.silent = False

if args.mount_point is not None:
storage['MOUNT_POINT'] = Path(args.mount_point)

if args.debug:
warn(f"Warning: --debug mode will write certain credentials to {storage['LOG_PATH']}/{storage['LOG_FILE']}!")

Expand Down
5 changes: 2 additions & 3 deletions archinstall/lib/configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import os
import readline
import stat
from pathlib import Path
Expand Down Expand Up @@ -117,14 +116,14 @@ def save_user_config(self, dest_path: Path) -> None:
if self._is_valid_path(dest_path):
target = dest_path / self._user_config_file
target.write_text(self.user_config_to_json())
os.chmod(target, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)

def save_user_creds(self, dest_path: Path) -> None:
if self._is_valid_path(dest_path):
if user_creds := self.user_credentials_to_json():
target = dest_path / self._user_creds_file
target.write_text(user_creds)
os.chmod(target, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)

def save(self, dest_path: Path | None = None) -> None:
dest_path = dest_path or self._default_save_path
Expand Down
5 changes: 1 addition & 4 deletions archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,8 @@ def load_devices(self) -> None:
partition_infos.append(
_PartitionInfo.from_partition(
partition,
lsblk_info,
fs_type,
lsblk_info.partn,
lsblk_info.partuuid,
lsblk_info.uuid,
lsblk_info.mountpoints,
subvol_infos
)
)
Expand Down
22 changes: 11 additions & 11 deletions archinstall/lib/disk/device_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
_: Callable[[str], DeferredTranslation]


ENC_IDENTIFIER = 'ainst'


class DiskLayoutType(Enum):
Default = 'default_layout'
Manual = 'manual_partitioning'
Expand Down Expand Up @@ -96,7 +99,7 @@ def parse_arg(cls, disk_config: _DiskLayoutConfigurationSerialization) -> DiskLa
mods = device_handler.detect_pre_mounted_mods(path)
device_modifications.extend(mods)

storage['MOUNT_POINT'] = path
storage['arguments']['mount_point'] = path

config.mountpoint = path

Expand Down Expand Up @@ -447,11 +450,8 @@ def table_data(self) -> dict[str, str]:
def from_partition(
cls,
partition: Partition,
lsblk_info: LsblkInfo,
fs_type: FilesystemType | None,
partn: int | None,
partuuid: str | None,
uuid: str | None, # pylint: disable=redefined-outer-name
mountpoints: list[Path],
btrfs_subvol_infos: list[_BtrfsSubvolumeInfo] = []
) -> _PartitionInfo:
partition_type = PartitionType.get_type_from_code(partition.type)
Expand All @@ -478,11 +478,11 @@ def from_partition(
start=start,
length=length,
flags=flags,
partn=partn,
partuuid=partuuid,
uuid=uuid,
partn=lsblk_info.partn,
partuuid=lsblk_info.partuuid,
uuid=lsblk_info.uuid,
disk=partition.disk,
mountpoints=mountpoints,
mountpoints=lsblk_info.mountpoints,
btrfs_subvol_infos=btrfs_subvol_infos
)

Expand Down Expand Up @@ -919,7 +919,7 @@ def is_create_or_modify(self) -> bool:
@property
def mapper_name(self) -> str | None:
if self.dev_path:
return f'{storage.get("ENC_IDENTIFIER", "ai")}{self.dev_path.name}'
return f'{ENC_IDENTIFIER}{self.dev_path.name}'
return None

def set_flag(self, flag: PartitionFlag) -> None:
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def obj_id(self) -> str:
@property
def mapper_name(self) -> str | None:
if self.dev_path:
return f'{storage.get("ENC_IDENTIFIER", "ai")}{self.safe_dev_path.name}'
return f'{ENC_IDENTIFIER}{self.safe_dev_path.name}'
return None

@property
Expand Down
8 changes: 2 additions & 6 deletions archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def peak(self, output: str | bytes) -> bool:
peek_output_log.write(str(output))

if change_perm:
os.chmod(str(peak_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
peak_logfile.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)

sys.stdout.write(str(output))
sys.stdout.flush()
Expand Down Expand Up @@ -317,14 +317,10 @@ def execute(self) -> bool:
cmd_log.write(f"{time.time()} {self.cmd}\n")

if change_perm:
os.chmod(str(history_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
history_logfile.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
except (PermissionError, FileNotFoundError):
# If history_logfile does not exist, ignore the error
pass
except Exception as e:
exception_type = type(e).__name__
error(f"Unexpected {exception_type} occurred in {self.cmd}: {e}")
raise e

if storage.get('arguments', {}).get('debug'):
debug(f"Executing: {self.cmd}")
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/interactions/disk_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def select_disk_config(

mods = disk.device_handler.detect_pre_mounted_mods(path)

storage['MOUNT_POINT'] = path
storage['arguments']['mount_point'] = path

return disk.DiskLayoutConfiguration(
config_type=disk.DiskLayoutType.Pre_mount,
Expand Down
13 changes: 6 additions & 7 deletions archinstall/lib/models/audio_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from ..output import info


@dataclass
class Audio(Enum):
NoAudio = 'No audio server'
Pipewire = 'pipewire'
Pulseaudio = 'pulseaudio'
NO_AUDIO = 'No audio server'
PIPEWIRE = 'pipewire'
PULSEAUDIO = 'pulseaudio'


@dataclass
Expand All @@ -36,12 +35,12 @@ def install_audio_config(
info(f'Installing audio server: {self.audio.name}')

match self.audio:
case Audio.Pipewire:
case Audio.PIPEWIRE:
PipewireProfile().install(installation)
case Audio.Pulseaudio:
case Audio.PULSEAUDIO:
installation.add_additional_packages("pulseaudio")

if self.audio != Audio.NoAudio:
if self.audio != Audio.NO_AUDIO:
if SysInfo.requires_sof_fw():
installation.add_additional_packages('sof-firmware')

Expand Down
5 changes: 2 additions & 3 deletions archinstall/lib/profile/profiles_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ..hardware import GfxDriver
from ..networking import fetch_data_from_url, list_interfaces
from ..output import debug, error, info
from ..storage import storage
from .profile_model import ProfileConfiguration

if TYPE_CHECKING:
Expand All @@ -29,7 +28,6 @@

class ProfileHandler:
def __init__(self) -> None:
self._profiles_path: Path = storage['PROFILE']
self._profiles: list[Profile] | None = None

# special variable to keep track of a profile url configuration
Expand Down Expand Up @@ -346,8 +344,9 @@ def _find_available_profiles(self) -> list[Profile]:
"""
Search the profile path for profile definitions
"""
profiles_path = Path(__file__).parents[2] / 'default_profiles'
profiles = []
for file in self._profiles_path.glob('**/*.py'):
for file in profiles_path.glob('**/*.py'):
# ignore the abstract default_profiles class
if 'profile.py' in file.name:
continue
Expand Down
3 changes: 0 additions & 3 deletions archinstall/lib/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from typing import Any

storage: dict[str, Any] = {
'PROFILE': Path(__file__).parent.parent.joinpath('default_profiles'),
'LOG_PATH': Path('/var/log/archinstall'),
'LOG_FILE': Path('install.log'),
'MOUNT_POINT': Path('/mnt/archinstall'),
'ENC_IDENTIFIER': 'ainst',
}
2 changes: 1 addition & 1 deletion archinstall/scripts/guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def guided() -> None:
)

fs_handler.perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')))
perform_installation(archinstall.arguments.get('mount_point', Path('/mnt')))


guided()
2 changes: 1 addition & 1 deletion archinstall/scripts/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def minimal() -> None:
)

fs_handler.perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')))
perform_installation(archinstall.arguments.get('mount_point', Path('/mnt')))


minimal()
2 changes: 1 addition & 1 deletion archinstall/scripts/only_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def only_hd() -> None:
)

fs_handler.perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')))
perform_installation(archinstall.arguments.get('mount_point', Path('/mnt')))


only_hd()
6 changes: 3 additions & 3 deletions archinstall/scripts/swiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def execute(self) -> None:
archinstall.arguments[item.key] = item.action(item.value)

perform_installation(
archinstall.storage.get('MOUNT_POINT', Path('/mnt')),
archinstall.arguments.get('mount_point', Path('/mnt')),
self._execution_mode
)
case ExecutionMode.Only_OS:
Expand All @@ -87,7 +87,7 @@ def execute(self) -> None:
break

perform_installation(
archinstall.storage.get('MOUNT_POINT', Path('/mnt')),
archinstall.arguments.get('mount_point', Path('/mnt')),
self._execution_mode
)
case _:
Expand Down Expand Up @@ -266,7 +266,7 @@ def swiss() -> None:
)

fs_handler.perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')), mode)
perform_installation(archinstall.arguments.get('mount_point', Path('/mnt')), mode)


swiss()
2 changes: 1 addition & 1 deletion examples/interactive_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _guided() -> None:
)

fs_handler.perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')))
perform_installation(archinstall.arguments.get('mount_point', Path('/mnt')))


_guided()
2 changes: 1 addition & 1 deletion examples/minimal_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _minimal() -> None:
)

fs_handler.perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')))
perform_installation(archinstall.arguments.get('mount_point', Path('/mnt')))


_minimal()
2 changes: 1 addition & 1 deletion examples/only_hd_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _only_hd() -> None:
)

fs_handler.perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', Path('/mnt')))
perform_installation(archinstall.arguments.get('mount_point', Path('/mnt')))


_only_hd()
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Source = "https://github.com/archlinux/archinstall"
[project.optional-dependencies]
log = ["systemd_python==235"]
dev = [
"mypy==1.13.0",
"mypy==1.14.1",
"flake8==7.1.1",
"pre-commit==4.0.1",
"ruff==0.8.4",
"pylint==3.3.2",
"ruff==0.8.5",
"pylint==3.3.3",
"pylint-pydantic==0.3.4",
"pytest==8.3.4",
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_config_file_parsing(
),
bootloader=Bootloader.Systemd,
uki=False,
audio_config=AudioConfiguration(Audio.Pipewire),
audio_config=AudioConfiguration(Audio.PIPEWIRE),
hostname='archy',
kernels=['linux-zen'],
ntp=True,
Expand Down

0 comments on commit 409f4af

Please sign in to comment.