[gnome-build-meta/abderrahim/flatpak-sdk: 14/15] project.conf: import rules for stripping binaries from freedesktop-sdk



commit e54552f25d915819d16668c2b410120c2762f8fb
Author: Abderrahim Kitouni <akitouni gnome org>
Date:   Fri Aug 17 14:52:24 2018 +0100

    project.conf: import rules for stripping binaries from freedesktop-sdk
    
    This should be eventually done with buildstream includes but let's just
    copy-paste for now.

 project.conf | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
---
diff --git a/project.conf b/project.conf
index 470611d..9c6add9 100644
--- a/project.conf
+++ b/project.conf
@@ -207,6 +207,51 @@ variables:
     - arch == "arm":
         abi: "gnueabihf"
 
+  # This should eventually done with buildstream includes
+  strip-binaries: |
+    touch source-files
+    find "%{install-root}" -type f \
+      '(' -perm -111 -o -name '*.so*' \
+          -o -name '*.cmxs' -o -name '*.node' ')' \
+          -print0 | while read -r -d $'\0' file; do
+      read -n4 hdr <"${file}" || continue # check for elf header
+      if [ "$hdr" != "$(printf \\x7fELF)" ]; then
+        continue
+      fi
+      if objdump -j .gnu_debuglink -s "${file}" &>/dev/null; then
+        continue
+      fi
+      case "${file}" in
+        "%{install-root}%{debugdir}/"*)
+          continue
+          ;;
+        *)
+          ;;
+      esac
+      realpath="$(realpath -s --relative-to="%{install-root}" "${file}")"
+      debugfile="%{install-root}%{debugdir}/${realpath}.debug"
+      mkdir -p "$(dirname "$debugfile")"
+      debugedit -i --list-file=source-files.part --base-dir="%{build-root}" 
--dest-dir="%{debugdir}/source/%{element-name}" "${file}"
+      cat source-files.part >>source-files
+      objcopy %{objcopy-extract-args} "${file}" "$debugfile"
+      chmod 644 "$debugfile"
+      mode="$(stat -c 0%a "${file}")"
+      [ -w "${file}" ] || chmod +w "${file}"
+      strip %{strip-args} "${file}"
+      objcopy %{objcopy-link-args} "$debugfile" "${file}"
+      chmod "${mode}" "${file}"
+    done
+    sort -zu  <source-files | while read -r -d $'\0' source; do
+      dst="%{install-root}%{debugdir}/source/%{element-name}/${source}"
+      src="%{build-root}/${source}"
+      if [ -d "${src}" ]; then
+        install -m0755 -d "${dst}"
+        continue
+      fi
+      [ -f "${src}" ] || continue
+      install -m0644 -D "${src}" "${dst}"
+    done
+
 plugins:
 - origin: local
   path: plugins


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]