[UWE] Notify internal API compatibility when installing rpm 98/238898/8
authorYoungsoo Choi <kenshin.choi@samsung.com>
Wed, 15 Jul 2020 08:22:52 +0000 (01:22 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Thu, 13 Aug 2020 08:34:59 +0000 (01:34 -0700)
Previously, the second and third versions haven't been used.
So, this removes the unused versions except for the wrtjs version
and newly adds {TPK_VERSION} and {INTERNAL_API_REVISION} like below:

{TPK_VERSION}.{INTERNAL_API_REVISION}.{WRTJS_VERSION}

The {TPK_VERSION} needs for deploying tpk file via app server.
The {INTERNAL_API_REVISION} needs to check API compatibility
between chromium-efl and wrtjs.

In addition, this notifies internal API version compatibility result
using the {INTERNAL_API_REVISION} when installing rpm file.
The internal API compatibility can be guaranteed only if the
{INTERNAL_API_REVISION} is same with chromium-efl.

'\033[32m' means green, '\033[31m' means red color, and '\033[m' means
end of the colors in the %pre script.

Change-Id: Ib00f4bf3523e9e022c388b838e8d96cc7089d599
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
packaging/wrtjs.spec

index 0659467..d97c6c3 100755 (executable)
@@ -1,6 +1,8 @@
 Name:       wrtjs
 Summary:    Javascript based Runtime for Tizen
-Version:    1.0.0
+# Version: {TPK_VERSION}.{INTERNAL_API_REVISION}.{WRTJS_VERSION}
+# The {INTERNAL_API_REVISION} is used to check compatibility with chromium-efl.
+Version:    1.0.1
 Release:    1
 Group:      Web Framework/Web Runtime
 License:    Apache-2.0
@@ -157,6 +159,42 @@ cp -r %{app_dir}/* %{buildroot}%{_resourcedir}/
   echo "No TPK generation"
 %endif
 
+%pre
+if (( $(rpm -qa | grep 'chromium-efl-[[:digit:]]' | wc -l) > 1 )); then
+  echo -e "\033[31m*****************************************************"
+  echo -e "Please remove chromium-efl rpm(s) except for one:\n"
+  rpm -qa | grep 'chromium-efl-[[:digit:]]'
+  echo -e "*****************************************************\033[m"
+  exit 1
+fi
+
+export CHROMIUM_REVISION=$(rpm -qa | grep chromium-efl | awk -F. '{print $2}')
+export WRTJS_REVISION=$(echo %{version} | awk -F. '{print $2}')
+if [[ "${CHROMIUM_REVISION}" == "" ]]; then
+  CHROMIUM_REVISION="not installed"
+fi
+
+echo -e "\033[32m*****************************************************"
+echo -e "* chromium-efl revision : ${CHROMIUM_REVISION}"
+echo -e "* wrtjs revision        : ${WRTJS_REVISION}"
+echo -e "*"
+if [[ "${CHROMIUM_REVISION}" == "not installed" ]] || \
+    (( ${CHROMIUM_REVISION} == ${WRTJS_REVISION} )); then
+  echo -e "* Succeeded to check rpm versions"
+  echo -e "*****************************************************\033[m"
+else
+  if (( ${CHROMIUM_REVISION} > ${WRTJS_REVISION} )); then
+    echo -e "\033[31m* You're trying to install too old wrtjs."
+    echo -e "* Please install wrtjs as revision $CHROMIUM_REVISION"
+    echo -e "* or"
+  else
+    echo -e "\033[31m* You have too old chromium-efl."
+  fi
+  echo -e "* please re-install chromium-efl as revision $WRTJS_REVISION first."
+  echo -e "*****************************************************\033[m"
+  exit 1
+fi
+
 %post
 
 %postun