from bundlewrap.metadata import atomic

defaults = {
    'apt': {
        'repos': {
            'deb-multimedia': {
                'items': {
                    'deb https://ftp-stud.hs-esslingen.de/pub/Mirrors/debian-multimedia/ {os_release} main',
                    #'deb https://ftp-stud.hs-esslingen.de/pub/Mirrors/debian-multimedia/ {os_release}-backports main',
                },
            },
        },
        'packages': {
            'cec-utils': {},
            'fonts-noto': {},
            'fonts-roboto': {},
            'kodi': {},
            'kodi-inputstream-adaptive': {},
            'libasound2': {},
            'ttf-mscorefonts-installer': {},
            'tv-fonts': {},
            'xfonts-base': {},
            'xinit': {},
            'xserver-xorg': {},
            'xserver-xorg-legacy': {},
        },
    },
    'backups': {
        'paths': {
            '/home/kodi',
        },
    },
    'users': {
        'kodi': {
            'groups': {
                'audio',
                'tty',
                'video',
            },
        },
    },
}


@metadata_reactor.provides(
    'firewall/port_rules/8080',
    'firewall/port_rules/9090',
)
def firewall(metadata):
    return {
        'firewall': {
            'port_rules': {
                '8080': atomic(metadata.get('kodi/restrict-to', {'*'})),
                '9090': atomic(metadata.get('kodi/restrict-to', {'*'})),
            },
        },
    }