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

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

7 8 9 10 11 12 13 14
# Assistant reclaim their rpm package supports ALT
repack="--scripts"

if [ "$1" = "--remove" ] ; then
    epm remove $repack $PKGNAME
    exit
fi

15 16
. $(dirname $0)/common.sh

17

18
arch="$($DISTRVENDOR -a)"
19 20
pkg="$($DISTRVENDOR -p)"

21 22 23 24 25 26 27 28
# 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

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

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

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

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

#repack=''
#[ "$($DISTRVENDOR -p)" = "deb" ] || repack='--repack'

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

70
LANG=ru_RU.UTF8 epm $repack install "$URL" || exit
71 72 73

[ "$repack" = "--scripts" ] && echo "Warning! Privileged scripts from the vendor were running."

74
# TODO:
75 76 77
# after install:
#/usr/share/assistantd/daemon.sh --install
#/opt/assistant/scripts/fonts.sh --install