Commit f066c3c4 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm play: change get_github_url to accept wildcard instead of regexp

parent 58d3bd08
...@@ -14,7 +14,7 @@ arch="$(epm print info --debian-arch)" ...@@ -14,7 +14,7 @@ arch="$(epm print info --debian-arch)"
#https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v2.2.3/Clash.Verge-2.2.3-1.x86_64.rpm #https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v2.2.3/Clash.Verge-2.2.3-1.x86_64.rpm
# Clash.Verge_2.2.3_amd64.deb # Clash.Verge_2.2.3_amd64.deb
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/clash-verge-rev/clash-verge-rev/" "Clash.Verge_.${VERSION}_$arch.deb") PKGURL=$(get_github_url "https://github.com/clash-verge-rev/clash-verge-rev/" "Clash.Verge_${VERSION}_$arch.deb")
else else
PKGURL="https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v${VERSION}/Clash.Verge_${VERSION}_$arch.deb" PKGURL="https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v${VERSION}/Clash.Verge_${VERSION}_$arch.deb"
fi fi
......
...@@ -184,6 +184,15 @@ get_latest_version() ...@@ -184,6 +184,15 @@ get_latest_version()
done done
} }
# copied from epm-sh-functions
# copied from eget's filter_glob
# check man glob
__convert_glob__to_regexp()
{
# translate glob to regexp
echo "$1" | sed -e "s|\*|.*|g" -e "s|?|.|g"
}
get_github_release_info() { get_github_release_info() {
local url="$1" local url="$1"
local user_and_repo=${url#https://github.com/} local user_and_repo=${url#https://github.com/}
...@@ -196,8 +205,11 @@ get_github_url() ...@@ -196,8 +205,11 @@ get_github_url()
local url="$1" local url="$1"
local asset_name="$2" local asset_name="$2"
echo "$asset_name" | grep -q "\.[*?]" && fatal "Only glob symbols * and ? are supported. Don't use regexp! Input string: $asset_name"
wc="$(__convert_glob__to_regexp "$asset_name")"
if [ "$3" == "prerelease" ] ; then if [ "$3" == "prerelease" ] ; then
get_github_release_info "$url" | grep 'browser_download_url' | grep -iEo 'https.*download.*' | grep "$2" | head -n1 get_github_release_info "$url" | grep 'browser_download_url' | grep -iEo 'https.*download.*' | grep -E "$wc" | head -n1
else else
get_github_release_info "$url" \ get_github_release_info "$url" \
| awk '{ | awk '{
...@@ -210,7 +222,7 @@ get_github_url() ...@@ -210,7 +222,7 @@ get_github_url()
match($0, /"browser_download_url": "(https[^"]*)"/, arr); match($0, /"browser_download_url": "(https[^"]*)"/, arr);
print arr[1]; print arr[1];
} }
}' | grep "$2" | head -1 }' | grep -E "$wc" | head -1
fi fi
} }
......
...@@ -16,7 +16,7 @@ esac ...@@ -16,7 +16,7 @@ esac
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/juanfont/headscale/" "${PKGNAME}_.${VERSION}_linux_$arch.deb") PKGURL=$(get_github_url "https://github.com/juanfont/headscale/" "${PKGNAME}_${VERSION}_linux_$arch.deb")
else else
PKGURL="https://github.com/juanfont/headscale/releases/download/v$VERSION/${PKGNAME}_${VERSION}_linux_$arch.deb" PKGURL="https://github.com/juanfont/headscale/releases/download/v$VERSION/${PKGNAME}_${VERSION}_linux_$arch.deb"
fi fi
......
...@@ -10,7 +10,7 @@ URL="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher" ...@@ -10,7 +10,7 @@ URL="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher"
arch=x86_64 arch=x86_64
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/" "${PKGNAME}-.${VERSION}-linux-$arch.AppImage") PKGURL=$(get_github_url "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/" "${PKGNAME}-${VERSION}-linux-$arch.AppImage")
else else
PKGURL="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/download/v$VERSION/${PKGNAME}-${VERSION}-linux-$arch.AppImage" PKGURL="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/download/v$VERSION/${PKGNAME}-${VERSION}-linux-$arch.AppImage"
fi fi
......
...@@ -13,6 +13,6 @@ URL="https://www.getmailspring.com/" ...@@ -13,6 +13,6 @@ URL="https://www.getmailspring.com/"
arch=amd64 arch=amd64
pkgtype=deb pkgtype=deb
PKGURL=$(get_github_url https://github.com/Foundry376/Mailspring/ "$PKGNAME.*.$VERSION.*$arch.$pkgtype") PKGURL=$(get_github_url https://github.com/Foundry376/Mailspring/ "$PKGNAME.*$VERSION.*$arch.$pkgtype")
install_pkgurl install_pkgurl
...@@ -10,7 +10,7 @@ URL="https://mattermost.com/" ...@@ -10,7 +10,7 @@ URL="https://mattermost.com/"
arch="$(epm print info --debian-arch)" arch="$(epm print info --debian-arch)"
PKGURL=$(get_github_url "https://github.com/mattermost/desktop/" "$(epm print constructname $PKGNAME ".$VERSION*" $arch "deb")") PKGURL=$(get_github_url "https://github.com/mattermost/desktop/" "$(epm print constructname $PKGNAME "$VERSION*" $arch "deb")")
install_pkgurl install_pkgurl
...@@ -9,7 +9,7 @@ URL="https://moonlight-stream.org/" ...@@ -9,7 +9,7 @@ URL="https://moonlight-stream.org/"
. $(dirname $0)/common.sh . $(dirname $0)/common.sh
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/moonlight-stream/moonlight-qt/" "$PKGNAME-.$VERSION-x86_64.AppImage") PKGURL=$(get_github_url "https://github.com/moonlight-stream/moonlight-qt/" "$PKGNAME-$VERSION-x86_64.AppImage")
else else
PKGURL="https://github.com/moonlight-stream/moonlight-qt/releases/download/v$VERSION/$PKGNAME-$VERSION-x86_64.AppImage" PKGURL="https://github.com/moonlight-stream/moonlight-qt/releases/download/v$VERSION/$PKGNAME-$VERSION-x86_64.AppImage"
fi fi
......
...@@ -27,7 +27,7 @@ else ...@@ -27,7 +27,7 @@ else
fi fi
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/cyanfish/naps2/" "$PKGNAME-.$VERSION-linux-$arch.$pkgtype") PKGURL=$(get_github_url "https://github.com/cyanfish/naps2/" "$PKGNAME-$VERSION-linux-$arch.$pkgtype")
else else
PKGURL="https://github.com/cyanfish/naps2/releases/download/v$VERSION/$PKGNAME-$VERSION-linux-$arch.$pkgtype" PKGURL="https://github.com/cyanfish/naps2/releases/download/v$VERSION/$PKGNAME-$VERSION-linux-$arch.$pkgtype"
fi fi
......
...@@ -9,7 +9,7 @@ URL="https://persepolisdm.github.io/" ...@@ -9,7 +9,7 @@ URL="https://persepolisdm.github.io/"
. $(dirname $0)/common.sh . $(dirname $0)/common.sh
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/persepolisdm/persepolis/" "${PKGNAME}_.${VERSION}_all.deb") PKGURL=$(get_github_url "https://github.com/persepolisdm/persepolis/" "${PKGNAME}_${VERSION}_all.deb")
else else
PKGURL="https://github.com/persepolisdm/persepolis/releases/download/$VERSION/${PKGNAME}_${VERSION}_all.deb" PKGURL="https://github.com/persepolisdm/persepolis/releases/download/$VERSION/${PKGNAME}_${VERSION}_all.deb"
fi fi
......
...@@ -12,25 +12,23 @@ pkgtype="$(epm print info -p)" ...@@ -12,25 +12,23 @@ pkgtype="$(epm print info -p)"
case $pkgtype in case $pkgtype in
# rpm) # rpm)
# mask="${PKGNAME}-.${VERSION}.x86_64.rpm" # mask="${PKGNAME}-${VERSION}.x86_64.rpm"
# ;; # ;;
deb) deb)
mask="${PKGNAME}-.${VERSION}_amd64.deb" mask="${PKGNAME}-${VERSION}_amd64.deb"
;; ;;
*) *)
mask="SchildiChat-.${VERSION}.AppImage" mask="SchildiChat-${VERSION}.AppImage"
;; ;;
esac esac
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/SchildiChat/schildichat-desktop/" "$mask") PKGURL=$(get_github_url "https://github.com/SchildiChat/schildichat-desktop/" "$mask")
else else
# need because get_github_url doesn't support ${VERSION} without a dot before VERSION in mask PKGURL="https://github.com/SchildiChat/schildichat-desktop/releases/download/v$VERSION/$mask"
direct_mask="$(echo $mask | sed 's/\.//')"
PKGURL="https://github.com/SchildiChat/schildichat-desktop/releases/download/v$VERSION/$direct_mask"
fi fi
if [ $mask = "SchildiChat-.${VERSION}.AppImage" ]; then if [ $mask = "SchildiChat-${VERSION}.AppImage" ]; then
install_pack_pkgurl install_pack_pkgurl
else else
install_pkgurl install_pkgurl
......
...@@ -20,7 +20,7 @@ case "$(epm print info -a)" in ...@@ -20,7 +20,7 @@ case "$(epm print info -a)" in
esac esac
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/Automattic/simplenote-electron/" "$PKGNAME-.$VERSION-$arch.AppImage") PKGURL=$(get_github_url "https://github.com/Automattic/simplenote-electron/" "$PKGNAME-$VERSION-$arch.AppImage")
else else
PKGURL="https://github.com/Automattic/simplenote-electron/releases/download/v$VERSION/$PKGNAME-$VERSION-$arch.AppImage" PKGURL="https://github.com/Automattic/simplenote-electron/releases/download/v$VERSION/$PKGNAME-$VERSION-$arch.AppImage"
fi fi
......
...@@ -26,7 +26,7 @@ esac ...@@ -26,7 +26,7 @@ esac
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/Eugeny/tabby/" "tabby-.$VERSION-linux-$arch.$pkgtype") PKGURL=$(get_github_url "https://github.com/Eugeny/tabby/" "tabby-$VERSION-linux-$arch.$pkgtype")
else else
PKGURL="https://github.com/Eugeny/tabby/releases/download/v$VERSION/tabby-$VERSION-linux-$arch.$pkgtype" PKGURL="https://github.com/Eugeny/tabby/releases/download/v$VERSION/tabby-$VERSION-linux-$arch.$pkgtype"
fi fi
......
...@@ -11,7 +11,7 @@ URL="https://github.com/Windscribe/Desktop-App" ...@@ -11,7 +11,7 @@ URL="https://github.com/Windscribe/Desktop-App"
arch="$(epm print info --debian-arch)" arch="$(epm print info --debian-arch)"
if [ "$VERSION" = "*" ] ; then if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/Windscribe/Desktop-App/" "${PKGNAME}_.${VERSION}_$arch.deb") PKGURL=$(get_github_url "https://github.com/Windscribe/Desktop-App/" "${PKGNAME}_${VERSION}_$arch.deb")
else else
PKGURL="https://github.com/Windscribe/Desktop-App/releases/download/v$VERSION/${PKGNAME}_${VERSION}_$arch.deb" PKGURL="https://github.com/Windscribe/Desktop-App/releases/download/v$VERSION/${PKGNAME}_${VERSION}_$arch.deb"
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment