upgrades: Don't enable backports on Debian derivatives

- Avoid introducing dependency on dpkg-vendor.

Tested:

- Install a base-files package from Ubuntu. Change
  /etc/dpkg/origins/default to point to it. Running the
  setup-repositories action does not create the backports list in apt
  sources.

Closes: #1654.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2020-06-03 09:41:20 -04:00 committed by Sunil Mohan Adapa
parent ac103d7132
commit 848845c432
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -184,6 +184,21 @@ def _check_and_backports_sources():
print('Repositories list up-to-date. Skipping update.')
return
try:
with open('/etc/dpkg/origins/default', 'r') as default_origin:
matches = [
re.match(r'Vendor:\s+Debian', line, flags=re.IGNORECASE)
for line in default_origin.readlines()
]
except FileNotFoundError:
print('Could not open /etc/dpkg/origins/default')
return
if not any(matches):
print('System is running a derivative of Debian. Skip enabling '
'backports.')
return
protocol = _get_protocol()
if protocol == 'tor+http':
print('Package download over Tor is enabled.')