From 176ae7bff61818079cb21ce9c999978ac7fcea26 Mon Sep 17 00:00:00 2001 From: Matthew Thode Date: Mon, 4 Jan 2016 11:00:28 -0600 Subject: [PATCH] Initial add of gentoo support for diskimage-builder uses upstream's stage4 images, includes all the needed bells and whistles for openstack on kvm. Change-Id: Ibca43173c30c2a74a73a2e2d9dd6d6d832c62694 Closes-Bug: 1530911 --- elements/base/pkg-map | 5 + elements/bootloader/finalise.d/50-bootloader | 6 +- elements/gentoo/README.rst | 26 ++++ elements/gentoo/bin/install-packages | 121 ++++++++++++++++++ elements/gentoo/element-deps | 2 + elements/gentoo/element-provides | 1 + .../environment.d/10-gentoo-distro-name.bash | 1 + elements/gentoo/gentoo-releng.gpg | 84 ++++++++++++ .../gentoo/pre-install.d/01-gentoo-install | 9 ++ elements/gentoo/root.d/10-gentoo-image | 104 +++++++++++++++ elements/pkg-map/bin/pkg-map | 2 + elements/svc-map/tests/test_data_merge.py | 3 +- lib/img-functions | 3 + 13 files changed, 362 insertions(+), 5 deletions(-) create mode 100644 elements/gentoo/README.rst create mode 100755 elements/gentoo/bin/install-packages create mode 100644 elements/gentoo/element-deps create mode 100644 elements/gentoo/element-provides create mode 100644 elements/gentoo/environment.d/10-gentoo-distro-name.bash create mode 100644 elements/gentoo/gentoo-releng.gpg create mode 100755 elements/gentoo/pre-install.d/01-gentoo-install create mode 100755 elements/gentoo/root.d/10-gentoo-image diff --git a/elements/base/pkg-map b/elements/base/pkg-map index b09852de..0906c7ba 100644 --- a/elements/base/pkg-map +++ b/elements/base/pkg-map @@ -5,6 +5,11 @@ }, "suse": { "dkms_package": "" + }, + "gentoo": { + "dkms_package": "", + "grub-pc": "grub", + "extlinux": "syslinux" } }, "default": { diff --git a/elements/bootloader/finalise.d/50-bootloader b/elements/bootloader/finalise.d/50-bootloader index 838c95bc..4a904a2a 100755 --- a/elements/bootloader/finalise.d/50-bootloader +++ b/elements/bootloader/finalise.d/50-bootloader @@ -19,7 +19,7 @@ else fi function install_extlinux { - install-packages extlinux + install-packages -m base extlinux echo "Installing Extlinux..." @@ -59,9 +59,9 @@ function install_grub2 { if [ -f "/tmp/grub/install" ] ; then source /tmp/grub/install elif [[ "$ARCH" =~ "ppc" ]]; then - install-packages grub-ieee1275 + install-packages -m base grub-ieee1275 else - install-packages grub-pc + install-packages -m base grub-pc fi # XXX: grub-probe on the nbd0/loop0 device returns nothing - workaround, manually diff --git a/elements/gentoo/README.rst b/elements/gentoo/README.rst new file mode 100644 index 00000000..1185f214 --- /dev/null +++ b/elements/gentoo/README.rst @@ -0,0 +1,26 @@ +======== +Gentoo +======== +Use a Gentoo cloud image as the baseline for built disk images. The images are +located in profile specific sub directories: + + http://distfiles.gentoo.org/releases/amd64/autobuilds/ + +As of this writing, only x86_64 images are available. + +Notes: + +* There are very frequently new automated builds that include changes that + happen during the product maintenance. The download directories contain an + unversioned name and a versioned name. The unversioned name will always + point to the latest image, but will frequently change its content. The versioned + one will never change content, but will frequently be deleted and replaced + by a newer build with a higher version-release number. + +* Other profiles can be used by exporting GENTOO_PROFILE with a valid profile. + A list of valid profiles follows: + + default/linux/amd64/13.0 + default/linux/amd64/13.0/no-multilib + hardened/linux/amd64 + hardened/linux/amd64/no-multilib diff --git a/elements/gentoo/bin/install-packages b/elements/gentoo/bin/install-packages new file mode 100755 index 00000000..968f9b03 --- /dev/null +++ b/elements/gentoo/bin/install-packages @@ -0,0 +1,121 @@ +#!/usr/bin/env bash + +# Copyright 2016 Matthew Thode +# +# 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 + +ACTION='install' + +SCRIPTNAME="$(basename $0)" +function show_options { + echo "Usage: ${SCRIPTNAME} [package ...]" + echo + echo 'Options:' + echo ' -u -- update all packages' + echo ' -e -- erase/remove packages' + exit 0 +} + +function fix_shm { + if [[ "${RUN_ONCE_SHM}" == '1' ]]; then + mv /dev/shm /dev/shm.orig + mkdir /dev/shm + mount -t tmpfs none /dev/shm + chmod 1777 /dev/shm + RUN_ONCE_SHM='0' + fi +} + +function unfix_shm { + if [[ "${RUN_ONCE_SHM}" == '0' ]]; then + umount /dev/shm + rmdir /dev/shm + mv /dev/shm.orig /dev/shm + fi +} + +function install_gentoo_packages { + RUN_ONCE_SHM='1' + fix_shm + emerge "$@" + unfix_shm +} + +TEMP="$(getopt -o huem: -n ${SCRIPTNAME} -- ${@})" +if [[ "${?}" != 0 ]]; then + echo 'Terminating...' >&2 + exit 1 +fi +eval set -- "${TEMP}" + +while true; do + case "${1}" in + -u ) + emerge-webrsync -q + install_gentoo_packages -uDNv --with-bdeps=y --jobs=2 @world + install_gentoo_packages --verbose=n --depclean + install_gentoo_packages -v --usepkg=n @preserved-rebuild + etc-update --automode -5 + eselect news read new + exit 0; + ;; + -e ) + ACTION='remove' + shift + ;; + -m ) + MAP_ELEMENT="${2}" + shift 2 + ;; + -h ) + show_options + ;; + -- ) + shift + break + ;; + * ) + echo "Error: unsupported option ${1}." + exit 1 + ;; + esac +done + +PKGS="${@}" +if [[ -n "${MAP_ELEMENT:-}" ]]; then + PKGS="$(pkg-map --element ${MAP_ELEMENT} ${@})" + if [[ "${?}" != 0 ]]; then + echo "bin/pkg-map error. ${PKGS}" + exit 1 + fi +fi + +if [[ -z "${PKGS}" ]]; then + echo "Not running install-packages ${ACTION} with empty packages list" +else + if [[ "${ACTION}" == 'install' ]]; then + emerge-webrsync -q + install_gentoo_packages -q --jobs=2 --changed-use "${PKGS}" + elif [[ "${ACTION}" == 'remove' ]]; then + emerge-webrsync -q + install_gentoo_packages -C "${PKGS}" + else + echo 'something when really wrong, install action is not install or remove' + fi +fi diff --git a/elements/gentoo/element-deps b/elements/gentoo/element-deps new file mode 100644 index 00000000..5c6d5779 --- /dev/null +++ b/elements/gentoo/element-deps @@ -0,0 +1,2 @@ +cache-url +dib-run-parts diff --git a/elements/gentoo/element-provides b/elements/gentoo/element-provides new file mode 100644 index 00000000..a72e0496 --- /dev/null +++ b/elements/gentoo/element-provides @@ -0,0 +1 @@ +operating-system diff --git a/elements/gentoo/environment.d/10-gentoo-distro-name.bash b/elements/gentoo/environment.d/10-gentoo-distro-name.bash new file mode 100644 index 00000000..61ad3573 --- /dev/null +++ b/elements/gentoo/environment.d/10-gentoo-distro-name.bash @@ -0,0 +1 @@ +export DISTRO_NAME=gentoo diff --git a/elements/gentoo/gentoo-releng.gpg b/elements/gentoo/gentoo-releng.gpg new file mode 100644 index 00000000..7d0d26fd --- /dev/null +++ b/elements/gentoo/gentoo-releng.gpg @@ -0,0 +1,84 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBEqUWzgBEACXftaG+HVuSQBEqdpBIg2SOVgWW/KbCihO5wPOsdbM93e+psmb +wvw+OtNHADQvxocKMuZX8Q/j5i3nQ/ikQFW5Oj6UXvl1qyxZhR2P7GZSNQxn0eMI +zAX08o691ws2/dFGXKmNT6btYJ0FxuTtTVSK6zi68WF+ILGK/O2TZXK9EKfZKPDH +KHcGrUq4c03vcGANz/8ksJj2ZYEGxMr1h7Wfe9PVcm0gCB1MhYHNR755M47V5Pch +fyxbs6vaKz82PgrNjjjbT0PISvnKReUOdA2PFUWry6UKQkiVrLVDRkd8fryLL8ey +5JxgVoJZ4echoVWQ0JYJ5lJTWmcZyxQYSAbz2w9dLB+dPyyGpyPp1KX1ADukbROp +9S11I9+oVnyGdUBm+AUme0ecekWvt4qiCw3azghLSwEyGZc4a8nNcwSqFmH7Rqdd +1+gHc+4tu4WHmguhMviifGXKyWiRERULp0obV33JEo/c4uwyAZHBTJtKtVaLb92z +aRdh1yox2I85iumyt62lq9dfOuet4NNVDnUkqMYCQD23JB8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KVNOfHKhZ5NLuRTsvC/TylfS4joysZ9NuVFCgp +ZlAoZxNndvdCPaX0RdQcgDRkGP9E89qqrglACOJDc2DaEKK2lQ24wK9wwm0lKAHN +s3d5qz9TQ2PopBED1LQbyHk29pTy/zJqyKNn0mxD97blvH2mJDU1pISMxNqOv9HA +PysjrqRYzrme6Mhy6TfWknWThLhIMDaaOehzMrwTlIYi85bySWYd3DEa7NH3IvWc +6SfLQgaRh93GK7ImY3sI4A2MoIxGVU6CSzHiRfwW1RnOb+3fw0ffvrbV7Qr6axln +pF4RQaCXfpDAde8AzIwOGJJUcImdjd4Z2Ji33vmhx3drD2SyYiZ3/3cPjheHBJgH +p/LnOFb/ejlvaqIYpFKlIbqsPbl541mhjTsu2yrgfAlRBAIer9m6c0dtjIJnqnXB +yNhv11XdiH3rIURCJcKkZIBgMcosun3bMK9hHYQ+A2dvLbWIG4W67xDufYpzmRx8 +pLepfQa6FHgD/5a1AJ93fQrkkd0gaDbNt0H/DvQZqLaxaZHKtCVO7JZwPvxw4ttS +jq6MW8v78I1D9i/WC53rvUeFTiChm7xtCMzXr08g51Xu/t3q0oOtaHhCHYGOiQI7 +BBMBAgAlBQJKlFs5AhsDBQkHhM4ABgsJCAcDAgQVAggDAxYCAQIeAQIXgAAKCRC7 +Vy4OLRgpEBavEACN6PjhMdn3gv9Ee6s13ugDZARHVwxiBS2IIFarTj0tvwtX2GHm +e8u0AgQ8u1hhGIp/JvnUi8LylTTnxyoWeTS7kU7Lwv08pX0uI6MrGfTblRQoKWZQ +KGcTZ3b3Qj2l9EXUHIA0ZBj/RPPaqq4JQAjiQ3Ng2hCitpUNuMCvcMJtJSgBzbN3 +eas/U0Nj6KQR//////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////w== +=1qLu +-----END PGP PUBLIC KEY BLOCK----- diff --git a/elements/gentoo/pre-install.d/01-gentoo-install b/elements/gentoo/pre-install.d/01-gentoo-install new file mode 100755 index 00000000..59b38a01 --- /dev/null +++ b/elements/gentoo/pre-install.d/01-gentoo-install @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +install -m 0755 -o root -g root $(dirname $0)/../bin/* /usr/local/bin diff --git a/elements/gentoo/root.d/10-gentoo-image b/elements/gentoo/root.d/10-gentoo-image new file mode 100755 index 00000000..27b31dd4 --- /dev/null +++ b/elements/gentoo/root.d/10-gentoo-image @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# Copyright 2016 Matthew Thode +# All Rights Reserved. +# +# 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 + +[ -n "${ARCH}" ] +[ -n "${TARGET_ROOT}" ] + +if [ 'amd64' = "${ARCH}" ] ; then + ARCH='x86_64' +fi + +if ! [ 'x86_64' = "${ARCH}" ] ; then + echo "Only x86_64 images are currently available but ARCH is set to ${ARCH}." + exit 1 +fi + +# get the element location so we can refrence things relative to it +ELEMENT_DIR=${ELEMENT_DIR:-"${ELEMENTS_PATH}/gentoo"} +# valid gentoo profiles are as follows +# default/linux/amd64/13.0 +# default/linux/amd64/13.0/no-multilib +# hardened/linux/amd64 +# hardened/linux/amd64/no-multilib +GENTOO_PROFILE=${GENTOO_PROFILE:-'default/linux/amd64/13.0'} +if [[ "${GENTOO_PROFILE}" == "default/linux/amd64/13.0" ]]; then + FILENAME_BASE='gentoo-stage4' + SIGNED_SOURCE_SUFFIX='cloud' +elif [[ "${GENTOO_PROFILE}" == "default/linux/amd64/13.0/no-multilib" ]]; then + FILENAME_BASE='gentoo-stage4-nomultilib' + SIGNED_SOURCE_SUFFIX='cloud-nomultilib' +elif [[ "${GENTOO_PROFILE}" == "hardened/linux/amd64" ]]; then + FILENAME_BASE='gentoo-stage4-hardened' + SIGNED_SOURCE_SUFFIX='hardened+cloud' +elif [[ "${GENTOO_PROFILE}" == "hardened/linux/amd64/no-multilib" ]]; then + FILENAME_BASE='gentoo-stage4-hardened-nomultilib' + SIGNED_SOURCE_SUFFIX='hardened+cloud-nomultilib' +else + echo 'invalid profile, please select from the following profiles' + echo 'default/linux/amd64/13.0' + echo 'default/linux/amd64/13.0/no-multilib' + echo 'hardened/linux/amd64' + echo 'hardened/linux/amd64/no-multilib' + exit 1 +fi + +DIB_CLOUD_SOURCE=${DIB_CLOUD_SOURCE:-"http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage4-amd64-${SIGNED_SOURCE_SUFFIX}.txt"} +BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-"http://distfiles.gentoo.org/releases/amd64/autobuilds/$(curl ${DIB_CLOUD_SOURCE} -s | tail -n 1 | cut -d\ -f 1)"} +SIGNATURE_FILE="${SIGNATURE_FILE:-${BASE_IMAGE_FILE}.DIGESTS.asc}" +CACHED_FILE="${DIB_IMAGE_CACHE}/${FILENAME_BASE}.tar.bz2" +CACHED_SIGNATURE_FILE="${DIB_IMAGE_CACHE}/${FILENAME_BASE}.asc" + +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 "${SIGNATURE_FILE}" "${CACHED_SIGNATURE_FILE}" + "${TMP_HOOKS_PATH}"/bin/cache-url "${BASE_IMAGE_FILE}" "${CACHED_FILE}" + pushd "${DIB_IMAGE_CACHE}" + # import the key + # this key can be verified at one of the following places + # https://wiki.gentoo.org/wiki/Project:RelEng#Keys + # https://dev.gentoo.org/~dolsen/releases/keyrings/gentoo-keys-*.tar.xz + # http://distfiles.gentoo.org/distfiles/gentoo-keys-*.tar.xz + GPGDIR=$(mktemp -d -t) + gpg --no-default-keyring --keyring "${GPGDIR}"/gentookeys.gpg --import "${ELEMENT_DIR}"/gentoo-releng.gpg + # check the sig file + gpgv --keyring "${GPGDIR}"/gentookeys.gpg "${CACHED_SIGNATURE_FILE}" + if [[ "${?}" != 0 ]]; then + echo 'invalid signature file' + exit 1 + fi + rm -rf "${GPGDIR}" + echo 'valid key used' + CACHED_SHA512SUM=$(grep -A1 -e 'SHA512' "${CACHED_SIGNATURE_FILE}" | grep -e 'tar.bz2$' | cut -d\ -f 1) + ACTUAL_SHA512SUM=$(sha512sum "${CACHED_FILE}" | cut -d\ -f 1) + if [[ "${ACTUAL_SHA512SUM}" != "${CACHED_SHA512SUM}" ]]; then + echo "invalid checksum on downloaded tarball: ${CACHED_FILE}" + exit 1 + fi + echo 'valid checksum' + popd +fi + +# Extract the base image (use --numeric-owner to avoid UID/GID mismatch between +# image tarball and host OS) +sudo tar -C "${TARGET_ROOT}" --numeric-owner --xattrs -xjpf "${CACHED_FILE}" diff --git a/elements/pkg-map/bin/pkg-map b/elements/pkg-map/bin/pkg-map index 009f474d..85d03d67 100755 --- a/elements/pkg-map/bin/pkg-map +++ b/elements/pkg-map/bin/pkg-map @@ -33,6 +33,8 @@ def os_family(distro): family = 'debian' elif distro == 'opensuse': family = 'suse' + elif distro == 'gentoo': + family = 'gentoo' return family diff --git a/elements/svc-map/tests/test_data_merge.py b/elements/svc-map/tests/test_data_merge.py index 5356ae0b..df2dc2ed 100644 --- a/elements/svc-map/tests/test_data_merge.py +++ b/elements/svc-map/tests/test_data_merge.py @@ -13,13 +13,12 @@ # under the License. import imp import os +from oslotest import base module_path = (os.path.dirname(os.path.realpath(__file__)) + '/../extra-data.d/10-merge-svc-map-files') service_map = imp.load_source('service_map', module_path) -from oslotest import base - class TestDataMerge(base.BaseTestCase): diff --git a/lib/img-functions b/lib/img-functions index 38c46609..cf817ae8 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -191,6 +191,9 @@ function select_boot_kernel_initrd () { elif [ -f $TARGET_ROOT/etc/SuSE-release ]; then KERNEL=$(basename $(readlink -e $BOOTDIR/vmlinuz)) RAMDISK=$(basename $(readlink -e $BOOTDIR/initrd)) + elif [[ -f "${TARGET_ROOT}"/etc/gentoo-release ]]; then + KERNEL="$(basename $(ls -1rv $BOOTDIR/kernel-*-openstack | head -n 1))" + RAMDISK="$(basename $(ls -1rv $BOOTDIR/initramfs-*-openstack | head -n 1))" else echo "ERROR: Unable to detect operating system" exit 1