summaryrefslogtreecommitdiff
path: root/install
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-04-22 01:32:21 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-04-22 01:32:21 +0000
commit046cb960a3d8edf3eb779384323e800e13da6c41 (patch)
tree59859d9368850bae2d998be2b63792038d83eb79 /install
parentc8c53b8689ea0e8d848dc3428e99a3116b55f5c5 (diff)
downloadlive-046cb960a3d8edf3eb779384323e800e13da6c41.tar.gz
Diffstat (limited to 'install')
-rwxr-xr-xinstall151
1 files changed, 86 insertions, 65 deletions
diff --git a/install b/install
index 402f531..2fa0c14 100755
--- a/install
+++ b/install
@@ -25,6 +25,7 @@ import re
import sys
import math
import shutil
+import traceback
# Snack screen
screen = None
@@ -89,7 +90,7 @@ timeout 5
# a is the slice number; both are not used
grub_entry = r'''
title Dyson at {bootenv}
-findroot (pool_{rpool},0,a)
+findroot (pool_{rpool},{partition},{slice})
bootfs {bootenv}
kernel$ /platform/i86pc/kernel/amd64/unix -B $ZFS-BOOTFS
module$ /platform/i86pc/amd64/boot_archive
@@ -836,9 +837,18 @@ def configure_bootenv():
set_root_password()
create_bootarchive()
+
+def slice4grub(s):
+ '''c0t4d0s0 -> a, c0t4d0s3 -> d'''
+ try:
+ n = s[s.rfind('s')+1:]
+ return chr(int(n) + ord('a'))
+ except: # random
+ return 'a'
+
+
def configure_grub():
global rslice
- entry = grub_entry.format(rpool=rpool, bootenv=bootenv)
# write grub menu for references:
try:
menu = open(rootdir + '/boot/grub/menu.lst', 'w')
@@ -846,7 +856,7 @@ def configure_grub():
print('# Actual menu.lst used by GRUB is {}/boot/grub/menu.lst'.format(rpool), file=menu)
print('# where {} is the name of root ZFS pool'.format(rpool), file=menu)
print(grub_top, file=menu)
- print(entry, file=menu)
+ print(grub_entry.format(rpool=rpool, bootenv=bootenv, partition=1, slice='a'), file=menu)
menu.close()
except:
pass
@@ -859,35 +869,54 @@ def configure_grub():
rslice = slices[0]
items = []
+ default = None
text = ''
if rslice:
- items.append(('Install GRUB to MBR', 'mbr'))
text += 'Installing GRUB on the master boot sector (MBR) '
text += 'overrides any boot manager currently installed: '
text += 'the system will always boot the GRUB in the solaris partition'
- if solaris_partition:
- allow_non_mbr = not solaris_partition.logical
+ items.append(('Install GRUB to MBR', 'mbr'))
+ items.append(('Install GRUB to a partition only', 'partition'))
+ items.append(('Only update GRUB menu', 'menu'))
+ if not solaris_partition:
+ default = 'menu'
+ elif solaris_partition.logical:
+ default = 'mbr'
else:
- # XXX trying to guess
- installgrub_cmd = ['/usr/sbin/installgrub', '-n',
- '/boot/grub/stage1', '/boot/grub/stage2',
- '/dev/rdsk/' + rslice]
- rc, out, err = in_bootenv(installgrub_cmd)
- allow_non_mbr = out.find('stage1 written to master boot sector') == -1
- if allow_non_mbr:
- items.append(('Install GRUB to a partition only', 'partition'))
+ default = 'partition'
else:
text += 'It looks like root ZFS pool "{rpool}" was not created during this installation, '.format(rpool=rpool)
text += 'so installing GRUB is not supported. '
- text += 'You can only update GRUB menu, or completely skip '
- text += 'this step. Laterly you can configure GRUB using installgrub(1m) '
- text += 'utility and using /boot/grub/menu.lst as an example.'
- items.append(('Only update GRUB menu', 'menu'))
+ text += 'Laterly you can consult {bootenv}/boot/grub/menu.lst for details.'.format(bootenv=bootenv)
+ default = 'skip'
items.append(('Do nothing', 'skip'))
button, install = ListboxChoiceWindow(screen, title='Configure GRUB',
- text=text, items=items, buttons=['Ok'], width=50)
+ text=text, items=items, buttons=['Ok'], width=50, default=default)
if install == 'skip':
return
+
+ progress = ProgressMessage(screen, title='Configuring GRUB', width=50)
+ installgrub_cmd = ['/usr/sbin/installgrub']
+ if install == 'mbr':
+ progress.text = 'Installing GRUB to the master boot record ...'
+ installgrub_cmd += ['-f', '-m']
+ elif install == 'menu': # dry run, just to get partition number
+ progress.text = 'Updating GRUB menu ...'
+ installgrub_cmd += ['-n']
+ else:
+ progress.text = 'Installing GRUB to partition ...'
+
+ installgrub_cmd += ['/boot/grub/stage1', '/boot/grub/stage2', '/dev/rdsk/' + rslice]
+ rc, out, err = in_bootenv(installgrub_cmd)
+ if rc != 0:
+ ButtonChoiceWindow(screen, title='Error',
+ text='Installing of GRUB failed: ' + err, buttons=['Ok'], width=60)
+
+ m = re.search(r'stage1 written to partition (\d)', out)
+ if m:
+ partition = m.group(1)
+ else:
+ partition = 0 # Random
rpool_path = '/mnt/{rpool}/{rpool}'.format(rpool=rpool)
try:
if not exists(rpool_path + '/boot'):
@@ -910,37 +939,16 @@ def configure_grub():
have_this_bootenv = True
break
if not have_this_bootenv:
- print(entry, file=menu)
+ print(grub_entry.format(rpool=rpool, bootenv=bootenv,
+ partition=partition, slice=slice4grub(rslice)),
+ file=menu)
menu.close()
except EnvironmentError as e:
text = 'Failed to write GRUB configuration: '
if e.filename:
text += e.filename + ': '
text += e.strerror
- ButtonChoiceWindow(screen, title='Error',
- text=text, buttons=['Ok'], width=60)
- if install == 'menu':
- return
-
- # solaris_partition is not known - installing on existing pool,
- # installing GRUB is not supported.
- if solaris_partition == None:
- return
-
- progress = ProgressMessage(screen, title='Installing GRUB', width=50)
- installgrub_cmd = ['/usr/sbin/installgrub']
- if install == 'mbr':
- progress.text = 'Installing GRUB to the master boot record...'
- installgrub_cmd += ['-f', '-m']
- else:
- progress.text = 'Installing GRUB to partition...'
-
- installgrub_cmd += ['/boot/grub/stage1', '/boot/grub/stage2',
- '/dev/rdsk/' + rslice]
- rc, out, err = in_bootenv(installgrub_cmd)
- if rc != 0:
- ButtonChoiceWindow(screen, title='Error',
- text='Installing of GRUB failed: ' + err, buttons=['Ok'], width=60)
+ ButtonChoiceWindow(screen, title='Error', text=text, buttons=['Ok'], width=60)
def cleanup(destroy_bootenv=False):
@@ -976,27 +984,40 @@ def goodbye():
buttons=['Reboot'])
screen = SnackScreen()
-screen.pushHelpLine(' ')
-try:
- welcome()
- find_hdds()
- configure_rpool()
- configure_zfs()
- install()
- configure_bootenv()
- configure_grub()
- goodbye()
- cleanup()
-
-except Abort as e:
- cleanup(destroy_bootenv=True)
-except NoDisks as e:
- ButtonChoiceWindow(screen, title='Error',
- text='No disks found on the system. '
- 'Installation of Dyson is not possible.',
- buttons=['Exit'])
-finally:
- screen.finish()
+while True:
+ try:
+ screen.pushHelpLine('F2 - switch to console, F1 - switch back to the installer')
+ welcome()
+ screen.pushHelpLine(' ')
+ find_hdds()
+ configure_rpool()
+ configure_zfs()
+ install()
+ configure_bootenv()
+ configure_grub()
+ goodbye()
+ cleanup()
+ break
+
+ except Abort as e:
+ choice = ButtonChoiceWindow(screen, title='Cancel installation',
+ text='Installation is canceled. Would do you like to start it again or reboot?',
+ buttons=[('Restart', 'restart'), ('Reboot', 'reboot')], width=50)
+ cleanup(destroy_bootenv=True)
+ if choice == 'reboot':
+ break
+ except NoDisks as e:
+ ButtonChoiceWindow(screen, title='Error',
+ text='No disks found on the system. '
+ 'Installation of Dyson is not possible.',
+ buttons=['Reboot'])
+ break
+ except:
+ ButtonChoiceWindow(screen, title='FATAL ERROR',
+ text='The installer has badly failed:\n'+traceback.format_exc(),
+ width=70, buttons=['Restart the installer'])
+ cleanup(destroy_bootenv=True)
+screen.finish()
sys.exit(0)