From 5ddd59814aa76f5d1b3ca71345a85ee64b9c783a Mon Sep 17 00:00:00 2001 From: vponomaryov Date: Thu, 26 May 2016 17:11:34 +0300 Subject: [PATCH] Use ubuntu-minimal instead of ubuntu-core Support of ubuntu-core was dropped and now it is impossible to continue using it. Therefore, start using ubuntu-minimal OS element for building image. Also, add 'other-requirements.txt' file with list of required system packages to be installed prior to buidling image. Change-Id: Ief7059b9e6cc2aad03c81225663f5313a8d2f5f2 Closes-Bug: #1586351 --- README.rst | 10 ++- bin/manila-image-create | 9 +-- elements/manila-ubuntu-core/README.rst | 9 --- elements/manila-ubuntu-core/element-deps | 3 - .../environment.d/10-ubuntu-distro-name.bash | 3 - .../install.d/99-autoremove | 9 --- .../00-install-required-packages | 24 ------- .../pre-install.d/00-remove-apt-xapian-index | 11 ---- .../pre-install.d/00-remove-grub | 18 ------ .../root.d/10-cache-ubuntu-tarball | 62 ------------------- elements/manila-ubuntu-minimal/README.rst | 22 +++++++ elements/manila-ubuntu-minimal/element-deps | 1 + .../element-provides | 0 .../package-installs.yaml | 8 +++ .../50-set-bash-as-default-shell | 0 .../post-install.d/50-update-hosts-config | 2 +- .../post-install.d/50-update-vim-config | 0 .../pre-install.d/00-ubuntu-apt-update | 38 ++++++++++++ .../pre-install.d/01-set-ubuntu-mirror | 0 other-requirements.txt | 2 + 20 files changed, 81 insertions(+), 150 deletions(-) delete mode 100755 elements/manila-ubuntu-core/README.rst delete mode 100755 elements/manila-ubuntu-core/element-deps delete mode 100755 elements/manila-ubuntu-core/environment.d/10-ubuntu-distro-name.bash delete mode 100755 elements/manila-ubuntu-core/install.d/99-autoremove delete mode 100755 elements/manila-ubuntu-core/pre-install.d/00-install-required-packages delete mode 100755 elements/manila-ubuntu-core/pre-install.d/00-remove-apt-xapian-index delete mode 100755 elements/manila-ubuntu-core/pre-install.d/00-remove-grub delete mode 100755 elements/manila-ubuntu-core/root.d/10-cache-ubuntu-tarball create mode 100755 elements/manila-ubuntu-minimal/README.rst create mode 100755 elements/manila-ubuntu-minimal/element-deps rename elements/{manila-ubuntu-core => manila-ubuntu-minimal}/element-provides (100%) create mode 100755 elements/manila-ubuntu-minimal/package-installs.yaml rename elements/{manila-ubuntu-core => manila-ubuntu-minimal}/post-install.d/50-set-bash-as-default-shell (100%) rename elements/{manila-ubuntu-core => manila-ubuntu-minimal}/post-install.d/50-update-hosts-config (67%) rename elements/{manila-ubuntu-core => manila-ubuntu-minimal}/post-install.d/50-update-vim-config (100%) create mode 100755 elements/manila-ubuntu-minimal/pre-install.d/00-ubuntu-apt-update rename elements/{manila-ubuntu-core => manila-ubuntu-minimal}/pre-install.d/01-set-ubuntu-mirror (100%) create mode 100644 other-requirements.txt diff --git a/README.rst b/README.rst index 657f45e..c4b5a9b 100644 --- a/README.rst +++ b/README.rst @@ -1,18 +1,22 @@ Manila image elements project ============================== -This repo is a place for Manila-related for diskimage-builder elements. +This repo is a place for Manila-related diskimage-builder elements. * Free software: Apache license * Source: http://git.openstack.org/cgit/manila-image-elements -* Bugs: http://bugs.launchpad.net/manila-image +* Bugs: http://bugs.launchpad.net/manila-image-elements * Built Images: http://tarballs.openstack.org/manila-image-elements/images Build instructions ------------------ -Script for creating Ubuntu based image with our elements and default parameters. You should only need to run this command: +Script for creating Ubuntu based image with our elements and default parameters. + +Before building image make sure all system dependencies, +listed in other-requirements.txt file, are installed. +After it, you should only need to run this command: .. sourcecode:: bash diff --git a/bin/manila-image-create b/bin/manila-image-create index 7a2abb9..7d2fc74 100644 --- a/bin/manila-image-create +++ b/bin/manila-image-create @@ -42,7 +42,7 @@ MANILA_USER_AUTHORIZED_KEYS="None" # Manila image settings MANILA_IMG_ARCH=${MANILA_IMG_ARCH:-"i386"} -MANILA_IMG_OS=${MANILA_IMG_OS:-"manila-ubuntu-core"} +MANILA_IMG_OS=${MANILA_IMG_OS:-"manila-ubuntu-minimal"} MANILA_IMG_OS_VER=${MANILA_IMG_OS_VER:-"trusty"} MANILA_IMG_NAME=${MANILA_IMG_NAME:-"manila-service-image"} MANILA_LXD_METADATA_PACKAGE_NAME=${MANILA_LXD_METADATA_PACKAGE_NAME:-"manila-lxd-meta"} @@ -62,7 +62,7 @@ if [ "$MANILA_IMAGE_TYPE" = "lxd" ]; then MANILA_ENABLE_ZFS_SUPPORT="no" export INSTALL_KERNEL=false else - REQUIRED_ELEMENTS="manila-ssh vm $MANILA_IMG_OS dhcp-all-interfaces cleanup-kernel-initrd" + REQUIRED_ELEMENTS="manila-ssh vm $MANILA_IMG_OS dhcp-all-interfaces" IMAGE_FORMAT="qcow2" fi OPTIONAL_ELEMENTS= @@ -101,11 +101,6 @@ if [ "$DISABLE_IMG_COMPRESSION" = "yes" ]; then OPTIONAL_DIB_ARGS="$OPTIONAL_DIB_ARGS -u" fi -if [ "$MANILA_IMG_OS" = "manila-ubuntu-core" ] && [ "$MANILA_IMG_OS_VER" != "trusty" ]; then - echo "manila-ubuntu-core doesn't support '$MANILA_IMG_OS_VER' release." - echo "Change MANILA_IMG_OS to 'ubuntu' if you need another release." -fi - # Verify dependencies # ------------------- if [ -e /etc/os-release ]; then diff --git a/elements/manila-ubuntu-core/README.rst b/elements/manila-ubuntu-core/README.rst deleted file mode 100755 index 9d213f2..0000000 --- a/elements/manila-ubuntu-core/README.rst +++ /dev/null @@ -1,9 +0,0 @@ -================== -manila-ubuntu-core -================== - -Provides minimalistic Ubuntu 14.04 LTS based on Ubuntu Core image. - -Overrides: - * To use different mirrors rather than the default of archive.ubuntu.com and - security.ubuntu.com, use the environment variable DIB\_DISTRIBUTION\_MIRROR diff --git a/elements/manila-ubuntu-core/element-deps b/elements/manila-ubuntu-core/element-deps deleted file mode 100755 index 0617448..0000000 --- a/elements/manila-ubuntu-core/element-deps +++ /dev/null @@ -1,3 +0,0 @@ -cache-url -dib-run-parts -dpkg diff --git a/elements/manila-ubuntu-core/environment.d/10-ubuntu-distro-name.bash b/elements/manila-ubuntu-core/environment.d/10-ubuntu-distro-name.bash deleted file mode 100755 index 7964fa7..0000000 --- a/elements/manila-ubuntu-core/environment.d/10-ubuntu-distro-name.bash +++ /dev/null @@ -1,3 +0,0 @@ -export DISTRO_NAME=ubuntu -export DIB_RELEASE=${DIB_RELEASE:-trusty} -export INSTALL_KERNEL=${INSTALL_KERNEL:-true} diff --git a/elements/manila-ubuntu-core/install.d/99-autoremove b/elements/manila-ubuntu-core/install.d/99-autoremove deleted file mode 100755 index e04006d..0000000 --- a/elements/manila-ubuntu-core/install.d/99-autoremove +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - -apt-get -y autoremove diff --git a/elements/manila-ubuntu-core/pre-install.d/00-install-required-packages b/elements/manila-ubuntu-core/pre-install.d/00-install-required-packages deleted file mode 100755 index 3c8cbce..0000000 --- a/elements/manila-ubuntu-core/pre-install.d/00-install-required-packages +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - -sudo sed -i -E "s/#\s(deb.+universe)$/\1/g" /etc/apt/sources.list - -apt-get update -apt-get upgrade -y - -if $INSTALL_KERNEL ; then - apt-get install linux-image-generic -y -fi - -apt-get install \ - python \ - sudo \ - openssh-server \ - rpcbind \ - vim \ - -y diff --git a/elements/manila-ubuntu-core/pre-install.d/00-remove-apt-xapian-index b/elements/manila-ubuntu-core/pre-install.d/00-remove-apt-xapian-index deleted file mode 100755 index 9d04ccd..0000000 --- a/elements/manila-ubuntu-core/pre-install.d/00-remove-apt-xapian-index +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - -# This package is broken and causes real issues on update: -# https://bugs.launchpad.net/ubuntu/+source/apt-xapian-index/+bug/1227420 -apt-get --yes remove apt-xapian-index || : diff --git a/elements/manila-ubuntu-core/pre-install.d/00-remove-grub b/elements/manila-ubuntu-core/pre-install.d/00-remove-grub deleted file mode 100755 index 094a3f7..0000000 --- a/elements/manila-ubuntu-core/pre-install.d/00-remove-grub +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# The grub post-kernel install hook will barf if the block device can't be -# found (as happens in a chroot). -# Temporarily remove grub, to avoid that confusion. - -if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - -if dpkg-query -W grub-pc; then - apt-get -y remove grub-pc -fi - -if dpkg-query -W grub2-common; then - apt-get -y remove grub2-common -fi diff --git a/elements/manila-ubuntu-core/root.d/10-cache-ubuntu-tarball b/elements/manila-ubuntu-core/root.d/10-cache-ubuntu-tarball deleted file mode 100755 index 177c252..0000000 --- a/elements/manila-ubuntu-core/root.d/10-cache-ubuntu-tarball +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# These are useful, or at worst not harmful, for all images we build. - -if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - -[ -n "$ARCH" ] -[ -n "$TARGET_ROOT" ] - -shopt -s extglob - -DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cdimage.ubuntu.com/ubuntu-core/releases/} -DIB_RELEASE="trusty" # Note(u_glide): another releases not supported/tested -DIB_RELEASE_NUM="14.04" -BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-ubuntu-core-$DIB_RELEASE_NUM-core-$ARCH.tar.gz} -SHA256SUMS=${SHA256SUMS:-http://${DIB_CLOUD_IMAGES##http?(s)://}/$DIB_RELEASE/release/SHA256SUMS} -CACHED_FILE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE -CACHED_FILE_LOCK=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE.lock -CACHED_SUMS=$DIB_IMAGE_CACHE/SHA256SUMS.ubuntu.$DIB_RELEASE.$ARCH - -function get_ubuntu_tarball { - if [ -n "$DIB_OFFLINE" -a -f "$CACHED_FILE" ] ; then - echo "Not checking freshness of cached $CACHED_FILE." - else - echo "Fetching Base Image" - $TMP_HOOKS_PATH/bin/cache-url $SHA256SUMS $CACHED_SUMS - $TMP_HOOKS_PATH/bin/cache-url \ - $DIB_CLOUD_IMAGES/$DIB_RELEASE/release/$BASE_IMAGE_FILE $CACHED_FILE - pushd $DIB_IMAGE_CACHE - if ! grep "$BASE_IMAGE_FILE" $CACHED_SUMS | sha256sum --check - ; then - # It is likely that an upstream http(s) proxy has given us a skewed - # result - either a cached SHA file or a cached image. Use cache-busting - # to get (as long as caches are compliant...) fresh files. - # Try the sha256sum first, just in case that is the stale one (avoiding - # downloading the larger image), and then if the sums still fail retry - # the image. - $TMP_HOOKS_PATH/bin/cache-url -f $SHA256SUMS $CACHED_SUMS - if ! grep "$BASE_IMAGE_FILE" $CACHED_SUMS | sha256sum --check - ; then - $TMP_HOOKS_PATH/bin/cache-url -f \ - $DIB_CLOUD_IMAGES/$DIB_RELEASE/release/$BASE_IMAGE_FILE $CACHED_FILE - grep "$BASE_IMAGE_FILE" $CACHED_SUMS | sha256sum --check - - fi - fi - popd - fi - # Extract the base image (use --numeric-owner to avoid UID/GID mismatch between - # image tarball and host OS e.g. when building Ubuntu image on an openSUSE host) - sudo tar -C $TARGET_ROOT --numeric-owner -xzf $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE -} - -( - echo "Getting $CACHED_FILE_LOCK: $(date)" - # Wait up to 20 minutes for another process to download - if ! flock -w 1200 9 ; then - echo "Did not get $CACHED_FILE_LOCK: $(date)" - exit 1 - fi - get_ubuntu_tarball -) 9> $CACHED_FILE_LOCK diff --git a/elements/manila-ubuntu-minimal/README.rst b/elements/manila-ubuntu-minimal/README.rst new file mode 100755 index 0000000..0e7a04f --- /dev/null +++ b/elements/manila-ubuntu-minimal/README.rst @@ -0,0 +1,22 @@ +===================== +manila-ubuntu-minimal +===================== + +Create a minimal image based on Ubuntu. Default is trusty but DIB_RELEASE +is mapped to any series of Ubuntu. + +If necessary, a custom apt keyring and debootstrap script can be supplied +to the debootstrap command via DIB_APT_KEYRING and +DIB_DEBIAN_DEBOOTSTRAP_SCRIPT respectively. Both options require the use of +absolute rather than relative paths. + +Use of this element will also require the tool 'debootstrap' to be available +on your system. + +The DIB_OFFLINE or more specific DIB_DEBIAN_USE_DEBOOTSTRAP_CACHE variables +can be set to prefer the use of a pre-cached root filesystem tarball. + +The DIB_DEBOOTSTRAP_EXTRA_ARGS environment variable may be used to pass +extra arguments to the debootstrap command used to create the base +filesystem image. If --keyring is used in DIB_DEBOOTSTRAP_EXTRA_ARGS, +it will override DIB_APT_KEYRING if that is used as well. diff --git a/elements/manila-ubuntu-minimal/element-deps b/elements/manila-ubuntu-minimal/element-deps new file mode 100755 index 0000000..fe735d0 --- /dev/null +++ b/elements/manila-ubuntu-minimal/element-deps @@ -0,0 +1 @@ +ubuntu-minimal diff --git a/elements/manila-ubuntu-core/element-provides b/elements/manila-ubuntu-minimal/element-provides similarity index 100% rename from elements/manila-ubuntu-core/element-provides rename to elements/manila-ubuntu-minimal/element-provides diff --git a/elements/manila-ubuntu-minimal/package-installs.yaml b/elements/manila-ubuntu-minimal/package-installs.yaml new file mode 100755 index 0000000..6425001 --- /dev/null +++ b/elements/manila-ubuntu-minimal/package-installs.yaml @@ -0,0 +1,8 @@ +openssh-server: +sudo: +rpcbind: +vim: +iptables: +inetutils-ping: +net-tools: +python: diff --git a/elements/manila-ubuntu-core/post-install.d/50-set-bash-as-default-shell b/elements/manila-ubuntu-minimal/post-install.d/50-set-bash-as-default-shell similarity index 100% rename from elements/manila-ubuntu-core/post-install.d/50-set-bash-as-default-shell rename to elements/manila-ubuntu-minimal/post-install.d/50-set-bash-as-default-shell diff --git a/elements/manila-ubuntu-core/post-install.d/50-update-hosts-config b/elements/manila-ubuntu-minimal/post-install.d/50-update-hosts-config similarity index 67% rename from elements/manila-ubuntu-core/post-install.d/50-update-hosts-config rename to elements/manila-ubuntu-minimal/post-install.d/50-update-hosts-config index a5dc7eb..086a72f 100755 --- a/elements/manila-ubuntu-core/post-install.d/50-update-hosts-config +++ b/elements/manila-ubuntu-minimal/post-install.d/50-update-hosts-config @@ -8,4 +8,4 @@ set -o pipefail # Update 'hosts' file with dn-ip predefinitions hosts_config="/etc/hosts" -echo "127.0.0.1 localhost localhost.localdomain" >> $hosts_config +echo "127.0.0.1 ubuntu localhost localhost.localdomain" >> $hosts_config diff --git a/elements/manila-ubuntu-core/post-install.d/50-update-vim-config b/elements/manila-ubuntu-minimal/post-install.d/50-update-vim-config similarity index 100% rename from elements/manila-ubuntu-core/post-install.d/50-update-vim-config rename to elements/manila-ubuntu-minimal/post-install.d/50-update-vim-config diff --git a/elements/manila-ubuntu-minimal/pre-install.d/00-ubuntu-apt-update b/elements/manila-ubuntu-minimal/pre-install.d/00-ubuntu-apt-update new file mode 100755 index 0000000..db487e7 --- /dev/null +++ b/elements/manila-ubuntu-minimal/pre-install.d/00-ubuntu-apt-update @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright (c) 2014 Hewlett-Packard Development Company, L.P. +# +# 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. + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-http://archive.ubuntu.com/ubuntu} + +# We should manage this in a betterer way +cat << EOF >/etc/apt/sources.list +deb $DIB_DISTRIBUTION_MIRROR $DIB_RELEASE main restricted universe +deb $DIB_DISTRIBUTION_MIRROR $DIB_RELEASE-updates main restricted universe +deb $DIB_DISTRIBUTION_MIRROR $DIB_RELEASE-backports main restricted universe +deb $DIB_DISTRIBUTION_MIRROR $DIB_RELEASE-security main restricted universe +EOF + +# Need to update to retrieve the signed Release file +apt-get update + +apt-get clean +apt-get dist-upgrade -y diff --git a/elements/manila-ubuntu-core/pre-install.d/01-set-ubuntu-mirror b/elements/manila-ubuntu-minimal/pre-install.d/01-set-ubuntu-mirror similarity index 100% rename from elements/manila-ubuntu-core/pre-install.d/01-set-ubuntu-mirror rename to elements/manila-ubuntu-minimal/pre-install.d/01-set-ubuntu-mirror diff --git a/other-requirements.txt b/other-requirements.txt new file mode 100644 index 0000000..a3686ae --- /dev/null +++ b/other-requirements.txt @@ -0,0 +1,2 @@ +# Package 'debootstrap' is required for 'ubuntu-minimal' element. +debootstrap