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
This commit is contained in:
Rok Garbas 2016-12-03 17:43:38 +01:00
parent 3a1d52ff4f
commit d295d68609

View file

@ -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 <<EOF
{
version = "$version";
sources = [
EOF
for arch in linux-x86_64 linux-i686; do
for line in `echo "$shasums" | grep $arch | grep "firefox-$version.tar.bz2$" | tr " " ":"`; do
echo " { url = \"$url$version/$arch/`echo $line | cut -d\":\" -f3`\";" >> $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 <<EOF
{ url = "$url$version/$arch/`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
echo " ];" >> $tmpfile
echo "}" >> $tmpfile
cat >> $tmpfile <<EOF
];
}
EOF
cat $tmpfile > ${if isBeta then "beta_" else ""}sources.nix