From eed131c3732d69be0e49dfe80062f457eccb0360 Mon Sep 17 00:00:00 2001 From: Chris Krelle Date: Tue, 22 Apr 2014 16:44:37 -0500 Subject: [PATCH] update opensuse element This patch updates the openSuse element to work with the new base image file format. It should be noted that the base image file name has changed several times while updating this element, and and may need to be set manually via the "BASE_IMAGE_NAME" env var. Change-Id: I4dac8bf9a4bf76a00d4a04cbf063fd245b11f3d6 --- elements/opensuse/bin/install-packages | 5 +- .../install.d/00-opensuse-setup-installs | 11 ++++ elements/opensuse/post-install.d/10-mkinitrd | 6 +- .../post-install.d/99-remove-lost-and-found | 7 +++ .../opensuse/pre-install.d/00-opensuse-setup | 7 +++ .../opensuse/root.d/10-opensuse-cloud-image | 57 +++++++++++++++++-- 6 files changed, 83 insertions(+), 10 deletions(-) create mode 100755 elements/opensuse/install.d/00-opensuse-setup-installs create mode 100755 elements/opensuse/post-install.d/99-remove-lost-and-found create mode 100755 elements/opensuse/pre-install.d/00-opensuse-setup diff --git a/elements/opensuse/bin/install-packages b/elements/opensuse/bin/install-packages index 6af794be8..d556c9db2 100755 --- a/elements/opensuse/bin/install-packages +++ b/elements/opensuse/bin/install-packages @@ -53,8 +53,9 @@ done # Packages that aren't available in the distro but requested for installation # can be ignored by adding them to the exclude list -BLACKLIST=(dkms) -WHITELIST="" +BLACKLIST=('') +WHITELIST=('') + for i in "$@" do PKG_NAME=$i diff --git a/elements/opensuse/install.d/00-opensuse-setup-installs b/elements/opensuse/install.d/00-opensuse-setup-installs new file mode 100755 index 000000000..7ef24bf22 --- /dev/null +++ b/elements/opensuse/install.d/00-opensuse-setup-installs @@ -0,0 +1,11 @@ +#!/bin/bash +# Install requirments needed to build the image. +set -eu +set -o pipefail + +# install kernel package needed by dkms. +install-packages kernel-devel + +# sudo and lsb not included by default. +# so install them. +install-packages sudo lsb-release diff --git a/elements/opensuse/post-install.d/10-mkinitrd b/elements/opensuse/post-install.d/10-mkinitrd index 476d8f0a1..e59d2b385 100755 --- a/elements/opensuse/post-install.d/10-mkinitrd +++ b/elements/opensuse/post-install.d/10-mkinitrd @@ -1,5 +1,5 @@ #!/bin/bash -# The base tbz-image created by kiwi does not contain an initrd so create one +# The base image created by kiwi does not contain an initrd so create one # here. set -eu @@ -15,7 +15,9 @@ source $_LIB/img-defaults # tmpfs even). echo "rootfstype=$FS_TYPE" > /etc/sysconfig/initrd -mkinitrd -A +# openSuse mkinitrd requires a valid root device be in fstab. +sed -i 's/vda1/sda1/' /etc/fstab +mkinitrd -A -B # And cleanup again rm /etc/sysconfig/initrd diff --git a/elements/opensuse/post-install.d/99-remove-lost-and-found b/elements/opensuse/post-install.d/99-remove-lost-and-found new file mode 100755 index 000000000..226f74d23 --- /dev/null +++ b/elements/opensuse/post-install.d/99-remove-lost-and-found @@ -0,0 +1,7 @@ +#!/bin/bash +# ensure we do not have a lost+found directory in the root folder +# that could cause copy to fail. +set -eu +set -o pipefail + +rm -rf lost+found diff --git a/elements/opensuse/pre-install.d/00-opensuse-setup b/elements/opensuse/pre-install.d/00-opensuse-setup new file mode 100755 index 000000000..c0e73626b --- /dev/null +++ b/elements/opensuse/pre-install.d/00-opensuse-setup @@ -0,0 +1,7 @@ +#!/bin/bash +# Setup repo required for dkms package. + +set -eu +set -o pipefail + +zypper ar -f http://download.opensuse.org/repositories/X11:/Bumblebee/openSUSE_13.1/X11:Bumblebee.repo diff --git a/elements/opensuse/root.d/10-opensuse-cloud-image b/elements/opensuse/root.d/10-opensuse-cloud-image index 8d467189d..6c1376b8e 100755 --- a/elements/opensuse/root.d/10-opensuse-cloud-image +++ b/elements/opensuse/root.d/10-opensuse-cloud-image @@ -3,6 +3,20 @@ set -eu set -o pipefail +function find_free_nbd_device () { + # Return first free nbd device + return_device='' + for chk_device in /sys/class/block/nbd*; do + # find free nbd device by checking size field + size_chk=`cat $chk_device/size` + if [ "$size_chk" = "0" ]; then + # device looks free. lets use it. + return_device=$chk_device + break + fi + done + echo $return_device +} [ -n "$ARCH" ] [ -n "$TARGET_ROOT" ] @@ -17,7 +31,8 @@ fi DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://download.opensuse.org/repositories/Cloud:/Images/images/} DIB_RELEASE=${DIB_RELEASE:-13.1} # FIXME: Hard coded build numbers, versions, etc. -BASE_IMAGE_NAME=${BASE_IMAGE_NAME:-openSUSE-$DIB_RELEASE-OpenStack-Guest.$ARCH} +# NOTE: Actual file name seems unstable, and has changed several times. +BASE_IMAGE_NAME=${BASE_IMAGE_NAME:-openSUSE-$DIB_RELEASE-OS-guest.$ARCH-0.0.2-Build3.1} if [ -z "$DIB_OFFLINE" ] ; then # XXX: Try to extract the filename of the current built from the index @@ -26,7 +41,7 @@ if [ -z "$DIB_OFFLINE" ] ; then # https://bugzilla.novell.com/show_bug.cgi?id=853882 is deployed echo "Looking up current built of Base Image ($BASE_IMAGE_NAME):" BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$(curl $DIB_CLOUD_IMAGES | \ - sed -n "s/^.*\