mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
1 parent
7caed57caf
commit
6b0744c1c7
4 files changed
+15
-20
No files matched your search
@@ -7,12 +7,12 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block status %}
|
||||
{% if backports_in_use %}
|
||||
{% if is_backports_enabled %}
|
||||
<h3>{% trans "Security Notice" %}</h3>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
You are using packages from Debian backports. Please note that these
|
||||
packages do not have security support from Debian. However, they are
|
||||
Backports are enabled. Please note that packages from the backports
|
||||
repository do not have security support from Debian. However, they are
|
||||
maintained on a best-effort basis by contributors in Debian and
|
||||
FreedomBox community.
|
||||
{% endblocktrans %}
|
||||
|
||||
@@ -9,7 +9,7 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
from plinth import action_utils, actions
|
||||
from plinth.modules import security
|
||||
from plinth.modules.upgrades import get_backports_in_use
|
||||
from plinth.modules.upgrades import is_backports_enabled
|
||||
|
||||
from .forms import SecurityForm
|
||||
|
||||
@@ -33,7 +33,7 @@ def index(request):
|
||||
request, 'security.html', {
|
||||
'app_info': security.app.info,
|
||||
'form': form,
|
||||
'backports_in_use': get_backports_in_use(),
|
||||
'is_backports_enabled': is_backports_enabled(),
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
FreedomBox app for upgrades.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -32,6 +33,8 @@ _description = [
|
||||
|
||||
app = None
|
||||
|
||||
SOURCES_LIST = '/etc/apt/sources.list.d/freedombox2.list'
|
||||
|
||||
|
||||
class UpgradesApp(app_module.App):
|
||||
"""FreedomBox app for software upgrades."""
|
||||
@@ -135,22 +138,14 @@ def setup_repositories(data):
|
||||
actions.superuser_run('upgrades', ['setup-repositories'])
|
||||
|
||||
|
||||
def get_backports_in_use():
|
||||
"""Return whether backports packages are installed."""
|
||||
# Only freedombox package is set to be installed from backports currently.
|
||||
output = subprocess.check_output(['apt-cache', 'policy', 'freedombox'])
|
||||
for line in output.decode().split('\n'):
|
||||
if 'Installed:' in line:
|
||||
version = line.strip().split(': ')[1]
|
||||
if 'bpo' in version:
|
||||
return True
|
||||
|
||||
return False
|
||||
def is_backports_enabled():
|
||||
"""Return whether backports are enabled."""
|
||||
return os.path.exists(SOURCES_LIST)
|
||||
|
||||
|
||||
def can_activate_backports():
|
||||
"""Return whether backports can be activated."""
|
||||
if get_backports_in_use():
|
||||
if is_backports_enabled():
|
||||
return False
|
||||
|
||||
release = subprocess.check_output(['lsb_release', '--release',
|
||||
|
||||
Reference in new issue
Block a user