3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/networking/browsers/firefox/update.nix

37 lines
904 B
Nix
Raw Normal View History

{ writeScript
, stdenv
, lib
2016-12-25 08:35:20 +00:00
, xidel
, common-updater-scripts
2016-12-25 08:35:20 +00:00
, coreutils
, gnused
, gnugrep
, curl
, attrPath
, runtimeShell
2016-12-25 08:35:20 +00:00
, baseUrl ? "http://archive.mozilla.org/pub/firefox/releases/"
, versionSuffix ? ""
, versionKey ? "version"
2016-12-25 08:35:20 +00:00
}:
writeScript "update-${attrPath}" ''
#!${runtimeShell}
PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused xidel ]}
2016-12-25 08:35:20 +00:00
url=${baseUrl}
# retriving latest released version
# - extracts all links from the $url
# - extracts lines only with number and dots followed by a slash
# - removes trailing slash
# - sorts everything with semver in mind
# - picks up latest release
2018-03-14 12:01:25 +00:00
version=`xidel -s $url --extract "//a" | \
2016-12-25 08:35:20 +00:00
grep "^[0-9.]*${versionSuffix}/$" | \
sed s/[/]$// | \
sort --version-sort | \
tail -n 1`
update-source-version ${attrPath} "$version" "" "" ${versionKey}
2016-12-25 08:35:20 +00:00
''