{ name , writeScript , xidel , coreutils , gnused , gnugrep , curl , gnupg , baseName ? "firefox" , basePath ? "pkgs/applications/networking/browsers/firefox-bin" , baseUrl ? "http://archive.mozilla.org/pub/firefox/releases/" }: let version = (builtins.parseDrvName name).version; isBeta = builtins.stringLength version + 1 == builtins.stringLength (builtins.replaceStrings ["b"] ["bb"] version); in writeScript "update-${baseName}-bin" '' PATH=${coreutils}/bin:${gnused}/bin:${gnugrep}/bin:${xidel}/bin:${curl}/bin:${gnupg}/bin set -eux pushd ${basePath} HOME=`mktemp -d` cat ${./firefox.key} | gpg2 --import tmpfile=`mktemp` url=${baseUrl} # retriving latest released version # - extracts all links from the $url # - removes . and .. # - this line remove everything not starting with a number # - this line sorts everything with semver in mind # - we remove lines that are mentioning funnelcake # - this line removes beta version if we are looking for final release # versions or removes release versions if we are looking for beta # versions # - this line pick up latest release version=`xidel -q $url --extract "//a" | \ sed s"/.$//" | \ grep "^[0-9]" | \ sort --version-sort | \ grep -v "funnelcake" | \ grep -e "${if isBeta then "b" else ""}\([[:digit:]]\|[[:digit:]][[:digit:]]\)$" | ${if isBeta then "" else "grep -v \"b\" |"} \ tail -1` curl --silent -o $HOME/shasums "$url$version/SHA512SUMS" curl --silent -o $HOME/shasums.asc "$url$version/SHA512SUMS.asc" gpgv2 --keyring=$HOME/.gnupg/pubring.kbx $HOME/shasums.asc $HOME/shasums # this is a list of sha512 and tarballs for both arches shasums=`cat $HOME/shasums` cat > $tmpfile <> $tmpfile <> $tmpfile <