# /*
#  * Copyright (C) 2020, KylinSoft Co., Ltd.
#  *
#  * This program is free software: you can redistribute it and/or modify
#  * it under the terms of the GNU General Public License as published by
#  * the Free Software Foundation, either version 3 of the License, or
#  * (at your option) any later version.
#  *
#  * This program is distributed in the hope that it will be useful,
#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  * GNU General Public License for more details.
#  *
#  * You should have received a copy of the GNU General Public License
#  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
#  */

#!/usr/bin/python3

from SystemUpdater.modules.i18n import _
from SystemUpdater.Core.errors import *
from SystemUpdater.Core.enums import *
from SystemUpdater.configs import JSONConfig
from pydantic import BaseModel

RUN_SETTINGS = "/var/lib/unattended-upgrades/kylin-update-strategy.json"
DEFAULT_SETTINGS = "/usr/share/kylin-system-updater/kylin-update-strategy.json"
OPT_DEFAULT_SETTINGS = "/opt/update-module/current/usr/share/kylin-system-updater/kylin-update-strategy.json"

class AutoUpdateConfig(BaseModel):
    autobackup: bool = True

class StrategiesConfig(BaseModel):
    autoupdate: AutoUpdateConfig = {}


# 配置文件读取的顺序，/opt自更新的配置优先级最高-> /etc -> /var/cache下面的配置文件 优先级高的覆盖优先级低的
G_strategies = JSONConfig(
    settings_files=[
        DEFAULT_SETTINGS,
        OPT_DEFAULT_SETTINGS,
        RUN_SETTINGS
    ]
)
