Replace scripts for asan-runtime-env package with files 33/195733/3 sandbox/mkashkarov/asan-runtime-env accepted/tizen/base/20190503.075137 submit/tizen_base/20190426.043255
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Mon, 17 Dec 2018 16:58:11 +0000 (19:58 +0300)
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Thu, 10 Jan 2019 07:28:26 +0000 (10:28 +0300)
Mic is now supporting %prepackages section which allows rpm installation
without executing scripts.

The main problem is that we want to place the same file /etc/ld.so.preload
with different context into different packages(asan/lsan-runtime-env) and
rpm doesn't let us do this easely:

http://lists.rpm.org/pipermail/rpm-list/2011-June/000911.html

Fix only *asan-runtime-env* package for now.

Change-Id: Ibbfc3cf2ca464022f997440161aaad3f4a56ac4c

packaging/gcc-contrib.spec

index e534890..185cb3a 100644 (file)
@@ -459,18 +459,6 @@ Requires:   libasan
 %description -n asan-runtime-env
 Asan runtime environment
 
-%post -n asan-runtime-env
-# Add /usr/lib/libasan.so to /etc/ld.so.preload
-[ -f /etc/ld.so.preload ] && mv -v /etc/ld.so.preload /etc/ld.so.preload.orig
-echo "%{libdir}/libasan.so" > /etc/ld.so.preload
-[ -f /etc/ld.so.preload.orig ] && cat /etc/ld.so.preload.orig >> /etc/ld.so.preload
-echo "%{asan_runtime_options}" > /ASAN_OPTIONS
-chsmack -a "_" /etc/ld.so.preload /ASAN_OPTIONS
-
-%preun -n asan-runtime-env
-# Restore /etc/ld.so.preload
-[ -f /etc/ld.so.preload.orig ] && mv -v /etc/ld.so.preload.orig /etc/ld.so.preload
-
 %package -n ubsan-runtime-env
 Summary:    UBSan runtime environment for target device
 Group:      Development/Libraries
@@ -552,9 +540,12 @@ echo "%{lsan_runtime_options}"  | tee LSAN_OPTIONS
 echo "%{tsan_runtime_options}"  | tee TSAN_OPTIONS
 echo "%{ubsan_runtime_options}" | tee UBSAN_OPTIONS
 
+echo "%{libdir}/libasan.so" | tee asan-runtime-ld.so.preload
+
 %install
 mkdir -p %buildroot%_prefix
 mkdir -p %buildroot%_prefix/bin
+mkdir -p %{buildroot}/etc/
 sed -e 's|GCC_LIBSUBDIR|%{libsubdir}|' -i %{SOURCE15}
 
 install -m 0755 %{SOURCE15} %{buildroot}%{_prefix}/bin/
@@ -562,6 +553,7 @@ install -m 0755 %{SOURCE16} %{buildroot}%{_prefix}/bin/
 install -m 0755 %{SOURCE17} %{buildroot}%{_prefix}/bin/
 
 install -m 0644 ASAN_OPTIONS %{buildroot}
+install -m 0644 asan-runtime-ld.so.preload %{buildroot}/etc/ld.so.preload
 
 %ifarch %lsan_arch
 install -m 0644 LSAN_OPTIONS %{buildroot}
@@ -641,6 +633,8 @@ install -m 0755 %{SOURCE25} %{buildroot}/%{_rpmconfigdir}/tizen/
 
 %files -n asan-runtime-env
 %defattr(-,root,root,-)
+/ASAN_OPTIONS
+/etc/ld.so.preload
 
 %ifarch %lsan_arch
 %files -n lsan-runtime-env