@@ -56,6 +56,11 @@ stdenv.mkDerivation rec {
5656 zlib ncurses libcap
5757 ];
5858
59+ postPatch = ''
60+ # Removes absolute paths in scripts
61+ sed -i 's,/sbin/,,g' ctdb/config/functions
62+ '';
63+
5964 enableParallelBuilding = true;
6065
6166 configureFlags = [
@@ -111,6 +116,19 @@ stdenv.mkDerivation rec {
111116
112117 stripAllList = [ "bin" "sbin" ];
113118
119+ postFixup = ''
120+ export SAMBA_LIBS="$(find $out -type f -name \*.so -exec dirname {} \; | sort | uniq)"
121+ read -r -d "" SCRIPT << EOF
122+ [ -z "\$SAMBA_LIBS" ] && exit 1;
123+ BIN='{}';
124+ OLD_LIBS="\$(patchelf --print-rpath "\$BIN" 2>/dev/null | tr ':' '\n')";
125+ ALL_LIBS="\$(echo -e "\$SAMBA_LIBS\n\$OLD_LIBS" | sort | uniq | tr '\n' ':')";
126+ patchelf --set-rpath "\$ALL_LIBS" "\$BIN" 2>/dev/null || exit $?;
127+ patchelf --shrink-rpath "\$BIN";
128+ EOF
129+ find $out -type f -exec $SHELL -c "$SCRIPT" \;
130+ '';
131+
114132 meta = with stdenv.lib; {
115133 homepage = http://www.samba.org/;
116134 description = "The standard Windows interoperability suite of programs for Linux and Unix";