dropbox: overwrite existing installation if our installer is newer

This commit is contained in:
Thomas Tuegel
2017-11-17 11:47:55 -06:00
parent eb85761137
commit 9ce215862e

View File

@@ -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"
'';