From e433aebf7d77b070264bd10b4e66643146a16933 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Tue, 18 Jun 2019 10:02:36 -0700 Subject: [PATCH] Add DIB_UBUNTU_KERNEL to ubuntu-minimal This patch adds a new environment variable to the ubuntu-minimal element called DIB_UBUNTU_KERNEL that allows you to specify the kernel meta package that will be using to install the kernel inside the image. It supports "linux-image-generic" (The default), "linux-image-kvm", and "linux-image-virtual". This allows building images that are smaller in size (~200MB smaller qcow2) that have only the kernel modules necessary for virtual machines. Change-Id: I8ce65e1d357d15e8ed8995ad1dcaea02bbd1986f --- .../elements/ubuntu-minimal/README.rst | 13 +++++++++++++ .../environment.d/11-ubuntu-kernel.bash | 15 +++++++++++++++ .../elements/ubuntu-minimal/package-installs.yaml | 7 +++++++ .../Add-DIB-UBUNTU-KERNEL-5f75a809f3ce9bab.yaml | 7 +++++++ 4 files changed, 42 insertions(+) create mode 100644 diskimage_builder/elements/ubuntu-minimal/environment.d/11-ubuntu-kernel.bash create mode 100644 releasenotes/notes/Add-DIB-UBUNTU-KERNEL-5f75a809f3ce9bab.yaml diff --git a/diskimage_builder/elements/ubuntu-minimal/README.rst b/diskimage_builder/elements/ubuntu-minimal/README.rst index 44e70127..df764b87 100644 --- a/diskimage_builder/elements/ubuntu-minimal/README.rst +++ b/diskimage_builder/elements/ubuntu-minimal/README.rst @@ -14,4 +14,17 @@ be created, the variable ``DIB_RELEASE`` can be set appropriately. Note that this element installs ``systemd-sysv`` as the init system for 18.04+. +Environment Variables +--------------------- + +DIB_UBUNTU_KERNEL: + :Required: No + :Default: ``linux-image-generic`` + :Description: Specifies the kernel meta package to install in the image. + :Example: ``DIB_UBUNTU_KERNEL=linux-image-kvm`` + :Options: ``linux-image-generic``, ``linux-image-kvm``, + ``linux-image-virtual`` + :Notes: The element must know about the package, otherwise it will select + the default. + .. element_deps:: diff --git a/diskimage_builder/elements/ubuntu-minimal/environment.d/11-ubuntu-kernel.bash b/diskimage_builder/elements/ubuntu-minimal/environment.d/11-ubuntu-kernel.bash new file mode 100644 index 00000000..35d4a64a --- /dev/null +++ b/diskimage_builder/elements/ubuntu-minimal/environment.d/11-ubuntu-kernel.bash @@ -0,0 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. + +export DIB_UBUNTU_KERNEL=${DIB_UBUNTU_KERNEL:-"linux-image-generic"} diff --git a/diskimage_builder/elements/ubuntu-minimal/package-installs.yaml b/diskimage_builder/elements/ubuntu-minimal/package-installs.yaml index d73a1fe3..e6efe9f2 100644 --- a/diskimage_builder/elements/ubuntu-minimal/package-installs.yaml +++ b/diskimage_builder/elements/ubuntu-minimal/package-installs.yaml @@ -1,5 +1,12 @@ linux-image-generic: not-arch: arm64 + when: DIB_UBUNTU_KERNEL = linux-image-generic +linux-image-kvm: + not-arch: arm64 + when: DIB_UBUNTU_KERNEL = linux-image-kvm +linux-image-virtual: + not-arch: arm64 + when: DIB_UBUNTU_KERNEL = linux-image-virtual # TODO(ianw): this is Xenial specific, for now. This kernel works # much better, however, including better support for cdrom's for # config-drive. We'll need to filter this further for future diff --git a/releasenotes/notes/Add-DIB-UBUNTU-KERNEL-5f75a809f3ce9bab.yaml b/releasenotes/notes/Add-DIB-UBUNTU-KERNEL-5f75a809f3ce9bab.yaml new file mode 100644 index 00000000..20401ab7 --- /dev/null +++ b/releasenotes/notes/Add-DIB-UBUNTU-KERNEL-5f75a809f3ce9bab.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Added an environment variable, DIB_UBUNTU_KERNEL, that allows you to + specify the kernel meta package to install in the image. + It currently supports "linux-image-generic" (The default), + "linux-image-kvm", and "linux-image-virtual".