oem: allow to disable install on desktop and force install on server
By default, OEM meta-packages get installed on ubuntu-desktop and don't get installed on ubuntu-server. Using autoinstall, we can now give more control. The autoinstall section supports the following: Install on server and desktop: oem: install: true Do not install even on desktop: oem: install: false Install only on desktop (the default): oem: install: auto Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
7e8c1eedd5
commit
e6ccfcc118
|
@ -489,6 +489,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"oem": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"install": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"const": "auto"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"install"
|
||||||
|
]
|
||||||
|
},
|
||||||
"timezone": {
|
"timezone": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -575,6 +575,21 @@ Whether to install the ubuntu-restricted-addons package.
|
||||||
|
|
||||||
Whether to install the available third-party drivers.
|
Whether to install the available third-party drivers.
|
||||||
|
|
||||||
|
<a name="oem"></a>
|
||||||
|
|
||||||
|
### oem
|
||||||
|
|
||||||
|
**type:** mapping, see below
|
||||||
|
**default:** see below
|
||||||
|
**can be interactive:** no
|
||||||
|
|
||||||
|
#### install
|
||||||
|
|
||||||
|
**type:** boolean or string (special value `auto`)
|
||||||
|
**default:**: `auto`
|
||||||
|
|
||||||
|
Whether to install the available OEM meta-packages. The special value `auto` - which is the default - enables the installation on ubuntu-desktop but not on ubuntu-server.
|
||||||
|
|
||||||
<a name="snaps"></a>
|
<a name="snaps"></a>
|
||||||
|
|
||||||
### snaps
|
### snaps
|
||||||
|
|
|
@ -509,6 +509,25 @@ The [JSON schema](https://json-schema.org/) for autoinstall data is as follows:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"oem": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"install": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"const": "auto"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"install"
|
||||||
|
]
|
||||||
|
},
|
||||||
"timezone": {
|
"timezone": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +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 logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
|
@ -32,3 +32,34 @@ class OEMModel:
|
||||||
# List of OEM metapackages relevant to the current hardware.
|
# List of OEM metapackages relevant to the current hardware.
|
||||||
# When the list is None, it has not yet been retrieved.
|
# When the list is None, it has not yet been retrieved.
|
||||||
self.metapkgs: Optional[List[OEMMetaPkg]] = None
|
self.metapkgs: Optional[List[OEMMetaPkg]] = None
|
||||||
|
|
||||||
|
# By default, skip looking for OEM meta-packages if we are running
|
||||||
|
# ubuntu-server. OEM meta-packages expect the default kernel flavor to
|
||||||
|
# be HWE (which is only true for ubuntu-desktop).
|
||||||
|
self.install_on = {
|
||||||
|
"server": False,
|
||||||
|
"desktop": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
def make_autoinstall(self) -> Dict[str, Union[str, bool]]:
|
||||||
|
server = self.install_on["server"]
|
||||||
|
desktop = self.install_on["desktop"]
|
||||||
|
|
||||||
|
if server and desktop:
|
||||||
|
return {"install": True}
|
||||||
|
if not server and not desktop:
|
||||||
|
return {"install": False}
|
||||||
|
|
||||||
|
# Having server = True and desktop = False is not supported.
|
||||||
|
assert desktop and not server
|
||||||
|
|
||||||
|
return {"install": "auto"}
|
||||||
|
|
||||||
|
def load_autoinstall_data(self, data: Dict[str, Any]) -> None:
|
||||||
|
if data["install"] == "auto":
|
||||||
|
self.install_on["server"] = False
|
||||||
|
self.install_on["desktop"] = True
|
||||||
|
return
|
||||||
|
|
||||||
|
self.install_on["server"] = data["install"]
|
||||||
|
self.install_on["desktop"] = data["install"]
|
||||||
|
|
|
@ -39,7 +39,25 @@ class OEMController(SubiquityController):
|
||||||
|
|
||||||
endpoint = API.oem
|
endpoint = API.oem
|
||||||
|
|
||||||
model_name = "oem"
|
autoinstall_key = model_name = "oem"
|
||||||
|
autoinstall_schema = {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"install": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"const": "auto",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["install"],
|
||||||
|
}
|
||||||
|
autoinstall_default = {"install": "auto"}
|
||||||
|
|
||||||
def __init__(self, app) -> None:
|
def __init__(self, app) -> None:
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
|
@ -67,6 +85,12 @@ class OEMController(SubiquityController):
|
||||||
self.load_metapkgs_task = asyncio.create_task(
|
self.load_metapkgs_task = asyncio.create_task(
|
||||||
list_and_mark_configured())
|
list_and_mark_configured())
|
||||||
|
|
||||||
|
def make_autoinstall(self):
|
||||||
|
return self.model.make_autoinstall()
|
||||||
|
|
||||||
|
def load_autoinstall_data(self, *args, **kwargs) -> None:
|
||||||
|
self.model.load_autoinstall_data(*args, **kwargs)
|
||||||
|
|
||||||
async def wants_oem_kernel(self, pkgname: str,
|
async def wants_oem_kernel(self, pkgname: str,
|
||||||
*, context, overlay) -> bool:
|
*, context, overlay) -> bool:
|
||||||
""" For a given package, tell whether it wants the OEM or the default
|
""" For a given package, tell whether it wants the OEM or the default
|
||||||
|
@ -103,9 +127,9 @@ class OEMController(SubiquityController):
|
||||||
# Skip looking for OEM meta-packages if we are running ubuntu-server.
|
# Skip looking for OEM meta-packages if we are running ubuntu-server.
|
||||||
# OEM meta-packages expect the default kernel flavor to be HWE (which
|
# OEM meta-packages expect the default kernel flavor to be HWE (which
|
||||||
# is only true for ubuntu-desktop).
|
# is only true for ubuntu-desktop).
|
||||||
if self.app.base_model.source.current.variant == "server":
|
variant: str = self.app.base_model.source.current.variant
|
||||||
log.debug("not listing OEM meta-packages since we are installing"
|
if not self.model.install_on[variant]:
|
||||||
" ubuntu-server")
|
log.debug("listing of OEM meta-packages disabled on %s", variant)
|
||||||
self.model.metapkgs = []
|
self.model.metapkgs = []
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue