2019-06-16 20:59:06 +01: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
|
2019-02-26 11:45:54 +00:00
|
|
|
, runtimeShell
|
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}" ''
|
2019-02-26 11:45:54 +00:00
|
|
|
#!${runtimeShell}
|
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}
|
|
|
|
|
2019-06-18 20:25:13 +01:00
|
|
|
export GNUPGHOME=`mktemp -d`
|
2019-06-18 20:21:12 +01:00
|
|
|
gpg --keyserver hkps://gpg.mozilla.org --recv-keys 14F26682D0916CDD81E37B6D61B7B526D98F0353
|
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"
|
2019-06-18 20:25:13 +01:00
|
|
|
gpgv --keyring=$GNUPGHOME/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
|
|
|
|
''
|