Skip to content

Commit

Permalink
Turn into a generic solution
Browse files Browse the repository at this point in the history
Consume .kiwi.package_manager.env in all package managers
  • Loading branch information
schaefi committed Jan 13, 2025
1 parent 47e4fd4 commit 17ac65e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions kiwi/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
PLATFORM_MACHINE = platform.machine()
EFI_FAT_IMAGE_SIZE = 20

# optional zypp/zypper environment variables
ZYPP_ENV_VARS = '/.zypp.env'
# optional package manager environment variables
PACKAGE_MANAGER_ENV_VARS = '/.kiwi.package_manager.env'

log = logging.getLogger('kiwi')

Expand Down
3 changes: 3 additions & 0 deletions kiwi/repository/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
from typing import List, Dict

# project
import kiwi.defaults as defaults
from kiwi.utils.temporary import (
Temporary, TmpT
)
from kiwi.repository.template.apt import PackageManagerTemplateAptGet
from kiwi.repository.base import RepositoryBase
from kiwi.path import Path
from kiwi.command import Command
from kiwi.utils.toenv import ToEnv

log = logging.getLogger('kiwi')

Expand Down Expand Up @@ -306,6 +308,7 @@ def _add_components(self, components: str) -> None:
def _create_apt_get_runtime_environment(self) -> Dict:
for apt_get_dir in list(self.shared_apt_get_dir.values()):
Path.create(apt_get_dir)
ToEnv(self.root_dir, defaults.PACKAGE_MANAGER_ENV_VARS)
return dict(
os.environ, LANG='C', DEBIAN_FRONTEND='noninteractive'
)
Expand Down
3 changes: 3 additions & 0 deletions kiwi/repository/dnf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import List, Dict

# project
import kiwi.defaults as defaults
from kiwi.utils.temporary import (
Temporary, TmpT
)
Expand All @@ -29,6 +30,7 @@
from kiwi.repository.base import RepositoryBase
from kiwi.path import Path
from kiwi.utils.rpm_database import RpmDataBase
from kiwi.utils.toenv import ToEnv


class RepositoryDnf4(RepositoryBase):
Expand Down Expand Up @@ -315,6 +317,7 @@ def cleanup_unused_repos(self) -> None:
def _create_dnf_runtime_environment(self) -> Dict:
for dnf_dir in list(self.shared_dnf_dir.values()):
Path.create(dnf_dir)
ToEnv(self.root_dir, defaults.PACKAGE_MANAGER_ENV_VARS)
return dict(
os.environ, LANG='C'
)
Expand Down
3 changes: 3 additions & 0 deletions kiwi/repository/dnf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import List, Dict

# project
import kiwi.defaults as defaults
from kiwi.utils.temporary import (
Temporary, TmpT
)
Expand All @@ -29,6 +30,7 @@
from kiwi.repository.base import RepositoryBase
from kiwi.path import Path
from kiwi.utils.rpm_database import RpmDataBase
from kiwi.utils.toenv import ToEnv


class RepositoryDnf5(RepositoryBase):
Expand Down Expand Up @@ -315,6 +317,7 @@ def cleanup_unused_repos(self) -> None:
def _create_dnf_runtime_environment(self) -> Dict:
for dnf_dir in list(self.shared_dnf_dir.values()):
Path.create(dnf_dir)
ToEnv(self.root_dir, defaults.PACKAGE_MANAGER_ENV_VARS)
return dict(
os.environ, LANG='C'
)
Expand Down
3 changes: 3 additions & 0 deletions kiwi/repository/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
)

# project
import kiwi.defaults as defaults
from kiwi.utils.temporary import (
Temporary, TmpT
)
from kiwi.repository.base import RepositoryBase
from kiwi.path import Path
from kiwi.command import Command
from kiwi.utils.toenv import ToEnv


class RepositoryPacman(RepositoryBase):
Expand Down Expand Up @@ -90,6 +92,7 @@ def runtime_config(self) -> Dict:
"""
pacman runtime configuration and environment
"""
ToEnv(self.root_dir, defaults.PACKAGE_MANAGER_ENV_VARS)
return {
'pacman_args': self.pacman_args,
'command_env': os.environ
Expand Down
2 changes: 1 addition & 1 deletion kiwi/repository/zypper.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def cleanup_unused_repos(self) -> None:
def _create_zypper_runtime_environment(self) -> Dict:
for zypper_dir in list(self.shared_zypper_dir.values()):
Path.create(zypper_dir)
ToEnv(self.root_dir, defaults.ZYPP_ENV_VARS)
ToEnv(self.root_dir, defaults.PACKAGE_MANAGER_ENV_VARS)
return dict(
os.environ,
LANG='C',
Expand Down

0 comments on commit 17ac65e

Please sign in to comment.