dadc7eb329
Whenever we create scripts that are installed to $out, we must use runtimeShell in order to get the shell that can be executed on the machine we create the package for. This is relevant for cross-compiling. The only use case for stdenv.shell are scripts that are executed as part of the build system. Usages in checkPhase are borderline however to decrease the likelyhood of people copying the wrong examples, I decided to use runtimeShell as well.
37 lines
904 B
Nix
37 lines
904 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" "" "" ${versionKey}
|
|
''
|