ubsan-build-env package created 54/94854/3
authorSlava Barinov <v.barinov@samsung.com>
Tue, 30 Aug 2016 09:21:55 +0000 (12:21 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Wed, 16 Nov 2016 04:30:40 +0000 (20:30 -0800)
The package contains UBSAN_OPTIONS to force log writing to file and
script to pack logs into rpm package.

Change-Id: If902ab5e416ab4d273eb688f793c6f5a222c5af1
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
packaging/UBSAN_OPTIONS [new file with mode: 0644]
packaging/extract-ubsan-logs [new file with mode: 0755]
packaging/gcc-aarch64.spec
packaging/gcc-armv7l.spec
packaging/linaro-gcc.spec
packaging/macros.ubsan [new file with mode: 0644]

diff --git a/packaging/UBSAN_OPTIONS b/packaging/UBSAN_OPTIONS
new file mode 100644 (file)
index 0000000..0fbf7a7
--- /dev/null
@@ -0,0 +1 @@
+print_cmdline=true:log_path=/tmp/ubsan.log
\ No newline at end of file
diff --git a/packaging/extract-ubsan-logs b/packaging/extract-ubsan-logs
new file mode 100755 (executable)
index 0000000..d7a8ddf
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# /usr/lib/rpm/tizen/extract-ubsan-logs
+
+# If using normal root, avoid changing anything.
+if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
+        exit 0
+fi
+
+mkdir -p "$RPM_BUILD_ROOT/usr/share/ubsan"
+find "/tmp/" -name 'ubsan.log*' | xargs -I {} cp {} "$RPM_BUILD_ROOT/usr/share/ubsan/"
+find "$RPM_BUILD_ROOT/usr/share/ubsan/" -name 'ubsan.log*' | xargs -I {} sed -e "s#/.*rpmbuild/##" -i {}
+find "$RPM_BUILD_ROOT/usr/share/ubsan/" -name 'ubsan.log*' -exec rename ubsan ${RPM_PACKAGE_NAME}-ubsan {} \;
+
+# Avoid empty resulting RPMs: create a placeholder if there's no logs in directory.
+(find "$RPM_BUILD_ROOT/usr/share/ubsan/" -mindepth 1 -print -quit | grep -q .) || \
+    touch "$RPM_BUILD_ROOT/usr/share/ubsan/ubsan.log.empty"
index 7fe6cac..748778d 100644 (file)
@@ -89,6 +89,9 @@ Source17: ASAN_OPTIONS
 Source18: asan_symbolize.py
 Source19: LSAN_OPTIONS
 Source20: gcc.manifest
+Source21: UBSAN_OPTIONS
+Source22: macros.ubsan
+Source23: extract-ubsan-logs
 Group:         Development/Building
 Summary:       The GNU C Compiler and Support Files
 License:       GPL-3.0+
@@ -639,6 +642,18 @@ chmod a-w /usr/bin
 [ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-4.9.2/obj/gcc/
 /usr/bin/gcc-unforce-options
 
+%package -n ubsan-build-env
+Summary:    UBSan build environment
+Group:      System Environment
+Requires:   gcc
+Requires:   libubsan rpm
+
+%description -n ubsan-build-env
+UBSan build environment support files and scripts
+
+%post -n ubsan-build-env
+cat %{_rpmconfigdir}/macros.ubsan >> %{_rpmconfigdir}/tizen_macros
+
 %package -n lsan-force-options
 Summary:    Scripts to enable automatic package sanitization
 Group:      System Environment
@@ -930,6 +945,10 @@ tar -czf libsanitizer.tar.bz libsanitizer
 mkdir -p %{buildroot}/src
 mv -v libsanitizer.tar.bz %{buildroot}/src
 
+mkdir -p %{buildroot}/%{_rpmconfigdir}/tizen/
+install -m 0644 %{SOURCE21} %{buildroot}/
+install -m 0644 %{SOURCE22} %{buildroot}/%{_rpmconfigdir}/
+install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/
 }
 
 %files
@@ -1189,6 +1208,14 @@ mv -v libsanitizer.tar.bz %{buildroot}/src
 /LSAN_OPTIONS
 %endif
 
+%ifarch %ubsan_arch
+%files -n ubsan-build-env
+%defattr(-,root,root,-)
+/UBSAN_OPTIONS
+%{_rpmconfigdir}/macros.ubsan
+%{_rpmconfigdir}/tizen/extract-ubsan-logs
+%endif
+
 %files -n sanitizer-devel
 %defattr(-,root,root,-)
 %{_prefix}/bin/asan_symbolize.py
index 33f9e8b..5862872 100644 (file)
@@ -89,6 +89,9 @@ Source17: ASAN_OPTIONS
 Source18: asan_symbolize.py
 Source19: LSAN_OPTIONS
 Source20: gcc.manifest
+Source21: UBSAN_OPTIONS
+Source22: macros.ubsan
+Source23: extract-ubsan-logs
 Group:         Development/Building
 Summary:       The GNU C Compiler and Support Files
 License:       GPL-3.0+
@@ -639,6 +642,18 @@ chmod a-w /usr/bin
 [ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-4.9.2/obj/gcc/
 /usr/bin/gcc-unforce-options
 
+%package -n ubsan-build-env
+Summary:    UBSan build environment
+Group:      System Environment
+Requires:   gcc
+Requires:   libubsan rpm
+
+%description -n ubsan-build-env
+UBSan build environment support files and scripts
+
+%post -n ubsan-build-env
+cat %{_rpmconfigdir}/macros.ubsan >> %{_rpmconfigdir}/tizen_macros
+
 %package -n lsan-force-options
 Summary:    Scripts to enable automatic package sanitization
 Group:      System Environment
@@ -930,6 +945,10 @@ tar -czf libsanitizer.tar.bz libsanitizer
 mkdir -p %{buildroot}/src
 mv -v libsanitizer.tar.bz %{buildroot}/src
 
+mkdir -p %{buildroot}/%{_rpmconfigdir}/tizen/
+install -m 0644 %{SOURCE21} %{buildroot}/
+install -m 0644 %{SOURCE22} %{buildroot}/%{_rpmconfigdir}/
+install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/
 }
 
 %files
@@ -1189,6 +1208,14 @@ mv -v libsanitizer.tar.bz %{buildroot}/src
 /LSAN_OPTIONS
 %endif
 
+%ifarch %ubsan_arch
+%files -n ubsan-build-env
+%defattr(-,root,root,-)
+/UBSAN_OPTIONS
+%{_rpmconfigdir}/macros.ubsan
+%{_rpmconfigdir}/tizen/extract-ubsan-logs
+%endif
+
 %files -n sanitizer-devel
 %defattr(-,root,root,-)
 %{_prefix}/bin/asan_symbolize.py
index 330fcca..ad3cbf0 100644 (file)
@@ -86,6 +86,9 @@ Source17: ASAN_OPTIONS
 Source18: asan_symbolize.py
 Source19: LSAN_OPTIONS
 Source20: gcc.manifest
+Source21: UBSAN_OPTIONS
+Source22: macros.ubsan
+Source23: extract-ubsan-logs
 Group:         Development/Building
 Summary:       The GNU C Compiler and Support Files
 License:       GPL-3.0+
@@ -636,6 +639,18 @@ chmod a-w /usr/bin
 [ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-4.9.2/obj/gcc/
 /usr/bin/gcc-unforce-options
 
+%package -n ubsan-build-env
+Summary:    UBSan build environment
+Group:      System Environment
+Requires:   gcc
+Requires:   libubsan rpm
+
+%description -n ubsan-build-env
+UBSan build environment support files and scripts
+
+%post -n ubsan-build-env
+cat %{_rpmconfigdir}/macros.ubsan >> %{_rpmconfigdir}/tizen_macros
+
 %package -n lsan-force-options
 Summary:    Scripts to enable automatic package sanitization
 Group:      System Environment
@@ -927,6 +942,10 @@ tar -czf libsanitizer.tar.bz libsanitizer
 mkdir -p %{buildroot}/src
 mv -v libsanitizer.tar.bz %{buildroot}/src
 
+mkdir -p %{buildroot}/%{_rpmconfigdir}/tizen/
+install -m 0644 %{SOURCE21} %{buildroot}/
+install -m 0644 %{SOURCE22} %{buildroot}/%{_rpmconfigdir}/
+install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/
 }
 
 %files
@@ -1186,6 +1205,14 @@ mv -v libsanitizer.tar.bz %{buildroot}/src
 /LSAN_OPTIONS
 %endif
 
+%ifarch %ubsan_arch
+%files -n ubsan-build-env
+%defattr(-,root,root,-)
+/UBSAN_OPTIONS
+%{_rpmconfigdir}/macros.ubsan
+%{_rpmconfigdir}/tizen/extract-ubsan-logs
+%endif
+
 %files -n sanitizer-devel
 %defattr(-,root,root,-)
 %{_prefix}/bin/asan_symbolize.py
diff --git a/packaging/macros.ubsan b/packaging/macros.ubsan
new file mode 100644 (file)
index 0000000..f1f0fec
--- /dev/null
@@ -0,0 +1,39 @@
+# /etc/rpm/macros.ubsan
+
+%_enable_ubsan_packages 1
+
+%__ubsan_install_post   /usr/lib/rpm/tizen/extract-ubsan-logs
+
+# See original macro (before expansion) and correct lines after the first one.
+# Mine is from Fedora RPM macros, YMMV.
+%__spec_install_post\
+    %{?__ubsan_package:%{__ubsan_install_post}}\
+    %{?__debug_package:%{__debug_install_post}}\
+    %{__arch_install_post}\
+    %{__os_install_post}\
+%{nil}
+
+# Same goes here, see your original macro.
+%install %{?_enable_ubsan_packages:%{ubsan_package}}\
+%{?_enable_debug_packages:%{debug_package}}\
+%%install\
+LANG=C\
+export LANG\
+unset DISPLAY\
+rm -rf %{?buildroot:%{buildroot}} \
+mkdir -p %{?buildroot:%{buildroot}} \
+%{nil}
+
+#       Template for ubsan logs sub-package.
+%ubsan_package \
+%global __ubsan_package 1\
+%package ubsan-logs\
+Summary: UBSan logs for package %{name}\
+Group: Development/UBSan\
+AutoReqProv: 0\
+%description ubsan-logs\
+This package provides UBSan log files for package %{name}.\
+%files ubsan-logs\
+%defattr(-,root,root)\
+/usr/share/ubsan/*ubsan.log*\
+%{nil}