Blame ovirt-node-ng-image.spec

b84d9c
%global	_node_image_dir /usr/share/%{name}/image/
b84d9c
%global	_node_image_file %{_node_image_dir}/%{name}-4.5.0-0.0.squashfs.img
b84d9c
b84d9c
# Disable compression, because the image is already compressed
b84d9c
%define _source_payload w0.gzdio
b84d9c
%define _binary_payload w0.gzdio
b84d9c
b84d9c
Name:       ovirt-node-ng-image-update
b84d9c
Version:    4.5.0
b84d9c
Release:    0.0
b84d9c
License:    GPLv2
b84d9c
Summary:    oVirt Node Next Image Update
b84d9c
URL:        http://www.ovirt.org/node/
b84d9c
Source0:    %{name}-4.5.0.tar.gz
b84d9c
Source1:    ovirt-node-ng-image.squashfs.img
b84d9c
Source2:    product.img
b84d9c
b84d9c
Requires:   imgbased >= 0.7.2
b84d9c
Obsoletes:  %{name}-placeholder < %{version}-%{release}
b84d9c
Provides:   %{name}-placeholder = %{version}-%{release}
b84d9c
Obsoletes:  ovirt-node-ng-image < %{version}-%{release}
b84d9c
Provides:   ovirt-node-ng-image = %{version}-%{release}
b84d9c
b84d9c
BuildArch:  noarch
b84d9c
BuildRequires: autoconf
b84d9c
BuildRequires: automake
b84d9c
b84d9c
%description
b84d9c
This package will update an  oVirt Node Next host with the new image.
b84d9c
b84d9c
%prep
b84d9c
%setup -q -n %{name}-4.5.0
b84d9c
b84d9c
%build
b84d9c
%configure
b84d9c
make %{?_smp_mflags}
b84d9c
b84d9c
%install
b84d9c
# Install the image
b84d9c
/usr/bin/install -d %{buildroot}/%{_node_image_dir}
b84d9c
/usr/bin/install -m 644 %{SOURCE1} %{buildroot}/%{_node_image_file}
b84d9c
/usr/bin/install -m 644 %{SOURCE2} %{buildroot}/%{_node_image_dir}/product.img
b84d9c
b84d9c
%pre
b84d9c
# Veriying avoiding installing over an active local storage,
b84d9c
# we use the following 'find' options:
b84d9c
#   -xdev, Don't descend directories on other filesystems, those are not considered local storages,
b84d9c
#          and are not affected by the installation
b84d9c
#   -not -empty, Skip empty metadata files as storage domains cannot have empty metadata file.
b84d9c
# we also exclude folders starting with /rhvh which holds symbolic links to block storage domains
b84d9c
# Or mounted file based storage domains, although these are likely skipped by -xdev.
b84d9c
local_sds=($(find / -xdev -path "*/dom_md/metadata" -not -empty | egrep -v ^/rhev/))
b84d9c
b84d9c
if [ "$local_sds" ]; then
b84d9c
    echo "Local storage domains were found on the same filesystem as / ! Please migrate the data to a new LV before upgrading, or you will lose the VMs"
b84d9c
    echo "See: https://bugzilla.redhat.com/show_bug.cgi?id=1550205#c3"
b84d9c
    echo "Storage domains were found in:"
b84d9c
    for sd in "${local_sds[@]}"; do
b84d9c
        echo -e "\t$(dirname $sd)"
b84d9c
    done
b84d9c
    exit 1
b84d9c
fi
b84d9c
b84d9c
%post
b84d9c
set -e
b84d9c
# Some magic to ensure that imgbase from
b84d9c
# the new image is used for updates
b84d9c
export IMGBASED_IMAGE_UPDATE_RPM=$(lsof -p $PPID 2>/dev/null | grep image-update | awk '{print $9}')
b84d9c
export MNTDIR="$(mktemp -d)"
b84d9c
mount "%{_node_image_file}" "$MNTDIR"
b84d9c
mount "$MNTDIR"/LiveOS/rootfs.img "$MNTDIR"
b84d9c
export PYTHONPATH=$(find $MNTDIR/usr/lib/python* -name imgbased -type d -exec dirname {} \; | sort | tail -1):$PYTHONPATH
b84d9c
imgbase --debug update --format liveimg %{_node_image_file} >> /var/log/imgbased.log 2>&1
b84d9c
umount "$MNTDIR"
b84d9c
umount "$MNTDIR"
b84d9c
b84d9c
%files
b84d9c
%dir %{_node_image_dir}
b84d9c
%{_node_image_file}
b84d9c
%{_node_image_dir}/product.img
b84d9c
b84d9c
%changelog
b84d9c
* Tue Sep 07 2021 Sandro Bonazzola <sbonazzo@redhat.com> - 4.5.0
b84d9c
- oVirt Node 4.5.0