-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for building openSUSE images
This is currently experimental/incomplete. See elements/opensuse/README.md for details. Change-Id: Ie5bcab15c9703cf15ceb642fb986a8afc34f96fb Co-Authored-By: Ralf Haferkamp <rhafer@suse.de>
- Loading branch information
Showing
9 changed files
with
227 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Use an openSUSE cloud image as the baseline for built disk images. The base | ||
image is located here: | ||
|
||
http://download.opensuse.org/repositories/Cloud:/Images/images/ | ||
|
||
This image should currently be considered experimental. Right now, we've only | ||
got a 64 bit image, and no 32 bit image. But it's a start. | ||
|
||
Notes: | ||
|
||
* The filename of the base image in the above repository is currently not | ||
stable (e.g. it includes a build number and image version). A fix for that | ||
will be rolled out to the repositories soon. A tempoary workaround to figure | ||
out the correct filename has been added to root.d/10-opensuse-cloud-image. | ||
* Building with DIB\_EXTLINUX=1 doesn't work. It fails with: | ||
/tmp/in\_target.d/finalise.d/51-bootloader: line 14: 16286 Segmentation fault | ||
extlinux --install /boot/syslinux | ||
(https://bugzilla.novell.com/show_bug.cgi?id=852856) | ||
* This element doesn't need half of the rpm-distro element's pre-install | ||
hooks. The exceptions are 01-install-bin, which has been copied to | ||
this element, and 01-override-zypp-arch (which is something that | ||
could probably be jammed into the base image...). | ||
* We might want to use the local-config element (after updating that element to | ||
inject http\_proxy properly for openSUSE, of course). | ||
(https://bugs.launchpad.net/diskimage-builder/+bug/1256982) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
# Copyright 2013 SUSE Linux Products GmbH | ||
# 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. | ||
|
||
set -e | ||
|
||
function run_zypper() { | ||
# TODO: Uncertain if this can ever block wanting input from user | ||
zypper --non-interactive --gpg-auto-import-keys "$@" | ||
} | ||
|
||
if [ "$1" = "-u" ] ; then | ||
run_zypper dist-upgrade | ||
exit 0 | ||
elif [ "$1" = "-d" ] ; then | ||
EXTRA_ARGS="--download-only" | ||
shift | ||
fi | ||
|
||
# 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=() | ||
for i in "$@" | ||
do | ||
if [[ ! ${BLACKLIST[*]} =~ $i ]]; then | ||
WHITELIST+="$i " | ||
else | ||
echo "The package $i is not available and will not be installed" | ||
fi | ||
done | ||
if [ -n "$WHITELIST" ]; then | ||
run_zypper install $EXTRA_ARGS $(map-packages $WHITELIST) | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2013 SUSE Linux Products GmbH | ||
# 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. | ||
|
||
import sys | ||
|
||
# Manually maintained for brevity; consider making this compiled from | ||
# distromatch or other rich data sources. | ||
# Debian name on the left, openSUSE on the right. | ||
package_map = { | ||
'grub-pc': 'grub2', | ||
'linux-image-generic': 'kernel-default', | ||
'python-dev': 'python-devel', | ||
'libc6-dev': 'glibc-devel', | ||
'libxml2-dev': 'libxml2-devel', | ||
'libxslt-dev': 'libxslt-devel', | ||
'python-libvirt': 'libvirt-python', | ||
'libvirt-bin': 'libvirt', | ||
'python-memcache': 'python-python-memcached', | ||
'build-essential': 'make automake gcc gcc-c++ kernel-devel', | ||
'python-mysqldb': 'python-mysql', | ||
'openvswitch-common': 'openvswitch', | ||
'openvswitch-switch': 'openvswitch-switch', | ||
'libssl-dev': 'openssl-devel', | ||
'libz-dev': 'zlib-devel', | ||
'qemu-utils': 'qemu-tools', | ||
'python-pyopenssl': 'python-pyOpenSSL', | ||
'libmysqlclient-dev': 'libmysqlclient-devel', | ||
'arping': 'iputils', | ||
'augeas-tools': 'augeas', | ||
'openssh-client': 'openssh', | ||
'extlinux': 'syslinux', | ||
'mysql-client-5.5': 'mysql-community-server-client', | ||
'mysql-server-5.5': 'mysql-community-server', | ||
'libmysql-java': 'mysql-connector-java', | ||
'default-jre': 'java', # Will match 'java' as capability | ||
'atftpd': 'atftp', | ||
} | ||
|
||
for arg in sys.argv[1:]: | ||
print(package_map.get(arg, arg)) | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
cache-url | ||
dib-run-parts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
export OPENSUSE_EXTRAS_PATH="$TMP_MOUNT_PATH/tmp/opensuse-extras" | ||
mkdir -p $OPENSUSE_EXTRAS_PATH | ||
|
||
for file in common-defaults img-defaults ; do | ||
cp $_LIB/$file $OPENSUSE_EXTRAS_PATH | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# The base tbz-image created by kiwi does not contain an initrd so create one | ||
# here. | ||
|
||
set -eu | ||
|
||
# To have access to FS_TYPE | ||
_LIB="/tmp/opensuse-extras" | ||
source $_LIB/img-defaults | ||
|
||
# This is to tell mkinitrd to include the right tools for the root filesystem | ||
# that will actually be used for the final image. This is likely something | ||
# different than what the chroot is currently on (which might currently be a | ||
# tmpfs even). | ||
echo "rootfstype=$FS_TYPE" > /etc/sysconfig/initrd | ||
|
||
mkinitrd -A | ||
|
||
# And cleanup again | ||
rm /etc/sysconfig/initrd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
install -m 0755 -o root -g root $(dirname $0)/../bin/* /usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
[ -n "$ARCH" ] | ||
[ -n "$TARGET_ROOT" ] | ||
|
||
if [ 'amd64' = "$ARCH" ] ; then | ||
ARCH="x86_64" | ||
fi | ||
|
||
if [ 'i386' = "$ARCH" ] ; then | ||
ARCH="i586" | ||
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} | ||
|
||
if [ -z "$DIB_OFFLINE" ] ; then | ||
# XXX: Try to extract the filename of the current built from the index | ||
# page. As there is one built available in the repo at a given time, this | ||
# should work. This is a tempoary workaround until the fix for | ||
# 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/^.*\<a\ href\=\"\($BASE_IMAGE_NAME.*\.tbz\)\".*$/\1/p")} | ||
if [ -n "$BASE_IMAGE_FILE" ]; then | ||
echo "Using base image: $DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE" | ||
else | ||
echo -e "Failed to extract image file name from $DIB_CLOUD_IMAGES" \ | ||
"\nPlease set BASE_IMAGE_FILE manually and retry." | ||
exit 1 | ||
fi | ||
else | ||
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$BASE_IMAGE_NAME-0.0.1-Build6.1.tbz} | ||
fi | ||
|
||
# FIXME: either check the checksums into git or verify the signature | ||
# on the checksums. We should not be trusting checksums we download | ||
# over HTTP | ||
SHA256SUMS=${SHA256SUMS:-$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE.sha256} | ||
CACHED_FILE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE | ||
|
||
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 $DIB_IMAGE_CACHE/SHA256SUMS.openSUSE.$DIB_RELEASE.$ARCH | ||
$TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE $CACHED_FILE | ||
pushd $DIB_IMAGE_CACHE | ||
grep "$BASE_IMAGE_FILE" SHA256SUMS.openSUSE.$DIB_RELEASE.$ARCH | sha256sum --check - | ||
popd | ||
fi | ||
# Extract the base image (use --numeric-owner to avoid possible UID/GID mismatch | ||
# between image tarball and host OS) | ||
sudo tar -C $TARGET_ROOT --numeric-owner -xjf $DIB_IMAGE_CACHE/$BASE_IMAGE_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters