Commit 5a1efdbb authored by Nikos Skalkotos's avatar Nikos Skalkotos

Add support for syslinux

Extend the use-persistent-block-device-names sysprep to include support
for the syslinux configuration file (/boot/syslinux.cfg).

This resolves #40
parent 7f893790
# -*- coding: utf-8 -*-
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2015 GRNET S.A.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -19,9 +19,11 @@
from image_creator.os_type.unix import Unix, sysprep
import os
import re
import time
import pkg_resources
import tempfile
'CINNAMON': 'cinnamon',
......@@ -233,9 +235,12 @@ class Linux(Unix):
# convert all devices in fstab to persistent
persistent_root = self._persistent_fstab()
# convert all devices in grub1 to persistent
# convert root device in grub1 to persistent
# convert root device in syslinux to persistent
@sysprep('Disabling IPv6 privacy extensions',
display='Disable IPv6 privacy enxtensions')
def _disable_ipv6_privacy_extensions(self):
......@@ -294,6 +299,34 @@ class Linux(Unix):
def _persistent_syslinux(self, new_root):
"""Replace non-persistent root device name occurrences with persistent
ones in the syslinux configuration files.
config = '/boot/syslinux/syslinux.cfg'
append_regexp = re.compile(
r'\s*APPEND\s+.*\broot=/dev/[hsv]d[a-z][1-9]*\b', re.IGNORECASE)
if not self.image.g.is_file(config):
# There is no augeas lense for syslinux :-(
tmpfd, tmp = tempfile.mkstemp()
for line in
if append_regexp.match(line):
line = re.sub(r'\broot=/dev/[hsv]d[a-z][1-9]*\b',
'root=%s' % new_root, line)
os.write(tmpfd, line + '\n')
tmpfd = None
self.image.g.upload(tmp, config)
if tmpfd is not None:
def _persistent_fstab(self):
"""Replaces non-persistent device name occurrences in /etc/fstab with
persistent ones.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment