fix hardcoded paths in installpath model

This commit is contained in:
Michael Hudson-Doyle 2018-06-15 09:39:21 +12:00
parent 56c637fed7
commit 4906fd2e79
2 changed files with 24 additions and 18 deletions

View File

@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
log = logging.getLogger("subiquity.models.installpath")
@ -30,7 +31,8 @@ class InstallpathModel(object):
# update() is not run, upon selecting the default choice...
curtin = {}
def __init__(self, sources=None):
def __init__(self, target, sources=None):
self.target = target
self.cmdline_sources = sources
if sources:
self.path = 'cmdline'
@ -58,6 +60,10 @@ class InstallpathModel(object):
def update(self, results):
self.curtin = {}
def t(path):
return os.path.join(self.target, path)
if self.path == 'maas_region':
self.curtin['debconf_selections'] = {
'maas-username': ('maas-region-controller maas/username '
@ -69,8 +75,8 @@ class InstallpathModel(object):
# Maintainer scripts cache results, from config files, if they
# exist. These shouldn't exist, since this was fixed in
# livecd-rootfs but remove these, just to be sure.
'900-maas': ['rm', '-f', '/target/etc/maas/rackd.conf'],
'901-maas': ['rm', '-f', '/target/etc/maas/region.conf'],
'900-maas': ['rm', '-f', t('etc/maas/rackd.conf')],
'901-maas': ['rm', '-f', t('etc/maas/region.conf')],
# All the crazy things are workarounds for maas maintainer
# scripts deficiencies see:
# LP: #1766209
@ -92,34 +98,34 @@ class InstallpathModel(object):
# and invoke-rc.d --force to not faill and a running postgresql
# is needed, to change the role password and to create an admin
# user.
'904-maas': ['mount', '-o', 'bind', '/proc', '/target/proc'],
'905-maas': ['mount', '-o', 'bind', '/sys', '/target/sys'],
'906-maas': ['mount', '-o', 'bind', '/dev', '/target/dev'],
'907-maas': ['mount', '-o', 'bind', '/target/bin/true',
'/target/usr/sbin/invoke-rc.d'],
'908-maas': ['chroot', '/target', 'sh', '-c',
'904-maas': ['mount', '-o', 'bind', '/proc', t('proc')],
'905-maas': ['mount', '-o', 'bind', '/sys', t('sys')],
'906-maas': ['mount', '-o', 'bind', '/dev', t('dev')],
'907-maas': ['mount', '-o', 'bind', t('bin/true'),
t('usr/sbin/invoke-rc.d')],
'908-maas': ['chroot', self.target, 'sh', '-c',
'pg_ctlcluster --skip-systemctl-redirect '
'$(/bin/ls /var/lib/postgresql/) main start'],
# These are called like this, because reconfigure doesn't
# create nor change an admin user account, nor regens the
# semi-autogenerated maas-url
'909-maas':
['chroot', '/target', 'sh', '-c', (
['chroot', self.target, 'sh', '-c', (
'debconf -fnoninteractive -omaas-region-controller '
'/var/lib/dpkg/info/maas-region-controller.config '
'configure')],
'910-maas':
['chroot', '/target', 'sh', '-c', (
['chroot', self.target, 'sh', '-c', (
'debconf -fnoninteractive -omaas-region-controller '
'/var/lib/dpkg/info/maas-region-controller.postinst '
'configure')],
'911-maas': ['chroot', '/target', 'sh', '-c', (
'911-maas': ['chroot', self.target, 'sh', '-c', (
'pg_ctlcluster --skip-systemctl-redirect '
'$(/bin/ls /var/lib/postgresql/) main stop')],
'912-maas': ['umount', '/target/usr/sbin/invoke-rc.d'],
'913-maas': ['umount', '/target/dev'],
'914-maas': ['umount', '/target/sys'],
'915-maas': ['umount', '/target/proc'],
'912-maas': ['umount', t('usr/sbin/invoke-rc.d')],
'913-maas': ['umount', t('dev')],
'914-maas': ['umount', t('sys')],
'915-maas': ['umount', t('proc')],
}
elif self.path == 'maas_rack':
self.curtin['debconf_selections'] = {
@ -131,7 +137,7 @@ class InstallpathModel(object):
'password %s' % results['secret']),
}
self.curtin['late_commands'] = {
'90-maas': ['rm', '-f', '/target/etc/maas/rackd.conf'],
'90-maas': ['rm', '-f', t('etc/maas/rackd.conf')],
'91-maas': ['curtin', 'in-target', '--', 'maas-rack',
'config', '--init'],
# maas-rack-controller is broken, and does db_input & go on

View File

@ -54,7 +54,7 @@ class SubiquityModel:
root = os.path.abspath(".subiquity")
self.locale = LocaleModel(common['signal'])
self.keyboard = KeyboardModel(root)
self.installpath = InstallpathModel(sources=common['opts'].sources)
self.installpath = InstallpathModel(target=self.target, sources=common['opts'].sources)
self.network = NetworkModel(support_wlan=False)
self.filesystem = FilesystemModel(common['prober'])
self.identity = IdentityModel()