mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
upgrades: Add button to activate backports
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
f41cc116a1
commit
7caed57caf
@ -58,7 +58,7 @@ class UpgradesApp(app_module.App):
|
||||
# Check every day for setting up apt backport sources, every 3 minutes
|
||||
# in debug mode.
|
||||
interval = 180 if cfg.develop else 24 * 3600
|
||||
glib.schedule(interval, _setup_repositories)
|
||||
glib.schedule(interval, setup_repositories)
|
||||
|
||||
def _show_new_release_notification(self):
|
||||
"""When upgraded to new release, show a notification."""
|
||||
@ -111,7 +111,7 @@ def setup(helper, old_version=None):
|
||||
|
||||
# Try to setup apt repositories, if needed, if possible, on first install
|
||||
# and on version increment.
|
||||
helper.call('post', _setup_repositories, None)
|
||||
helper.call('post', setup_repositories, None)
|
||||
|
||||
|
||||
def is_enabled():
|
||||
@ -130,7 +130,7 @@ def disable():
|
||||
actions.superuser_run('upgrades', ['disable-auto'])
|
||||
|
||||
|
||||
def _setup_repositories(data):
|
||||
def setup_repositories(data):
|
||||
"""Setup apt backport repositories."""
|
||||
actions.superuser_run('upgrades', ['setup-repositories'])
|
||||
|
||||
@ -146,3 +146,16 @@ def get_backports_in_use():
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def can_activate_backports():
|
||||
"""Return whether backports can be activated."""
|
||||
if get_backports_in_use():
|
||||
return False
|
||||
|
||||
release = subprocess.check_output(['lsb_release', '--release',
|
||||
'--short']).decode().strip()
|
||||
if release in ['testing', 'unstable']:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@ -8,6 +8,40 @@
|
||||
{% load static %}
|
||||
|
||||
{% block extra_content %}
|
||||
{% if can_activate_backports %}
|
||||
<h3>{% trans "Backports" %}</h3>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
Backports can be activated. This will allow a limited set of software,
|
||||
including FreedomBox service, to be upgraded to newer versions from
|
||||
Debian backports repository.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
Please note that backports packages do not have security support from
|
||||
Debian. However, they are maintained on a best-effort basis by
|
||||
contributors in Debian and FreedomBox community.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
{% url 'snapshot:index' as snapshot_url %}
|
||||
{% blocktrans trimmed %}
|
||||
<strong>Warning!</strong> Once backports are activated, they cannot be
|
||||
easily deactivated. You may wish to take a snapshot using
|
||||
<a href="{{ snapshot_url }}">Storage Snapshots</a> before continuing.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
<p>
|
||||
<form class="form" method="post"
|
||||
action="{% url 'upgrades:activate-backports' %}">
|
||||
{% csrf_token %}
|
||||
<input type="submit" class="btn btn-warning"
|
||||
value="{% trans 'Activate backports' %}"/>
|
||||
</form>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<h3>{% trans "Manual update" %}</h3>
|
||||
{% if is_busy %}
|
||||
<p>
|
||||
|
||||
@ -10,5 +10,7 @@ from . import views
|
||||
urlpatterns = [
|
||||
url(r'^sys/upgrades/$', views.UpgradesConfigurationView.as_view(),
|
||||
name='index'),
|
||||
url(r'^sys/upgrades/activate-backports/$', views.activate_backports,
|
||||
name='activate-backports'),
|
||||
url(r'^sys/upgrades/upgrade/$', views.upgrade, name='upgrade'),
|
||||
]
|
||||
|
||||
@ -28,6 +28,7 @@ class UpgradesConfigurationView(AppView):
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context['can_activate_backports'] = upgrades.can_activate_backports()
|
||||
context['is_busy'] = package.is_package_manager_busy()
|
||||
context['log'] = get_log()
|
||||
context['refresh_page_sec'] = 3 if context['is_busy'] else None
|
||||
@ -77,3 +78,12 @@ def upgrade(request):
|
||||
messages.error(request, _('Starting upgrade failed.'))
|
||||
|
||||
return redirect(reverse_lazy('upgrades:index'))
|
||||
|
||||
|
||||
def activate_backports(request):
|
||||
"""Activate backports."""
|
||||
if request.method == 'POST':
|
||||
upgrades.setup_repositories(None)
|
||||
messages.success(request, _('Backports activated.'))
|
||||
|
||||
return redirect(reverse_lazy('upgrades:index'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user