upgrades: Use only sources file to determine if backports enabled

Tests:
- Build deb and install in buster image. Manually remove backports
  sources file. Security page does not show backports notice. Updates
  page shows button to activate backports.
- Activate backports from updates page. Success message is shown and
  button to activate backports is removed. Security page shows
  backports notice.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2020-07-13 14:44:13 -07:00
1 parent 7caed57caf
commit 6b0744c1c7
4 files changed
+15 -20

No files matched your search

+3 -3
View File
@@ -13,6 +13,7 @@ import sys
from plinth.action_utils import run_apt_command
from plinth.modules.apache.components import check_url
from plinth.modules.upgrades import is_backports_enabled, SOURCES_LIST
AUTO_CONF_FILE = '/etc/apt/apt.conf.d/20auto-upgrades'
LOG_FILE = '/var/log/unattended-upgrades/unattended-upgrades.log'
@@ -192,8 +193,7 @@ def _check_and_backports_sources():
if os.path.exists(old_sources_list):
os.remove(old_sources_list)
sources_list = '/etc/apt/sources.list.d/freedombox2.list'
if os.path.exists(sources_list):
if is_backports_enabled():
print('Repositories list up-to-date. Skipping update.')
return
@@ -229,7 +229,7 @@ def _check_and_backports_sources():
return
print(f'{dist}-backports is now available. Adding to sources.')
_add_backports_sources(sources_list, protocol, dist)
_add_backports_sources(SOURCES_LIST, protocol, dist)
def _add_apt_preferences():