Blame ovirt-node-ng-image.spec.tmpl

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
3f16f8
Name:       $name
3f16f8
Version:    $version
3f16f8
Release:    $release%{?extra_release}
3f16f8
#if $epoch
3f16f8
Epoch:      $epoch
3f16f8
#end if
b84d9c
License:    GPLv2
b84d9c
Summary:    oVirt Node Next Image Update
b84d9c
URL:        http://www.ovirt.org/node/
35736d
Source:     $artifacts['.squashfs'][0]
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
b07851
ExclusiveArch: x86_64
b07851
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}
b07851
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.
3f16f8
local_sds=(\$(find / -xdev -path "*/dom_md/metadata" -not -empty | egrep -v ^/rhev/))
b84d9c
3f16f8
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:"
3f16f8
    for sd in "\${local_sds[@]}"; do
3f16f8
        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
3f16f8
export IMGBASED_IMAGE_UPDATE_RPM=\$(lsof -p \$PPID 2>/dev/null | grep image-update | awk '{print \$9}')
3f16f8
export MNTDIR="\$(mktemp -d)"
3f16f8
mount "%{_node_image_file}" "\$MNTDIR"
3f16f8
mount "\$MNTDIR"/LiveOS/rootfs.img "\$MNTDIR"
3f16f8
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
3f16f8
umount "\$MNTDIR"
3f16f8
umount "\$MNTDIR"
b84d9c
b84d9c
%files
b84d9c
%dir %{_node_image_dir}
b84d9c
%{_node_image_file}
b07851
b84d9c
b84d9c
%changelog
b84d9c
* Tue Sep 07 2021 Sandro Bonazzola <sbonazzo@redhat.com> - 4.5.0
b84d9c
- oVirt Node 4.5.0