From 42d1960351c0039ed7018e8e78b14d96809b2f4a Mon Sep 17 00:00:00 2001
From: Vitaly Lipatov <lav@etersoft.ru>
Date: Mon, 18 Apr 2022 01:46:03 +0300
Subject: [PATCH] epm play: cleanup rules

---
 play.d/assistant.sh     |  8 +++-----
 play.d/chrome.sh        | 13 -------------
 play.d/chromium-gost.sh |  1 +
 play.d/code.sh          | 12 +++---------
 play.d/discord.sh       |  2 ++
 play.d/eagle.sh         | 11 ++++++++---
 play.d/ktalk.sh         |  5 ++++-
 play.d/mssql-tools.sh   |  4 ++--
 8 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/play.d/assistant.sh b/play.d/assistant.sh
index 9c7cd105..a10c4cfb 100755
--- a/play.d/assistant.sh
+++ b/play.d/assistant.sh
@@ -18,15 +18,13 @@ arch="$($DISTRVENDOR -a)"
 
 pkg="$($DISTRVENDOR -p)"
 
-echo "ОШИБКА: невозможно проверить сертификат xn--80akicokc0aablc.xn--p1ai, выпущенный «CN=Sectigo RSA Domain Validation Secure Server CA,O=Sectigo Limited,L=Salford,ST=Greater Manchester,C=GB»:"
-
 case $arch-$pkg in
     x86_64-rpm)
-        URL="http://мойассистент.рф/%D1%81%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C/Download/542"
+        URL="https://мойассистент.рф/%D1%81%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C/Download/542"
         OPKG=assistant-4.8-0.x86_64.rpm
         ;;
     x86_64-deb)
-        URL="http://мойассистент.рф/%D1%81%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C/Download/545"
+        URL="https://мойассистент.рф/%D1%81%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C/Download/545"
         OPKG=assistant_4.8-0_amd64.deb
         ;;
     aarch64-rpm)
@@ -51,7 +49,7 @@ esac
 
 [ "$($DISTRVENDOR -d)" = "ALTLinux" ] && epmi --skip-installed fontconfig-disable-type1-font-for-assistant
 
-epm $repack install "$URL" || exit
+LANG=ru_RU.UTF8 epm $repack install "$URL" || exit
 
 [ "$repack" = "--scripts" ] && echo "Warning! Privileged scripts from the vendor were running."
 
diff --git a/play.d/chrome.sh b/play.d/chrome.sh
index cc6512bd..2c750178 100755
--- a/play.d/chrome.sh
+++ b/play.d/chrome.sh
@@ -17,19 +17,6 @@ pkgtype=deb
 # we have workaround for their postinstall script, so always repack rpm package
 [ "$($DISTRVENDOR -p)" = "deb" ] || repack='--repack'
 
-# don't used
-complex_get()
-{
-    epm assure curl || fatal
-    # see https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=google-chrome
-    _channel=stable
-    pkgver=$(a= curl -s https://dl.google.com/linux/chrome/rpm/stable/x86_64/repodata/other.xml.gz | gzip -df | grep -A1 google-chrome-stable | tail -n1 | sed -e 's|.* ver="\(.*\)" .*|\1|')
-
-    pkgtype=deb
-
-    PKG="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-${_channel}/google-chrome-${_channel}_${pkgver}-1_amd64.deb"
-}
-
 PKG="https://dl.google.com/linux/direct/google-chrome-stable_current_$arch.$pkgtype"
 
 epm install $repack "$PKG"
diff --git a/play.d/chromium-gost.sh b/play.d/chromium-gost.sh
index 32f3b7e9..d4078b00 100755
--- a/play.d/chromium-gost.sh
+++ b/play.d/chromium-gost.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+# filename does not contain -stable, but package name with -stable
 PKGNAME=chromium-gost-stable
 DESCRIPTION="Chromium with GOST support from the official site"
 
diff --git a/play.d/code.sh b/play.d/code.sh
index 6d2b179c..eb8ebbe8 100755
--- a/play.d/code.sh
+++ b/play.d/code.sh
@@ -29,16 +29,10 @@ pkgtype="$($DISTRVENDOR -p)"
 # we have workaround for their postinstall script, so always repack rpm package
 [ "$pkgtype" = "deb" ] || repack='--repack'
 
-PKG=/tmp/$PKGNAME.$pkgtype
-
 if [ -n "$VERSION" ] ; then
-    # get the version
-    $EGET -O $PKG "https://update.code.visualstudio.com/$VERSION/linux-$pkgtype-$arch/stable" || fatal
+    URL="https://update.code.visualstudio.com/$VERSION/linux-$pkgtype-$arch/stable"
 else
-    # get latest version
-    # TODO: wget does not support:  Content-Disposition: attachment; filename="code-1.52.1-1608137084.el7.x86_64.rpm"
-    $EGET -O $PKG "https://code.visualstudio.com/sha/download?build=stable&os=linux-$pkgtype-$arch" || fatal
+    URL="https://code.visualstudio.com/sha/download?build=stable&os=linux-$pkgtype-$arch"
 fi
 
-epm install $repack "$PKG" || exit
-rm -fv $PKG
+epm install $repack "$URL"
diff --git a/play.d/discord.sh b/play.d/discord.sh
index a8e8b63d..6badbeed 100755
--- a/play.d/discord.sh
+++ b/play.d/discord.sh
@@ -8,5 +8,7 @@ DESCRIPTION="Discord from the official site"
 
 [ "$($DISTRVENDOR -a)" != "x86_64" ] && echo "Only x86_64 is supported" && exit 1
 
+# curl can't get filename: https://github.com/curl/curl/issues/8461
+epm assure wget
 epm install "https://discord.com/api/download?platform=linux&format=deb"
 
diff --git a/play.d/eagle.sh b/play.d/eagle.sh
index 762f4873..584e117f 100755
--- a/play.d/eagle.sh
+++ b/play.d/eagle.sh
@@ -12,14 +12,19 @@ VERSION=9.6.2
 IPFSHASH=Qmd38jJnTnUMUeJuKSDBGesqXF3SxEahUVZc6NUPyMKgj1
 PKGURL="https://trial2.autodesk.com/NET17SWDLD/2017/EGLPRM/ESD/Autodesk_EAGLE_${VERSION}_English_Linux_64bit.tar.gz"
 
-if ! epm install --repack "$PKGURL" ; then
+PKGDIR="$(mktemp -d)"
+cd $PKGDIR || fatal
+if ! $EGET $PKGURL ; then
     echo "It is possible you are blocked from USA, trying get from IPFS ..."
     pkgname=$(basename $PKGURL)
     $EGET -O $pkgname http://dhash.ru/ipfs/$IPFSHASH || fatal "Can't get $pkgname from IPFS."
-    epm install --repack $pkgname || exit
-    rm -fv $pkgname
 fi
 
+epm install --repack *.tar.gz
+RES=$?
+
+rm -rfv $PKGDIR
+
 echo
 echo "
 Run via
diff --git a/play.d/ktalk.sh b/play.d/ktalk.sh
index 1b87482e..9067eb19 100755
--- a/play.d/ktalk.sh
+++ b/play.d/ktalk.sh
@@ -10,10 +10,13 @@ DESCRIPTION="Контур.Толк (ktalk) from the official site"
 
 URL="https://app.ktalk.ru/system/dist/download/linux"
 
+# curl can't get filename: https://github.com/curl/curl/issues/8461
+epm assure wget || fatal
+
 # hack due ОШИБКА: невозможно проверить сертификат app.ktalk.ru, выпущенный «CN=RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1,O=DigiCert Inc,C=US»
 PKGDIR="$(mktemp -d)"
 cd $PKGDIR || fatal
-$EGET --no-check-certificate "$URL"
+$EGET --no-check-certificate "$URL" || fatal
 
 epm install *.AppImage
 RES=$?
diff --git a/play.d/mssql-tools.sh b/play.d/mssql-tools.sh
index 80b9a2c9..f04f28e7 100755
--- a/play.d/mssql-tools.sh
+++ b/play.d/mssql-tools.sh
@@ -14,16 +14,16 @@ fi
 
 case "$($DISTRVENDOR -d)" in
   "AstraLinux")
+    epm install unixodbc
     epm install https://packages.microsoft.com/debian/8/prod/pool/main/m/msodbcsql17/msodbcsql17_1*_amd64.deb
     epm install https://packages.microsoft.com/debian/8/prod/pool/main/m/mssql-tools/mssql-tools_1*_amd64.deb
     #epm install https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/mssql-tools/mssql-tools_1*_amd64.deb
     #epm install https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql17/msodbcsql17_1*_amd64.deb
-    epm install unixodbc
     ;;
   ALTLinux|ALTServer)
+    epm install unixODBC
     epm install --repack https://packages.microsoft.com/rhel/8/prod/mssql-tools-1*.x86_64.rpm
     epm install --repack https://packages.microsoft.com/rhel/8/prod/msodbcsql17-1*.x86_64.rpm
-    epm install unixODBC
     ;;
   *)
     fatal "$(DISTRVENDOR -d) is not supported yet."
-- 
2.24.1