On Sat, 27 Jun 2015 23:13:27 +0300
Lars Wirzenius <l...@liw.fi> wrote:

> On Mon, May 25, 2015 at 07:44:40AM -0400, James Valleroy wrote:
> > linux-image-486 isn't available in sid. It appears to have been
> > replaced with linux-image-586.
> > 
> > The attached patch will change the kernel_arch to 586 for i386
> > builds. After this change, i386 image builds are successful.
> 
> This solves the problem if you're targeting unstable (or anything
> after jessie), but breaks it for wheezy. As I need to support wheezy
> for my own stuff, I offer the attached patch, which also adds a
> --kernel-package option to override frail logic in the future.
> 
> Neil, also available as liw/kernel-package-name in git.

I've thought about using distro-info for this kind of check before. To
avoid the ugliness to which the patch itself refers, something like the
attached could work but it's just an uncommitted draft to show the
flow. Essentially, distro-info replaces codenames (like wheezy) and
the logic which surround them, with dates - vmdebootstrap looks up the
support based on when the relevant support change was released as
stable or became oldstable. I'll also incorporate the kernel-arch
setting from Lars' branch.

This change would introduce a dependency on python-distro-info and would
possibly preclude the use of the version of python-distro-info on
oldstable from building a codename of testing which had not been
announced when oldstable was released (as stable). This may be a
problem, it might not - more likely affecting building the development
Ubuntu suite on current or old LTS, depending on how python-distro-info
gets updated. There's always the option to use a backport of
python-distro-info in such situations - vmdebootstrap previously had to
rely on debootstrap falling over in a heap to tell whether the
self.settings['distribution'] was a valid string.

So the final change will have some notes in the manpage as well as
proper line formatting and testing (possibly tomorrow).

-- 


Neil Williams
=============
http://www.linux.codehelp.co.uk/

diff --git a/vmdebootstrap b/vmdebootstrap
index 49c21c8..2ac611e 100755
--- a/vmdebootstrap
+++ b/vmdebootstrap
@@ -22,9 +22,11 @@ import logging
 import os
 import re
 import shutil
+import datetime
 import subprocess
 import tempfile
 import time
+from distro_info import DebianDistroInfo
 
 
 __version__ = '0.7'
@@ -38,6 +40,8 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
         super(VmDebootstrap, self).__init__(progname, version, description, epilog)
         self.remove_dirs = []
         self.mount_points = []
+        self.debian_info = DebianDistroInfo()
+        self.ubuntu_info = UbuntuDistroInfo()
 
     def add_settings(self):
         default_arch = subprocess.check_output(
@@ -184,7 +188,9 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
         if self.settings['image'] and not self.settings['size']:
             raise cliapp.AppException(
                 'If disk image is specified, you must give image size.')
-
+        if not self.debian_info.valid(self.settings['distribution']) and not self.ubuntu_info.valid(self.settings['distribution']):
+            raise cliapp.AppException(
+                '%s is not a valid Debian or Ubuntu suite or codename.' % self.settings['distribution'])
         rootdir = None
         try:
             rootdev = None
@@ -410,6 +416,20 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
         self.message('Creating filesystem %s' % fstype)
         self.runcmd(['mkfs', '-t', fstype, device])
 
+    def suite_to_codename(distro):
+        suite = self.distro_info.codename(distro, datetime.date.today())
+        if not suite:
+            return distro
+        return suite
+
+    def was_oldstable(limit):
+        suite = self.suite_to_codename(self.settings['distribution'])
+        return suite == self.distro_info.old(limit)
+
+    def was_stable(limit):
+        suite = self.suite_to_codename(self.settings['distribution'])
+        return suite == self.distro_info.stable(limit)
+
     def debootstrap(self, rootdir):
         msg = "(%s)" % self.settings['variant'] if self.settings['variant'] else ''
         self.message('Debootstrapping %s %s' % (self.settings['distribution'], msg))
@@ -421,10 +441,14 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
 
         if self.settings['grub']:
             include.append('grub-pc')
-
+        
         if not self.settings['no-kernel']:
             if self.settings['arch'] == 'i386':
-                kernel_arch = '486'
+                # wheezy (which became oldstable on 04/25/2015) used '486'
+                if self.was_oldstable(datetime.date(2015, 4, 26)):
+                    kernel_arch = '486'
+                else:
+                    kernel_arch = '586'
             elif self.settings['arch'] == 'armhf':
                 kernel_arch = 'armmp'
             else:

Attachment: pgpJ6_MbRMpMw.pgp
Description: OpenPGP digital signature

Reply via email to