Add UI for managing Qubes update repositories
Depends on QubesOS/qubes-core-admin-linux#48 Fixes QubesOS/qubes-issues#4550
This commit is contained in:
parent
a8df324b2d
commit
fdd06d32a5
@ -24,6 +24,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import traceback
|
import traceback
|
||||||
|
import subprocess
|
||||||
from PyQt4 import QtCore, QtGui # pylint: disable=import-error
|
from PyQt4 import QtCore, QtGui # pylint: disable=import-error
|
||||||
|
|
||||||
from qubesadmin import Qubes
|
from qubesadmin import Qubes
|
||||||
@ -233,8 +234,15 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
|
|||||||
qmemman_config_file.writelines(config_lines)
|
qmemman_config_file.writelines(config_lines)
|
||||||
qmemman_config_file.close()
|
qmemman_config_file.close()
|
||||||
|
|
||||||
def __init_updates__(self):
|
def __run_qrexec_repo(self, service, arg=''):
|
||||||
|
# Fake up a "qrexec call" to dom0 because dom0 can't qrexec to itself yet
|
||||||
|
cmd = '/etc/qubes-rpc/' + service
|
||||||
|
p = subprocess.run(['sudo', cmd, arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
assert not p.stderr
|
||||||
|
assert p.returncode == 0
|
||||||
|
return p.stdout.decode('utf-8')
|
||||||
|
|
||||||
|
def __init_updates__(self):
|
||||||
# TODO: remove workaround when it is no longer needed
|
# TODO: remove workaround when it is no longer needed
|
||||||
self.dom0_updates_file_path = '/var/lib/qubes/updates/disable-updates'
|
self.dom0_updates_file_path = '/var/lib/qubes/updates/disable-updates'
|
||||||
|
|
||||||
@ -251,6 +259,73 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
|
|||||||
self.enable_updates_all.clicked.connect(self.__enable_updates_all)
|
self.enable_updates_all.clicked.connect(self.__enable_updates_all)
|
||||||
self.disable_updates_all.clicked.connect(self.__disable_updates_all)
|
self.disable_updates_all.clicked.connect(self.__disable_updates_all)
|
||||||
|
|
||||||
|
repos = dict()
|
||||||
|
for i in self.__run_qrexec_repo('qubes.repos.List').split('\n'):
|
||||||
|
l = i.split('\0')
|
||||||
|
# Keyed by repo name
|
||||||
|
d = repos[l[0]] = dict()
|
||||||
|
d['prettyname'] = l[1]
|
||||||
|
d['enabled'] = True if l[2] == 'enabled' else False
|
||||||
|
|
||||||
|
if repos['qubes-dom0-unstable']['enabled']:
|
||||||
|
self.dom0_updates_repo.setCurrentIndex(3)
|
||||||
|
elif repos['qubes-dom0-current-testing']['enabled']:
|
||||||
|
self.dom0_updates_repo.setCurrentIndex(2)
|
||||||
|
elif repos['qubes-dom0-security-testing']['enabled']:
|
||||||
|
self.dom0_updates_repo.setCurrentIndex(1)
|
||||||
|
elif repos['qubes-dom0-current']['enabled']:
|
||||||
|
self.dom0_updates_repo.setCurrentIndex(0)
|
||||||
|
else:
|
||||||
|
raise Exception('Cannot detect enabled dom0 update repositories')
|
||||||
|
|
||||||
|
if repos['qubes-templates-itl-testing']['enabled']:
|
||||||
|
self.itl_tmpl_updates_repo.setCurrentIndex(1)
|
||||||
|
elif repos['qubes-templates-itl']['enabled']:
|
||||||
|
self.itl_tmpl_updates_repo.setCurrentIndex(0)
|
||||||
|
else:
|
||||||
|
raise Exception('Cannot detect enabled ITL template update repositories')
|
||||||
|
|
||||||
|
if repos['qubes-templates-community-testing']['enabled']:
|
||||||
|
self.comm_tmpl_updates_repo.setCurrentIndex(2)
|
||||||
|
elif repos['qubes-templates-community']['enabled']:
|
||||||
|
self.comm_tmpl_updates_repo.setCurrentIndex(1)
|
||||||
|
else:
|
||||||
|
self.comm_tmpl_updates_repo.setCurrentIndex(0)
|
||||||
|
|
||||||
|
self.dom0_updates_repo.currentIndexChanged.connect(self.__handle_dom0_updates_combobox)
|
||||||
|
self.itl_tmpl_updates_repo.currentIndexChanged.connect(self.__handle_itl_tmpl_updates_combobox)
|
||||||
|
self.comm_tmpl_updates_repo.currentIndexChanged.connect(self.__handle_comm_tmpl_updates_combobox)
|
||||||
|
|
||||||
|
def __manage_repos(self, l, action):
|
||||||
|
for i in l:
|
||||||
|
assert self.__run_qrexec_repo('qubes.repos.' + action, i) == 'ok\n'
|
||||||
|
|
||||||
|
def __handle_dom0_updates_combobox(self, idx):
|
||||||
|
idx += 1
|
||||||
|
l = ['qubes-dom0-current', 'qubes-dom0-security-testing',
|
||||||
|
'qubes-dom0-current-testing', 'qubes-dom0-unstable']
|
||||||
|
enable = l[:idx]
|
||||||
|
disable = l[idx:]
|
||||||
|
self.__manage_repos(enable, 'Enable')
|
||||||
|
self.__manage_repos(disable, 'Disable')
|
||||||
|
|
||||||
|
def __handle_itl_tmpl_updates_combobox(self, idx):
|
||||||
|
idx += 1
|
||||||
|
l = ['qubes-templates-itl', 'qubes-templates-itl-testing']
|
||||||
|
enable = l[:idx]
|
||||||
|
disable = l[idx:]
|
||||||
|
self.__manage_repos(enable, 'Enable')
|
||||||
|
self.__manage_repos(disable, 'Disable')
|
||||||
|
|
||||||
|
def __handle_comm_tmpl_updates_combobox(self, idx):
|
||||||
|
# We don't increment idx by 1 because this is the only combobox that
|
||||||
|
# has an explicit "disable this repository entirely" option
|
||||||
|
l = ['qubes-templates-community', 'qubes-templates-community-testing']
|
||||||
|
enable = l[:idx]
|
||||||
|
disable = l[idx:]
|
||||||
|
self.__manage_repos(enable, 'Enable')
|
||||||
|
self.__manage_repos(disable, 'Disable')
|
||||||
|
|
||||||
def __enable_updates_all(self):
|
def __enable_updates_all(self):
|
||||||
reply = QtGui.QMessageBox.question(
|
reply = QtGui.QMessageBox.question(
|
||||||
self, self.tr("Change state of all qubes"),
|
self, self.tr("Change state of all qubes"),
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -209,6 +209,30 @@
|
|||||||
<string>Updates</string>
|
<string>Updates</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QComboBox" name="dom0_updates_repo">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Stable updates</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Testing updates (security only)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Testing updates</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Unstable updates</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QPushButton" name="disable_updates_all">
|
<widget class="QPushButton" name="disable_updates_all">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -243,6 +267,39 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QComboBox" name="itl_tmpl_updates_repo">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>ITL template updates</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>ITL template updates (testing)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QComboBox" name="comm_tmpl_updates_repo">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>(Community templates disabled)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Community template updates</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Community template updates (testing)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user