-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
erofs is an alternative readonly filesystem that can be used as alternative to squashfs. This Fixes #2633
- Loading branch information
Showing
11 changed files
with
135 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,26 @@ | ||
#!/bin/bash | ||
#================ | ||
# FILE : config.sh | ||
#---------------- | ||
# PROJECT : OpenSuSE KIWI Image System | ||
# COPYRIGHT : (c) 2006 SUSE LINUX Products GmbH. All rights reserved | ||
# : | ||
# AUTHOR : Marcus Schaefer <ms@suse.de> | ||
# : | ||
# BELONGS TO : Operating System images | ||
# : | ||
# DESCRIPTION : configuration script for SUSE based | ||
# : operating systems | ||
#---------------- | ||
#====================================== | ||
# Functions... | ||
#-------------------------------------- | ||
test -f /.kconfig && . /.kconfig | ||
test -f /.profile && . /.profile | ||
|
||
set -ex | ||
|
||
declare kiwi_profiles=${kiwi_profiles} | ||
declare kiwi_iname=${kiwi_iname} | ||
|
||
#====================================== | ||
# Greeting... | ||
#-------------------------------------- | ||
echo "Configure image: [$kiwi_iname]..." | ||
|
||
#====================================== | ||
# Setup baseproduct link | ||
#-------------------------------------- | ||
suseSetupProduct | ||
|
||
#====================================== | ||
# Activate services | ||
#-------------------------------------- | ||
suseInsertService sshd | ||
systemctl enable sshd | ||
|
||
#====================================== | ||
# Setup default target, multi-user | ||
# Include erofs module | ||
#-------------------------------------- | ||
baseSetRunlevel 3 | ||
for profile in ${kiwi_profiles//,/ }; do | ||
if [ "${profile}" = "EroFS" ]; then | ||
# remove from blacklist | ||
rm -f /usr/lib/modprobe.d/60-blacklist_fs-erofs.conf | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright (c) 2024 SUSE Software Solutions Germany GmbH. All rights reserved. | ||
# | ||
# This file is part of kiwi. | ||
# | ||
# kiwi is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# kiwi is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with kiwi. If not, see <http://www.gnu.org/licenses/> | ||
# | ||
from typing import List | ||
|
||
# project | ||
from kiwi.filesystem.base import FileSystemBase | ||
from kiwi.command import Command | ||
|
||
|
||
class FileSystemEroFs(FileSystemBase): | ||
""" | ||
**Implements creation of erofs filesystem** | ||
""" | ||
def create_on_file( | ||
self, filename, label: str = None, exclude: List[str] = None | ||
): | ||
""" | ||
Create erofs filesystem from data tree | ||
:param string filename: result file path name | ||
:param string label: volume label | ||
:param list exclude: list of exclude dirs/files | ||
""" | ||
self.filename = filename | ||
exclude_options = [] | ||
# compression = self.custom_args.get('compression') | ||
|
||
if exclude: | ||
for item in exclude: | ||
exclude_options.append(f'--exclude-regex={item}') | ||
|
||
if label: | ||
self.custom_args['create_options'].append('-L') | ||
self.custom_args['create_options'].append(label) | ||
|
||
Command.run( | ||
[ | ||
'mkfs.erofs' | ||
] + self.custom_args['create_options'] + exclude_options + [ | ||
self.filename, self.root_dir | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from unittest.mock import patch | ||
|
||
import unittest.mock as mock | ||
|
||
from kiwi.defaults import Defaults | ||
from kiwi.filesystem.erofs import FileSystemEroFs | ||
|
||
|
||
class TestFileSystemEroFs: | ||
@patch('os.path.exists') | ||
def setup(self, mock_exists): | ||
mock_exists.return_value = True | ||
self.erofs = FileSystemEroFs(mock.Mock(), 'root_dir') | ||
|
||
@patch('os.path.exists') | ||
def setup_method(self, cls, mock_exists): | ||
self.setup() | ||
|
||
@patch('kiwi.filesystem.erofs.Command.run') | ||
def test_create_on_file(self, mock_command): | ||
Defaults.set_platform_name('x86_64') | ||
self.erofs.create_on_file('myimage', 'label') | ||
mock_command.assert_called_once_with( | ||
['mkfs.erofs', '-L', 'label', 'myimage', 'root_dir'] | ||
) | ||
|
||
@patch('kiwi.filesystem.erofs.Command.run') | ||
def test_create_on_file_exclude_data(self, mock_command): | ||
Defaults.set_platform_name('x86_64') | ||
self.erofs.create_on_file('myimage', 'label', ['foo']) | ||
mock_command.assert_called_once_with( | ||
[ | ||
'mkfs.erofs', '-L', 'label', | ||
'--exclude-regex=foo', 'myimage', 'root_dir' | ||
] | ||
) |