From 38a00d8abd987f0f94e9df3a6d954bb0770acf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krizs=C3=A1n=20P=C3=A9ter?= Date: Thu, 17 Oct 2024 23:57:32 +0200 Subject: [PATCH] Added getLatestSourceforgeRelease function --- update_package_versions.sh | 61 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/update_package_versions.sh b/update_package_versions.sh index 1e4f9b2..e59f4b6 100755 --- a/update_package_versions.sh +++ b/update_package_versions.sh @@ -1,39 +1,54 @@ #!/bin/bash # This script checks and updates the latest versions of the packages +# Prints which package is about to update. +greetMsg() +{ + printf "\nUpdating package: $1\n" +} + +# Does the actual update of the package with the found version. +updatePkg() +{ + sed -i -E "s@($1-version \"+)(.+\">)@\1$2\">@" add_packages.sh + sed -i -E "s@($1-download-http \"+)(.+\">)@\1$3\">@" ./$4/$1.xml + echo "Latest version: $2" + printf "Found package: $3\n" +} + # Function that gets the latest release of a specific package. # This function works only with packages stored on github. getLatestGithubRelease() { - printf "\nUpdating package: $2\n" - URL="https://github.com/$1/releases" - URL=`curl -v --silent $URL 2>&1 | grep 'loading="lazy" src=' | tr '"' '\n' | grep /releases/ -m1` + greetMsg $2 + URL=`curl -v --silent "https://github.com/$1/releases" 2>&1 | grep 'loading="lazy" src=' | tr '"' '\n' | grep /releases/ -m1` URL="https://github.com`curl -v --silent $URL 2>&1 | grep ')@\1$URL\">@" ./$3/$2.xml VER=`echo $URL | awk -F/ '{ print $(NF-1) }' | awk -F- '{ print $NF }'` if [[ $4 ]]; then VER=`echo $VER | cut -c$4` fi - sed -i -E "s@($2-version \"+)(.+\">)@\1$VER\">@" add_packages.sh - echo "Latest version: $VER" - printf "Found package: $URL\n" + updatePkg $2 $VER $URL $3 +} + +# Function that gets the latest release of a specific package. +# This function works only with packages stored on sourceforge. +getLatestSourceforgeRelease() +{ + greetMsg $2 + URL=`curl -v --silent "https://sourceforge.net/projects/$1/files/$2/" 2>&1 | grep net.sf.files | tr '"' '\n' | grep http -m1 | rev | cut -c10- | rev` + VER=`echo $URL | awk -F/ '{ print $NF }'` + if [[ $4 ]]; then + VER=`echo $VER | cut -c$4` + fi + URL=$URL/$2-$VER.tar.gz + updatePkg $2 $VER $URL $3 } #minidlna -DOWNLOAD_URL=`curl -v --silent https://sourceforge.net/projects/minidlna/files/minidlna/ 2>&1 | grep net.sf.files | tr '"' '\n' | grep http -m1` -DOWNLOAD_URL="${DOWNLOAD_URL%/download}" -LATEST_VERSION=`echo $DOWNLOAD_URL | awk -F/ '{ print $NF }'` -sed -i -E "s@(minidlna-version \"+)(.+\">)@\1$LATEST_VERSION\">@" add_packages.sh -DOWNLOAD_URL=$DOWNLOAD_URL/minidlna-$LATEST_VERSION.tar.gz -sed -i -E "s@(minidlna-download-http \"+)(.+\">)@\1$DOWNLOAD_URL\">@" ./server/other/minidlna.xml +getLatestSourceforgeRelease minidlna minidlna server/other #libid3tag -DOWNLOAD_URL=`curl -v --silent https://sourceforge.net/projects/mad/files/libid3tag/ 2>&1 | grep net.sf.files | tr '"' '\n' | grep http -m1` -DOWNLOAD_URL="${DOWNLOAD_URL%/download}" -LATEST_VERSION=`echo $DOWNLOAD_URL | awk -F/ '{ print $NF }'` -sed -i -E "s@(libid3tag-version \"+)(.+\">)@\1$LATEST_VERSION\">@" add_packages.sh -DOWNLOAD_URL=$DOWNLOAD_URL/libid3tag-$LATEST_VERSION.tar.gz -sed -i -E "s@(libid3tag-download-http \"+)(.+\">)@\1$DOWNLOAD_URL\">@" ./multimedia/libdriv/libid3tag.xml +getLatestSourceforgeRelease mad libid3tag multimedia/libdriv #pkcs11-helper getLatestGithubRelease OpenSC/pkcs11-helper pkcs11-helper postlfs/security @@ -42,13 +57,7 @@ getLatestGithubRelease OpenSC/pkcs11-helper pkcs11-helper postlfs/security getLatestGithubRelease zaps166/QMPlay2 qmplay2 multimedia/videoutils #qBittorrent -URL="https://www.qbittorrent.org/download" -DOWNLOAD_URL=`curl -v --silent $URL 2>&1 | tr '"' '\n' | grep '.tar.xz/'` -DOWNLOAD_URL="${DOWNLOAD_URL%/download}" -sed -i -E "s@(qbittorrent-download-http \"+)(.+\">)@\1$DOWNLOAD_URL\">@" ./xsoft/other/qbittorrent.xml -LATEST_VERSION=`echo $DOWNLOAD_URL | tr '-' '\n' | tr '/' '\n' | grep '.tar.xz'` -LATEST_VERSION="${LATEST_VERSION%.tar.xz}" -sed -i -E "s@(qbittorrent-version \"+)(.+\">)@\1$LATEST_VERSION\">@" add_packages.sh +getLatestSourceforgeRelease qbittorrent qbittorrent xsoft/other 13- #libtorrent-rasterbar getLatestGithubRelease arvidn/libtorrent libtorrent-rasterbar networking/netlibs 2-