summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/networking/browsers/firefox-bin/update.nix
diff options
context:
space:
mode:
authorRok Garbas <rok@garbas.si>2016-12-16 16:34:25 +0100
committerRok Garbas <rok@garbas.si>2016-12-18 16:45:33 +0100
commita66b703f94e80215a46b10bbd613ae9c8d9d74ec (patch)
tree52e5df000a3b4a4ad3d6bc56fa407c8d2c9b6b5b /pkgs/applications/networking/browsers/firefox-bin/update.nix
parent56cb5b7609f97e07bf4633ba5d59d230193a0248 (diff)
firefox-bin/thunderbird-bin: reuse the same updateScript for both
Diffstat (limited to 'pkgs/applications/networking/browsers/firefox-bin/update.nix')
-rw-r--r--pkgs/applications/networking/browsers/firefox-bin/update.nix78
1 files changed, 78 insertions, 0 deletions
diff --git a/pkgs/applications/networking/browsers/firefox-bin/update.nix b/pkgs/applications/networking/browsers/firefox-bin/update.nix
new file mode 100644
index 000000000000..d32f4dfcf5b0
--- /dev/null
+++ b/pkgs/applications/networking/browsers/firefox-bin/update.nix
@@ -0,0 +1,78 @@
+{ name
+, writeScript
+, xidel
+, coreutils
+, gnused
+, gnugrep
+, curl
+, 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
+
+ pushd ${basePath}
+
+ 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`
+
+ # this is a list of sha512 and tarballs for both arches
+ shasums=`curl --silent $url$version/SHA512SUMS`
+
+ cat > $tmpfile <<EOF
+ {
+ version = "$version";
+ sources = [
+ EOF
+ for arch in linux-x86_64 linux-i686; do
+ # 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 "${baseName}-$version.tar.bz2$" | \
+ tr " " ":"`; do
+ # create an entry for every locale
+ cat >> $tmpfile <<EOF
+ { url = "$url$version/`echo $line | cut -d":" -f3`";
+ locale = "`echo $line | cut -d":" -f3 | sed "s/$arch\///" | sed "s/\/.*//"`";
+ arch = "$arch";
+ sha512 = "`echo $line | cut -d":" -f1`";
+ }
+ EOF
+ done
+ done
+ cat >> $tmpfile <<EOF
+ ];
+ }
+ EOF
+
+ mv $tmpfile ${if isBeta then "beta_" else ""}sources.nix
+
+ popd
+''