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

View File

@ -54,7 +54,7 @@ class SubiquityModel:
root = os.path.abspath(".subiquity") root = os.path.abspath(".subiquity")
self.locale = LocaleModel(common['signal']) self.locale = LocaleModel(common['signal'])
self.keyboard = KeyboardModel(root) 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.network = NetworkModel(support_wlan=False)
self.filesystem = FilesystemModel(common['prober']) self.filesystem = FilesystemModel(common['prober'])
self.identity = IdentityModel() self.identity = IdentityModel()