Merge "New elements replace-partition(-redhat)"
This commit is contained in:
commit
6632aaa80e
@ -27,6 +27,7 @@ uuid-runtime [platform:dpkg]
|
||||
debootstrap [platform:dpkg]
|
||||
zstd [platform:dpkg]
|
||||
procps [platform:dpkg]
|
||||
libguestfs-tools [platform:dpkg]
|
||||
# Version/distro specific items
|
||||
python-lzma [platform:ubuntu-bionic platform:debian-buster]
|
||||
yum-utils [platform:ubuntu-bionic platform:debian-buster]
|
||||
@ -34,6 +35,7 @@ dnf [platform:dpkg !platform:debian-buster !platform:ubuntu-trusty !platform:ubu
|
||||
|
||||
# centos/fedora
|
||||
qemu-img [platform:redhat]
|
||||
libguestfs [platform:redhat]
|
||||
policycoreutils-python [platform:rhel-7 platform:centos-7]
|
||||
policycoreutils-python-utils [platform:fedora platform:rhel-8 platform:centos-8]
|
||||
procps-ng [platform:redhat]
|
||||
|
@ -0,0 +1,22 @@
|
||||
========================
|
||||
replace-partition-redhat
|
||||
========================
|
||||
|
||||
A redhat family specific version of the ``replace-partition`` element.
|
||||
|
||||
A standalone element which consumes a base image which was created with
|
||||
``diskimage-builder`` and rebuilds it without making any packaging changes.
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
The following will use ``./my-dib-image.qcow2`` as the base image and create a
|
||||
new image ``my-dib-image-custom.qcow2`` with the partition layout defined in
|
||||
``./block-device-custom.yaml``:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export DISTRO_NAME=rhel
|
||||
export DIB_BLOCK_DEVICE_CONFIG=file://./block-device-custom.yaml
|
||||
export DIB_LOCAL_IMAGE=./my-dib-image.qcow2
|
||||
disk-image-create -x -a x86_64 -o my-dib-image-custom.qcow2 --image-size 6GiB replace-partition-redhat
|
@ -0,0 +1,2 @@
|
||||
replace-partition
|
||||
selinux-fixfiles-restore
|
@ -0,0 +1,12 @@
|
||||
if [ -z "${DISTRO_NAME:-}" ]; then
|
||||
echo "DISTRO_NAME is not set! Can not continue"
|
||||
exit 1
|
||||
fi
|
||||
export DIB_RELEASE=${DIB_RELEASE:-9}
|
||||
if [[ $DISTRO_NAME =~ "rhel" ]]; then
|
||||
export EFI_BOOT_DIR="EFI/redhat"
|
||||
else
|
||||
export EFI_BOOT_DIR="EFI/$DISTRO_NAME"
|
||||
fi
|
||||
export DIB_BLOCK_DEVICE=efi
|
||||
export DIB_INIT_SYSTEM=systemd
|
31
diskimage_builder/elements/replace-partition/README.rst
Normal file
31
diskimage_builder/elements/replace-partition/README.rst
Normal file
@ -0,0 +1,31 @@
|
||||
=================
|
||||
replace-partition
|
||||
=================
|
||||
|
||||
A standalone element which consumes a base image which was created with
|
||||
``diskimage-builder`` and rebuilds it without making any packaging changes. This
|
||||
allows the image contents to be copied to a new block device layout. Use cases
|
||||
for this element include:
|
||||
|
||||
* Rebuilding a whole-disk image with a different partition layout by setting
|
||||
``DIB_BLOCK_DEVICE_CONFIG``
|
||||
* Rebuilding a whole-disk image with the same partitions but with the sector
|
||||
size increased to 4096 bytes
|
||||
|
||||
See element ``replace-partition-redhat`` for a full example of how to use this element
|
||||
|
||||
Arguments
|
||||
=========
|
||||
|
||||
The following arguments are mandatory and should be set to the correct values as
|
||||
for other distro elements:
|
||||
|
||||
* ``DISTRO_NAME``
|
||||
* ``DIB_RELEASE``
|
||||
* ``EFI_BOOT_DIR``
|
||||
* ``DIB_INIT_SYSTEM``
|
||||
* ``DIB_BLOCK_DEVICE``
|
||||
* ``DIB_LOCAL_IMAGE``
|
||||
|
||||
``DIB_SOURCE_BLOCK_SIZE`` can be set to 4096 if the base image
|
||||
``DIB_LOCAL_IMAGE`` was created with a 4096 byte sector size.
|
@ -0,0 +1 @@
|
||||
bootloader
|
@ -0,0 +1 @@
|
||||
operating-system
|
@ -0,0 +1,25 @@
|
||||
if [ -z "${DISTRO_NAME:-}" ]; then
|
||||
echo "DISTRO_NAME is not set! Can not continue"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${DIB_RELEASE:-}" ]; then
|
||||
echo "DIB_RELEASE is not set! Can not continue"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${EFI_BOOT_DIR:-}" ]; then
|
||||
echo "EFI_BOOT_DIR is not set! Can not continue"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${DIB_INIT_SYSTEM:-}" ]; then
|
||||
echo "DIB_INIT_SYSTEM is not set! Can not continue"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${DIB_BLOCK_DEVICE:-}" ]; then
|
||||
echo "DIB_BLOCK_DEVICE is not set! Can not continue"
|
||||
exit 1
|
||||
fi
|
||||
export DIB_SKIP_GRUB_PACKAGE_INSTALL=True
|
||||
export DIB_SKIP_BASE_PACKAGE_INSTALL=1
|
||||
export DIB_AVOID_PACKAGES_UPDATE=1
|
||||
export DIB_IMAGE_EXTRACT_GUESTFISH=True
|
||||
export DIB_SOURCE_BLOCK_SIZE=512
|
26
diskimage_builder/elements/replace-partition/root.d/10-local-image-extract
Executable file
26
diskimage_builder/elements/replace-partition/root.d/10-local-image-extract
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
[ -n "$TARGET_ROOT" ]
|
||||
|
||||
DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""}
|
||||
|
||||
if [ -n "$DIB_LOCAL_IMAGE" ]; then
|
||||
IMAGE_LOCATION=$DIB_LOCAL_IMAGE
|
||||
# No need to copy a local image into the cache directory, so just specify
|
||||
# the cached path as the original path.
|
||||
CACHED_IMAGE=$IMAGE_LOCATION
|
||||
else
|
||||
echo "DIB_LOCAL_IMAGE is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
guestfish -v -x -i --blocksize=$DIB_SOURCE_BLOCK_SIZE -a $CACHED_IMAGE <<EOF
|
||||
tar-out / - numericowner:true xattrs:true | sudo tar -C $TARGET_ROOT --numeric-owner --xattrs --xattrs-include='*' --xattrs-exclude='security.selinux' -xf -
|
||||
EOF
|
||||
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new element ``replace-partition`` has been added which allows a
|
||||
diskimage-builder built image to be used as the base image so that it can be
|
||||
copied to a new partition layout. This allows the content to be copied from
|
||||
one image to a new one without making any package changes. The element
|
||||
``replace-partition-redhat`` has a documented example for redhat family
|
||||
images.
|
Loading…
Reference in New Issue
Block a user