mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-19 20:23:02 +00:00
0105058698
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.
37 lines
918 B
Nix
37 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}
|
|
''
|