arch-pkgs/.repo/pkgver/firefox-nightly-en-gb.sh
George Rawlinson db2ecb84e0
nvchecker: add external scripts
Something is wrong with .gitignore, these scripts were not being added
previously.

*shoots .gitignore*
2021-07-24 12:58:02 +00:00

45 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
set -e
# check dependencies
count=0
for dependency in grep cut sort tail sed; do
if [ ! -x "$(command -v $dependency)" ]; then
echo "$dependency missing"
count=$((count+1))
fi
done
# exit script if any dependencies missing
if [ $count -ne 0 ]; then
exit 1
fi
# options to pass to cURL, including custom user agent
USER_AGENT="nightly-version-checker/1.0 george@rawlinson.net.nz"
CURL_OPTS=(--silent --user-agent "$USER_AGENT")
# package variables
_name=firefox
_channel=nightly
_lang="en-GB"
CARCH=x86_64
_base_url="https://ftp.mozilla.org/pub/${_name}/${_channel}"
_version=$(curl "${CURL_OPTS[@]}" ${_base_url}/latest-mozilla-central-l10n/ | grep "${_lang}.linux-${CARCH}.checksums" | sort | tail -n 1 | sed "s/^.*>firefox-//; s/\.${_lang}.*//")
_build_id_raw="$(curl "${CURL_OPTS[@]}" "${_base_url}/latest-mozilla-central-l10n/${_name}-${_version}.${_lang}.linux-${CARCH}.checksums" | grep '.partial.mar' | cut -d' ' -f4 | grep -E -o '[[:digit:]]{14}' | sort | tail -n1)"
declare -A _build_id
_build_id=(
[year]="${_build_id_raw:0:4}"
[month]="${_build_id_raw:4:2}"
[day]="${_build_id_raw:6:2}"
[hour]="${_build_id_raw:8:2}"
[min]="${_build_id_raw:10:2}"
[sec]="${_build_id_raw:12:2}"
[date]="${_build_id_raw:0:8}"
[time]="${_build_id_raw:8:6}"
)
echo "${_version}.${_build_id[date]}.${_build_id[time]}"
exit 0