A única maneira de abrir sources.list
e/ou sources.list.d
? Eu gostaria de ter algo como:
apt list enabled_repos
Responder1
Depende do formato de saída que você deseja.
apt-cache policy
mostra as fontes atuais com a prioridade aplicada a cada uma:
~ apt-cache policy
Package files:
100 /var/lib/dpkg/status
release a=now
500 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main i386 Packages
release v=16.04,o=LP-PPA-webupd8team-java,a=xenial,n=xenial,l=Oracle Java (JDK) 8 / 9 Installer PPA,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main amd64 Packages
release v=16.04,o=LP-PPA-webupd8team-java,a=xenial,n=xenial,l=Oracle Java (JDK) 8 / 9 Installer PPA,c=main,b=amd64
origin ppa.launchpad.net
500 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial/main i386 Packages
release v=16.04,o=LP-PPA-ubuntu-wine,a=xenial,n=xenial,l=Wine Team PPA,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial/main amd64 Packages
release v=16.04,o=LP-PPA-ubuntu-wine,a=xenial,n=xenial,l=Wine Team PPA,c=main,b=amd64
origin ppa.launchpad.net
500 http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial/main i386 Packages
release v=16.04,o=LP-PPA-jonathonf-vim,a=xenial,n=xenial,l=Vim,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial/main amd64 Packages
release v=16.04,o=LP-PPA-jonathonf-vim,a=xenial,n=xenial,l=Vim,c=main,b=amd64
....
As informações aqui podem ser usadas em outras configurações do apt, como aptpreferences
ou a configuração para unattended-upgrades
.
Você também pode usara API Python:
#! /usr/bin/env python3
import aptsources.sourceslist
sources = sourcesList.SourcesList()
for source in sources:
if not (source.disabled or source.invalid):
print(source.line.strip())
O que fornece resultados como:
deb http://jp.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://jp.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://jp.archive.ubuntu.com/ubuntu/ xenial universe
deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial universe
deb http://jp.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://jp.archive.ubuntu.com/ubuntu/ xenial multiverse
deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://jp.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://jp.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://jp.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb-src http://security.ubuntu.com/ubuntu xenial-security universe