git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #33867 from dtzWill/update/mendeley-1.17.13-and-update-checker

mendeley: add update script, use it, add myself as maintainer

commitebc090c1259238f9f70b7f0ae0294105d8662334 authoradisbladis <adisbladis@gmail.com> dateMon 15 Jan 2018, 09:49 (9 years ago) parent9af3b9d0e4fd35
2 files changed+71−6
pkgs/applications/office/mendeley/default.nix+11−6 pkgs/applications/office/mendeley/update.nix+60
pkgs/applications/office/mendeley/default.nix+11−6
@@ -31,6 +31,8 @@
3131# will leave entries on your system after uninstalling mendeley.
3232# (they can be removed by running '$out/bin/install-mendeley-link-handler.sh -u')
3333, autorunLinkHandler ? true
34+# Update script
35+, writeScript
3436}:
3537
3638assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
@@ -43,14 +45,14 @@ let
4345 then "i386"
4446 else "amd64";
4547
46− shortVersion = "1.17.12-stable";
48+ shortVersion = "1.17.13-stable";
4749
4850 version = "${shortVersion}_${arch}";
4951
5052 url = "http://desktop-download.mendeley.com/download/apt/pool/main/m/mendeleydesktop/mendeleydesktop_${version}.deb";
5153 sha256 = if stdenv.system == arch32
52− then "09n910ny8k103g1v8m19f9n827l2y0kmz79cwgy95k6acf2rkc2x"
53− else "11z65mj1a2rw6cwfarl8r1vzpcz4ww5mgvd5fyv31l60mbmnqkap";
54+ then "0q4x62k00whmq8lskphpcxc610cvclxzcr5k0v7pxjxs9sx5yx43"
55+ else "01ylyily1hip35z0d4qkdpbzp5yn4r015psc5773xsqlgrnlwjm3";
5456
5557 deps = [
5658 qtbase
@@ -133,11 +135,14 @@ stdenv.mkDerivation {
133135 dontStrip = true;
134136 dontPatchElf = true;
135137
136− meta = {
138+ updateScript = import ./update.nix { inherit writeScript; };
139+
140+ meta = with stdenv.lib; {
137141 homepage = http://www.mendeley.com;
138142 description = "A reference manager and academic social network";
139− license = stdenv.lib.licenses.unfree;
140− platforms = stdenv.lib.platforms.linux;
143+ license = licenses.unfree;
144+ platforms = platforms.linux;
145+ maintainers = with maintainers; [ dtzWill ];
141146 };
142147
143148}
pkgs/applications/office/mendeley/update.nixnew file+60
@@ -0,0 +1,60 @@
1+{ writeScript }:
2+
3+writeScript "update-mendeley" ''
4+ function follow() {
5+ local URL=$1
6+ while true; do
7+ NEWURL=$(curl -m20 -sI "$URL" -o /dev/null -w '%{redirect_url}')
8+ [ -z "$NEWURL" ] && break
9+ [[ $NEWURL = $URL ]] && (echo "redirect loop?!"; exit 1)
10+ echo "Following $URL -> $NEWURL ..." >&2
11+ URL=$NEWURL
12+ done
13+
14+ echo $URL
15+ }
16+
17+ amd64URL=$(follow https://www.mendeley.com/repositories/ubuntu/stable/amd64/mendeleydesktop-latest)
18+ amd64V=$(basename $amd64URL|grep -m1 -o "[0-9]\+\.[0-9]\+\.[0-9]\+")
19+ i386URL=$(follow https://www.mendeley.com/repositories/ubuntu/stable/i386/mendeleydesktop-latest)
20+ i386V=$(basename $i386URL|grep -m1 -o "[0-9]\+\.[0-9]\+\.[0-9]\+")
21+
22+ echo "amd64 version: $amd64V"
23+ echo "i386 version: $i386V"
24+ if [[ $amd64V != $i386V ]]; then
25+ echo "Versions not the same!"
26+ exit 1
27+ fi
28+
29+ if grep -q -F "$amd64V" ${./default.nix}; then
30+ echo "No new version yet, nothing to do."
31+ echo "Have a nice day!"
32+ exit 0
33+ fi
34+
35+ amd64OldHash=$(nix-instantiate --eval --strict -A "mendeley.src.drvAttrs.outputHash" --argstr system "x86_64-linux"| tr -d '"')
36+ i386OldHash=$(nix-instantiate --eval --strict -A "mendeley.src.drvAttrs.outputHash" --argstr system "i686-linux"| tr -d '"')
37+
38+ echo "Prefetching amd64..."
39+ amd64NewHash=$(nix-prefetch-url $amd64URL)
40+ echo "Prefetching i386..."
41+ i386NewHash=$(nix-prefetch-url $i386URL)
42+
43+ # Don't actually update, just report that an update is available
44+ cat <<EOF
45+
46+
47+ Time to update to $amd64V !
48+
49+ 32bit (i386):
50+ Old: $i386OldHash
51+ New: $i386NewHash
52+ 64bit (amd64):
53+ Old: $amd64OldHash
54+ New: $amd64NewHash
55+
56+ Exiting so this information is seen...
57+ (no update is actually performed here)
58+ EOF
59+ exit 1
60+''