about summary refs log tree commit diff
path: root/pkgs/applications/networking/dropbox
diff options
context:
space:
mode:
authorThomas Tuegel <ttuegel@mailbox.org>2017-11-17 11:47:55 -0600
committerThomas Tuegel <ttuegel@mailbox.org>2017-11-17 11:47:55 -0600
commit9ce215862e28823906b47f76d9b22eb41fa915f5 (patch)
treeb230a2d7fe4d21d534393a50b0376449e42f785e /pkgs/applications/networking/dropbox
parenteb857611378576f96022867a9fd15a7a841e518c (diff)
downloadnixlib-9ce215862e28823906b47f76d9b22eb41fa915f5.tar
nixlib-9ce215862e28823906b47f76d9b22eb41fa915f5.tar.gz
nixlib-9ce215862e28823906b47f76d9b22eb41fa915f5.tar.bz2
nixlib-9ce215862e28823906b47f76d9b22eb41fa915f5.tar.lz
nixlib-9ce215862e28823906b47f76d9b22eb41fa915f5.tar.xz
nixlib-9ce215862e28823906b47f76d9b22eb41fa915f5.tar.zst
nixlib-9ce215862e28823906b47f76d9b22eb41fa915f5.zip
dropbox: overwrite existing installation if our installer is newer
Diffstat (limited to 'pkgs/applications/networking/dropbox')
-rw-r--r--pkgs/applications/networking/dropbox/default.nix23
1 files changed, 21 insertions, 2 deletions
diff --git a/pkgs/applications/networking/dropbox/default.nix b/pkgs/applications/networking/dropbox/default.nix
index e60fd82ff016..27052454e7a4 100644
--- a/pkgs/applications/networking/dropbox/default.nix
+++ b/pkgs/applications/networking/dropbox/default.nix
@@ -35,7 +35,7 @@ buildFHSUserEnv {
   targetPkgs = pkgs: with pkgs; with xlibs; [
     libICE libSM libX11 libXcomposite libXdamage libXext libXfixes libXrender
     libXxf86vm libxcb xkeyboardconfig
-    curl dbus fontconfig freetype gcc glib gnutar libxml2 libxslt zlib
+    curl dbus fontconfig freetype gcc glib gnutar libxml2 libxslt procps zlib
   ];
 
   extraInstallCommands = ''
@@ -44,12 +44,31 @@ buildFHSUserEnv {
   '';
 
   runScript = writeScript "install-and-start-dropbox" ''
+    set -e
+
+    do_install=
     if ! [ -d "$HOME/.dropbox-dist" ]; then
+        do_install=1
+    else
+        installed_version=$(cat "$HOME/.dropbox-dist/VERSION")
+        latest_version=$(printf "${version}\n$installed_version\n" | sort -V | head -n 1)
+        if [ "x$installed_version" != "x$latest_version" ]; then
+            do_install=1
+        fi
+    fi
+
+    if [ -n "$do_install" ]; then
+        installer=$(mktemp)
         # Dropbox is not installed.
         # Download and unpack the client. If a newer version is available,
         # the client will update itself when run.
-        curl '${installer}' | tar -C "$HOME" -x -z
+        curl '${installer}' >"$installer"
+        pkill dropbox || true
+        rm -fr "$HOME/.dropbox-dist"
+        tar -C "$HOME" -x -z -f "$installer"
+        rm "$installer"
     fi
+
     exec "$HOME/.dropbox-dist/dropboxd"
   '';