2021-08-09 10:09:43 +00:00
|
|
|
{ pname
|
2017-06-08 13:33:24 +00: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 18:28:02 +00:00
|
|
|
, baseUrl
|
2016-12-16 15:34:25 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2017-06-08 13:33:24 +00:00
|
|
|
isBeta =
|
|
|
|
channel != "release";
|
|
|
|
|
2021-08-09 10:09:43 +00:00
|
|
|
in writeScript "update-${pname}" ''
|
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}
|
|
|
|
|
2020-09-20 18:04:28 +00:00
|
|
|
HOME=`mktemp -d`
|
2019-06-18 19:25:13 +00:00
|
|
|
export GNUPGHOME=`mktemp -d`
|
2020-09-20 18:05:17 +00:00
|
|
|
|
2021-06-16 15:05:31 +00:00
|
|
|
gpg --receive-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`
|
|
|
|
|
2020-07-14 18:26:15 +00:00
|
|
|
curl --silent -o $HOME/shasums "$url$version/SHA256SUMS"
|
|
|
|
curl --silent -o $HOME/shasums.asc "$url$version/SHA256SUMS.asc"
|
2019-06-18 19:25:13 +00:00
|
|
|
gpgv --keyring=$GNUPGHOME/pubring.kbx $HOME/shasums.asc $HOME/shasums
|
2017-02-19 18:33:31 +00:00
|
|
|
|
2020-07-14 18:26:56 +00:00
|
|
|
# this is a list of sha256 and tarballs for both arches
|
|
|
|
# Upstream files contains python repr strings like b'somehash', hence the sed dance
|
2020-10-25 04:45:44 +00:00
|
|
|
shasums=`cat $HOME/shasums | sed -E s/"b'([a-f0-9]{64})'?(.*)"/'\1\2'/ | grep tar.bz2`
|
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";
|
2020-07-14 18:26:15 +00:00
|
|
|
sha256 = "`echo $line | cut -d":" -f1`";
|
2016-12-16 15:34:25 +00:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
done
|
|
|
|
cat >> $tmpfile <<EOF
|
|
|
|
];
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2017-06-08 13:33:24 +00:00
|
|
|
mv $tmpfile ${channel}_sources.nix
|
2016-12-16 15:34:25 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
''
|