Merge "Remove fedora-atomic diskimage-builder element"

This commit is contained in:
Zuul 2018-09-11 15:03:56 +00:00 committed by Gerrit Code Review
commit d13957dc5e
7 changed files with 0 additions and 210 deletions

View File

@ -1,82 +0,0 @@
=============
fedora-atomic
=============
Generates a Fedora Atomic image based on a public deployed tree. This element has been tested under Debian, Ubuntu, CentOS and Fedora operating systems.
Pre-requisites to run diskimage-builder
---------------------------------------
For diskimage-builder to work, following packages need to be
present:
* python-dev
* build-essential
* python-pip
* kpartx
* python-lzma
* qemu-utils
* yum
* yum-utils
* python-yaml
* curl
For Debian/Ubuntu systems, use::
apt-get install python-dev build-essential python-pip kpartx python-lzma \
qemu-utils yum yum-utils python-yaml git curl
For CentOS and Fedora < 22, use::
yum install python-dev build-essential python-pip kpartx python-lzma qemu-utils yum yum-utils python-yaml curl
For Fedora >= 22, use::
dnf install python-devel @development-tools python-pip kpartx python-backports-lzma @virtualization yum yum-utils python-yaml curl
How to generate Fedora Atomic image
-----------------------------------
To generate an atomic image for Fedora 25 these commands can be
executed::
# Install diskimage-builder in virtual environment
virtualenv .
. bin/activate
pip install diskimage-builder
git clone https://git.openstack.org/openstack/magnum
git clone https://git.openstack.org/openstack/dib-utils.git
export PATH="${PWD}/dib-utils/bin:$PATH"
export ELEMENTS_PATH=$(python -c 'import os, diskimage_builder, pkg_resources;print(os.path.abspath(pkg_resources.resource_filename(diskimage_builder.__name__, "elements")))')
export ELEMENTS_PATH="${ELEMENTS_PATH}:${PWD}/magnum/magnum/drivers/common/image"
export DIB_RELEASE=25 # this can be switched to the desired version
export DIB_IMAGE_SIZE=2.5 # we need to give a bit more space to loopback device
disk-image-create fedora-atomic -o fedora-atomic
This element can consume already published trees, but you can use it
to consume your own generated trees. Documentation about creating own trees
can be found at `http://developers.redhat.com/blog/2015/01/08/creating-custom-atomic-trees-images-and-installers-part-1/ <http://developers.redhat.com/blog/2015/01/08/creating-custom-atomic-trees-images-and-installers-part-1/>`_
Environment Variables
---------------------
To properly reference the tree, the following env vars can be set:
FEDORA_ATOMIC_TREE_URL
:Required: Yes
:Description: Url for the public fedora-atomic tree to use. It can
reference to own published trees.
:Default: ``https://kojipkgs.fedoraproject.org/atomic/${DIB_RELEASE}/``
FEDORA_ATOMIC_TREE_REF
:Required: Yes
:Description: Reference of the tree to install.
:Default: ``$(curl ${FEDORA_ATOMIC_TREE_URL}/refs/heads/fedora-atomic/${DIB_RELEASE}/x86_64/docker-host)``
You can use the defaults or export your url and reference, like following::
export FEDORA_ATOMIC_TREE_URL="https://kojipkgs.fedoraproject.org/atomic/25/"
export FEDORA_ATOMIC_TREE_REF="$(curl https://kojipkgs.fedoraproject.org/atomic/25/refs/heads/fedora-atomic/25/x86_64/docker-host)"

View File

@ -1,4 +0,0 @@
fedora-minimal
growroot
package-installs
vm

View File

@ -1,2 +0,0 @@
export FEDORA_ATOMIC_TREE_URL=${FEDORA_ATOMIC_TREE_URL:-https://kojipkgs.fedoraproject.org/atomic/${DIB_RELEASE}/}
export FEDORA_ATOMIC_TREE_REF=${FEDORA_ATOMIC_TREE_REF:-$(curl ${FEDORA_ATOMIC_TREE_URL}/refs/heads/fedora-atomic/${DIB_RELEASE}/x86_64/docker-host)}

View File

@ -1,69 +0,0 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# generate ostree in root
cd /
ostree admin os-init fedora-atomic
ostree remote add --set=gpg-verify=false fedora-atomic ${FEDORA_ATOMIC_TREE_URL}
ostree pull fedora-atomic ${FEDORA_ATOMIC_TREE_REF}
ostree remote delete fedora-atomic
ostree admin deploy --os=fedora-atomic ${FEDORA_ATOMIC_TREE_REF} --karg-proc-cmdline --karg=selinux=0
# copy /etc/fstab to the deployed directory
SYSROOT=/ostree/deploy/fedora-atomic/deploy/${FEDORA_ATOMIC_TREE_REF}.0
cp /etc/fstab $SYSROOT/etc/
# need to find the generated images
DEPLOYED_DIRECTORY=$(find /boot/ostree -name fedora-atomic-* -type d)
DEPLOYED_ID=${DEPLOYED_DIRECTORY##*-}
INIT_IMAGE=$(find ${DEPLOYED_DIRECTORY} -name initramfs*.img)
VMLINUZ_IMAGE=$(find ${DEPLOYED_DIRECTORY} -name vmlinuz*)
# generate ostree boot
cat > /etc/grub.d/15_ostree <<EOF
cat <<EOL
menuentry 'Fedora ${DIB_RELEASE} (ostree)' --class gnu-linux --class gnu --class os --unrestricted "ostree-0-${DIB_IMAGE_ROOT_FS_UUID}" {
set gfxpayload=text
insmod gzio
insmod part_msdos
insmod ext2
search --no-floppy --set=root --label ${DIB_ROOT_LABEL}
linux16 ${VMLINUZ_IMAGE} root=LABEL=${DIB_ROOT_LABEL} ro nofb nomodeset vga=normal console=tty0 console=ttyS0,115200 no_timer_check rd.shell=0 ostree=/ostree/boot.1/fedora-atomic/${DEPLOYED_ID}/0
initrd16 ${INIT_IMAGE}
}
EOL
EOF
chmod +x /etc/grub.d/15_ostree
# start cloud-init on boot
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-config.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-config.service
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-final.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-final.service
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-init.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-init.service
ln -sf $SYSROOT/usr/lib/systemd/system/cloud-init-local.service $SYSROOT/etc/systemd/system/multi-user.target.wants/cloud-init-local.service
# disabled docker-storage-setup
rm $SYSROOT/etc/systemd/system/multi-user.target.wants/docker-storage-setup.service
# remove previous entry and generate config
rm /etc/grub.d/10_linux
grub2-mkconfig -o /boot/grub2/grub.cfg
# remove non usable images
rm -rf /boot/vmlinuz*
rm -rf /boot/initramfs*
# image cleanup
if [ $DIB_RELEASE -ge 22 ]; then
dnf -y remove dracut grubby kernel initscript man-pages redhat-lsb-core selinux-policy selinux-policy-targeted
dnf autoremove
dnf clean all
else
yum -y remove dracut grubby kernel initscript man-pages redhat-lsb-core selinux-policy selinux-policy-targeted
yum autoremove
yum clean all
fi

View File

@ -1,22 +0,0 @@
#!/bin/bash
# This script installs all needed dependencies to generate
# images using diskimage-builder. Please not it only has been
# tested on Ubuntu Trusty
set -eux
set -o pipefail
sudo apt-get update || true
sudo apt-get install -y \
debootstrap \
kpartx \
qemu-utils \
python-dev \
build-essential \
python-pip \
python-lzma \
yum \
yum-utils \
python-yaml \
curl

View File

@ -1,2 +0,0 @@
# Install packages needed for atomic
ostree:

View File

@ -1,29 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2016 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.
set -e
# check that image is valid
qemu-img check -q $1
# validate estimated size
FILESIZE=$(stat -c%s "$1")
MIN_SIZE=629145600 # 600MB
if [ $FILESIZE -lt $MIN_SIZE ] ; then
echo "Error: generated image size is lower than expected."
exit 1
fi