Skip to content

Commit

Permalink
Merge pull request #1727 from mwhudson/no-apt-configuration-for-core
Browse files Browse the repository at this point in the history
support core installs a bit more
  • Loading branch information
mwhudson authored Jul 19, 2023
2 parents 1d4b0ff + 55c68b5 commit b57087c
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 34 deletions.
24 changes: 24 additions & 0 deletions examples/answers/core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#source-catalog: examples/sources/core.yaml
Source:
source: ubuntu-core
Welcome:
lang: en_US
Refresh:
update: no
Keyboard:
layout: us
Zdev:
accept-default: yes
Network:
accept-default: yes
Proxy:
proxy: ""
Filesystem:
guided: yes
guided-index: 0
UbuntuPro:
token: ""
InstallProgress:
reboot: yes
Drivers:
install: yes
10 changes: 10 additions & 0 deletions examples/sources/core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- description:
en: This test source provides a "Ubuntu Core" base install
id: ubuntu-core
locale_support: none
name:
en: Ubuntu Server
path: ubuntu-core.squashfs
size: 530485248
type: fsimage
variant: core
8 changes: 6 additions & 2 deletions scripts/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ validate () {
if [ "$opt" = reset-only ]; then
return
fi
python3 scripts/validate-autoinstall-user-data.py < $tmpdir/var/log/installer/autoinstall-user-data
if [ $answers != examples/answers/core.yaml ]; then
python3 scripts/validate-autoinstall-user-data.py < $tmpdir/var/log/installer/autoinstall-user-data
fi
netplan generate --root $tmpdir
elif [ "${mode}" = "system_setup" ]; then
setup_mode="$2"
Expand Down Expand Up @@ -194,7 +196,9 @@ for answers in examples/answers/*.yaml; do
--snaps-from-examples \
--source-catalog $catalog
validate install
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
if [ $answers != examples/answers/core.yaml ]; then
grep -q 'finish: subiquity/Install/install/postinstall/run_unattended_upgrades: SUCCESS: downloading and installing security updates' $tmpdir/subiquity-server-debug.log
fi
else
# The OOBE doesn't exist in WSL < 20.04
if [ "${RELEASE%.*}" -ge 20 ]; then
Expand Down
1 change: 1 addition & 0 deletions subiquity/models/oem.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self):
self.install_on = {
"server": False,
"desktop": True,
"core": False,
}

def make_autoinstall(self) -> Dict[str, Union[str, bool]]:
Expand Down
6 changes: 6 additions & 0 deletions subiquity/models/subiquity.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ def _cloud_init_files(self):
return files

def configure_cloud_init(self):
if self.target is None:
# i.e. reset_partition_only
return
if self.source.current.variant == 'core':
# can probably be supported but requires changes
return
for path, content, cmode in self._cloud_init_files():
path = os.path.join(self.target, path)
os.makedirs(os.path.dirname(path), exist_ok=True)
Expand Down
70 changes: 40 additions & 30 deletions subiquity/server/controllers/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ async def unmount_target(self, *, context, target):
if not self.app.opts.dry_run:
shutil.rmtree(target)

def supports_apt(self) -> bool:
return self.model.target is not None and \
self.model.source.current.variant != 'core'

@with_context(
description="configuring apt", level="INFO", childlevel="DEBUG")
async def configure_apt(self, *, context):
Expand All @@ -189,6 +193,8 @@ async def configure_apt(self, *, context):
return await configurer.configure_for_install(context)

async def setup_target(self, context):
if not self.supports_apt():
return
mirror = self.app.controllers.Mirror
await mirror.final_apt_configurer.setup_target(context, self.tpath())

Expand Down Expand Up @@ -472,32 +478,34 @@ async def install(self, *, context):

self.app.update_state(ApplicationState.RUNNING)

if not self.app.controllers.Filesystem.reset_partition_only:
for_install_path = await self.configure_apt(context=context)
if self.model.target is None:
for_install_path = None
elif self.supports_apt():
for_install_path = 'cp://' + await self.configure_apt(
context=context)

await self.app.hub.abroadcast(InstallerChannels.APT_CONFIGURED)

if os.path.exists(self.model.target):
await self.unmount_target(
context=context, target=self.model.target)
else:
for_install_path = ''
fsc = self.app.controllers.Filesystem
for_install_path = self.model.source.get_source(fsc._info.name)

if self.app.controllers.Filesystem.reset_partition:
self.app.package_installer.start_installing_pkg('efibootmgr')

await self.curtin_install(
context=context, source='cp://' + for_install_path)
if self.model.target is not None:
if os.path.exists(self.model.target):
await self.unmount_target(
context=context, target=self.model.target)

if not self.app.controllers.Filesystem.reset_partition_only:
await self.curtin_install(context=context, source=for_install_path)

self.app.update_state(ApplicationState.WAITING)
self.app.update_state(ApplicationState.WAITING)

await self.model.wait_postinstall()
await self.model.wait_postinstall()

self.app.update_state(ApplicationState.RUNNING)
self.app.update_state(ApplicationState.RUNNING)

await self.postinstall(context=context)
await self.postinstall(context=context)

self.app.update_state(ApplicationState.DONE)
except Exception:
Expand All @@ -518,22 +526,24 @@ async def postinstall(self, *, context):
{"autoinstall": self.app.make_autoinstall()})
write_file(autoinstall_path, autoinstall_config)
await self.configure_cloud_init(context=context)
packages = await self.get_target_packages(context=context)
for package in packages:
await self.install_package(context=context, package=package)
if self.model.drivers.do_install:
with context.child(
"ubuntu-drivers-install",
"installing third-party drivers") as child:
ubuntu_drivers = self.app.controllers.Drivers.ubuntu_drivers
await ubuntu_drivers.install_drivers(root_dir=self.tpath(),
context=child)

if self.model.network.has_network:
self.app.update_state(ApplicationState.UU_RUNNING)
policy = self.model.updates.updates
await self.run_unattended_upgrades(context=context, policy=policy)
await self.restore_apt_config(context=context)
if self.supports_apt():
packages = await self.get_target_packages(context=context)
for package in packages:
await self.install_package(context=context, package=package)
if self.model.drivers.do_install:
with context.child(
"ubuntu-drivers-install",
"installing third-party drivers") as child:
udrivers = self.app.controllers.Drivers.ubuntu_drivers
await udrivers.install_drivers(
root_dir=self.tpath(),
context=child)
if self.model.network.has_network:
self.app.update_state(ApplicationState.UU_RUNNING)
policy = self.model.updates.updates
await self.run_unattended_upgrades(
context=context, policy=policy)
await self.restore_apt_config(context=context)
if self.model.active_directory.do_join:
hostname = self.model.identity.hostname
if not hostname:
Expand Down
5 changes: 3 additions & 2 deletions subiquity/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ def get_installer_password_from_cloudinit_log():
"filesystem",
"kernel",
"keyboard",
"mirror",
"network",
"proxy",
"source",
})
},
desktop={'mirror'},
server={'mirror'})

POSTINSTALL_MODEL_NAMES = ModelNames({
"drivers",
Expand Down

0 comments on commit b57087c

Please sign in to comment.