Skip to content

Commit 2edcfed

Browse files
committed
Rename btrfs_root_is_snapshot
Rename btrfs_root_is_snapshot to btrfs_root_is_snapper_snapshot. This happens in preparation for the changes suggested in #2697 where we want to get rid of snapper specific btrfs code which will be available in snapper natively soon. To make sure a btrfs layout specific to snapper(and SUSE), the implicitly used attribute named btrfs_root_is_snapshot now becomes explicit and its new name will indicate that snapper sits behind it. Along with the rename a XSLT stylesheet to automatically convert the old name into the new name for schema v8.3 will be performed.
1 parent 719686d commit 2edcfed

File tree

15 files changed

+146
-80
lines changed

15 files changed

+146
-80
lines changed

doc/source/image_description/elements.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,18 @@ btrfs_root_is_subvolume="true|false":
448448
449449
By default the creation of a toplevel volume is set to: `true`
450450

451-
btrfs_root_is_snapshot="true|false":
451+
btrfs_root_is_snapper_snapshot="true|false":
452452
Boolean parameter that tells {kiwi} to install
453-
the system into a btrfs snapshot. The snapshot layout is compatible with
454-
snapper. By default snapshots are turned off.
453+
the system into a btrfs snapshot. The snapshot layout is compatible
454+
with the snapper management toolkit and follows a concept by SUSE.
455+
By default snapshots are turned off.
455456

456457
btrfs_root_is_readonly_snapshot="true|false":
457458
Boolean parameter notifying {kiwi} that
458459
the btrfs root filesystem snapshot has to made read-only. if this option
459460
is set to true, the root filesystem snapshot it will be turned into
460461
read-only mode, once all data has been placed to it. The option is only
461-
effective if `btrfs_root_is_snapshot` is also set to true. By default the
462+
effective if `btrfs_root_is_snapper_snapshot` is also set to true. By default the
462463
root filesystem snapshot is writable.
463464

464465
bootstrap_package="package_name":

kiwi/boot/image/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def import_system_description_elements(self) -> None:
359359
type_attributes = [
360360
'bootkernel',
361361
'bootprofile',
362-
'btrfs_root_is_snapshot',
362+
'btrfs_root_is_snapper_snapshot',
363363
'gpt_hybrid_mbr',
364364
'devicepersistency',
365365
'filesystem',

kiwi/bootloader/config/grub2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ def _setup_default_grub(self):
800800
)
801801
if os.path.exists(os.sep.join([self.root_dir, theme_background])):
802802
grub_default_entries['GRUB_BACKGROUND'] = theme_background
803-
if self.xml_state.build_type.get_btrfs_root_is_snapshot():
803+
if self.xml_state.build_type.get_btrfs_root_is_snapper_snapshot():
804804
grub_default_entries['SUSE_BTRFS_SNAPSHOT_BOOTING'] = 'true'
805805
if self.custom_args.get('crypto_disk'):
806806
grub_default_entries['GRUB_ENABLE_CRYPTODISK'] = 'y'

kiwi/builder/disk.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def __init__(
226226
self.custom_root_creation_args,
227227
'root_label':
228228
self.disk_setup.get_root_label(),
229-
'root_is_snapshot':
230-
self.xml_state.build_type.get_btrfs_root_is_snapshot(),
229+
'root_is_snapper_snapshot':
230+
self.xml_state.build_type.get_btrfs_root_is_snapper_snapshot(),
231231
'root_is_readonly_snapshot':
232232
self.xml_state.build_type.get_btrfs_root_is_readonly_snapshot(),
233233
'root_is_subvolume':
@@ -1308,14 +1308,14 @@ def _write_generic_fstab(
13081308
self, device_map: Dict, setup: SystemSetup,
13091309
system: Optional[Union[FileSystemBase, VolumeManagerBase]]
13101310
) -> None:
1311-
root_is_snapshot = \
1312-
self.xml_state.build_type.get_btrfs_root_is_snapshot()
1311+
root_is_snapper_snapshot = \
1312+
self.xml_state.build_type.get_btrfs_root_is_snapper_snapshot()
13131313
root_is_readonly_snapshot = \
13141314
self.xml_state.build_type.get_btrfs_root_is_readonly_snapshot()
13151315

13161316
fs_check_interval = '0 1'
13171317
custom_root_mount_args = list(self.custom_root_mount_args)
1318-
if root_is_snapshot and root_is_readonly_snapshot:
1318+
if root_is_snapper_snapshot and root_is_readonly_snapshot:
13191319
custom_root_mount_args += ['ro']
13201320
fs_check_interval = '0 0'
13211321

@@ -1788,11 +1788,11 @@ def _setup_property_root_is_readonly_snapshot(
17881788
self, system: Union[FileSystemBase, VolumeManagerBase]
17891789
) -> None:
17901790
if self.volume_manager_name:
1791-
root_is_snapshot = \
1792-
self.xml_state.build_type.get_btrfs_root_is_snapshot()
1791+
root_is_snapper_snapshot = \
1792+
self.xml_state.build_type.get_btrfs_root_is_snapper_snapshot()
17931793
root_is_readonly_snapshot = \
17941794
self.xml_state.build_type.get_btrfs_root_is_readonly_snapshot()
1795-
if root_is_snapshot and root_is_readonly_snapshot:
1795+
if root_is_snapper_snapshot and root_is_readonly_snapshot:
17961796
log.info(
17971797
'Setting root filesystem into read-only mode'
17981798
)

kiwi/schema/kiwi.rnc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ div {
6666
attribute xsi:schemaLocation { xsd:anyURI }
6767
k.image.schemaversion.attribute =
6868
## The allowed Schema version (fixed value)
69-
attribute schemaversion { "8.2" }
69+
attribute schemaversion { "8.3" }
7070
k.image.id =
7171
## An identification number which is represented in a file
7272
## named /etc/ImageID
@@ -1524,20 +1524,21 @@ div {
15241524
sch:param [ name = "attr" value = "btrfs_root_is_subvolume" ]
15251525
sch:param [ name = "types" value = "oem" ]
15261526
]
1527-
k.type.btrfs_root_is_snapshot.attribute =
1527+
k.type.btrfs_root_is_snapper_snapshot.attribute =
15281528
## Tell kiwi to install the system into a btrfs snapshot
15291529
## The snapshot layout is compatible with the snapper management
1530-
## toolkit. By default no snapshots are used
1531-
attribute btrfs_root_is_snapshot { xsd:boolean }
1532-
>> sch:pattern [ id = "btrfs_root_is_snapshot" is-a = "image_type"
1533-
sch:param [ name = "attr" value = "btrfs_root_is_snapshot" ]
1530+
## toolkit and follows a concept by SUSE.
1531+
## By default no snapshots are used
1532+
attribute btrfs_root_is_snapper_snapshot { xsd:boolean }
1533+
>> sch:pattern [ id = "btrfs_root_is_snapper_snapshot" is-a = "image_type"
1534+
sch:param [ name = "attr" value = "btrfs_root_is_snapper_snapshot" ]
15341535
sch:param [ name = "types" value = "oem" ]
15351536
]
15361537
k.type.btrfs_root_is_readonly_snapshot.attribute =
15371538
## Tell kiwi to set the btrfs root filesystem snapshot read-only
15381539
## Once all data has been placed to the root filesystem snapshot
15391540
## it will be turned into read-only mode if this option is set to
1540-
## true. The option is only effective if btrfs_root_is_snapshot
1541+
## true. The option is only effective if btrfs_root_is_snapper_snapshot
15411542
## is also set to true. By default the root filesystem snapshot
15421543
## is writable
15431544
attribute btrfs_root_is_readonly_snapshot { xsd:boolean }
@@ -2354,7 +2355,7 @@ div {
23542355
k.type.dosparttable_extended_layout.attribute? &
23552356
k.type.bootprofile.attribute? &
23562357
k.type.btrfs_quota_groups.attribute? &
2357-
k.type.btrfs_root_is_snapshot.attribute? &
2358+
k.type.btrfs_root_is_snapper_snapshot.attribute? &
23582359
k.type.btrfs_root_is_subvolume.attribute? &
23592360
k.type.btrfs_set_default_volume.attribute? &
23602361
k.type.btrfs_root_is_readonly_snapshot.attribute? &

kiwi/schema/kiwi.rng

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ second the location of the XSD Schema
150150
<define name="k.image.schemaversion.attribute">
151151
<attribute name="schemaversion">
152152
<a:documentation>The allowed Schema version (fixed value)</a:documentation>
153-
<value>8.2</value>
153+
<value>8.3</value>
154154
</attribute>
155155
</define>
156156
<define name="k.image.id">
@@ -2255,15 +2255,16 @@ By default the creation of a root subvolume is set to: true</a:documentation>
22552255
<sch:param name="types" value="oem"/>
22562256
</sch:pattern>
22572257
</define>
2258-
<define name="k.type.btrfs_root_is_snapshot.attribute">
2259-
<attribute name="btrfs_root_is_snapshot">
2258+
<define name="k.type.btrfs_root_is_snapper_snapshot.attribute">
2259+
<attribute name="btrfs_root_is_snapper_snapshot">
22602260
<a:documentation>Tell kiwi to install the system into a btrfs snapshot
22612261
The snapshot layout is compatible with the snapper management
2262-
toolkit. By default no snapshots are used</a:documentation>
2262+
toolkit and follows a concept by SUSE.
2263+
By default no snapshots are used</a:documentation>
22632264
<data type="boolean"/>
22642265
</attribute>
2265-
<sch:pattern id="btrfs_root_is_snapshot" is-a="image_type">
2266-
<sch:param name="attr" value="btrfs_root_is_snapshot"/>
2266+
<sch:pattern id="btrfs_root_is_snapper_snapshot" is-a="image_type">
2267+
<sch:param name="attr" value="btrfs_root_is_snapper_snapshot"/>
22672268
<sch:param name="types" value="oem"/>
22682269
</sch:pattern>
22692270
</define>
@@ -2272,7 +2273,7 @@ toolkit. By default no snapshots are used</a:documentation>
22722273
<a:documentation>Tell kiwi to set the btrfs root filesystem snapshot read-only
22732274
Once all data has been placed to the root filesystem snapshot
22742275
it will be turned into read-only mode if this option is set to
2275-
true. The option is only effective if btrfs_root_is_snapshot
2276+
true. The option is only effective if btrfs_root_is_snapper_snapshot
22762277
is also set to true. By default the root filesystem snapshot
22772278
is writable</a:documentation>
22782279
<data type="boolean"/>
@@ -3405,7 +3406,7 @@ kiwi-ng result bundle ...</a:documentation>
34053406
<ref name="k.type.btrfs_quota_groups.attribute"/>
34063407
</optional>
34073408
<optional>
3408-
<ref name="k.type.btrfs_root_is_snapshot.attribute"/>
3409+
<ref name="k.type.btrfs_root_is_snapper_snapshot.attribute"/>
34093410
</optional>
34103411
<optional>
34113412
<ref name="k.type.btrfs_root_is_subvolume.attribute"/>

kiwi/system/profile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def _type_to_profile(self):
289289
# kiwi_fsmountoptions
290290
# kiwi_bootprofile
291291
# kiwi_vga
292-
# kiwi_btrfs_root_is_snapshot
292+
# kiwi_btrfs_root_is_snapper_snapshot
293293
# kiwi_startsector
294294
type_section = self.xml_state.build_type
295295
self.dot_profile['kiwi_type'] = \
@@ -322,8 +322,8 @@ def _type_to_profile(self):
322322
self.xml_state.get_build_type_bootloader_console()[0] or 'default',
323323
self.xml_state.get_build_type_bootloader_console()[1] or 'default'
324324
)
325-
self.dot_profile['kiwi_btrfs_root_is_snapshot'] = \
326-
type_section.get_btrfs_root_is_snapshot()
325+
self.dot_profile['kiwi_btrfs_root_is_snapper_snapshot'] = \
326+
type_section.get_btrfs_root_is_snapper_snapshot()
327327
self.dot_profile['kiwi_gpt_hybrid_mbr'] = \
328328
type_section.get_gpt_hybrid_mbr()
329329
self.dot_profile['kiwi_devicepersistency'] = \

kiwi/volume_manager/btrfs.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def post_init(self, custom_args):
6565
self.custom_args = {}
6666
if 'root_label' not in self.custom_args:
6767
self.custom_args['root_label'] = 'ROOT'
68-
if 'root_is_snapshot' not in self.custom_args:
69-
self.custom_args['root_is_snapshot'] = False
68+
if 'root_is_snapper_snapshot' not in self.custom_args:
69+
self.custom_args['root_is_snapper_snapshot'] = False
7070
if 'btrfs_default_volume_requested' not in self.custom_args:
7171
self.custom_args['btrfs_default_volume_requested'] = True
7272
if 'root_is_readonly_snapshot' not in self.custom_args:
@@ -86,11 +86,11 @@ def post_init(self, custom_args):
8686
self.root_volume_name = volume.name
8787
self.default_volume_name = self.root_volume_name
8888

89-
if self.custom_args['root_is_snapshot'] and \
89+
if self.custom_args['root_is_snapper_snapshot'] and \
9090
self.root_volume_name == '/':
91-
log.warning('root_is_snapshot requires a toplevel sub-volume')
92-
log.warning('root_is_snapshot has been disabled')
93-
self.custom_args['root_is_snapshot'] = False
91+
log.warning('root_is_snapper_snapshot requires a toplevel sub-volume')
92+
log.warning('root_is_snapper_snapshot has been disabled')
93+
self.custom_args['root_is_snapper_snapshot'] = False
9494

9595
self.subvol_mount_list = []
9696
self.toplevel_mount = None
@@ -134,7 +134,7 @@ def setup(self, name=None):
134134
Command.run(
135135
['btrfs', 'subvolume', 'create', root_volume]
136136
)
137-
if self.custom_args['root_is_snapshot']:
137+
if self.custom_args['root_is_snapper_snapshot']:
138138
snapshot_volume = self.mountpoint + \
139139
f'/{self.root_volume_name}/.snapshots'
140140
Command.run(
@@ -233,7 +233,8 @@ def create_volumes(self, filesystem_name):
233233
)
234234

235235
volume_mountpoint = toplevel
236-
root_is_snapshot = self.custom_args['root_is_snapshot']
236+
root_is_snapper_snapshot = \
237+
self.custom_args['root_is_snapper_snapshot']
237238

238239
attributes = {
239240
'parent': volume.parent or '',
@@ -244,7 +245,7 @@ def create_volumes(self, filesystem_name):
244245
).lstrip(os.sep),
245246
'subvol_name': volume.name
246247
}
247-
if root_is_snapshot:
248+
if root_is_snapper_snapshot:
248249
volume_mountpoint = self.mountpoint + \
249250
f'/{self.root_volume_name}/.snapshots/1/snapshot/'
250251
attributes = {
@@ -263,7 +264,7 @@ def create_volumes(self, filesystem_name):
263264
os.sep.join(
264265
[
265266
volume_mountpoint,
266-
self.root_volume_name if not root_is_snapshot else '',
267+
self.root_volume_name if not root_is_snapper_snapshot else '',
267268
volume.realpath
268269
]
269270
)
@@ -397,7 +398,7 @@ def get_mountpoint(self) -> str:
397398
sync_target: List[str] = [self.mountpoint]
398399
if self.root_volume_name != '/':
399400
sync_target.append(self.root_volume_name)
400-
if self.custom_args.get('root_is_snapshot'):
401+
if self.custom_args.get('root_is_snapper_snapshot'):
401402
sync_target.extend(['.snapshots', '1', 'snapshot'])
402403
return os.path.join(*sync_target)
403404

@@ -412,7 +413,7 @@ def sync_data(self, exclude=None):
412413
"""
413414
if self.toplevel_mount:
414415
sync_target = self.get_mountpoint()
415-
if self.custom_args['root_is_snapshot']:
416+
if self.custom_args['root_is_snapper_snapshot']:
416417
self._create_snapshot_info(
417418
''.join(
418419
[
@@ -426,18 +427,18 @@ def sync_data(self, exclude=None):
426427
options=Defaults.get_sync_options(), exclude=exclude
427428
)
428429
if self.custom_args['quota_groups'] and \
429-
self.custom_args['root_is_snapshot']:
430+
self.custom_args['root_is_snapper_snapshot']:
430431
self._create_snapper_quota_configuration()
431432

432433
def set_property_readonly_root(self):
433434
"""
434435
Sets the root volume to be a readonly filesystem
435436
"""
436-
root_is_snapshot = \
437-
self.custom_args['root_is_snapshot']
437+
root_is_snapper_snapshot = \
438+
self.custom_args['root_is_snapper_snapshot']
438439
root_is_readonly_snapshot = \
439440
self.custom_args['root_is_readonly_snapshot']
440-
if root_is_snapshot and root_is_readonly_snapshot:
441+
if root_is_snapper_snapshot and root_is_readonly_snapshot:
441442
sync_target = self.get_mountpoint()
442443
Command.run(
443444
['btrfs', 'property', 'set', sync_target, 'ro', 'true']

0 commit comments

Comments
 (0)