2019-06-16 21:59:06 +02:00
|
|
|
{ writeScript, runtimeShell }:
|
2018-01-14 20:58:15 +01:00
|
|
|
|
|
|
|
writeScript "update-mendeley" ''
|
2019-02-26 12:45:54 +01:00
|
|
|
#!${runtimeShell}
|
2018-01-14 20:58:15 +01:00
|
|
|
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)
|
2018-04-24 19:25:43 +02:00
|
|
|
amd64V=$(basename $amd64URL|grep -m1 -o "[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?")
|
2018-01-14 20:58:15 +01:00
|
|
|
i386URL=$(follow https://www.mendeley.com/repositories/ubuntu/stable/i386/mendeleydesktop-latest)
|
2018-04-24 19:25:43 +02:00
|
|
|
i386V=$(basename $i386URL|grep -m1 -o "[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?")
|
2018-01-14 20:58:15 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
''
|