(distro_id, interactive)
Enable Blockstream Satellite's binary package repository

    Args:
        distro_id: Linux distribution ID
        interactive: Interactive mode
Enable Blockstream Satellite's binary package repository
Enable Blockstream Satellite s binary package repository
def _enable_pkg_repo(distro_id, interactive):
    """Enable Blockstream Satellite's binary package repository

    Args:
        distro_id: Linux distribution ID
        interactive: Interactive mode

    """
    cmds = list()
    if (which("apt")):
        apt_repo = _get_apt_repo(distro_id)

        # On debian, add the apt repository through "add-apt-repository". On
        # raspbian, where "add-apt-repository" does not work, manually add a
        # file into /etc/apt/sources.list.d/.
        if distro_id == "raspbian":
            release_codename = distro.codename()
            apt_list_filename = "blockstream-satellite-{}-{}.list".format(
                distro_id, release_codename)
            apt_list_file = os.path.join("/etc/apt/sources.list.d/",
                                         apt_list_filename)
            apt_component = "main"
            apt_file_content = "deb {0} {1} {2}\n# deb-src {0} {1} {2}".format(
                apt_repo, release_codename, apt_component)
            # In execution mode, create a temporary file and move it to
            # /etc/apt/sources.list.d/. With that, only the move command needs
            # root permissions, whereas the temporary file does not. In dry-run
            # mode, print an equivalent echo command.
            if (runner.dry):
                cmd = [
                    "echo", "-e",
                    repr(apt_file_content), ">>", apt_list_file
                ]
            else:
                tmp_file = tempfile.NamedTemporaryFile(mode="w", delete=False)
                with tmp_file as fd:
                    fd.write(apt_file_content)
                cmd = ["mv", tmp_file.name, apt_list_file]
        else:
            cmd = ["add-apt-repository", apt_repo]
            if (not interactive):
                cmd.append("-y")

        cmds.append(cmd)

        if distro_id in ["debian", "raspbian"]:
            cmd = [
                "apt-key", "adv", "--keyserver", "keyserver.ubuntu.com",
                "--recv-keys", defs.blocksat_pubkey
            ]
            cmds.append(cmd)

        cmd = ["apt", "update"]
        if (not interactive):
            cmd.append("-y")
        cmds.append(cmd)
    elif (which("dnf")):
        cmd = ["dnf", "copr", "enable", "blockstream/satellite"]
        if (not interactive):
            cmd.append("-y")
        cmds.append(cmd)
    elif (which("yum")):
        cmd = ["yum", "copr", "enable", "blockstream/satellite"]
        if (not interactive):
            cmd.append("-y")
        cmds.append(cmd)
    else:
        raise RuntimeError("Could not find a supported package manager")

    for cmd in cmds:
        runner.run(cmd, root=True)
def _enable_pkg_repo ( distro_id , interactive ) : cmds = list ( ) if ( which ( "apt" ) ) : apt_repo = _get_apt_repo ( distro_id ) # On debian, add the apt repository through "add-apt-repository". On # raspbian, where "add-apt-repository" does not work, manually add a # file into /etc/apt/sources.list.d/. if distro_id == "raspbian" : release_codename = distro . codename ( ) apt_list_filename = "blockstream-satellite-{}-{}.list" . format ( distro_id , release_codename ) apt_list_file = os . path . join ( "/etc/apt/sources.list.d/" , apt_list_filename ) apt_component = "main" apt_file_content = "deb {0} {1} {2}\n# deb-src {0} {1} {2}" . format ( apt_repo , release_codename , apt_component ) # In execution mode, create a temporary file and move it to # /etc/apt/sources.list.d/. With that, only the move command needs # root permissions, whereas the temporary file does not. In dry-run # mode, print an equivalent echo command. if ( runner . dry ) : cmd = [ "echo" , "-e" , repr ( apt_file_content ) , ">>" , apt_list_file ] else : tmp_file = tempfile . NamedTemporaryFile ( mode = "w" , delete = False ) with tmp_file as fd : fd . write ( apt_file_content ) cmd = [ "mv" , tmp_file . name , apt_list_file ] else : cmd = [ "add-apt-repository" , apt_repo ] if ( not interactive ) : cmd . append ( "-y" ) cmds . append ( cmd ) if distro_id in [ "debian" , "raspbian" ] : cmd = [ "apt-key" , "adv" , "--keyserver" , "keyserver.ubuntu.com" , "--recv-keys" , defs . blocksat_pubkey ] cmds . append ( cmd ) cmd = [ "apt" , "update" ] if ( not interactive ) : cmd . append ( "-y" ) cmds . append ( cmd ) elif ( which ( "dnf" ) ) : cmd = [ "dnf" , "copr" , "enable" , "blockstream/satellite" ] if ( not interactive ) : cmd . append ( "-y" ) cmds . append ( cmd ) elif ( which ( "yum" ) ) : cmd = [ "yum" , "copr" , "enable" , "blockstream/satellite" ] if ( not interactive ) : cmd . append ( "-y" ) cmds . append ( cmd ) else : raise RuntimeError ( "Could not find a supported package manager" ) for cmd in cmds : runner . run ( cmd , root = True )