mambabase.py: initial support for extra components and other improvements
This commit is contained in:
parent
8b9fd9e648
commit
39bc23faf6
@ -23,23 +23,17 @@ class InstallThread(QtCore.QThread):
|
||||
updateProgressSignal = QtCore.pyqtSignal(dict)
|
||||
pkggroups = {}
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent=None, pkggroups={}):
|
||||
super(InstallThread, self).__init__(parent)
|
||||
self.parent = parent
|
||||
self.pkggroups = pkggroups
|
||||
self.doneSignal.connect(parent.installationPage.completeChanged)
|
||||
self.updateProgressSignal.connect(
|
||||
parent.installationPage.updateProgressSlot)
|
||||
# Load packages group db into a dict
|
||||
result = subprocess.run(['/usr/libexec/mambabase-pkggroups-parser.sh'],
|
||||
stdout=subprocess.PIPE)
|
||||
lines = result.stdout.decode('UTF-8').splitlines()
|
||||
for line in lines:
|
||||
if line:
|
||||
(key, val) = line.split("=")
|
||||
self.pkggroups[key] = val
|
||||
|
||||
def run(self):
|
||||
install = {}
|
||||
install_extras = {}
|
||||
parent = self.parent
|
||||
|
||||
# Disable back and next buttons
|
||||
@ -48,62 +42,11 @@ class InstallThread(QtCore.QThread):
|
||||
self.updateProgressSignal.emit(
|
||||
{ 'value': 1, 'label': _("Starting installation...")})
|
||||
|
||||
# Groups
|
||||
install['base'] = \
|
||||
parent.selectGroupsPage.inst_base.isChecked()
|
||||
install['office'] = \
|
||||
parent.selectGroupsPage.inst_office.isChecked()
|
||||
install['players'] = \
|
||||
parent.selectGroupsPage.inst_players.isChecked()
|
||||
install['multimedia_editing'] = \
|
||||
parent.selectGroupsPage.inst_multimedia_editing.isChecked()
|
||||
install['internet'] = \
|
||||
parent.selectGroupsPage.inst_internet.isChecked()
|
||||
install['graphics'] = \
|
||||
parent.selectGroupsPage.inst_graphics.isChecked()
|
||||
install['games'] = \
|
||||
parent.selectGroupsPage.inst_games.isChecked()
|
||||
install['virtualization'] = \
|
||||
parent.selectGroupsPage.inst_virtualization.isChecked()
|
||||
install['server'] = \
|
||||
parent.selectGroupsPage.inst_server.isChecked()
|
||||
install['devel'] = \
|
||||
parent.selectGroupsPage.inst_devel.isChecked()
|
||||
# Extra proprietary
|
||||
install['nvidia'] = \
|
||||
parent.selectExtraPage.inst_nvidia.isChecked()
|
||||
install['fglrx'] = \
|
||||
parent.selectExtraPage.inst_fglrx.isChecked()
|
||||
install['fglrx_legacy'] = \
|
||||
parent.selectExtraPage.inst_fglrx_legacy.isChecked()
|
||||
install['broadcom_sta'] = \
|
||||
parent.selectExtraPage.inst_broadcom_sta.isChecked()
|
||||
install['b43'] = \
|
||||
parent.selectExtraPage.inst_b43.isChecked()
|
||||
install['flash'] = \
|
||||
parent.selectExtraPage.inst_flash.isChecked()
|
||||
install['pepperflash'] = \
|
||||
parent.selectExtraPage.inst_pepperflash.isChecked()
|
||||
install['msttcf'] = \
|
||||
parent.selectExtraPage.inst_msttcf.isChecked()
|
||||
install['codecs'] = \
|
||||
parent.selectExtraPage.inst_codecs.isChecked()
|
||||
install['java'] = \
|
||||
parent.selectExtraPage.inst_java.isChecked()
|
||||
install['skype'] = \
|
||||
parent.selectExtraPage.inst_skype.isChecked()
|
||||
install['spotify'] = \
|
||||
parent.selectExtraPage.inst_spotify.isChecked()
|
||||
install['virtualbox'] = \
|
||||
parent.selectExtraPage.inst_virtualbox.isChecked()
|
||||
install['widevine'] = \
|
||||
parent.selectExtraPage.inst_widevine.isChecked()
|
||||
|
||||
# Update packages list
|
||||
self.updateProgressSignal.emit({ 'value': 5,
|
||||
'label': _("Updating packages list...")})
|
||||
|
||||
result = subprocess.run(['pkcon', 'refresh', 'force'],
|
||||
result = subprocess.run(['pkcon', 'refresh'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if result.returncode == 0:
|
||||
if result.stdout:
|
||||
@ -131,19 +74,25 @@ class InstallThread(QtCore.QThread):
|
||||
|
||||
self.updateProgressSignal.emit({ 'value': 20 })
|
||||
|
||||
# Install requested packages
|
||||
arch = os.uname()[4]
|
||||
if arch == 'i686':
|
||||
arch = 'i586'
|
||||
elif arch[:3] == 'arm':
|
||||
arch = 'arm'
|
||||
client = packagekit.Client()
|
||||
|
||||
# Install requested package groups
|
||||
for group in parent.selectGroupsPage.groups_checkboxes:
|
||||
install[group] = \
|
||||
parent.selectGroupsPage.groups_checkboxes[group].isChecked() \
|
||||
and parent.selectGroupsPage.groups_checkboxes[group].isEnabled()
|
||||
|
||||
for inst in install:
|
||||
if install[inst]:
|
||||
parent.installationPage.progressLabel.setText(
|
||||
_("Installing %s packages..." % inst))
|
||||
for p in self.pkggroups[inst].split():
|
||||
result =client.resolve(0, (p,), None,
|
||||
self.updateProgressSignal.emit({
|
||||
'label': _("Installing %s packages..." % inst)})
|
||||
for pkg in self.pkggroups[inst].split():
|
||||
result =client.resolve(0, (pkg,), None,
|
||||
self.packagekit_progress_cb, None)
|
||||
pkgs = result.get_package_array()
|
||||
for p in pkgs:
|
||||
@ -156,6 +105,29 @@ class InstallThread(QtCore.QThread):
|
||||
client.install_packages(False, (packageid, ), None,
|
||||
self.packagekit_progress_cb, p.get_name())
|
||||
|
||||
# Install requested extra packages
|
||||
for extra in parent.selectExtraPage.extra_checkboxes:
|
||||
install_extras[extra] = \
|
||||
parent.selectExtraPage.extra_checkboxes[extra].isChecked() \
|
||||
and parent.selectExtraPage.extra_checkboxes[extra].isEnabled()
|
||||
|
||||
for extra in install_extras:
|
||||
if install_extras[extra]:
|
||||
self.updateProgressSignal.emit({
|
||||
'label': _("Installing %s extra component..." % extra)})
|
||||
result = subprocess.run(['/usr/bin/openmamba-netsrpms', extra],
|
||||
stdout=subprocess.PIPE)
|
||||
if result.returncode == 0:
|
||||
if result.stdout:
|
||||
self.updateProgressSignal.emit({
|
||||
'details': result.stdout.decode('UTF-8')})
|
||||
else:
|
||||
if result.stderr:
|
||||
self.updateProgressSignal.emit({
|
||||
'details': result.stderr.decode('UTF-8')})
|
||||
|
||||
|
||||
# Finished
|
||||
self.updateProgressSignal.emit({ 'value': 100,
|
||||
'label': _("Installation finished!")})
|
||||
|
||||
@ -183,10 +155,11 @@ class MambabaseWizard(QtWidgets.QWizard):
|
||||
self.addPage(self.installationPage)
|
||||
self.finishPage = FinishPage(self)
|
||||
self.addPage(self.finishPage)
|
||||
self.setWindowTitle("openmamba base network installations - openmamba.org")
|
||||
self.setWindowTitle(_("openmamba base network installations") +
|
||||
" - openmamba.org")
|
||||
self.setFixedSize(571,465)
|
||||
self.currentIdChanged.connect(self.currentIdChangedSlot)
|
||||
self.installThread = InstallThread(self)
|
||||
self.installThread = InstallThread(self, self.selectGroupsPage.pkggroups)
|
||||
|
||||
def currentIdChangedSlot(self, currentId):
|
||||
if currentId == 3:
|
||||
@ -201,28 +174,106 @@ class WelcomePage(QtWidgets.QWizardPage):
|
||||
|
||||
|
||||
class SelectGroupsPage(QtWidgets.QWizardPage):
|
||||
groups_checkboxes = {}
|
||||
pkggroups = {}
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(SelectGroupsPage, self).__init__(parent)
|
||||
uic.loadUi('SelectGroupsPage.ui', self)
|
||||
self.loadPkgGroups()
|
||||
self.show()
|
||||
|
||||
def loadPkgGroups(self):
|
||||
self.groups_checkboxes = {
|
||||
'base': self.inst_base,
|
||||
'office': self.inst_office,
|
||||
'multimedia_players': self.inst_players,
|
||||
'multimedia_editing': self.inst_multimedia_editing,
|
||||
'internet': self.inst_internet,
|
||||
'graphics': self.inst_graphics,
|
||||
'games': self.inst_games,
|
||||
'virtualization': self.inst_virtualization,
|
||||
'server': self.inst_server,
|
||||
'devel': self.inst_devel
|
||||
}
|
||||
# Load packages group db into a dict
|
||||
result = subprocess.run(['/usr/libexec/mambabase-pkggroups-parser.sh'],
|
||||
stdout=subprocess.PIPE)
|
||||
lines = result.stdout.decode('UTF-8').splitlines()
|
||||
for line in lines:
|
||||
if line:
|
||||
(key, val) = line.split("=")
|
||||
self.pkggroups[key] = val
|
||||
|
||||
# Check for groups already installed
|
||||
client = packagekit.Client()
|
||||
for group in self.groups_checkboxes:
|
||||
group_installed = True
|
||||
if group in self.pkggroups:
|
||||
for pkg in self.pkggroups[group].split():
|
||||
result = client.resolve(0, (pkg,), None,
|
||||
self.packagekit_progress_cb, None)
|
||||
pkgs_found = result.get_package_array()
|
||||
package_installed = False
|
||||
for p in pkgs_found:
|
||||
if 'installed' in p.get_data().split(':'):
|
||||
package_installed = True
|
||||
break
|
||||
if not package_installed and len(pkgs_found) > 0:
|
||||
group_installed = False
|
||||
elif len(pkgs_found) == 0:
|
||||
print(_("WARNING: package %s from group %s not found in repositories"
|
||||
% (pkg, group)))
|
||||
if group_installed:
|
||||
self.groups_checkboxes[group].setChecked(True)
|
||||
self.groups_checkboxes[group].setEnabled(False)
|
||||
|
||||
def packagekit_progress_cb(self, status, typ, data=None):
|
||||
pass
|
||||
|
||||
|
||||
class SelectExtraPage(QtWidgets.QWizardPage):
|
||||
extra_checkboxes = {}
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(SelectExtraPage, self).__init__(parent)
|
||||
uic.loadUi('SelectExtraPage.ui', self)
|
||||
self.setCommitPage(True)
|
||||
self.setExtras()
|
||||
self.show()
|
||||
|
||||
def setExtras(self):
|
||||
self.extra_checkboxes = {
|
||||
'nvidia': self.inst_nvidia,
|
||||
'fglrx': self.inst_fglrx,
|
||||
'fglrx_legacy': self.inst_fglrx_legacy,
|
||||
'broadcom_sta': self.inst_broadcom_sta,
|
||||
'b43-firmware': self.inst_b43,
|
||||
'flashplugin': self.inst_flash,
|
||||
'chromium-pepper-flash': self.inst_pepperflash,
|
||||
'msttcorefonts': self.inst_msttcf,
|
||||
'win32codecs': self.inst_codecs,
|
||||
'sun-java': self.inst_java,
|
||||
'skype': self.inst_skype,
|
||||
'spotify': self.inst_spotify,
|
||||
'virtualbox-extension-pack': self.inst_virtualbox,
|
||||
'chromium-widevine': self.inst_widevine
|
||||
}
|
||||
for extra in self.extra_checkboxes:
|
||||
result = subprocess.run(['/usr/bin/openmamba-netsrpms', '-c', extra],
|
||||
stdout=subprocess.PIPE)
|
||||
if result.returncode < 2:
|
||||
self.extra_checkboxes[extra].setChecked(True)
|
||||
self.extra_checkboxes[extra].setEnabled(False)
|
||||
|
||||
|
||||
class InstallationPage(QtWidgets.QWizardPage):
|
||||
done = False
|
||||
parent = None
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(InstallationPage, self).__init__(parent)
|
||||
uic.loadUi('InstallationPage.ui', self)
|
||||
self.parent = parent
|
||||
self.setCommitPage(True)
|
||||
self.show()
|
||||
|
||||
def isComplete(self):
|
||||
@ -249,7 +300,7 @@ if __name__ == '__main__':
|
||||
import sys
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
app.setWindowIcon(QtGui.QIcon("mamba-128x128.png"))
|
||||
wizard = MambabaseWizard()
|
||||
gettext.install('mambabase', '/usr/share/locale')
|
||||
wizard = MambabaseWizard()
|
||||
wizard.show()
|
||||
sys.exit(app.exec_())
|
||||
|
Loading…
Reference in New Issue
Block a user