e605fba042c43babb99994897ac2a4c8ccc3473b
[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.1.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 _appdir %TZ_SYS_RO_APP
13 %define _bindir %TZ_SYS_BIN
14 %define _xmldir %TZ_SYS_RO_PACKAGES
15 %define app_dir out/gen/app
16 %define crosswalk_extensions_service tizen-extensions-crosswalk-service
17 # The d2d is public feature
18 %if "%{?profile}" != "wearable" && "%{?_with_da_profile}" != "1"
19   %define _use_d2d 1
20 %endif
21
22 # The nmt is public feature
23 # The category is public feature
24 %if "%{?profile}" != "tv" && "%{?profile}" != "wearable" && "%{?_with_da_profile}" != "1"
25 %ifarch armv7l
26   %define _use_nmt 0
27 %endif
28   %define _use_category 0
29 %endif
30
31 BuildRequires: pkgconfig(chromium-efl)
32
33 %if "%{?profile}" != "tv" || 0%{?_use_nmt} || 0%{?_use_category}
34 BuildRequires: ninja
35 BuildRequires: pkgconfig(dlog)
36 %endif
37
38 %if "%{?profile}" == "tv"
39 BuildRequires: app-signer
40 %if 0%{?_use_d2d}
41 BuildRequires: squashfs
42 %endif
43 %endif
44 BuildRequires: hash-signer, zip
45 BuildRequires: pkgconfig(libtzplatform-config)
46
47 %description
48 Web Runtime Engine based on Electron
49
50 %define _tizen_version %{tizen_version_major}%{tizen_version_minor}
51 %define _pkgid org.tizen.%{name}
52 %define __pkgid %{_pkgid}
53 %if 0%{?_use_tpk}
54   # The tv profile has a different tpk generation policy.
55   # 2 types(update, upgrade) of tpk can be generated and used simultaneously.
56   # If tpktype is not defined and tizen version is less than 6.0, upgrade type
57   # is generated by default.
58   %if "%{?profile}" == "tv"
59     %if "%{?tpktype}" == "upgrade" || (0%{!?tpktype:1} && %{_tizen_version} < 60)
60       %define __pkgid %{_pkgid}-upgrade
61     %endif
62   %endif
63 %endif
64 # Generated app directory
65 %global GENERATED_APP_DIR /tmp/%{name}
66 # Directory for WRTjs tizen application package
67 %global WRTJS_APP_DIR %{TZ_SYS_RO_APP}/%{__pkgid}
68
69 %prep
70 %setup -q
71
72 %build
73 # The "_repository" flag was changed to "_vd_cfg_target_repository"
74 # since tizen 4.0 product tv.
75 %if "%{?profile}" == "tv"
76   %define _manifestname %{_pkgid}-vd
77   # The onemain branch haven't defined _vd_cfg_target_repository.
78   # So, this hijack code is added to set the repo_name to "MuseM".
79   # Remove this code when _vd_cfg_target_repository is defined in onemain.
80   %if "%{?_vd_cfg_target_repository}"
81     %define repo_name %{_vd_cfg_target_repository}
82   %else
83     %define repo_name MuseM
84   %endif
85 %else
86   %define _manifestname %{_pkgid}
87   %define repo_name %{_repository}
88 %endif
89
90 %if "%{?profile}" != "tv"
91   %define _outdir $PWD/out
92   ./build/tools/gn gen %{_outdir}
93   ninja -C %{_outdir} wrt-loader
94 %endif
95
96 %if 0%{?_use_nmt} || 0%{?_use_category}
97 %if "%{?profile}" == "tv"
98   %define _outdir $PWD/out
99   ./build/tools/gn gen %{_outdir}
100 %endif
101 %if 0%{?_use_nmt}
102   ninja -C %{_outdir} nmt
103 %endif
104 %if 0%{?_use_category}
105   ninja -C %{_outdir} category
106 %endif
107 %endif
108
109 ./build/tools/node ./node_modules/.bin/tsc
110 absolute_appdir=$PWD/%{app_dir}
111 (cd wrt_app/ && find . -type f ! -name '*.ts' -exec cp --parents {} ${absolute_appdir} \;)
112
113 %if 0%{?_use_tpk}
114   %if "%{_vd_cfg_chip_vendor}" != "EMUL" && "%{?profile}" == "tv"
115     %define __package_signing 1
116   %else
117     %define __package_signing 0
118   %endif
119   sed -e 's#@TIZEN_VERSION@#%{tizen_version_major}.%{tizen_version_minor}#g' \
120       -e 's#@WRTJS_VERSION@#%{version}#g' \
121       -e 's#@PACKAGE_ID@#%{__pkgid}#g' \
122       packaging/%{_manifestname}.xml.in \
123       > packaging/tizen-manifest-tpk.xml
124 %endif
125
126 %if 0%{?_use_d2d_offload}
127   # Create a self-signed certificates for signaling server
128   openssl genrsa -out key.pem 2048
129   openssl req -new -x509 -nodes -key key.pem -out cert.pem \
130       -subj "/CN=localhost" -days 9999
131 %endif
132
133 %install
134 %ifarch armv7l
135   %define ARCHITECTURE armv7l
136 %endif
137 %ifarch aarch64
138   %define ARCHITECTURE aarch64
139 %endif
140 %ifarch i586 i686
141   %define ARCHITECTURE ix86
142 %endif
143 %ifarch x86_64
144   %define ARCHITECTURE x86_64
145 %endif
146
147 %define _resourcedir /usr/share/wrt/app
148 install -d %{GENERATED_APP_DIR}
149 install -d %{buildroot}%{_bindir}
150 install -d %{buildroot}%{_datadir}/aul
151 install -d %{buildroot}%{_resourcedir}
152 install -d %{buildroot}%{WRTJS_APP_DIR}
153
154 mkdir -p %{buildroot}%{_datadir}/wrtjs
155 echo %{version} > %{buildroot}%{_datadir}/wrtjs/version
156 %if 0%{?_use_tpk}
157   %if 0%{?__package_signing}
158     install -m 0644 tizen/downloadable/vd_sign/author-signature.xml %{buildroot}%{WRTJS_APP_DIR}
159     install -m 0644 tizen/downloadable/vd_sign/signature1.xml %{buildroot}%{WRTJS_APP_DIR}
160   %else
161     %define tizen_sign 1
162     %define tizen_sign_base %{WRTJS_APP_DIR}
163     %define tizen_sign_level platform
164     %define tizen_author_sign 1
165     %define tizen_dist_sign 1
166   %endif
167 %endif
168
169 %if "%{?profile}" == "tv"
170   ln -s %{_bindir}/wrt %{buildroot}%{_bindir}/wrt-loader
171   %if "%{_vd_cfg_product_type}" != "LFD"
172     install -m 0644 packaging/wrt_tv.loader %{buildroot}%{_datadir}/aul/wrt.loader
173   %endif
174 %else
175   install -m 0755 %{_outdir}/wrt-loader %{buildroot}%{_bindir}
176   install -m 0644 packaging/wrt.loader %{buildroot}%{_datadir}/aul/
177 %endif
178
179 mkdir -p %{buildroot}%{_libdir}/%{crosswalk_extensions_service}
180 cp packaging/plugins.json %{buildroot}%{_libdir}/%{crosswalk_extensions_service}
181 cp -r %{app_dir}/* %{buildroot}%{_resourcedir}/
182
183 %if 0%{?_use_tpk}
184   # The debugsources.list is needed by __spec_install_post to generate tpk file
185   # but it's missing in the build process. So, the temporary file is touched.
186   touch debugsources.list
187   %define _tpk_file_name %{__pkgid}-%{version}-v%{tizen_version_major}.%{tizen_version_minor}.%{repo_name}.%{ARCHITECTURE}.tpk
188   %define __tpk_install_post \
189       tizen/build/build_app.sh %{GENERATED_APP_DIR} wrtjs_tpk_root %{_tpk_file_name} tpk platform %{?profile}
190   %define __spec_install_post \
191       %{?__tpk_install_post} \
192       %{nil}
193 %else
194   echo "No TPK generation"
195 %endif
196
197 %if 0%{?_use_d2d}
198 %if "%{?tizen_profile_name}" == "tv"
199   %define _d2d_app_file_name device_home.tmg
200   %define _d2d_app_extension tmg
201   %define _d2d_install_path %{TZ_SYS_DATA}/device_home
202   install -m 0644 packaging/config_tv.xml.in device_home/config.xml
203 %else
204   %define _d2d_app_file_name device_home.wgt
205   %define _d2d_app_extension wgt
206   %define _d2d_install_path %{_appdir}/.preload-rw-wgt
207   install -m 0644 packaging/config.xml.in device_home/config.xml
208 %endif
209 %if 0%{?_use_d2d_offload}
210   install -m 0644 key.pem device_home/signaling_server/gen/
211   install -m 0644 cert.pem device_home/signaling_server/gen/
212 %endif
213   tizen/build/build_app.sh %{buildroot} device_home %{_d2d_app_file_name} %{_d2d_app_extension} platform %{?profile}
214
215   install -d %{buildroot}/%{_d2d_install_path}
216   install -m 0755 %{buildroot}/%{_d2d_app_file_name} %{buildroot}/%{_d2d_install_path}/
217   rm -f %{buildroot}/%{_d2d_app_file_name}
218 %endif
219
220 %if 0%{?_use_nmt}
221   install -m 0644 wrt_feature/nmt_service/node_modules/nmt/lib/%{ARCHITECTURE}/*    "%{buildroot}"%{_libdir}/
222   install -d %{buildroot}%{_datadir}/wrt/feature/nmt_service/node_modules
223   install -m 0644 "%{_outdir}"/libnmt.node                            %{buildroot}%{_datadir}/wrt/feature/nmt_service/node_modules/
224 %endif
225
226 %if 0%{?_use_category}
227   install -d %{buildroot}%{_datadir}/wrt/feature/category_service/node_modules
228   install -d %{buildroot}%{_datadir}/wrt/feature/category_service/data
229   install -m 0644 "%{_outdir}"/libcategory.node                  %{buildroot}%{_datadir}/wrt/feature/category_service/node_modules/
230   install -m 0644 wrt_feature/category_service/data/*        %{buildroot}%{_datadir}/wrt/feature/category_service/data/
231 %endif
232
233 %pre
234 export CHROMIUM_REVISION=
235 if [ -f "%{_datadir}/chromium-efl/version" ]; then
236   CHROMIUM_REVISION=$(cat  %{_datadir}/chromium-efl/version | awk -F. '{print $2}')
237 else
238   CHROMIUM_REVISION="not installed"
239 fi
240 export WRTJS_REVISION=$(echo %{version} | awk -F. '{print $2}')
241
242 echo -e "\033[32m*****************************************************"
243 echo -e "* chromium-efl revision : ${CHROMIUM_REVISION}"
244 echo -e "* wrtjs revision        : ${WRTJS_REVISION}"
245 echo -e "*"
246 if [[ "${CHROMIUM_REVISION}" == "not installed" ]] || \
247     (( ${CHROMIUM_REVISION} == ${WRTJS_REVISION} )); then
248   echo -e "* Succeeded to check rpm versions"
249   echo -e "*****************************************************\033[m"
250 else
251   if (( ${CHROMIUM_REVISION} > ${WRTJS_REVISION} )); then
252     echo -e "\033[31m* You're trying to install too old wrtjs."
253     echo -e "* Please install wrtjs as revision $CHROMIUM_REVISION"
254     echo -e "* or"
255   else
256     echo -e "\033[31m* You have too old chromium-efl."
257   fi
258   echo -e "* please re-install chromium-efl as revision $WRTJS_REVISION first."
259   echo -e "*****************************************************\033[m"
260   exit 1
261 fi
262
263 %post
264 %if "%{?_local_build}" == "1"
265 %if 0%{?_use_d2d}
266   pkgcmd -un 9z6IujVul3
267   pkgcmd -i -t wgt -p %{_d2d_install_path}/%{_d2d_app_file_name}
268 %endif
269 %endif
270
271 %postun
272
273 %clean
274 rm -fr %{buildroot}
275
276 %files
277 %manifest packaging/wrtjs.manifest
278 %license LICENSE
279 %if 0%{?_use_d2d}
280   %{_d2d_install_path}/%{_d2d_app_file_name}
281 %endif
282 %if "%{?tizen_profile_name}" != "tv"
283   %caps(cap_setgid,cap_sys_admin=ei) %{_bindir}/wrt-loader
284 %else
285   %{_bindir}/wrt-loader
286 %endif
287 %if "%{_vd_cfg_product_type}" != "LFD"
288   %{_datadir}/aul/wrt.loader
289 %endif
290 %{_datadir}/wrtjs/version
291 %{_libdir}/%{crosswalk_extensions_service}/plugins.json
292
293 %if 0%{?_use_nmt}
294   %{_libdir}/libmanager.so
295   %{_libdir}/libsentencepiece.so.0
296   %{_libdir}/libsr_odnmt.so
297   %{_libdir}/libsrcb_bpe.so
298   %{_libdir}/libsrcb_langid.so
299   %{_libdir}/libtransformer.so
300   %{_datadir}/wrt/feature/nmt_service/node_modules/libnmt.node
301 %endif
302
303 %if 0%{?_use_category}
304   %{_datadir}/wrt/feature/category_service/node_modules/libcategory.node
305   %{_datadir}/wrt/feature/category_service/data/*
306 %endif
307
308 %{_resourcedir}/*
309 %if 0%{?__package_signing}
310   %{WRTJS_APP_DIR}/author-signature.xml
311   %{WRTJS_APP_DIR}/signature1.xml
312 %endif