[netinstall] made packages optional

A group can now contain only subgroups. Thus packages can be categorized
through sub-categories such as Internet->Web Browsers->firefox
This commit is contained in:
Philip 2017-02-04 12:45:25 +01:00
parent a6016c63aa
commit dd25323a08
2 changed files with 25 additions and 20 deletions

View File

@ -231,10 +231,11 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent )
item->setCritical( item->setCritical(
CalamaresUtils::yamlToVariant( itemDefinition["critical"] ).toBool() ); CalamaresUtils::yamlToVariant( itemDefinition["critical"] ).toBool() );
for ( YAML::const_iterator packageIt = itemDefinition["packages"].begin(); if ( itemDefinition["packages"] )
packageIt != itemDefinition["packages"].end(); ++packageIt ) for ( YAML::const_iterator packageIt = itemDefinition["packages"].begin();
item->appendChild( packageIt != itemDefinition["packages"].end(); ++packageIt )
new PackageTreeItem( CalamaresUtils::yamlToVariant( *packageIt ).toString(), item ) ); item->appendChild(
new PackageTreeItem( CalamaresUtils::yamlToVariant( *packageIt ).toString(), item ) );
if ( itemDefinition["subgroups"] ) if ( itemDefinition["subgroups"] )
setupModelData( itemDefinition["subgroups"], item ); setupModelData( itemDefinition["subgroups"], item );

View File

@ -4,7 +4,8 @@
# === This file is part of Calamares - <http://github.com/calamares> === # === This file is part of Calamares - <http://github.com/calamares> ===
# #
# Copyright 2014, Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> # Copyright 2014, Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
# Copyright 2016, Kyle Robbertze <kyle@aims.ac.za> # Copyright 2015-2017, Teo Mrnjavac <teo@kde.org>
# Copyright 2016-2017, Kyle Robbertze <kyle@aims.ac.za>
# #
# Calamares is free software: you can redistribute it and/or modify # Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -97,7 +98,7 @@ class PackageManager:
if self.backend == "packagekit": if self.backend == "packagekit":
check_target_env_call(["pkcon", "refresh"]) check_target_env_call(["pkcon", "refresh"])
elif self.backend == "zypp": elif self.backend == "zypp":
check_target_env_call(["zypper", "update"]) check_target_env_call(["zypper", "--non-interactive", "update"])
elif self.backend == "urpmi": elif self.backend == "urpmi":
check_target_env_call(["urpmi.update", "-a"]) check_target_env_call(["urpmi.update", "-a"])
elif self.backend == "apt": elif self.backend == "apt":
@ -137,34 +138,37 @@ def run_operations(pkgman, entry):
for key in entry.keys(): for key in entry.keys():
entry[key] = subst_locale(entry[key]) entry[key] = subst_locale(entry[key])
if key == "install": if key == "install":
if isinstance(entry[key], list): if isinstance(package, str):
pkgman.install(entry[key])
else:
for package in entry[key]: for package in entry[key]:
pkgman.run(package["pre-script"]) pkgman.run(package["pre-script"])
pkgman.install([package["package"]]) pkgman.install([package["package"]])
pkgman.run(package["post-script"]) pkgman.run(package["post-script"])
else:
pkgman.install(entry[key])
elif key == "try_install": elif key == "try_install":
if isinstance(entry[key], list): # we make a separate package manager call for each package so a single
for package in entry[key]: # failing package won't stop all of them
for package in entry[key]:
if isinstance(package, str):
try:
pkgman.install([package])
except subprocess.CalledProcessError:
libcalamares.utils.debug("WARNING: could not install package {}".format(package))
else:
try: try:
pkgman.run(package["pre-script"]) pkgman.run(package["pre-script"])
pkgman.install([package["package"]]) pkgman.install([package["package"]])
pkgman.run(package["post-script"]) pkgman.run(package["post-script"])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
libcalamares.utils.debug("WARNING: could not install packages {}".format(package["package"])) libcalamares.utils.debug("WARNING: could not install packages {}".format(package["package"]))
else:
try:
pkgman.install(entry[key])
except subprocess.CalledProcessError:
libcalamares.utils.debug("WARNING: could not install packages {}".format(", ".join(entry[key])))
elif key == "remove": elif key == "remove":
pkgman.remove(entry[key]) pkgman.remove(entry[key])
elif key == "try_remove": elif key == "try_remove":
try: for package in entry[key]:
pkgman.remove(entry[key]) try:
except subprocess.CalledProcessError: pkgman.remove([package])
libcalamares.utils.debug("WARNING: could not remove packages {}".format(", ".join(entry[key]))) except subprocess.CalledProcessError:
libcalamares.utils.debug("WARNING: could not remove package {}".format(package))
elif key == "localInstall": elif key == "localInstall":
pkgman.install(entry[key], from_local=True) pkgman.install(entry[key], from_local=True)