From 0a971b5a040540cd56789be3dc9143c1ade46935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Romildo=20Malaquias?= Date: Wed, 14 Nov 2018 12:31:14 -0200 Subject: [PATCH] deepin: add setup hook with helper functions --- pkgs/desktops/deepin/default.nix | 2 ++ pkgs/desktops/deepin/setup-hook.sh | 53 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 pkgs/desktops/deepin/setup-hook.sh diff --git a/pkgs/desktops/deepin/default.nix b/pkgs/desktops/deepin/default.nix index 4c0e44f6b72..68c1302a6be 100644 --- a/pkgs/desktops/deepin/default.nix +++ b/pkgs/desktops/deepin/default.nix @@ -2,6 +2,8 @@ let packages = self: with self; { + setupHook = ./setup-hook.sh; + updateScript = callPackage ./update.nix { }; dbus-factory = callPackage ./dbus-factory { }; diff --git a/pkgs/desktops/deepin/setup-hook.sh b/pkgs/desktops/deepin/setup-hook.sh new file mode 100755 index 00000000000..15fe5be1538 --- /dev/null +++ b/pkgs/desktops/deepin/setup-hook.sh @@ -0,0 +1,53 @@ +# Helper functions for deepin packaging + +searchHardCodedPaths() { + # looks for ocurrences of hard coded paths in given (current) + # directory and command invocations for the purpose of debugging a + # derivation + + local dir=$1 + + echo ----------- looking for command invocations + grep --color=always -r -E '\<(ExecStart|Exec|startDetached|execute|exec\.(Command|LookPath))\>' $dir || true + + echo ----------- looking for hard coded paths + grep --color=always -r -E '/(usr|bin|sbin|etc|var|opt)\>' $dir || true + + echo ----------- done +} + +fixPath() { + # Usage: + # + # fixPath + # + # replaces occurences of by in + # removing /usr from the start of if present + + local parentdir=$1 + local path=$2 + local newpath=$parentdir$(echo $path | sed "s,^/usr,,") + local files=("${@:3}") + echo ======= grep --color=always "${path}" "${files[@]}" + grep --color=always "${path}" "${files[@]}" + echo +++++++ sed -i -e "s,$path,$newpath,g" "${files[@]}" + sed -i -e "s,$path,$newpath,g" "${files[@]}" +} + +searchForUnresolvedDLL() { + # Usage: + # + # searchForUnresolvedDLL + # + # looks in for executables with unresolved dynamic library paths + + local dir="$1" + echo ======= Looking for executables with unresolved dynamic library dependencies + echo $dir + for f in $(find -L "$dir" -type f -executable); do + if (ldd $f | grep -q "not found"); then + echo $f + ldd $f | grep --color=always "not found" + fi + done +}