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)"
#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
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
PKGURL="https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v${VERSION}/Clash.Verge_${VERSION}_$arch.deb"
fi
......
......@@ -184,6 +184,15 @@ get_latest_version()
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() {
local url="$1"
local user_and_repo=${url#https://github.com/}
......@@ -196,8 +205,11 @@ get_github_url()
local url="$1"
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
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
get_github_release_info "$url" \
| awk '{
......@@ -210,7 +222,7 @@ get_github_url()
match($0, /"browser_download_url": "(https[^"]*)"/, arr);
print arr[1];
}
}' | grep "$2" | head -1
}' | grep -E "$wc" | head -1
fi
}
......
......@@ -16,7 +16,7 @@ esac
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
PKGURL="https://github.com/juanfont/headscale/releases/download/v$VERSION/${PKGNAME}_${VERSION}_linux_$arch.deb"
fi
......
......@@ -10,7 +10,7 @@ URL="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher"
arch=x86_64
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
PKGURL="https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/download/v$VERSION/${PKGNAME}-${VERSION}-linux-$arch.AppImage"
fi
......
......@@ -13,6 +13,6 @@ URL="https://www.getmailspring.com/"
arch=amd64
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
......@@ -10,7 +10,7 @@ URL="https://mattermost.com/"
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
......@@ -9,7 +9,7 @@ URL="https://moonlight-stream.org/"
. $(dirname $0)/common.sh
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
PKGURL="https://github.com/moonlight-stream/moonlight-qt/releases/download/v$VERSION/$PKGNAME-$VERSION-x86_64.AppImage"
fi
......
......@@ -27,7 +27,7 @@ else
fi
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
PKGURL="https://github.com/cyanfish/naps2/releases/download/v$VERSION/$PKGNAME-$VERSION-linux-$arch.$pkgtype"
fi
......
......@@ -9,7 +9,7 @@ URL="https://persepolisdm.github.io/"
. $(dirname $0)/common.sh
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
PKGURL="https://github.com/persepolisdm/persepolis/releases/download/$VERSION/${PKGNAME}_${VERSION}_all.deb"
fi
......
......@@ -12,25 +12,23 @@ pkgtype="$(epm print info -p)"
case $pkgtype in
# rpm)
# mask="${PKGNAME}-.${VERSION}.x86_64.rpm"
# mask="${PKGNAME}-${VERSION}.x86_64.rpm"
# ;;
deb)
mask="${PKGNAME}-.${VERSION}_amd64.deb"
mask="${PKGNAME}-${VERSION}_amd64.deb"
;;
*)
mask="SchildiChat-.${VERSION}.AppImage"
mask="SchildiChat-${VERSION}.AppImage"
;;
esac
if [ "$VERSION" = "*" ] ; then
PKGURL=$(get_github_url "https://github.com/SchildiChat/schildichat-desktop/" "$mask")
else
# need because get_github_url doesn't support ${VERSION} without a dot before VERSION in mask
direct_mask="$(echo $mask | sed 's/\.//')"
PKGURL="https://github.com/SchildiChat/schildichat-desktop/releases/download/v$VERSION/$direct_mask"
PKGURL="https://github.com/SchildiChat/schildichat-desktop/releases/download/v$VERSION/$mask"
fi
if [ $mask = "SchildiChat-.${VERSION}.AppImage" ]; then
if [ $mask = "SchildiChat-${VERSION}.AppImage" ]; then
install_pack_pkgurl
else
install_pkgurl
......
......@@ -20,7 +20,7 @@ case "$(epm print info -a)" in
esac
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
PKGURL="https://github.com/Automattic/simplenote-electron/releases/download/v$VERSION/$PKGNAME-$VERSION-$arch.AppImage"
fi
......
......@@ -26,7 +26,7 @@ esac
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
PKGURL="https://github.com/Eugeny/tabby/releases/download/v$VERSION/tabby-$VERSION-linux-$arch.$pkgtype"
fi
......
......@@ -11,7 +11,7 @@ URL="https://github.com/Windscribe/Desktop-App"
arch="$(epm print info --debian-arch)"
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
PKGURL="https://github.com/Windscribe/Desktop-App/releases/download/v$VERSION/${PKGNAME}_${VERSION}_$arch.deb"
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