assistant.sh 2.25 KB
Newer Older
1 2 3
#!/bin/sh

PKGNAME=assistant
4
SUPPORTEDARCHES="x86_64 aarch64"
5 6
DESCRIPTION="Assistant (Ассистент) from the official site"

7
if [ "$1" = "--remove" ] ; then
8
    epm remove $PKGNAME
9 10 11
    exit
fi

12 13
. $(dirname $0)/common.sh

14

15
arch="$($DISTRVENDOR -a)"
16 17
pkg="$($DISTRVENDOR -p)"

18 19 20 21 22 23 24 25
# some locale depend troubles (ALT with bash 4 needs LANG=ru_RU.UTF-8, Ubuntu with bash 5 needs LANG=C.UTF-8)
#URL="https://мойассистент.рф/скачать"
URL="https://xn--80akicokc0aablc.xn--p1ai/%D1%81%D0%BA%D0%B0%D1%87%D0%B0%D1%82%D1%8C"
if ! LANG=ru_RU.UTF8 check_url_is_accessible "$URL" ; then
    epm tool eget -O- "$URL"
    fatal "Please, check why $URL is not accessible"
fi

26 27
# parse vendor site
tmpfile=$(mktemp)
28
trap "rm -f $tmpfile" EXIT
29
epm tool eget -q -O- "$URL" | grep -A200 "Ассистент для LINUX" >$tmpfile
30

31
url_by_text()
32
{
33
    local text="$1"
34
    local pkg="$(cat $tmpfile | grep -B1 "$text" | head -n1 | grep "/Download/" | sed -e 's|.*href="||' -e 's|".*||')"
35
    [ -n "$pkg" ] || fatal "Can't get Download href for $text"
36 37
    #echo "https://мойассистент.рф$pkg"
    echo "https://xn--80akicokc0aablc.xn--p1ai$pkg"
38 39
}

40 41
case $arch-$pkg in
    x86_64-rpm)
42
        URL="$(url_by_text "Скачать RPM пакет")"
43 44
        ;;
    x86_64-deb)
45 46 47 48 49 50 51
        URL="$(url_by_text "Скачать DEB пакет")"
        ;;
    aarch64-rpm)
        URL="$(url_by_text "Скачать RPM пакет для ARM устройств")"
        ;;
    aarch64-deb)
        URL="$(url_by_text "Скачать DEB пакет для ARM устройств")"
52 53
        ;;
    *)
54
        fatal "$($DISTRVENDOR -e) is not supported (arch $arch, package type is $pkg)"
55 56 57 58 59 60 61
        ;;
esac

# after repack on ALT:
#  assistant: Требует: /lib/init/vars.sh но пакет не может быть установлен
#             Требует: libyuv.so()(64bit) но пакет не может быть установлен

62
[ "$($DISTRVENDOR -s)" = "alt" ] && epmi --skip-installed fontconfig-disable-type1-font-for-assistant
63

64
# TODO: disable scripts (see /etc/eepm/pkgallowscripts.list)
65
LANG=ru_RU.UTF8 epm install "$URL" || exit
66

67 68
echo "Note: original package runs /opt/assistant/scripts/setup.sh --install during install.."
echo "It is dangerous. Use this package at your own risk."