if [[ $(lsb_release -cs) = "buster" ]]; then
    APT_BACKPORTS_SRC=/etc/apt/sources.list.d/backports.list
    APT_BACKPORTS_REPO=$(lsb_release -cs)-backports
    BACKPORTS_DIRTY=
    if ! [[ -f $APT_BACKPORTS_SRC ]]; then
        echo "deb http://ftp.fi.muni.cz/pub/linux/debian/ $APT_BACKPORTS_REPO main contrib non-free" > $APT_BACKPORTS_SRC
        echo "deb-src http://ftp.fi.muni.cz/pub/linux/debian/ $APT_BACKPORTS_REPO main contrib non-free" >> $APT_BACKPORTS_SRC
        BACKPORTS_DIRTY=1
    fi
    APT_PIN=/etc/apt/preferences.d/
    APT_STABLE_PIN=$APT_PIN/30_stable
    if ! [[ -f $APT_STABLE_PIN ]]; then
        cat > $APT_STABLE_PIN <<EOF
Package: *
Pin: release a=stable
Pin-Priority: 900
EOF
        BACKPORTS_DIRTY=1
    fi
    APT_BACKPORTS_PIN=$APT_PIN/31_backports
    if ! [[ -f $APT_BACKPORTS_PIN ]]; then
        cat > $APT_BACKPORTS_PIN <<EOF
Package: *
Pin: release a=$APT_BACKPORTS_REPO
Pin-Priority: 750
EOF
        BACKPORTS_DIRTY=1
    fi
    if [[ -n "$BACKPORTS_DIRTY" ]]; then
        apt update
    fi
fi
