summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authoradisbladis <adisbladis@gmail.com>2018-01-15 09:49:52 +0800
committerGitHub <noreply@github.com>2018-01-15 09:49:52 +0800
commitebc090c1259238f9f70b7f0ae0294105d8662334 (patch)
treea5e2d21a273741fa6f2348a90cd62a829b1145d5 /pkgs
parent9af3b9d7b284ca0e9d504eb06c0d83640b9404b8 (diff)
parent0e4fd35147a5efb16c08e927ef03c36f5a75f348 (diff)
downloadnixpkgs-ebc090c1259238f9f70b7f0ae0294105d8662334.tar
nixpkgs-ebc090c1259238f9f70b7f0ae0294105d8662334.tar.gz
nixpkgs-ebc090c1259238f9f70b7f0ae0294105d8662334.tar.bz2
nixpkgs-ebc090c1259238f9f70b7f0ae0294105d8662334.tar.lz
nixpkgs-ebc090c1259238f9f70b7f0ae0294105d8662334.tar.xz
nixpkgs-ebc090c1259238f9f70b7f0ae0294105d8662334.tar.zst
nixpkgs-ebc090c1259238f9f70b7f0ae0294105d8662334.zip
Merge pull request #33867 from dtzWill/update/mendeley-1.17.13-and-update-checker
mendeley: add update script, use it, add myself as maintainer
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/office/mendeley/default.nix17
-rw-r--r--pkgs/applications/office/mendeley/update.nix60
2 files changed, 71 insertions, 6 deletions
diff --git a/pkgs/applications/office/mendeley/default.nix b/pkgs/applications/office/mendeley/default.nix
index c2b6dc710ba..6a741e0ab9e 100644
--- a/pkgs/applications/office/mendeley/default.nix
+++ b/pkgs/applications/office/mendeley/default.nix
@@ -31,6 +31,8 @@
 # will leave entries on your system after uninstalling mendeley.
 # (they can be removed by running '$out/bin/install-mendeley-link-handler.sh -u')
 , autorunLinkHandler ? true
+# Update script
+, writeScript
 }:
 
 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
@@ -43,14 +45,14 @@ let
     then "i386"
     else "amd64";
 
-  shortVersion = "1.17.12-stable";
+  shortVersion = "1.17.13-stable";
 
   version = "${shortVersion}_${arch}";
 
   url = "http://desktop-download.mendeley.com/download/apt/pool/main/m/mendeleydesktop/mendeleydesktop_${version}.deb";
   sha256 = if stdenv.system == arch32
-    then "09n910ny8k103g1v8m19f9n827l2y0kmz79cwgy95k6acf2rkc2x"
-    else "11z65mj1a2rw6cwfarl8r1vzpcz4ww5mgvd5fyv31l60mbmnqkap";
+    then "0q4x62k00whmq8lskphpcxc610cvclxzcr5k0v7pxjxs9sx5yx43"
+    else "01ylyily1hip35z0d4qkdpbzp5yn4r015psc5773xsqlgrnlwjm3";
 
   deps = [
     qtbase
@@ -133,11 +135,14 @@ stdenv.mkDerivation {
   dontStrip = true;
   dontPatchElf = true;
 
-  meta = {
+  updateScript = import ./update.nix { inherit writeScript; };
+
+  meta = with stdenv.lib; {
     homepage = http://www.mendeley.com;
     description = "A reference manager and academic social network";
-    license = stdenv.lib.licenses.unfree;
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.unfree;
+    platforms = platforms.linux;
+    maintainers  = with maintainers; [ dtzWill ];
   };
 
 }
diff --git a/pkgs/applications/office/mendeley/update.nix b/pkgs/applications/office/mendeley/update.nix
new file mode 100644
index 00000000000..9ac82615c56
--- /dev/null
+++ b/pkgs/applications/office/mendeley/update.nix
@@ -0,0 +1,60 @@
+{ writeScript }:
+
+writeScript "update-mendeley" ''
+  function follow() {
+    local URL=$1
+    while true; do
+      NEWURL=$(curl -m20 -sI "$URL" -o /dev/null -w '%{redirect_url}')
+      [ -z "$NEWURL" ] && break
+      [[ $NEWURL = $URL ]] && (echo "redirect loop?!"; exit 1)
+      echo "Following $URL -> $NEWURL ..." >&2
+      URL=$NEWURL
+    done
+
+    echo $URL
+  }
+
+  amd64URL=$(follow https://www.mendeley.com/repositories/ubuntu/stable/amd64/mendeleydesktop-latest)
+  amd64V=$(basename $amd64URL|grep -m1 -o "[0-9]\+\.[0-9]\+\.[0-9]\+")
+  i386URL=$(follow https://www.mendeley.com/repositories/ubuntu/stable/i386/mendeleydesktop-latest)
+  i386V=$(basename $i386URL|grep -m1 -o "[0-9]\+\.[0-9]\+\.[0-9]\+")
+
+  echo "amd64 version: $amd64V"
+  echo "i386 version:  $i386V"
+  if [[ $amd64V != $i386V ]]; then
+    echo "Versions not the same!"
+    exit 1
+  fi
+
+  if grep -q -F "$amd64V" ${./default.nix}; then
+    echo "No new version yet, nothing to do."
+    echo "Have a nice day!"
+    exit 0
+  fi
+
+  amd64OldHash=$(nix-instantiate --eval --strict -A "mendeley.src.drvAttrs.outputHash" --argstr system "x86_64-linux"| tr -d '"')
+  i386OldHash=$(nix-instantiate --eval --strict -A "mendeley.src.drvAttrs.outputHash" --argstr system "i686-linux"| tr -d '"')
+
+  echo "Prefetching amd64..."
+  amd64NewHash=$(nix-prefetch-url $amd64URL)
+  echo "Prefetching i386..."
+  i386NewHash=$(nix-prefetch-url $i386URL)
+
+  # Don't actually update, just report that an update is available
+  cat <<EOF
+
+
+  Time to update to $amd64V !
+
+  32bit (i386):
+    Old: $i386OldHash
+    New: $i386NewHash
+  64bit (amd64):
+    Old: $amd64OldHash
+    New: $amd64NewHash
+
+  Exiting so this information is seen...
+  (no update is actually performed here)
+  EOF
+  exit 1
+''