diff --git a/image_creator/os_type/__init__.py b/image_creator/os_type/__init__.py index b19d573dbc815313e3621c599d68e81a202bfa90..052a3e35cd4d07938891bc6ed23e545d2ada65cb 100644 --- a/image_creator/os_type/__init__.py +++ b/image_creator/os_type/__init__.py @@ -120,6 +120,7 @@ class OSBase(object): wrapper = textwrap.TextWrapper() wrapper.subsequent_indent = '\t' wrapper.initial_indent = '\t' + wrapper.width = 72 output("Enabled system preperation operations:") if len(enabled) == 0: @@ -127,7 +128,7 @@ class OSBase(object): else: for sysprep in enabled: name = sysprep.__name__.replace('_', '-') - descr = wrapper.fill(sysprep.__doc__) + descr = wrapper.fill(textwrap.dedent(sysprep.__doc__)) output(' %s:\n%s\n' % (name, descr)) output("Disabled system preperation operations:") @@ -136,7 +137,7 @@ class OSBase(object): else: for sysprep in disabled: name = sysprep.__name__.replace('_', '-') - descr = wrapper.fill(sysprep.__doc__) + descr = wrapper.fill(textwrap.dedent(sysprep.__doc__)) output(' %s:\n%s\n' % (name, descr)) @add_prefix diff --git a/image_creator/os_type/linux.py b/image_creator/os_type/linux.py index de82e7d0ad8cd2c20d1b820a4b24f218175713b2..e128396e5bbee06d1d3c6c4df098ba23091f8104 100644 --- a/image_creator/os_type/linux.py +++ b/image_creator/os_type/linux.py @@ -125,6 +125,29 @@ class Linux(Unix): if self.g.is_file(rule_file): self.g.rm(rule_file) + @sysprep() + def remove_swap_entry(self, print_header=True): + """Remove swap entry from /etc/fstab. If swap is the last partition + then the partition will be removed when shrinking is performed. If the + swap partition is not the last partition in the disk or if you are not + going to shrink the image you should probably disable this. + """ + + if print_header: + output('Removing swap entry from fstab') + + new_fstab = "" + fstab = self.g.cat('/etc/fstab') + for line in fstab.splitlines(): + + entry = line.split('#')[0].strip().split() + if len(entry) == 6 and entry[2] == 'swap': + continue + + new_fstab += "%s\n" % line + + self.g.write('/etc/fstab', new_fstab) + @sysprep() def persistent_devs(self, print_header=True): """Scan fstab & grub configuration files and replace all non-persistent