From d295d6860965622d7e565d3edc2f29a234aa527c Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Sat, 3 Dec 2016 17:43:38 +0100 Subject: [PATCH] firefox-bin: updated the updateScript with suggestions from @Mic92 also added some comments to the update script so that a new person looking at it know what is happening --- .../browsers/firefox-bin/default.nix | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox-bin/default.nix b/pkgs/applications/networking/browsers/firefox-bin/default.nix index dd767d6984f6..d828a5486fd6 100644 --- a/pkgs/applications/networking/browsers/firefox-bin/default.nix +++ b/pkgs/applications/networking/browsers/firefox-bin/default.nix @@ -184,6 +184,17 @@ stdenv.mkDerivation { tmpfile=`mktemp` url=http://archive.mozilla.org/pub/firefox/releases/ + + # 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]" | \ @@ -191,22 +202,39 @@ stdenv.mkDerivation { grep -v "funnelcake" | \ grep -e "${if isBeta then "b" else ""}\([[:digit:]]\|[[:digit:]][[:digit:]]\)$" | ${if isBeta then "" else "grep -v \"b\" |"} \ tail -1` + + # this is a list of sha512 and tarballs for both arches shasums=`curl --silent $url$version/SHA512SUMS` - echo "{" > $tmpfile - echo " version = \"$version\";" >> $tmpfile - echo " sources = [" >> $tmpfile + cat > $tmpfile <> $tmpfile - echo " locale = \"`echo $line | cut -d\":\" -f3 | sed \"s/$arch\///\" | sed \"s/\/.*//\"`\";" >> $tmpfile - echo " arch = \"$arch\";" >> $tmpfile - echo " sha512 = \"`echo $line | cut -d\":\" -f1`\";" >> $tmpfile - echo " }" >> $tmpfile + # retriving a list of all tarballs for each arch + # - only select tarballs for current arch + # - only select tarballs for current version + # - rename space with colon so that for loop doesnt + # - inteprets sha and path as 2 lines + for line in `echo "$shasums" | \ + grep $arch | \ + grep "firefox-$version.tar.bz2$" | \ + tr " " ":"`; do + # create an entry for every locale + cat >> $tmpfile <> $tmpfile - echo "}" >> $tmpfile + cat >> $tmpfile < ${if isBeta then "beta_" else ""}sources.nix