diff options
-rw-r--r-- | console-login | 3 | ||||
-rwxr-xr-x | install | 151 | ||||
-rw-r--r-- | installer-screenrc | 2 | ||||
-rwxr-xr-x | protostar | 11 |
4 files changed, 95 insertions, 72 deletions
diff --git a/console-login b/console-login index d6e9e76..07b8a42 100644 --- a/console-login +++ b/console-login @@ -4,6 +4,9 @@ TERM=sun-color USER=root HOME=/root +PATH=/sbin:/usr/sbin:/usr/bin + +export TERM USER HOME PATH exec screen -q </dev/console >/dev/console 2>&1 @@ -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) diff --git a/installer-screenrc b/installer-screenrc index a5cadbc..282f55c 100644 --- a/installer-screenrc +++ b/installer-screenrc @@ -3,7 +3,7 @@ startup_message off bindkey -k k1 select 1 bindkey -k k2 select 2 -screen -t installer 1 /usr/install/install +screen -t installer 1 sh -c "/usr/install/install && reboot" screen -t console 2 sh -c "while true; do /bin/bash -l; sleep 1; done" hardstatus alwayslastline "%{kB} %w %= | Dyson Installer" @@ -12,7 +12,8 @@ REPO="${REPO:-http://apt.osdyson.org}" # We will search for usr archive on CD: USR_IMG=usr.img.$(echo $DATE | md5sum | cut -f1 -d ' ') -ISONAME="${ISONAME:-dyson-${DIST}-${DATE}}.iso" +ISOLABEL="${ISOLABEL:-dyson-bok-netinst}" +ISONAME="${ISONAME:-${ISOLABEL}-${DATE}}.iso" ROOT="${TMP}/ROOT" BOOTSTRAPFS="${BOOTSTRAPFS:-dyson/deb}" @@ -83,6 +84,7 @@ cat <<VFSTAB > $ROOT/etc/vfstab # /devices/ramdisk:a - / ufs 1 no rw,nologging fd - /dev/fd fd - no - +swap - /tmp tmpfs - yes - VFSTAB @@ -252,12 +254,9 @@ default=0 timeout=3 foreground=ffffff background=215ECA -title Dyson ($DIST) LiveCD, $DATE +title Dyson ($DIST) installer and LiveCD, $DATE kernel /platform/i86pc/kernel/amd64/unix module /boot/boot_archive.gz -title Dyson ($DIST) LiveCD, $DATE - verbose boot - kernel /platform/i86pc/kernel/amd64/unix -k -m verbose - module /boot/boot_archive.gz GRUB echo "Making final ${ISONAME}..." @@ -273,7 +272,7 @@ genisoimage \ -no-iso-translate \ -cache-inodes \ -d -D \ - -V "${ISONAME}" \ + -V "${ISOLABEL}" \ "${ROOT}" ls -lh "${ISONAME}" |