summaryrefslogtreecommitdiff
path: root/install
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-03-31 23:34:57 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-04-01 00:32:30 +0000
commitad96e366d10a8b5fc49794a646eac6c5b5b0a949 (patch)
tree23b3fe554035c86e8be7eaedcdf6bf1c20036289 /install
parent6e6dea80e5c938494c71796c9d7bd977f5c21db9 (diff)
downloadlive-ad96e366d10a8b5fc49794a646eac6c5b5b0a949.tar.gz
New installer: use snack (newt); can configure disks
Diffstat (limited to 'install')
-rwxr-xr-xinstall175
1 files changed, 175 insertions, 0 deletions
diff --git a/install b/install
new file mode 100755
index 0000000..3aa1192
--- /dev/null
+++ b/install
@@ -0,0 +1,175 @@
+#!/usr/bin/python
+
+from lib.hdd import HDD
+from snack import *
+from subprocess import Popen, PIPE, call
+from pprint import pprint
+import re
+import sys
+
+# Snack screen
+screen = None
+
+# List of disks installed on the system:
+hdds = []
+
+# Number of HDDs installed on the system:
+number_of_disks = 0
+
+# List of zpools found on the system:
+zpools = []
+
+def welcome():
+ return ButtonChoiceWindow(screen, "Welcome to Dyson installer",
+ '''
+Dyson is an operating system derived from Debian and based on Illumos core. \
+It uses Illumos unix kernel and libc, ZFS file system and SMF to manage system startup. \
+To learn more visit http://osdyson.org
+
+This installer will guide you through disk paritioning, filesystem creation, \
+installation of base system and minimal configuration.
+
+Please note, this system IS VERY EXPERIMENTAL. \
+You can LOOSE ALL YOUR DATA which this system can reach ;-)
+
+Whould you like to continue?''',
+ buttons=[('Yes', True), ('No', False)], width=70, help=None)
+
+def get_imported_zpools():
+ zpool_cmd = Popen(['zpool', 'list', '-H', '-o', 'name'], stdout=PIPE)
+ zpool_list = zpool_cmd.stdout.read().rstrip().split('\n')
+ return zpool_list
+
+def get_exported_zpools():
+ zpool_cmd = Popen("zpool import | awk '/pool:/ {print $2}'", shell=True, stdout=PIPE)
+ zpool_list = zpool_cmd.stdout.read().rstrip().split('\n')
+ return zpool_list
+
+def get_hdds():
+ hdds = []
+ pat = re.compile('\d+\.\s+(\S+)\s+<(\S+)\s*.+>')
+ format_cmd = Popen('format </dev/null', shell=True, stdout=PIPE)
+ for line in format_cmd.stdout:
+ m = pat.search(line)
+ if m:
+ name = m.group(1)
+ desc = m.group(2)
+ hdds.append(HDD(name, desc))
+
+ return hdds
+
+
+def configure_hdd():
+ hdd_items = map(lambda x: '{}: {} {}'.format(x.name, x.capacity, x.description), hdds);
+ choice = None
+
+ while not choice in ['ok', 'cancel']:
+ (choice, hdd) = ListboxChoiceWindow(screen,
+ title='Choose hard disk drive',
+ text='Choose a hard drive for the root ZFS pool',
+ items=hdd_items,
+ buttons=[
+ ('Use selected disk', 'ok'),
+ ('Cancel', 'cancel')
+ ],
+ width=76,
+ scroll=1,
+ default=0,
+ help=None
+ )
+ if choice in ['ok', None]:
+ choice = configure_partitions(hdds[hdd], number_of_disks)
+ if choice == 'another':
+ choice = None
+
+def configure_partitions(hdd, number_of_disks = 1):
+ choice = None
+ top_text = 'For the root ZFS pool you need a disk containing exactly one solaris partition (id is 0xbf). \
+If this disk includes such a partition and you are happy with it, use this disk. \
+Otherwise you have to change partitioning. \
+'
+
+ while not choice in ['ok', 'another', 'cancel']:
+ part_info = top_text
+ part_info += '\n\n'
+
+ have_partitions = len(hdd.partitions) > 0
+ have_solaris_partition = False
+ buttons = []
+
+ if have_partitions:
+ for p in hdd.partitions:
+ part_info += '{capacity:10} {system} ({id}) - {primary}\n'.format(
+ capacity=p.capacity,
+ system=p.system,
+ id=hex(p.id),
+ primary=['primary', 'logical'][p.logical],
+ )
+ if p.id == 0xBF:
+ have_solaris_partition = True
+ else:
+ part_info += 'This disk is not partitioned.\n'
+
+ if have_solaris_partition:
+ buttons.append(('Use this disk', 'ok'))
+
+ buttons.append(('Edit partitions', 'fdisk'))
+
+ if number_of_disks > 1:
+ buttons.append(('Back', 'another'))
+
+ buttons.append(('Cancel', 'cancel'))
+
+ choice = ButtonChoiceWindow(screen,
+ title='Partitions of {}'.format(hdd.name),
+ text=part_info,
+ buttons=buttons,
+ width=76,
+ help=None
+ )
+ if choice == 'fdisk':
+ screen.suspend()
+ call(['cfdisk', hdd.raw_device])
+ hdd.reread_partitions()
+ screen.resume()
+ # end while
+
+ return choice
+
+
+class Abort(Exception):
+ pass
+class NoDisks(Exception):
+ pass
+
+
+# Begin installation:
+print("Getting list of hard disk drives ... ")
+hdds = get_hdds()
+number_of_disks = len(hdds)
+
+
+screen = SnackScreen()
+try:
+ screen.pushHelpLine(' ')
+
+ if number_of_disks == 0:
+ raise NoDisks('No disks found')
+
+ if not welcome():
+ raise Abort('Installation canceled')
+
+ zpools = []
+ zpools.append(get_imported_zpools())
+ zpools.append(get_exported_zpools())
+
+ configure_hdd()
+except Abort as e:
+ print (e)
+except NoDisks as e:
+ print (e)
+finally:
+ screen.finish()
+
+sys.exit(0)
+