[UWE] Notify internal API compatibility when installing rpm
[platform/framework/web/wrtjs.git] / packaging / wrtjs.spec
1 Name:       wrtjs
2 Summary:    Javascript based Runtime for Tizen
3 # Version: {TPK_VERSION}.{INTERNAL_API_REVISION}.{WRTJS_VERSION}
4 # The {INTERNAL_API_REVISION} is used to check compatibility with chromium-efl.
5 Version:    1.0.1
6 Release:    1
7 Group:      Web Framework/Web Runtime
8 License:    Apache-2.0
9 URL:        https://www.tizen.org
10 Source:     %{name}-%{version}.tar.gz
11
12 %define app_dir out/gen/app
13 %define crosswalk_extensions_service tizen-extensions-crosswalk-service
14
15 BuildRequires: pkgconfig(chromium-efl)
16
17 %if "%{?profile}" != "tv"
18 BuildRequires: ninja
19 BuildRequires: pkgconfig(dlog)
20 %endif
21
22 %if 0%{?_use_tpk}
23 %if "%{?profile}" == "tv"
24 BuildRequires: app-signer
25 %endif
26 BuildRequires: hash-signer, zip
27 BuildRequires: pkgconfig(libtzplatform-config)
28 %endif
29
30 %description
31 Web Runtime Engine based on Electron
32
33 %define _tizen_version %{tizen_version_major}%{tizen_version_minor}
34 %define _pkgid org.tizen.%{name}
35 %if 0%{?_use_tpk}
36   # The tv profile has a different tpk generation policy.
37   # 2 types(update, upgrade) of tpk can be generated and used simultaneously.
38   # If tpktype is not defined and tizen version is less than 6.0, upgrade type
39   # is generated by default.
40   %if "%{?profile}" == "tv"
41     %if "%{?tpktype}" == "upgrade" || (0%{!?tpktype:1} && %{_tizen_version} < 60)
42       %define _tpkid %{_pkgid}-upgrade
43     %endif
44   %endif
45   %if 0%{!?_tpkid:1}
46   %define _tpkid %{_pkgid}
47   %endif
48
49   # WRTjs TPK install directory
50   %global WRTJS_TPK_DIR /tmp
51   # Directory for WRTjs tizen application package
52   %global WRTJS_APP_DIR  %{TZ_SYS_RO_APP}/%{_tpkid}
53 %endif
54
55 %prep
56 %setup -q
57
58 %build
59 # The "_repository" flag was changed to "_vd_cfg_target_repository"
60 # since tizen 4.0 product tv.
61 %if "%{?profile}" == "tv"
62   %define _manifestname %{_pkgid}-vd
63   # The onemain branch haven't defined _vd_cfg_target_repository.
64   # So, this hijack code is added to set the repo_name to "MuseM".
65   # Remove this code when _vd_cfg_target_repository is defined in onemain.
66   %if "%{?_vd_cfg_target_repository}"
67     %define repo_name %{_vd_cfg_target_repository}
68   %else
69     %define repo_name MuseM
70   %endif
71 %else
72   %define _manifestname %{_pkgid}
73   %define repo_name %{_repository}
74 %endif
75
76 %if "%{?profile}" != "tv"
77   %define _outdir $PWD/out
78   ./build/tools/gn gen %{_outdir}
79   ninja -C %{_outdir} wrt-loader
80 %endif
81
82 ./build/tools/node ./node_modules/.bin/tsc
83 absolute_appdir=$PWD/%{app_dir}
84 (cd wrt_app/ && find . -type f ! -name '*.ts' -exec cp --parents {} ${absolute_appdir} \;)
85
86 %if 0%{?_use_tpk}
87   %if "%{_vd_cfg_chip_vendor}" != "EMUL" && "%{?profile}" == "tv"
88     %define __package_signing 1
89   %else
90     %define __package_signing 0
91   %endif
92   sed -e 's#@TIZEN_VERSION@#%{tizen_version_major}.%{tizen_version_minor}#g' \
93       -e 's#@WRTJS_VERSION@#%{version}#g' \
94       -e 's#@PACKAGE_ID@#%{_tpkid}#g' \
95       packaging/%{_manifestname}.xml.in \
96       > packaging/tizen-manifest-tpk.xml
97 %endif
98
99 %install
100 %ifarch armv7l
101   %define ARCHITECTURE armv7l
102 %endif
103 %ifarch aarch64
104   %define ARCHITECTURE aarch64
105 %endif
106 %ifarch i586 i686
107   %define ARCHITECTURE ix86
108 %endif
109 %ifarch x86_64
110   %define ARCHITECTURE x86_64
111 %endif
112 %define _resourcedir /usr/share/wrt/app
113 install -d %{buildroot}%{_bindir}
114 install -d %{buildroot}%{_datadir}/aul
115 install -d %{buildroot}%{_resourcedir}
116 install -d %{buildroot}%{WRTJS_APP_DIR}
117
118 %if 0%{?__package_signing}
119   install -m 0644 tizen/downloadable/vd_sign/author-signature.xml %{buildroot}%{WRTJS_APP_DIR}
120   install -m 0644 tizen/downloadable/vd_sign/signature1.xml %{buildroot}%{WRTJS_APP_DIR}
121 %else
122   %define tizen_sign 1
123   %define tizen_sign_base %{WRTJS_APP_DIR}
124   %define tizen_sign_level platform
125   %define tizen_author_sign 1
126   %define tizen_dist_sign 1
127 %endif
128
129 %if "%{?profile}" == "tv"
130   ln -s %{_bindir}/wrt %{buildroot}%{_bindir}/wrt-loader
131   %if "%{_vd_cfg_product_type}" != "LFD"
132     %if "%{_vd_cfg_platform_type}" == "FULL_SMART"
133       install -m 0644 packaging/wrt_tv.loader %{buildroot}%{_datadir}/aul/wrt.loader
134     %endif
135     %if "%{_vd_cfg_platform_type}" == "ENTRY_SMART"
136       install -m 0644 packaging/wrt_tv_lite.loader %{buildroot}%{_datadir}/aul/wrt.loader
137     %endif
138   %endif
139 %else
140   install -m 0755 %{_outdir}/wrt-loader %{buildroot}%{_bindir}
141   install -m 0644 packaging/wrt.loader %{buildroot}%{_datadir}/aul/
142 %endif
143
144 mkdir -p %{buildroot}%{_libdir}/%{crosswalk_extensions_service}
145 cp packaging/plugins.json %{buildroot}%{_libdir}/%{crosswalk_extensions_service}
146 cp -r %{app_dir}/* %{buildroot}%{_resourcedir}/
147
148 %if 0%{?_use_tpk}
149   # The debugsources.list is needed by __spec_install_post to generate tpk file
150   # but it's missing in the build process. So, the temporary file is touched.
151   touch debugsources.list
152   %define _tpk_file_name %{_tpkid}-%{version}-v%{tizen_version_major}.%{tizen_version_minor}.%{repo_name}.%{ARCHITECTURE}
153   %define __tpk_install_post \
154       tizen/build/build_tpk.sh %{buildroot}%{WRTJS_APP_DIR} %{WRTJS_TPK_DIR} %{_tpk_file_name} %{_tpkid} %{?profile}
155   %define __spec_install_post \
156       %{?__tpk_install_post} \
157       %{nil}
158 %else
159   echo "No TPK generation"
160 %endif
161
162 %pre
163 if (( $(rpm -qa | grep 'chromium-efl-[[:digit:]]' | wc -l) > 1 )); then
164   echo -e "\033[31m*****************************************************"
165   echo -e "Please remove chromium-efl rpm(s) except for one:\n"
166   rpm -qa | grep 'chromium-efl-[[:digit:]]'
167   echo -e "*****************************************************\033[m"
168   exit 1
169 fi
170
171 export CHROMIUM_REVISION=$(rpm -qa | grep chromium-efl | awk -F. '{print $2}')
172 export WRTJS_REVISION=$(echo %{version} | awk -F. '{print $2}')
173 if [[ "${CHROMIUM_REVISION}" == "" ]]; then
174   CHROMIUM_REVISION="not installed"
175 fi
176
177 echo -e "\033[32m*****************************************************"
178 echo -e "* chromium-efl revision : ${CHROMIUM_REVISION}"
179 echo -e "* wrtjs revision        : ${WRTJS_REVISION}"
180 echo -e "*"
181 if [[ "${CHROMIUM_REVISION}" == "not installed" ]] || \
182     (( ${CHROMIUM_REVISION} == ${WRTJS_REVISION} )); then
183   echo -e "* Succeeded to check rpm versions"
184   echo -e "*****************************************************\033[m"
185 else
186   if (( ${CHROMIUM_REVISION} > ${WRTJS_REVISION} )); then
187     echo -e "\033[31m* You're trying to install too old wrtjs."
188     echo -e "* Please install wrtjs as revision $CHROMIUM_REVISION"
189     echo -e "* or"
190   else
191     echo -e "\033[31m* You have too old chromium-efl."
192   fi
193   echo -e "* please re-install chromium-efl as revision $WRTJS_REVISION first."
194   echo -e "*****************************************************\033[m"
195   exit 1
196 fi
197
198 %post
199
200 %postun
201
202 %clean
203 rm -fr %{buildroot}
204
205 %files
206 %manifest packaging/wrtjs.manifest
207 %license LICENSE
208 %if "%{?tizen_profile_name}" != "tv"
209   %caps(cap_setgid,cap_sys_admin=ei) %{_bindir}/wrt-loader
210 %else
211   %{_bindir}/wrt-loader
212 %endif
213 %if "%{_vd_cfg_product_type}" != "LFD"
214   %{_datadir}/aul/wrt.loader
215 %endif
216 %{_libdir}/%{crosswalk_extensions_service}/plugins.json
217 %{_resourcedir}/*
218 %if 0%{?__package_signing}
219   %{WRTJS_APP_DIR}/author-signature.xml
220   %{WRTJS_APP_DIR}/signature1.xml
221 %endif