Skip to content

Commit

Permalink
Allow for OpenWrt release candidate package names (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
seud0nym committed Dec 6, 2024
1 parent 00d2478 commit d53506f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
16 changes: 11 additions & 5 deletions extras/src/adblock/adblock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ if [ "$1" = "setup" ]; then
adblock_installed="$(opkg list-installed | grep '^adblock ' | cut -d- -f2- | xargs)"
ca_bundle_installed="$(opkg list-installed | grep '^ca-bundle ' | cut -d- -f3- | xargs)"
ca_certificates_installed="$(opkg list-installed | grep '^ca-certificates ' | cut -d- -f3- | xargs)"
openwrt_latest="$(curl -skL https://downloads.openwrt.org/releases/ | grep -Eo 'packages-[0-9][0-9]\.[0-9.]+' | sort -ru | head -n1)"
adblock_current_filename="$(curl -skL https://downloads.openwrt.org/releases/${openwrt_latest}/arm_cortex-a9/packages/Packages | grep -E '^Filename: adblock_[0-9.-]+_all.ipk' | cut -d' ' -f2)"
adblock_current="$(echo $adblock_current_filename | grep -Eo '[0-9][0-9.-]+')"
openwrt_releases="$(curl -skL https://downloads.openwrt.org/releases/ | grep -Eo 'packages-[0-9][0-9]\.[0-9.]+' | sort -u)"
openwrt_latest="$(echo "$openwrt_releases" | tail -n1)"
i=1
while [ -z "$adblock_current_filename" -a $i -lt $(echo "$openwrt_releases" | wc -l) ]; do
openwrt_adblock="$(echo "$openwrt_releases" | tail -n$i | head -n1)"
adblock_current_filename="$(curl -skL https://downloads.openwrt.org/releases/${openwrt_adblock}/arm_cortex-a9/packages/Packages | grep -E "^Filename: adblock_$adblock_supported_version.[-r0-9.]+_all.ipk" | cut -d' ' -f2)"
i=$(( $i + 1 ))
done
adblock_current="$(echo $adblock_current_filename | grep -Eo '[0-9][-r0-9.]+')"
ca_current="$(curl -skL https://downloads.openwrt.org/releases/${openwrt_latest}/arm_cortex-a9/base/Packages | grep 'Filename: ca-' | cut -d' ' -f2)"
ca_bundle_current="$(echo "$ca_current" | grep bundle | grep -Eo '[0-9][0-9-]+')"
ca_certificates_current="$(echo "$ca_current" | grep certificates | grep -Eo '[0-9][0-9-]+')"
ca_bundle_current="$(echo "$ca_current" | grep bundle | grep -Eo '[0-9][-r0-9]+')"
ca_certificates_current="$(echo "$ca_current" | grep certificates | grep -Eo '[0-9][-r0-9]+')"
adblock_restart="n"
if [ \( -n "$adblock_current" -a "$(echo $adblock_current | cut -d. -f1-2)" != $adblock_supported_version \) ]; then
echo ">> Latest adblock version is $adblock_current but only version ${adblock_supported_version} is supported - unable to complete setup"
Expand Down
18 changes: 12 additions & 6 deletions extras/tch-gui-unhide-xtra.adblock
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ if [ "$1" = "setup" ]; then
adblock_installed="$(opkg list-installed | grep '^adblock ' | cut -d- -f2- | xargs)"
ca_bundle_installed="$(opkg list-installed | grep '^ca-bundle ' | cut -d- -f3- | xargs)"
ca_certificates_installed="$(opkg list-installed | grep '^ca-certificates ' | cut -d- -f3- | xargs)"
openwrt_latest="$(curl -skL https://downloads.openwrt.org/releases/ | grep -Eo 'packages-[0-9][0-9]\.[0-9.]+' | sort -ru | head -n1)"
adblock_current_filename="$(curl -skL https://downloads.openwrt.org/releases/${openwrt_latest}/arm_cortex-a9/packages/Packages | grep -E '^Filename: adblock_[0-9.-]+_all.ipk' | cut -d' ' -f2)"
adblock_current="$(echo $adblock_current_filename | grep -Eo '[0-9][0-9.-]+')"
openwrt_releases="$(curl -skL https://downloads.openwrt.org/releases/ | grep -Eo 'packages-[0-9][0-9]\.[0-9.]+' | sort -u)"
openwrt_latest="$(echo "$openwrt_releases" | tail -n1)"
i=1
while [ -z "$adblock_current_filename" -a $i -lt $(echo "$openwrt_releases" | wc -l) ]; do
openwrt_adblock="$(echo "$openwrt_releases" | tail -n$i | head -n1)"
adblock_current_filename="$(curl -skL https://downloads.openwrt.org/releases/${openwrt_adblock}/arm_cortex-a9/packages/Packages | grep -E "^Filename: adblock_$adblock_supported_version.[-r0-9.]+_all.ipk" | cut -d' ' -f2)"
i=$(( $i + 1 ))
done
adblock_current="$(echo $adblock_current_filename | grep -Eo '[0-9][-r0-9.]+')"
ca_current="$(curl -skL https://downloads.openwrt.org/releases/${openwrt_latest}/arm_cortex-a9/base/Packages | grep 'Filename: ca-' | cut -d' ' -f2)"
ca_bundle_current="$(echo "$ca_current" | grep bundle | grep -Eo '[0-9][0-9-]+')"
ca_certificates_current="$(echo "$ca_current" | grep certificates | grep -Eo '[0-9][0-9-]+')"
ca_bundle_current="$(echo "$ca_current" | grep bundle | grep -Eo '[0-9][-r0-9]+')"
ca_certificates_current="$(echo "$ca_current" | grep certificates | grep -Eo '[0-9][-r0-9]+')"
adblock_restart="n"
if [ \( -n "$adblock_current" -a "$(echo $adblock_current | cut -d. -f1-2)" != $adblock_supported_version \) ]; then
echo ">> Latest adblock version is $adblock_current but only version ${adblock_supported_version} is supported - unable to complete setup"
Expand Down Expand Up @@ -71,7 +77,7 @@ if [ "$1" = "setup" ]; then
echo ">> Downloading adblock v$adblock_current"
curl -kL https://downloads.openwrt.org/releases/${openwrt_latest}/arm_cortex-a9/packages/adblock_${adblock_current}_all.ipk -o /tmp/adblock_${adblock_current}_all.ipk || exit $?
echo ">> Installing adblock v$adblock_current"
opkg --force-overwrite --nodeps install /tmp/adblock_${adblock_current}_all.ipk
opkg --force-overwrite --no install /tmp/adblock_${adblock_current}_all.ipk
rm /tmp/adblock_${adblock_current}_all.ipk
adblock_restart="y"
fi
Expand Down
4 changes: 2 additions & 2 deletions utilities/update-ca-certificates
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ rm -f /tmp/ca-*.ipk
SRC="https://downloads.openwrt.org/releases/${OPENWRT_LATEST}/arm_cortex-a9/base"
for IPK in $(curl $CURL_OPT -s $SRC/Packages.gz | gunzip | grep '^Filename: ca-' | cut -d' ' -f2); do
PKG="$(echo $IPK | grep -Eo '^ca-[^_]+')"
VER="$(echo $IPK | grep -Eo '[0-9][0-9-]+')"
VER="$(echo $IPK | grep -Eo '[0-9][-r0-9]+')"
if [ $DE_TELSTRA = "N" -a "$(opkg list-installed 2>/dev/null | grep $PKG | cut -d- -f3- | xargs)" = "$VER" ]; then
log user.info $PKG is up to date: Version $VER already installed
else
Expand All @@ -127,7 +127,7 @@ if [ $DE_TELSTRA = "Y" ]; then
for IPK in /tmp/ca-*.ipk; do
log user.info Adding $IPK to $TARGET
PKG="$(echo $IPK | grep -Eo 'ca-[^_]+')"
VER="$(echo $IPK | grep -Eo '[0-9][0-9-]+')"
VER="$(echo $IPK | grep -Eo '[0-9][-r0-9]+')"
echo " if ! opkg list-installed | grep -q '$PKG - $VER'; then" >> $TARGET
echo " #region (Source = $SRC/$(basename $IPK))" >> $TARGET
echo " echo '$(base64 $IPK)' | base64 -d > $IPK" >> $TARGET
Expand Down

0 comments on commit d53506f

Please sign in to comment.