[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#861070: Tweaks for debian live builds



Package: live-wrapper
Version: 0.6
Severity: normal
Tags: patch

Hey folks,

I've got things working well with live-wrapper and I'm making live
images on pettersson again. Yay! Here's a patch with the changes I've
added. Sorry, it's all rolled into one at the moment...

* Add command-line config for the apt-mirror (the mirror to be
  configured inside the image), and change the default to use
  deb.debian.org

* Add command-line config for the location of the customise script (so
  I can tweak this more sensibly at runtime)

* Add explicit support for firmware packages. These are treated like
  "extra" packages during image creation, but are also copied into
  /firmware in the cdroot. That's where d-i will look for them on
  firmware-included images.

* In the customise script, also generate two extra output files: a
  list of all the packages installed (contents) and a list of all the
  source packages to match those. I use those in our automated build
  setup - we publish the contents file and generate source tarballs
  using the source packages list.

--- ./usr/lib/python2.7/dist-packages/lwr/apt_udeb.py	2017-01-23 00:56:18.000000000 +0000
+++ /./usr/lib/python2.7/dist-packages/lwr/apt_udeb.py	2017-04-23 17:12:01.885823000 +0100
@@ -195,6 +195,6 @@
     apt_handler.mirror = mirror
     apt_handler.architecture = architecture
     apt_handler.codename = codename
-    apt_handler.components = ['main']
+    apt_handler.components = ['main', 'contrib', 'non-free']
     apt_handler.prepare_apt()
     return apt_handler
--- ./usr/lib/python2.7/dist-packages/lwr/vm.py	2017-01-07 23:44:10.000000000 +0000
+++ /./usr/lib/python2.7/dist-packages/lwr/vm.py	2017-04-24 11:39:58.337823000 +0100
@@ -30,7 +30,7 @@
 
 class VMDebootstrap(object):
 
-    def __init__(self, distribution, architecture, mirror, cdroot):
+    def __init__(self, distribution, architecture, mirror, cdroot, customise, apt_mirror):
         self.cdroot = cdroot
         self.args = ["vmdebootstrap",
                      "--sudo", "--lock-root-password",
@@ -42,18 +42,13 @@
                      "--log-level", "debug"]
         self.args.extend(["--distribution", distribution])
         self.args.extend(["--mirror", mirror])
-        # FIXME: apt-mirror is for what the booted image will use
-        # this needs to be accessible over http://, not just file://
-        # FIXME: this should be declared in the command line args for lwr
-        self.args.extend(["--apt-mirror", 'http://ftp.debian.org/debian/'])
+        self.args.extend(["--apt-mirror", apt_mirror])
 
         # FIXME: Logging should happen here
-        if os.path.exists(os.path.join(".", "hooks", "customise.sh")):
-            self.args.extend(["--customize", "hooks/customise.sh"])
-        elif os.path.exists("/usr/share/live-wrapper/customise.sh"):
-            self.args.extend(["--customize", "/usr/share/live-wrapper/customise.sh"])
+        if os.path.exists(customise):
+            self.args.extend(["--customize", customise])
         else:
-            raise cliapp.AppException("Could not locate customise.sh")
+            raise cliapp.AppException("Could not read customise script at %s" % customise)
 
     def run(self):
         logging.debug("vmdebootstrap command: %s" % (' '.join(self.args),))
--- ./usr/lib/python2.7/dist-packages/lwr/run.py	2017-01-23 00:29:35.000000000 +0000
+++ /./usr/lib/python2.7/dist-packages/lwr/run.py	2017-04-24 11:39:07.605823000 +0100
@@ -27,7 +27,7 @@
 from lwr.disk import get_default_description
 from lwr.grub import install_grub
 from lwr.xorriso import Xorriso
-from lwr.apt_udeb import AptUdebDownloader
+from lwr.apt_udeb import AptUdebDownloader, get_apt_handler
 from lwr.utils import cdrom_image_url, KERNEL, RAMDISK
 from lwr.cdroot import CDRoot
 
@@ -62,6 +62,11 @@
             group='Base Settings',
             default='http://ftp.debian.org/debian/')
         self.settings.string(
+            ['apt-mirror'], 'Mirror to configure in the built image (default: %default)',
+            metavar='APT-MIRROR',
+            group='Base Settings',
+            default='http://deb.debian.org/debian/')
+        self.settings.string(
 	    ['description'], 'Description for the image to be created. A '
 			     'description will be automatically generated based '
 			     'on the distribution chosen if none is specified. '
@@ -77,6 +82,10 @@
             ['e', 'extra'], 'Extra packages to install',
             metavar='"PKG1 PKG2 ..."',
             group='Packages')
+        self.settings.string(
+            ['f', 'firmware'], 'Firmware packages to install',
+            metavar='"PKG1 PKG2 ..."',
+            group='Packages')
         self.settings.boolean(
             ['isolinux'], 'Add isolinux bootloader to the image '
             '(default: %default)', default=True, group="Bootloaders")
@@ -93,6 +102,11 @@
         self.settings.boolean(
             ['di-daily'], 'Use the daily Debian Installer builds not releases',
             default=False, group="Debian Installer")
+        self.settings.string(
+            ['customise'], 'Customisation script to run with vmdebootstrap (default: %default)',
+            metavar='CUSTOMISE',
+            group='Base Settings',
+            default='/usr/share/live-wrapper/customise.sh')
         # Logging overrides
         for s in ['log']:
             self.settings._canonical_names.remove(s)
@@ -195,6 +209,7 @@
         os.environ['LWR_DISTRIBUTION'] = self.settings['distribution']
         os.environ['LWR_TASK_PACKAGES'] = self.settings['tasks']
         os.environ['LWR_EXTRA_PACKAGES'] = self.settings['extra']
+        os.environ['LWR_FIRMWARE_PACKAGES'] = self.settings['firmware']
 
         for envvar in os.environ.keys():
             if envvar.startswith('LWR_'):
@@ -208,7 +223,10 @@
             logging.info("Running vmdebootstrap...")
             vm = VMDebootstrap(self.settings['distribution'],
                                self.settings['architecture'],
-                               self.settings['mirror'], self.cdroot.path)
+                               self.settings['mirror'],
+                               self.cdroot.path,
+                               self.settings['customise'],
+                               self.settings['apt-mirror'])
             vm.run()
 
         # Initialise menu
@@ -250,6 +268,21 @@
             print("... completed udeb downloads")
             logging.info("... completed udeb downloads")
 
+        # Download the firmware debs if desired
+        if len(self.settings['firmware']) > 0:
+            logging.info("Downloading firmware debs...")
+
+            # FIXME: may need a change to the download location
+            fw_root = self.cdroot['firmware'].path
+            handler = get_apt_handler(fw_root,
+                                      self.settings['mirror'],
+                                      self.settings['distribution'],
+                                      self.settings['architecture'])
+            for pkg in self.settings['firmware'].split(' '):
+                filename = handler.download_package(pkg, fw_root)
+            handler.clean_up_apt()
+            logging.info("... firmware deb downloads")
+
         # Generate boot config
         bootconfig = BootloaderConfig(self.cdroot.path)
 
--- ./usr/share/live-wrapper/customise.sh	2017-01-07 23:44:10.000000000 +0000
+++ /./usr/share/live-wrapper/customise.sh	2017-04-24 11:09:32.373823000 +0100
@@ -17,11 +17,32 @@
 
 prepare_apt_source "${LWR_MIRROR}" "${LWR_DISTRIBUTION}"
 
-chroot ${rootdir} apt-get -y install initramfs-tools live-boot live-config ${LWR_TASK_PACKAGES} ${LWR_EXTRA_PACKAGES} task-laptop task-english libnss-myhostname
+for PKG in ${FIRMWARE_PKGS}; do
+    echo "$PKG        $PKG/license/accepted       boolean true" | \
+	chroot ${rootdir} debconf-set-selections
+done
+
+chroot ${rootdir} apt-get -q -y install initramfs-tools live-boot live-config ${LWR_TASK_PACKAGES} ${LWR_EXTRA_PACKAGES} ${LWR_FIRMWARE_PACKAGES} task-laptop task-english libnss-myhostname >> vmdebootstrap.log 2>&1
 
 # Temporary fix for #843983
 chroot ${rootdir} chmod 755 /
 
+# Find all the packages included
+export COLUMNS=500
+chroot ${rootdir} dpkg -l | awk '/^ii/ {printf "%s %s\n",$2,$3}' > packages.list
+
+# Grab source URLs for all the packages
+cat > ${rootdir}//list-sources <<EOF
+#!/bin/sh
+export COLUMNS=500
+for PKG in \$(dpkg -l | awk '/^ii/ {printf "%s ",\$2}'); do
+    apt-get source -qq --print-uris \$PKG
+done
+EOF
+chmod +x ${rootdir}/list-sources
+chroot ${rootdir} /list-sources > sources.list
+rm -f ${rootdir}/list-sources
+
 echo "blacklist bochs-drm" > $rootdir/etc/modprobe.d/qemu-blacklist.conf
 
 replace_apt_source


-- System Information:
Debian Release: 8.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-0.bpo.1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)


Reply to: