#!/bin/bash
KOMPAS_REPO_URL="${KOMPAS_REPO_URL:-https://repo.ascon.ru/stable/rpm/redos/8.0/}"
installed_rpms_from_ascon=""
while read -r line
do
	rpm -q "$line" &>/dev/null && installed_rpms_from_ascon+=" $line"
done < <(dnf -q --refresh --repofrompath kompas,"$KOMPAS_REPO_URL" --disablerepo '*' --enablerepo kompas repoquery --qf '%{name}')

if [ -z "$installed_rpms_from_ascon" ]; then
	echo "Ни один из пакетов из репозитория Аскон не установлен, нечего обновлять"
	exit 0
fi

dnf --repofrompath kompas,"$KOMPAS_REPO_URL" upgrade -y $installed_rpms_from_ascon
