dropbox: prepare for Qt upgrade

This commit is contained in:
Thomas Tuegel 2015-09-27 12:14:51 -05:00
parent f998d502fc
commit d8d5e9868c
2 changed files with 59 additions and 31 deletions

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, makeDesktopItem, makeWrapper
{ stdenv, fetchurl, makeDesktopItem, makeWrapper, patchelf
, dbus_libs, gcc, glib, libdrm, libffi, libICE, libSM
, libX11, libXmu, ncurses, popt, qt5, zlib
, qtbase, qtdeclarative, qtwebkit
@ -33,20 +33,13 @@ let
"i686-linux" = "x86";
}."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
interpreter =
{
"x86_64-linux" = "ld-linux-x86-64.so.2";
"i686-linux" = "ld-linux.so.2";
}."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
# relative location where the dropbox libraries are stored
appdir = "opt/dropbox";
ldpath = stdenv.lib.makeSearchPath "lib"
[
dbus_libs gcc glib libdrm libffi libICE libSM libX11
libXmu ncurses popt qtbase qtdeclarative qtwebkit
zlib
dbus_libs gcc.cc glib libdrm libffi libICE libSM libX11 libXmu
ncurses popt qtbase qtdeclarative qtwebkit zlib
];
desktopItem = makeDesktopItem {
@ -59,24 +52,22 @@ let
};
in stdenv.mkDerivation {
name = "dropbox-${version}-bin";
name = "dropbox-${version}";
src = fetchurl {
name = "dropbox-${version}.tar.gz";
url = "https://dl-web.dropbox.com/u/17/dropbox-lnx.${arch}-${version}.tar.gz";
inherit sha256;
};
sourceRoot = ".";
sourceRoot = ".dropbox-dist";
patchPhase = ''
rm -f .dropbox-dist/dropboxd
'';
buildInputs = [ makeWrapper ];
buildInputs = [ makeWrapper patchelf ];
dontPatchELF = true; # patchelf invoked explicitly below
dontStrip = true; # already done
installPhase = ''
mkdir -p "$out/${appdir}"
cp -r ".dropbox-dist/dropbox-lnx.${arch}-${version}"/* "$out/${appdir}/"
cp -r "dropbox-lnx.${arch}-${version}"/* "$out/${appdir}/"
rm "$out/${appdir}/libdrm.so.2"
rm "$out/${appdir}/libffi.so.6"
@ -102,23 +93,56 @@ in stdenv.mkDerivation {
rm "$out/${appdir}/qt.conf"
rm -fr "$out/${appdir}/plugins"
find "$out/${appdir}" -type f -a -perm -0100 \
-print -exec patchelf --set-interpreter ${stdenv.glibc}/lib/${interpreter} {} \;
RPATH=${ldpath}:${gcc.cc}/lib:$out/${appdir}
echo "updating rpaths to: $RPATH"
find "$out/${appdir}" -type f -a -perm -0100 \
-print -exec patchelf --force-rpath --set-rpath "$RPATH" {} \;
mkdir -p "$out/share/applications"
cp "${desktopItem}/share/applications/"* $out/share/applications
mkdir -p "$out/bin"
makeWrapper "$out/${appdir}/dropbox" "$out/bin/dropbox" \
--prefix LD_LIBRARY_PATH : "${ldpath}"
mkdir -p "$out/share/icons"
ln -s "$out/${appdir}/images/hicolor" "$out/share/icons/hicolor"
mkdir -p "$out/bin"
RPATH="${ldpath}:$out/${appdir}"
makeWrapper "$out/${appdir}/dropbox" "$out/bin/dropbox" \
--prefix LD_LIBRARY_PATH : "$RPATH"
'';
fixupPhase = ''
INTERP=$(cat $NIX_CC/nix-support/dynamic-linker)
RPATH="${ldpath}:$out/${appdir}"
getType='s/ *Type: *\([A-Z]*\) (.*/\1/'
find "$out/${appdir}" -type f -a -perm -0100 -print | while read obj; do
dynamic=$(readelf -S "$obj" 2>/dev/null | grep "DYNAMIC" || true)
if [[ -n "$dynamic" ]]; then
type=$(readelf -h "$obj" 2>/dev/null | grep 'Type:' | sed -e "$getType")
if [[ "$type" == "EXEC" ]]; then
echo "patching interpreter path in $type $obj"
patchelf --set-interpreter "$INTERP" "$obj"
echo "patching RPATH in $type $obj"
oldRPATH=$(patchelf --print-rpath "$obj")
patchelf --set-rpath "''${oldRPATH:+$oldRPATH:}$RPATH" "$obj"
echo "shrinking RPATH in $type $obj"
patchelf --shrink-rpath "$obj"
elif [[ "$type" == "DYN" ]]; then
echo "patching RPATH in $type $obj"
oldRPATH=$(patchelf --print-rpath "$obj")
patchelf --set-rpath "''${oldRPATH:+$oldRPATH:}$RPATH" "$obj"
echo "shrinking RPATH in $type $obj"
patchelf --shrink-rpath "$obj"
else
echo "unknown ELF type \"$type\"; not patching $obj"
fi
fi
done
'';
meta = {

View File

@ -12681,7 +12681,11 @@ let
copy-com = callPackage ../applications/networking/copy-com { };
dropbox = qt5Libs.callPackage ../applications/networking/dropbox { };
dropbox = callPackage ../applications/networking/dropbox {
qtbase = qt5.base;
qtdeclarative = qt5.declarative;
qtwebkit = qt5.webkit;
};
dropbox-cli = callPackage ../applications/networking/dropbox-cli { };