nixpkgs/pkgs/applications/networking/browsers/firefox/update.nix
Jan Tojnar 59a94b57f0
update.nix: Run update scripts in parallel
To make updating large attribute sets faster, the update scripts
are now run in parallel.

Please note the following changes in semantics:

- The string passed to updateScript needs to be a path to an executable file.
- The updateScript can also be a list: the tail elements will then be passed
  to the head as command line arguments.
2018-12-01 19:17:13 +01:00

36 lines
889 B
Nix

{ writeScript
, stdenv
, lib
, xidel
, common-updater-scripts
, coreutils
, gnused
, gnugrep
, curl
, attrPath
, baseUrl ? "http://archive.mozilla.org/pub/firefox/releases/"
, versionSuffix ? ""
, versionKey ? "version"
}:
writeScript "update-${attrPath}" ''
#!${stdenv.shell}
PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused xidel ]}
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
version=`xidel -s $url --extract "//a" | \
grep "^[0-9.]*${versionSuffix}/$" | \
sed s/[/]$// | \
sort --version-sort | \
tail -n 1`
update-source-version ${attrPath} "$version" "" "" ${versionKey}
''