nixpkgs/pkgs/applications/networking/browsers/firefox/update.nix
Jan Tojnar 0105058698
common-updater-scripts: Add file and system flags
You can now optionally invoke update-source-versions with:

* --system flag changing the host platform, to be passed dirrectly to Nix commands.
  This is useful for binary packages which have different sources for each platform.
* --file flag allowing to change the file to be modified. This is useful for packages
  that offer multiple variants, listed in a different file than the derivation itself;
  e.g. packages.nix of Sublime Text 3.
* --version-key, which is now a keyword flag instead of a positional argument.
2019-03-02 23:03:04 +01:00

36 lines
918 B
Nix

{ writeScript
, stdenv
, lib
, xidel
, common-updater-scripts
, coreutils
, gnused
, gnugrep
, curl
, attrPath
, runtimeShell
, baseUrl ? "http://archive.mozilla.org/pub/firefox/releases/"
, versionSuffix ? ""
, versionKey ? "version"
}:
writeScript "update-${attrPath}" ''
#!${runtimeShell}
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" "" "" --version-key=${versionKey}
''