tags 742267 patch

Two patches as suggested by Petter (which I have a preference too):

vmdebootstrap-vmlinuz-nonversioned.patch - for non-versioned /vmlinux  boot

vmdebootstrap-etc-extlinux.patch for placing etclinux.conf in /etc
directory and to put a symlink there (if the filesystem supports this)

The alternative to the vmlinuz-nonversioned patch is a
/etc/kernel/postinst.d/update-extlinux hook like attached to update the
extlinux.conf. The name has to be further alphabetical than initramfs
because the script checks it was created before updateing extlinux.conf
--- /usr/sbin/vmdebootstrap.orig	2014-08-08 11:26:26.612391333 +1000
+++ /usr/sbin/vmdebootstrap	2014-08-08 11:31:56.596325797 +1000
@@ -410,18 +410,6 @@
     def install_extlinux(self, rootdev, rootdir):
         self.message('Installing extlinux')
 
-        def find(pattern):
-            dirname = os.path.join(rootdir, 'boot')
-            basenames = os.listdir(dirname)
-            logging.debug('find: %s' % basenames)
-            for basename in basenames:
-                if re.search(pattern, basename):
-                    return os.path.join('boot', basename)
-            raise cliapp.AppException('Cannot find match: %s' % pattern)
-
-        kernel_image = find('vmlinuz-.*')
-        initrd_image = find('initrd.img-.*')
-
         out = self.runcmd(['blkid', '-c', '/dev/null', '-o', 'value',
                            '-s', 'UUID', rootdev])
         uuid = out.splitlines()[0].strip()
@@ -438,8 +426,8 @@
 append initrd=%(initrd)s root=UUID=%(uuid)s ro %(kserial)s
 %(extserial)s
 ''' % {
-    'kernel': kernel_image,
-    'initrd': initrd_image,
+    'kernel': 'vmlinuz',
+    'initrd': 'initrd',
     'uuid': uuid,
     'kserial': 
         'console=ttyS0,115200' if self.settings['serial-console'] else '',
--- /tmp/vmdebootstrap	2014-08-08 11:50:59.126985327 +1000
+++ /usr/sbin/vmdebootstrap	2014-08-08 12:05:27.218098768 +1000
@@ -415,6 +415,14 @@
         uuid = out.splitlines()[0].strip()
 
         conf = os.path.join(rootdir, 'extlinux.conf')
+        confreal = os.path.join(rootdir, 'etc', 'extlinux.conf')
+        try:
+            conflink = os.join('etc', 'extlinux.conf')
+            os.symlink(conflink, conf)
+            conf =  confreal
+        except OSError, e:
+            logging.debug('symlink %s -> %s unsupported %s' % (conflink, conf, e))
+            pass
         logging.debug('configure extlinux %s' % conf)
         f = open(conf, 'w')
         f.write('''
#!/bin/sh
# Needs to run after initramfs-tools as we want to make sure that
# exists before changing extlinux.conf

version=$1
kernel=$2

if [ -f /etc/extlinux.conf ]
then
    extlinux=/etc/extlinux.conf
elif [ -f /extlinux.conf ]
then
    extlinux=/extlinux.conf
else
    exit
fi

if [ -f "${kernel}" ]
then
    sed -i -e "s|^kernel .*|kernel ${kernel}|" "${extlinux}"
fi

bootpath=${kernel%/*}
initramfs=${bootpath}/initrd.img-${version}

if [ -f "${initramfs}" ]
then
    sed -i -e "s|^\\(append .*\\)initrd=[^ 
]*\\(.*\\)|\\1initrd=${initramfs}\\2|"  "${extlinux}"
fi

Reply via email to