|
| 1 | +# Copyright (c) 2025 SUSE LLC. All rights reserved. |
| 2 | +# |
| 3 | +# This file is part of kiwi. |
| 4 | +# |
| 5 | +# kiwi is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License as published by |
| 7 | +# the Free Software Foundation, either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# kiwi is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License |
| 16 | +# along with kiwi. If not, see <http://www.gnu.org/licenses/> |
| 17 | +# |
| 18 | +import os |
| 19 | + |
| 20 | +# project |
| 21 | +from kiwi.container.setup.base import ContainerSetupBase |
| 22 | +from kiwi.exceptions import KiwiContainerSetupError |
| 23 | + |
| 24 | + |
| 25 | +class ContainerSetupWsl(ContainerSetupBase): |
| 26 | + """ |
| 27 | + WSL new tar setup |
| 28 | + """ |
| 29 | + def setup(self): |
| 30 | + """ |
| 31 | + Setup container metadata |
| 32 | + """ |
| 33 | + # It's expected that the container metadata for the |
| 34 | + # new WSL format is provided by a package or via overlay |
| 35 | + # data. Thus this setup routine only checks for the |
| 36 | + # presence of the data and fails when missing |
| 37 | + distribution_conf = os.path.normpath( |
| 38 | + os.sep.join([self.root_dir, 'etc', 'wsl-distribution.conf']) |
| 39 | + ) |
| 40 | + wsl_conf = os.path.normpath( |
| 41 | + os.sep.join([self.root_dir, 'etc', 'wsl.conf']) |
| 42 | + ) |
| 43 | + if not os.path.exists(distribution_conf): |
| 44 | + raise KiwiContainerSetupError( |
| 45 | + f'Mandatory WSL {distribution_conf} not found in root tree' |
| 46 | + ) |
| 47 | + if not os.path.exists(wsl_conf): |
| 48 | + raise KiwiContainerSetupError( |
| 49 | + f'Mandatory WSL {wsl_conf} not found in root tree' |
| 50 | + ) |
0 commit comments