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