@@ -130,12 +130,9 @@ def _get_mount_str(self, mount: dict, pad=False, pad_size=44) -> str:
130130 return out_str
131131
132132
133- def _to_mount_cmd (self , mount : dict , check_mount = False ) -> str :
133+ def _to_mount_cmd (self , mount : dict ) -> str :
134134 """ Prints the object as a mount command. """
135- out = []
136-
137- if check_mount :
138- out .append (f"if ! grep -qs { mount ['destination' ]} /proc/mounts; then" )
135+ out = [f"if ! grep -qs { mount ['destination' ]} /proc/mounts; then" ]
139136
140137 mount_command = f"mount { _get_mount_str (self , mount )} { mount ['destination' ]} "
141138 if options := mount .get ('options' ):
@@ -145,12 +142,10 @@ def _to_mount_cmd(self, mount: dict, check_mount=False) -> str:
145142
146143 mount_command += f" || _mount_fail 'failed to mount: { mount ['destination' ]} '"
147144
148- if check_mount :
149- out .append (f" { mount_command } " )
150- out += ['else' , f" ewarn 'Mount already exists, skipping: { mount ['destination' ]} '" ]
151- out .append ('fi' )
152- else :
153- out .append (mount_command )
145+ out += [f" { mount_command } " ,
146+ 'else' ,
147+ f" ewarn 'Mount already exists, skipping: { mount ['destination' ]} '" ,
148+ 'fi' ]
154149
155150 return out
156151
@@ -383,7 +378,7 @@ def autodetect_root(self) -> None:
383378
384379def mount_base (self ) -> list [str ]:
385380 """ Generates mount commands for the base mounts. """
386- out = [mount for mount in self ['mounts' ].values () if mount .get ('base_mount' )]
381+ out = [_to_mount_cmd ( self , mount ) for mount in self ['mounts' ].values () if mount .get ('base_mount' )]
387382 out += ['mkdir -p /run/vars' ,
388383 f'einfo "Mounting base mounts, version: { __version__ } "' ]
389384 return out
@@ -397,7 +392,7 @@ def mount_late(self) -> list[str]:
397392 for mount in self ['late_mounts' ].values ():
398393 if not str (mount ['destination' ]).startswith (target_dir ):
399394 mount ['destination' ] = Path (target_dir , str (mount ['destination' ]).removeprefix ('/' ))
400- out += _to_mount_cmd (self , mount , check_mount = True )
395+ out += _to_mount_cmd (self , mount )
401396 return out
402397
403398
0 commit comments