[Kimchi-devel] [PATCH 1/4] Upgrade to Kimchi 2.0: Save previous objectstore file.

pvital at linux.vnet.ibm.com pvital at linux.vnet.ibm.com
Mon Oct 26 19:16:26 UTC 2015


From: Paulo Vital <pvital at linux.vnet.ibm.com>

With the new structure of Wok and Kimchi, the objectstore file is deleted
when performing a upgrade from Kimchi 1.5.1 (or previous versions) to the
new Wok and Kimchi 2.0 RPM's.

This patch checks the current version of Kimchi, and if <= 1.5.1 it saves
a copy of the current objectstore file in the beggining of Kimchi 2.0
installation and restore this file in the end of the process.

Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
---
 src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in | 16 ++++++++++++++++
 src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in   | 17 +++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in b/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
index d1e0046..fbc59c4 100644
--- a/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
+++ b/src/wok/plugins/kimchi/contrib/kimchi.spec.fedora.in
@@ -64,11 +64,27 @@ Web application to manage KVM/Qemu virtual machines
 %endif
 make
 
+%pre
+# Check if upgrading from Kimchi < 2 and copy the objectstore file.
+if [ $1 -eq 2 ]; then
+    cur_version=$(rpm -qi kimchi | grep Version | cut -d ":" -f2 | cut -d "." -f1)
+    if [ -e %{_sharedstatedir}/kimchi/objectstore ] && [ $cur_version -lt 2 ]; then
+        mkdir -p %{_tmppath}/kimchi
+        cp %{_sharedstatedir}/kimchi/objectstore %{_tmppath}/kimchi/
+    fi
+fi
 
 %install
 rm -rf %{buildroot}
 make DESTDIR=%{buildroot} install
 
+%posttrans
+# Copy backup'ed objectstore file to correct place.
+if [ -e %{_tmppath}/kimchi/objectstore ]; then
+    cp %{_tmppath}/kimchi/objectstore %{_sharedstatedir}/kimchi/
+    rm -rf %{_tmppath}/kimchi
+fi
+
 
 %clean
 rm -rf $RPM_BUILD_ROOT
diff --git a/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in b/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
index 640ade9..5346c17 100644
--- a/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
+++ b/src/wok/plugins/kimchi/contrib/kimchi.spec.suse.in
@@ -52,10 +52,27 @@ Web application to manage KVM/Qemu virtual machines
 %configure --with-spice-html5
 make
 
+%pre
+# Check if upgrading from Kimchi < 2 and copy the objectstore file.
+if [ $1 -eq 2 ]; then
+    cur_version=$(rpm -qi kimchi | grep Version | cut -d ":" -f2 | cut -d "." -f1)
+    if [ -e %{_var}/lib/kimchi/objectstore ] && [ $cur_version -lt 2 ]; then
+        mkdir -p %{_tmppath}/kimchi
+        cp %{_var}/lib/kimchi/objectstore %{_tmppath}/kimchi/
+    fi
+fi
+
 %install
 rm -rf %{buildroot}
 make DESTDIR=%{buildroot} install
 
+%posttrans
+# Copy backup'ed objectstore file to correct place.
+if [ -e %{_tmppath}/kimchi/objectstore ]; then
+    cp %{_tmppath}/kimchi/objectstore %{_var}/lib/kimchi/
+    rm -rf %{_tmppath}/kimchi
+fi
+
 
 %clean
 rm -rf $RPM_BUILD_ROOT
-- 
2.4.3




More information about the Kimchi-devel mailing list