defer deciding search_drivers default with autoinstall
in particular, defer until we know if we are installing core boot classic
This commit is contained in:
parent
2306703918
commit
3672524761
|
@ -21,6 +21,7 @@ from subiquity.common.apidef import API
|
||||||
from subiquity.common.types import DriversPayload, DriversResponse
|
from subiquity.common.types import DriversPayload, DriversResponse
|
||||||
from subiquity.server.apt import OverlayCleanupError
|
from subiquity.server.apt import OverlayCleanupError
|
||||||
from subiquity.server.controller import SubiquityController
|
from subiquity.server.controller import SubiquityController
|
||||||
|
from subiquity.server.controllers.source import SEARCH_DRIVERS_AUTOINSTALL_DEFAULT
|
||||||
from subiquity.server.types import InstallerChannels
|
from subiquity.server.types import InstallerChannels
|
||||||
from subiquity.server.ubuntu_drivers import (
|
from subiquity.server.ubuntu_drivers import (
|
||||||
CommandNotFoundError,
|
CommandNotFoundError,
|
||||||
|
@ -123,6 +124,8 @@ class DriversController(SubiquityController):
|
||||||
await self.list_drivers_done_event.wait()
|
await self.list_drivers_done_event.wait()
|
||||||
|
|
||||||
search_drivers = self.app.controllers.Source.model.search_drivers
|
search_drivers = self.app.controllers.Source.model.search_drivers
|
||||||
|
if search_drivers is SEARCH_DRIVERS_AUTOINSTALL_DEFAULT:
|
||||||
|
search_drivers = True
|
||||||
|
|
||||||
return DriversResponse(
|
return DriversResponse(
|
||||||
install=self.model.do_install,
|
install=self.model.do_install,
|
||||||
|
|
|
@ -74,6 +74,7 @@ from subiquity.models.filesystem import (
|
||||||
)
|
)
|
||||||
from subiquity.server import snapdapi
|
from subiquity.server import snapdapi
|
||||||
from subiquity.server.controller import SubiquityController
|
from subiquity.server.controller import SubiquityController
|
||||||
|
from subiquity.server.controllers.source import SEARCH_DRIVERS_AUTOINSTALL_DEFAULT
|
||||||
from subiquity.server.mounter import Mounter
|
from subiquity.server.mounter import Mounter
|
||||||
from subiquity.server.snapdapi import (
|
from subiquity.server.snapdapi import (
|
||||||
StorageEncryptionSupport,
|
StorageEncryptionSupport,
|
||||||
|
@ -292,6 +293,11 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
self._configured = True
|
self._configured = True
|
||||||
if self._info is None:
|
if self._info is None:
|
||||||
self.set_info_for_capability(GuidedCapability.DIRECT)
|
self.set_info_for_capability(GuidedCapability.DIRECT)
|
||||||
|
if (
|
||||||
|
self.app.base_model.source.search_drivers
|
||||||
|
is SEARCH_DRIVERS_AUTOINSTALL_DEFAULT
|
||||||
|
):
|
||||||
|
self.app.base_model.source.search_drivers = not self.is_core_boot_classic()
|
||||||
await super().configured()
|
await super().configured()
|
||||||
self.stop_listening_udev()
|
self.stop_listening_udev()
|
||||||
|
|
||||||
|
@ -424,7 +430,11 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
"systems."
|
"systems."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if self.app.base_model.source.search_drivers:
|
search_drivers = self.app.base_model.source.search_drivers
|
||||||
|
if (
|
||||||
|
search_drivers is not SEARCH_DRIVERS_AUTOINSTALL_DEFAULT
|
||||||
|
and search_drivers
|
||||||
|
):
|
||||||
log.debug(
|
log.debug(
|
||||||
"Disabling core boot based install options as third-party "
|
"Disabling core boot based install options as third-party "
|
||||||
"drivers selected"
|
"drivers selected"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
@ -29,6 +30,8 @@ from subiquity.common.types import SourceSelection, SourceSelectionAndSetting
|
||||||
from subiquity.server.controller import SubiquityController
|
from subiquity.server.controller import SubiquityController
|
||||||
from subiquity.server.types import InstallerChannels
|
from subiquity.server.types import InstallerChannels
|
||||||
|
|
||||||
|
log = logging.getLogger("subiquity.server.controllers.source")
|
||||||
|
|
||||||
|
|
||||||
def _translate(d, lang):
|
def _translate(d, lang):
|
||||||
if lang:
|
if lang:
|
||||||
|
@ -50,6 +53,9 @@ def convert_source(source, lang):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
SEARCH_DRIVERS_AUTOINSTALL_DEFAULT = object()
|
||||||
|
|
||||||
|
|
||||||
class SourceController(SubiquityController):
|
class SourceController(SubiquityController):
|
||||||
model_name = "source"
|
model_name = "source"
|
||||||
|
|
||||||
|
@ -67,10 +73,6 @@ class SourceController(SubiquityController):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
# Defaults to true for backward compatibility with existing autoinstall
|
|
||||||
# configurations. Back then, then users were able to install third-party
|
|
||||||
# drivers without this field.
|
|
||||||
autoinstall_default = {"search_drivers": True}
|
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
|
@ -86,13 +88,15 @@ class SourceController(SubiquityController):
|
||||||
|
|
||||||
def load_autoinstall_data(self, data: Any) -> None:
|
def load_autoinstall_data(self, data: Any) -> None:
|
||||||
if data is None:
|
if data is None:
|
||||||
# NOTE: The JSON schema does not allow data to be null in this
|
data = {}
|
||||||
# context. However, Subiquity bypasses the schema validation when
|
|
||||||
# a section is set to null. So in practice, we can have data = None
|
|
||||||
# here.
|
|
||||||
data = {**self.autoinstall_default, "id": None}
|
|
||||||
|
|
||||||
self.model.search_drivers = data.get("search_drivers", True)
|
# Defaults to almost-true for backward compatibility with existing autoinstall
|
||||||
|
# configurations. Back then, then users were able to install third-party drivers
|
||||||
|
# without this field. The "almost-true" part is that search_drivers defaults to
|
||||||
|
# False for core boot classic installs.
|
||||||
|
self.model.search_drivers = data.get(
|
||||||
|
"search_drivers", SEARCH_DRIVERS_AUTOINSTALL_DEFAULT
|
||||||
|
)
|
||||||
|
|
||||||
# At this point, the model has not yet loaded the sources from the
|
# At this point, the model has not yet loaded the sources from the
|
||||||
# catalog. So we store the ID and lean on self.start to select the
|
# catalog. So we store the ID and lean on self.start to select the
|
||||||
|
@ -122,10 +126,14 @@ class SourceController(SubiquityController):
|
||||||
cur_lang = self.app.base_model.locale.selected_language
|
cur_lang = self.app.base_model.locale.selected_language
|
||||||
cur_lang = cur_lang.rsplit(".", 1)[0]
|
cur_lang = cur_lang.rsplit(".", 1)[0]
|
||||||
|
|
||||||
|
search_drivers = self.model.search_drivers
|
||||||
|
if search_drivers is SEARCH_DRIVERS_AUTOINSTALL_DEFAULT:
|
||||||
|
search_drivers = True
|
||||||
|
|
||||||
return SourceSelectionAndSetting(
|
return SourceSelectionAndSetting(
|
||||||
[convert_source(source, cur_lang) for source in self.model.sources],
|
[convert_source(source, cur_lang) for source in self.model.sources],
|
||||||
self.model.current.id,
|
self.model.current.id,
|
||||||
search_drivers=self.model.search_drivers,
|
search_drivers=search_drivers,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_handler(
|
def get_handler(
|
||||||
|
|
Loading…
Reference in New Issue