[SCM] GUI front-end for Debian Live. branch, master, updated. 08faf0d678877236b2a81da93a8c822d69ad49d1
Chris Lamb
chris at chris-lamb.co.uk
Fri Apr 4 17:23:23 UTC 2008
The following commit has been merged in the master branch:
commit 8c2968ce17dfe4afbc8d012479e7057a373ae4c2
Author: Chris Lamb <chris at chris-lamb.co.uk>
Date: Fri Apr 4 18:22:09 2008 +0100
Allow DebianLive.Config to take kwargs to be passed to lh_config
This fixes a large number of current and future problems where lh_config
is "too clever" and adjusts a setting when another setting has a specific
value.
For example, setting suite = "etch" causes the unionfs modules to be used,
whilst any other value will use aufs. This is completely correct, but means
that programs like live-magic must essentially initially configure the
config directory using lh_config with options, rather than modifying the
config file.
Signed-off-by: Chris Lamb <chris at chris-lamb.co.uk>
diff --git a/DebianLive/__init__.py b/DebianLive/__init__.py
index a631532..a026287 100644
--- a/DebianLive/__init__.py
+++ b/DebianLive/__init__.py
@@ -4,18 +4,33 @@ import os
import commands
class Config(object):
- def __init__(self, dir, spec=None):
+ def __init__(self, dir, spec=None, **kwargs):
self.dir = dir
if spec is None:
# Load default field specification
from spec import spec
+ from spec import constructor_args
+ for option in kwargs:
+ option = option.replace('_', '-')
+ if option not in constructor_args:
+ raise TypeError, 'Unexpected keyword argument "%s"' % option
+
# Create skeleton lh_config dir, if it does not already exist
- if not os.path.exists(os.path.join(self.dir, 'config')):
+ if os.path.exists(os.path.join(self.dir, 'config')):
+ if len(kwargs) > 0:
+ raise TypeError, \
+ 'Passing keyword arguments when config/ dir already exists'
+ else:
if not os.path.exists(self.dir):
os.makedirs(self.dir)
- cmd = 'cd "%s"; lh_config' % os.path.abspath(self.dir)
+
+ options = ["--%s='%s'" % (k.replace('_', '-'), v)
+ for k, v in kwargs.iteritems()]
+ cmd = 'cd "%s"; lh_config %s' % (os.path.abspath(self.dir),
+ ' '.join(options))
+
result, out = commands.getstatusoutput(cmd)
if result != 0:
raise IOError, out
diff --git a/DebianLive/spec.py b/DebianLive/spec.py
index 7139963..9af4f57 100644
--- a/DebianLive/spec.py
+++ b/DebianLive/spec.py
@@ -114,3 +114,26 @@ spec = {
'LH_SOURCE_IMAGES': list,
}),
}
+
+constructor_args = ('apt', 'apt-ftp-proxy', 'apt-http-proxy', 'apt-pdiffs',
+ 'apt-options', 'aptitude-options', 'apt-pipeline', 'apt-recommends',
+ 'apt-secure', 'architecture', 'binary-images', 'binary-filesystem',
+ 'binary-indices', 'bootappend-install', 'bootappend-live', 'bootloader',
+ 'bootstrap', 'bootstrap-config', 'bootstrap-flavour', 'bootstrap-keyring',
+ 'breakpoints', 'cache', 'cache-indices', 'cache-packages', 'cache-stages',
+ 'checksums', 'chroot-build', 'chroot-filesystem', 'conffile', 'debconf-frontend',
+ 'debconf-nowarnings', 'debconf-priority', 'debian-installer',
+ 'debian-installer-daily', 'distribution', 'encryption', 'fdisk', 'genisoimage',
+ 'grub-splash', 'hooks', 'hostname', 'includes', 'initramfs', 'interactive',
+ 'iso-application', 'iso-preparer', 'iso-publisher', 'iso-volume',
+ 'jffs2-eraseblock', 'keyring-packages', 'language', 'linux-flavours',
+ 'linux-packages', 'losetup', 'memtest', 'mirror', 'mirror-binary-security',
+ 'mirror-binary', 'mirror-bootstrap-security', 'mirror-bootstrap',
+ 'mirror-chroot', 'mirror-chroot-security', 'mode',
+ 'net-root-filesystem', 'net-root-mountoptions', 'net-root-path',
+ 'net-root-server', 'net-cow-filesystem', 'net-cow-mountoptions',
+ 'net-cow-path', 'net-cow-server', 'net-tarball', 'packages-lists', 'packages',
+ 'root-command', 'use-fakeroot', 'sections', 'security', 'source',
+ 'source-images', 'symlinks', 'syslinux-splash', 'syslinux-timeout',
+ 'syslinux-menu', 'sysvinit', 'tasksel', 'tasks', 'templates',
+ 'union-filesystem', 'exposed-root', 'username')
diff --git a/LiveMagic/controllers/wizard.py b/LiveMagic/controllers/wizard.py
index c579040..d28bdc6 100644
--- a/LiveMagic/controllers/wizard.py
+++ b/LiveMagic/controllers/wizard.py
@@ -7,21 +7,15 @@ class WizardController(object):
def on_wizard_apply(self, _):
- # Fill in data from model
- data = self.view.get_wizard_completed_details()
-
build_dir = utils.get_build_dir()
- self.model = Config(build_dir)
- self.model.binary['LH_BINARY_IMAGES'] = [data['media']]
- self.model.bootstrap['LH_MIRROR_BOOTSTRAP'] = data['mirror']
- self.model.chroot['LH_PACKAGES_LISTS'] = data['desktop']
- self.model.bootstrap['LH_ARCHITECTURE'] = data['arch']
+ data = self.view.get_wizard_completed_details()
# Use cdebootstrap if available
if os.path.exists('/usr/bin/cdebootstrap'):
- self.model.common['LH_BOOTSTRAP'] = 'cdebootstrap'
+ data['bootstrap'] = 'cdebootstrap'
+ self.model = Config(build_dir, **data)
self.model.save()
self.view.do_dim_wizard()
diff --git a/LiveMagic/views/wizard.py b/LiveMagic/views/wizard.py
index 1f4080c..bad7158 100644
--- a/LiveMagic/views/wizard.py
+++ b/LiveMagic/views/wizard.py
@@ -66,9 +66,9 @@ class WizardView(object):
return button.get_name().split('_')[2]
return {
- 'desktop' : get_active('radio_desktop_gnome'),
- 'media' : get_active('radio_media_usb'),
- 'arch' : get_active('radio_architecture_i386'),
+ 'packages_lists' : get_active('radio_desktop_gnome'),
+ 'binary_images' : get_active('radio_media_usb'),
+ 'architecture' : get_active('radio_architecture_i386'),
'mirror' : self['combobox_mirror'].get_active_text()
}
diff --git a/tests/test_config_constructor.py b/tests/test_config_constructor.py
new file mode 100755
index 0000000..1739c17
--- /dev/null
+++ b/tests/test_config_constructor.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+import unittest
+import os
+
+import sys
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from DebianLive import Config
+
+class TestConfigConstructor(unittest.TestCase):
+ def setUp(self):
+ import tempfile
+ self.dir = tempfile.mkdtemp()
+
+ def tearDown(self):
+ import shutil
+ shutil.rmtree(self.dir)
+
+class TestSimple(TestConfigConstructor):
+ def testArch386(self):
+ lh = Config(self.dir, architecture='i386')
+ self.assertEqual(lh.bootstrap['LH_ARCHITECTURE'], 'i386')
+
+ def testArchAmd64(self):
+ lh = Config(self.dir, architecture='amd64')
+ self.assertEqual(lh.bootstrap['LH_ARCHITECTURE'], 'amd64')
+
+ def testNoOptions(self):
+ lh = Config(self.dir)
+
+ def testInvalid(self):
+ self.assertRaises(TypeError, Config, self.dir, this_config_never_exists='value')
+
+class TestOther(TestConfigConstructor):
+ def testArchChangesKernelFlavour(self):
+ lh_i386 = Config(self.dir, architecture='i386')
+ self.setUp()
+ lh_amd64 = Config(self.dir, architecture='amd64')
+ self.assertNotEqual(lh_i386.chroot['LH_LINUX_FLAVOURS'],
+ lh_amd64.chroot['LH_LINUX_FLAVOURS'])
+
+ def testHyphenatedOption(self):
+ lh = Config(self.dir, packages_lists='my-package-list')
+ lh.save()
+ self.assertEqual(lh.chroot['LH_PACKAGES_LISTS'], ['my-package-list'])
+
+ def testSpaceInValue(self):
+ lh = Config(self.dir, packages_lists="hello there")
+ self.assertEqual(lh.chroot['LH_PACKAGES_LISTS'], ['hello', 'there'])
+
+if __name__ == "__main__":
+ unittest.main()
--
GUI front-end for Debian Live.
More information about the debian-live-changes
mailing list