diff --git a/README.md b/README.md index 5cd1de76e..577b99194 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,17 @@ part of the process you need to customise: alternative distribution support is added, or customisations such as building on an existing image. If no element configures a root, the ubuntu element will be automatically invoked to obtain an Ubuntu image. - Runs outside the chroot on the host environment, so should cleanup after - itself using the root-finished.d hook. - NB: Only one element can use this at a time. + Runs outside the chroot on the host environment. + + Only one element can use this at a time unless particular care is taken not + to blindly overwrite but instead to adapt the context extracted by other + elements. + + * inputs: $ARCH=i386|amd64 $TARGET\_ROOT=/path/to/target/workarea + +* cleanup.d: Perform cleanups of the root filesystem content. For instance, + temporary settings to use the image build environment HTTP proxy are removed + here in the dpkg element. Runs outside the chroot on the host environment. * inputs: $ARCH=i386|amd64 $TARGET\_ROOT=/path/to/target/workarea diff --git a/bin/disk-image-create b/bin/disk-image-create index 3a3a5441b..dbafb1518 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -109,9 +109,11 @@ mount_tmp_image ${IMAGE_BLOCK_DEVICE} create_base run_d extra-data -do_pre_install +# Run pre-install scripts. These do things that prepare the chroot for package installs +run_d_in_target pre-install do_extra_package_install -do_install +# Call install scripts to pull in the software users want. +run_d_in_target install prepare_first_boot finalise_base unmount_image diff --git a/elements/base/pre-install.d/02-baseline-tools b/elements/base/pre-install.d/02-baseline-tools index 403befd2f..401d6042a 100755 --- a/elements/base/pre-install.d/02-baseline-tools +++ b/elements/base/pre-install.d/02-baseline-tools @@ -3,6 +3,14 @@ set -e -apt-get -y update -install-packages python-software-properties -add-apt-repository -y ppa:tripleo/demo +DISTRO=`lsb_release -si` + +case $DISTRO in + 'Ubuntu'|'Debian') + # Note: add-apt-repository would be nice for RPM platforms too - so when we + # need something like it, create a wrapper in dpkg/bin and fedora/bin. + apt-get -y update + install-packages python-software-properties + add-apt-repository -y ppa:tripleo/demo + ;; +esac diff --git a/elements/dpkg/README.md b/elements/dpkg/README.md new file mode 100644 index 000000000..c4e725914 --- /dev/null +++ b/elements/dpkg/README.md @@ -0,0 +1,8 @@ +Provide dpkg specific image building glue. + +The ubuntu element needs customisations at the start and end of the image build +process that do not apply to RPM distributions, such as using the host machine +HTTP proxy when installing packages. These customisations live here, where they +can be used by any dpkg based element. + +The dpkg specific version of install-packages is also kept here. diff --git a/elements/base/bin/install-packages b/elements/dpkg/bin/install-packages similarity index 100% rename from elements/base/bin/install-packages rename to elements/dpkg/bin/install-packages diff --git a/elements/dpkg/cleanup.d/40-unblock-daemons b/elements/dpkg/cleanup.d/40-unblock-daemons new file mode 100755 index 000000000..a3095a17e --- /dev/null +++ b/elements/dpkg/cleanup.d/40-unblock-daemons @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +[ -n "$TARGET_ROOT" ] + +sudo mv $TARGET_ROOT/sbin/start-stop-daemon.REAL $TARGET_ROOT/sbin/start-stop-daemon +sudo mv $TARGET_ROOT/sbin/initctl.REAL $TARGET_ROOT/sbin/initctl +sudo mv $TARGET_ROOT/usr/sbin/invoke-rc.d.REAL $TARGET_ROOT/usr/sbin/invoke-rc.d + + diff --git a/elements/dpkg/cleanup.d/50-remove-img-build-proxy b/elements/dpkg/cleanup.d/50-remove-img-build-proxy new file mode 100755 index 000000000..3a27b68ec --- /dev/null +++ b/elements/dpkg/cleanup.d/50-remove-img-build-proxy @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +[ -n "$TARGET_ROOT" ] + +# Undo our proxy support +sudo rm -f $TARGET_ROOT/etc/apt/apt.conf.d/60img-build-proxy diff --git a/elements/base/pre-install.d/00-disable-apt-recommends b/elements/dpkg/pre-install.d/00-disable-apt-recommends similarity index 100% rename from elements/base/pre-install.d/00-disable-apt-recommends rename to elements/dpkg/pre-install.d/00-disable-apt-recommends diff --git a/elements/base/pre-install.d/01-install-bin b/elements/dpkg/pre-install.d/01-install-bin similarity index 100% rename from elements/base/pre-install.d/01-install-bin rename to elements/dpkg/pre-install.d/01-install-bin diff --git a/elements/base/pre-install.d/99-apt-get-update b/elements/dpkg/pre-install.d/99-apt-get-update similarity index 100% rename from elements/base/pre-install.d/99-apt-get-update rename to elements/dpkg/pre-install.d/99-apt-get-update diff --git a/elements/dpkg/root.d/50-build-with-http-cache b/elements/dpkg/root.d/50-build-with-http-cache new file mode 100755 index 000000000..dc66629f1 --- /dev/null +++ b/elements/dpkg/root.d/50-build-with-http-cache @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +[ -n "$TARGET_ROOT" ] + +# If we have a network proxy, use it. +if [ -n "$http_proxy" ] ; then + sudo dd of=$TARGET_ROOT/etc/apt/apt.conf.d/60img-build-proxy << _EOF_ +Acquire::http::Proxy "$http_proxy"; +_EOF_ +fi diff --git a/elements/dpkg/root.d/60-block-apt-translations b/elements/dpkg/root.d/60-block-apt-translations new file mode 100755 index 000000000..77a640cc9 --- /dev/null +++ b/elements/dpkg/root.d/60-block-apt-translations @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +[ -n "$TARGET_ROOT" ] + +# Configure APT not to fetch translations files +sudo dd of=$TARGET_ROOT/etc/apt/apt.conf.d/95no-translations <