1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#!/usr/bin/python
import dialog
import subprocess
import sys
import re
import pprint
from lib.hdd import Disk
d = dialog.Dialog(dialog='whiptail')
d.setBackgroundTitle('Dyson Installer')
class Installer(object):
HDD = {}
RPOOL = 'rpool'
RHDD = None
# method: (if true, if false)
flow = {}
def _read_hdd(self):
pat = re.compile('\d+\.\s+(\S+)\s+<(\S+)\s*.+>')
out = subprocess.Popen('format </dev/null', shell=True, stdout=subprocess.PIPE).stdout
self.HDD = {}
for line in out:
m = pat.search(line)
if m:
name = m.group(1)
self.HDD[name] = Disk(name, m.group(2))
if len(self.HDD) == 0:
d.msgbox(width=50, title='Error: no disks found',
text='\nSorry, no hard disks found on your system. Installation is not possible.')
return False
else:
return True
def choose_hdd(self):
choices = []
for hdd in sorted(self.HDD):
choices.append((hdd, self.HDD[hdd].cap + ' ' + self.HDD[hdd].desc))
cancel, self.RHDD = d.menu(choices=choices, width=70, height=20,
title='Choose a disk for ZFS root pool',
text='')
return not cancel
def welcome(self):
return not d.yesno(width=60, height=20, title='Welcome to Dyson installer',
text='''
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 though 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?''')
def choose_rpool_name(self):
cancel, pool = d.inputbox(width=40, title='ZFS root pool',
text='\nPlease, enter a name for ZFS root pool. Default is "rpool":',
init=self.RPOOL)
if cancel:
return False
else:
self.RPOOL = pool
return True
def __init__(self):
self._read_hdd()
self.flow['welcome'] = ('choose_hdd', 'cancel')
pass
def run(self, method='welcome'):
rc = getattr(self, method)()
if method in self.flow:
t, f = self.flow[method]
if rc:
self.run(t)
else:
self.run(f)
else:
self.done()
def done(self, code=0):
sys.exit(0)
def cancel(self):
self.done(1)
i = Installer()
i.run()
|