2016-12-16 15:34:25 +00:00
|
|
|
{ name
|
2017-06-08 14:33:24 +01:00
|
|
|
, channel
|
2016-12-16 15:34:25 +00:00
|
|
|
, writeScript
|
|
|
|
, xidel
|
|
|
|
, coreutils
|
|
|
|
, gnused
|
|
|
|
, gnugrep
|
|
|
|
, curl
|
2017-02-19 18:33:31 +00:00
|
|
|
, gnupg
|
2016-12-16 15:34:25 +00:00
|
|
|
, baseName ? "firefox"
|
2017-02-19 18:33:31 +00:00
|
|
|
, basePath ? "pkgs/applications/networking/browsers/firefox-bin"
|
2017-06-15 19:28:02 +01:00
|
|
|
, baseUrl
|
2016-12-16 15:34:25 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2017-06-08 14:33:24 +01:00
|
|
|
isBeta =
|
|
|
|
channel != "release";
|
|
|
|
|
|
|
|
in writeScript "update-${name}" ''
|
2017-02-19 18:33:31 +00:00
|
|
|
PATH=${coreutils}/bin:${gnused}/bin:${gnugrep}/bin:${xidel}/bin:${curl}/bin:${gnupg}/bin
|
|
|
|
set -eux
|
2016-12-16 15:34:25 +00:00
|
|
|
pushd ${basePath}
|
|
|
|
|
2017-02-19 18:33:31 +00:00
|
|
|
HOME=`mktemp -d`
|
2017-08-10 10:43:48 +01:00
|
|
|
cat ${./firefox.key} | gpg --import
|
2017-02-19 18:33:31 +00:00
|
|
|
|
2016-12-16 15:34:25 +00:00
|
|
|
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
|
2018-03-15 16:42:15 +00:00
|
|
|
version=`xidel -s $url --extract "//a" | \
|
2016-12-16 15:34:25 +00:00
|
|
|
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`
|
|
|
|
|
2017-02-19 18:33:31 +00:00
|
|
|
curl --silent -o $HOME/shasums "$url$version/SHA512SUMS"
|
|
|
|
curl --silent -o $HOME/shasums.asc "$url$version/SHA512SUMS.asc"
|
2017-08-10 10:43:48 +01:00
|
|
|
gpgv --keyring=$HOME/.gnupg/pubring.kbx $HOME/shasums.asc $HOME/shasums
|
2017-02-19 18:33:31 +00:00
|
|
|
|
2016-12-16 15:34:25 +00:00
|
|
|
# this is a list of sha512 and tarballs for both arches
|
2017-02-19 18:33:31 +00:00
|
|
|
shasums=`cat $HOME/shasums`
|
2016-12-16 15:34:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-06-08 14:33:24 +01:00
|
|
|
mv $tmpfile ${channel}_sources.nix
|
2016-12-16 15:34:25 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
''
|