1 |
slords |
1.1 |
# |
2 |
|
|
# upgrade_text.py: text mode upgrade dialogs |
3 |
|
|
# |
4 |
|
|
# Copyright 2001 Red Hat, Inc. |
5 |
|
|
# |
6 |
|
|
# This software may be freely redistributed under the terms of the GNU |
7 |
|
|
# library public license. |
8 |
|
|
# |
9 |
|
|
# You should have received a copy of the GNU Library Public License |
10 |
|
|
# along with this program; if not, write to the Free Software |
11 |
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
12 |
|
|
# |
13 |
|
|
|
14 |
|
|
import string |
15 |
|
|
import isys |
16 |
|
|
import iutil |
17 |
|
|
import upgrade |
18 |
|
|
from constants_text import * |
19 |
|
|
from snack import * |
20 |
|
|
from fsset import * |
21 |
|
|
from flags import flags |
22 |
|
|
from constants import * |
23 |
|
|
import smeupgradeclass |
24 |
|
|
UpgradeClass = smeupgradeclass.InstallClass |
25 |
|
|
|
26 |
|
|
from rhpl.log import log |
27 |
|
|
from rhpl.translate import _ |
28 |
|
|
|
29 |
|
|
class UpgradeMigrateFSWindow: |
30 |
|
|
def __call__ (self, screen, thefsset): |
31 |
|
|
|
32 |
|
|
migent = thefsset.getMigratableEntries() |
33 |
|
|
|
34 |
|
|
g = GridFormHelp(screen, _("Migrate File Systems"), "upmigfs", 1, 4) |
35 |
|
|
|
36 |
|
|
text = _("This release of %s supports " |
37 |
|
|
"the ext3 journalling file system. It has several " |
38 |
|
|
"benefits over the ext2 file system traditionally shipped " |
39 |
|
|
"in %s. It is possible to migrate the ext2 " |
40 |
|
|
"formatted partitions to ext3 without data loss.\n\n" |
41 |
|
|
"Which of these partitions would you like to migrate?" |
42 |
|
|
% (productName, productName)) |
43 |
|
|
|
44 |
|
|
tb = TextboxReflowed(60, text) |
45 |
|
|
g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1)) |
46 |
|
|
|
47 |
|
|
partlist = CheckboxTree(height=4, scroll=1) |
48 |
|
|
for entry in migent: |
49 |
|
|
if entry.fsystem.getName() != entry.origfsystem.getName(): |
50 |
|
|
migrating = 1 |
51 |
|
|
else: |
52 |
|
|
migrating = 0 |
53 |
|
|
|
54 |
|
|
partlist.append("/dev/%s - %s - %s" % (entry.device.getDevice(), |
55 |
|
|
entry.origfsystem.getName(), |
56 |
|
|
entry.mountpoint), entry, migrating) |
57 |
|
|
|
58 |
|
|
g.add(partlist, 0, 1, padding = (0, 0, 0, 1)) |
59 |
|
|
|
60 |
|
|
buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] ) |
61 |
|
|
g.add(buttons, 0, 3, anchorLeft = 1, growx = 1) |
62 |
|
|
|
63 |
|
|
while 1: |
64 |
|
|
result = g.run() |
65 |
|
|
|
66 |
|
|
if (buttons.buttonPressed(result)): |
67 |
|
|
result = buttons.buttonPressed(result) |
68 |
|
|
|
69 |
|
|
if result == TEXT_BACK_CHECK: |
70 |
|
|
screen.popWindow() |
71 |
|
|
return INSTALL_BACK |
72 |
|
|
|
73 |
|
|
# reset |
74 |
|
|
for entry in migent: |
75 |
|
|
entry.setFormat(0) |
76 |
|
|
entry.setMigrate(0) |
77 |
|
|
entry.fsystem = entry.origfsystem |
78 |
|
|
|
79 |
|
|
for entry in partlist.getSelection(): |
80 |
|
|
entry.setMigrate(1) |
81 |
|
|
entry.fsystem = fileSystemTypeGet("ext3") |
82 |
|
|
|
83 |
|
|
screen.popWindow() |
84 |
|
|
return INSTALL_OK |
85 |
|
|
|
86 |
|
|
class UpgradeSwapWindow: |
87 |
|
|
def __call__ (self, screen, intf, fsset, instPath, swapInfo, dispatch): |
88 |
|
|
rc = swapInfo |
89 |
|
|
|
90 |
|
|
(fsList, suggSize, suggMntPoint) = rc |
91 |
|
|
|
92 |
|
|
ramDetected = iutil.memInstalled()/1024 |
93 |
|
|
|
94 |
|
|
text = _("The 2.4 kernel needs significantly more swap than older " |
95 |
|
|
"kernels, as much as twice as much swap space as RAM on the " |
96 |
|
|
"system. You currently have %dMB of swap configured, but " |
97 |
|
|
"you may create additional swap space on one of your " |
98 |
|
|
"file systems now.") % (iutil.swapAmount() / 1024) |
99 |
|
|
|
100 |
|
|
tb = TextboxReflowed(60, text) |
101 |
|
|
amount = Entry(10, scroll = 0) |
102 |
|
|
amount.set(str(suggSize)) |
103 |
|
|
|
104 |
|
|
l = len(fsList) |
105 |
|
|
scroll = 0 |
106 |
|
|
if l > 4: |
107 |
|
|
l = 4 |
108 |
|
|
scroll = 1 |
109 |
|
|
listbox = Listbox(l, scroll = scroll) |
110 |
|
|
|
111 |
|
|
liLabel = Label("%-25s %-15s %8s" % (_("Mount Point"), |
112 |
|
|
_("Partition"), _("Free Space"))) |
113 |
|
|
|
114 |
|
|
count = 0 |
115 |
|
|
for (mnt, part, size) in fsList: |
116 |
|
|
listbox.append("%-25s /dev/%-10s %6dMB" % (mnt, part, size), count) |
117 |
|
|
|
118 |
|
|
if (mnt == suggMntPoint): |
119 |
|
|
listbox.setCurrent(count) |
120 |
|
|
|
121 |
|
|
count = count + 1 |
122 |
|
|
|
123 |
|
|
buttons = ButtonBar(screen, [TEXT_OK_BUTTON, (_("Skip"), "skip"), |
124 |
|
|
TEXT_BACK_BUTTON] ) |
125 |
|
|
|
126 |
|
|
amGrid = Grid(2, 3) |
127 |
|
|
amGrid.setField(Label(_("RAM detected (MB):")), 0, 0, anchorLeft = 1, |
128 |
|
|
padding = (0, 0, 1, 0)) |
129 |
|
|
amGrid.setField(Label(str(ramDetected)), 1, 0, anchorLeft = 1) |
130 |
|
|
amGrid.setField(Label(_("Suggested size (MB):")), 0, 1, anchorLeft = 1, |
131 |
|
|
padding = (0, 0, 1, 0)) |
132 |
|
|
amGrid.setField(Label(str(suggSize)), 1, 1, anchorLeft = 1) |
133 |
|
|
amGrid.setField(Label(_("Swap file size (MB):")), 0, 2, anchorLeft = 1, |
134 |
|
|
padding = (0, 0, 1, 0)) |
135 |
|
|
amGrid.setField(amount, 1, 2) |
136 |
|
|
|
137 |
|
|
liGrid = Grid(1, 2) |
138 |
|
|
liGrid.setField(liLabel, 0, 0) |
139 |
|
|
liGrid.setField(listbox, 0, 1) |
140 |
|
|
|
141 |
|
|
g = GridFormHelp(screen, _("Add Swap"), "upgradeswap", 1, 4) |
142 |
|
|
g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1)) |
143 |
|
|
g.add(amGrid, 0, 1, padding = (0, 0, 0, 1)) |
144 |
|
|
g.add(liGrid, 0, 2, padding = (0, 0, 0, 1)) |
145 |
|
|
g.add(buttons, 0, 3, anchorLeft = 1, growx = 1) |
146 |
|
|
|
147 |
|
|
while 1: |
148 |
|
|
result = g.run() |
149 |
|
|
|
150 |
|
|
if (buttons.buttonPressed(result)): |
151 |
|
|
result = buttons.buttonPressed(result) |
152 |
|
|
|
153 |
|
|
if result == TEXT_BACK_CHECK: |
154 |
|
|
screen.popWindow() |
155 |
|
|
return INSTALL_BACK |
156 |
|
|
elif result == "skip": |
157 |
|
|
screen.popWindow() |
158 |
|
|
return INSTALL_OK |
159 |
|
|
|
160 |
|
|
val = amount.value() |
161 |
|
|
|
162 |
|
|
try: |
163 |
|
|
val = int(val) |
164 |
|
|
except ValueError: |
165 |
|
|
intf.messageWindow(_("Error"), |
166 |
|
|
_("The value you entered is not a " |
167 |
|
|
"valid number.")) |
168 |
|
|
|
169 |
|
|
if type(val) == type(1): |
170 |
|
|
(mnt, part, size) = fsList[listbox.current()] |
171 |
|
|
if size < (val + 16): |
172 |
|
|
intf.messageWindow(_("Error"), |
173 |
|
|
_("There is not enough space on the " |
174 |
|
|
"device you selected for the swap " |
175 |
|
|
"partition.")) |
176 |
|
|
elif val > 2000 or val < 1: |
177 |
|
|
intf.messageWindow(_("Warning"), |
178 |
|
|
_("The swap file must be between 1 " |
179 |
|
|
"and 2000 MB in size.")) |
180 |
|
|
else: |
181 |
|
|
screen.popWindow() |
182 |
|
|
if flags.setupFilesystems: |
183 |
|
|
upgrade.createSwapFile(instPath, fsset, mnt, val) |
184 |
|
|
dispatch.skipStep("addswap", 1) |
185 |
|
|
return INSTALL_OK |
186 |
|
|
|
187 |
|
|
raise ValueError |
188 |
|
|
|
189 |
|
|
class UpgradeExamineWindow: |
190 |
|
|
def __call__ (self, screen, dispatch, intf, id, chroot): |
191 |
|
|
parts = id.rootParts |
192 |
|
|
|
193 |
|
|
height = min(len(parts), 11) + 1 |
194 |
|
|
if height == 12: |
195 |
|
|
scroll = 1 |
196 |
|
|
else: |
197 |
|
|
scroll = 0 |
198 |
|
|
partList = [] |
199 |
|
|
partList.append(_("Reinstall System")) |
200 |
|
|
|
201 |
|
|
for (drive, fs, desc) in parts: |
202 |
|
|
if drive[:5] != "/dev/": |
203 |
|
|
devname = "/dev/" + drive |
204 |
|
|
else: |
205 |
|
|
devname = drive |
206 |
|
|
partList.append("%s (%s)" %(desc, drive)) |
207 |
|
|
|
208 |
|
|
(button, choice) = ListboxChoiceWindow(screen, _("System to Upgrade"), |
209 |
|
|
_("One or more existing Linux installations " |
210 |
|
|
"have been found " |
211 |
|
|
"on your system.\n\nPlease choose one to upgrade, " |
212 |
|
|
"or select 'Reinstall System' to freshly install " |
213 |
|
|
"your system."), partList, |
214 |
|
|
[ TEXT_OK_BUTTON, |
215 |
|
|
TEXT_BACK_BUTTON ], |
216 |
|
|
width = 55, scroll = scroll, |
217 |
|
|
height = height, |
218 |
|
|
help = "upgraderoot") |
219 |
|
|
|
220 |
|
|
if button == TEXT_BACK_CHECK: |
221 |
|
|
return INSTALL_BACK |
222 |
|
|
else: |
223 |
|
|
if choice == 0: |
224 |
|
|
root = None |
225 |
|
|
else: |
226 |
|
|
root = parts[choice - 1] |
227 |
|
|
|
228 |
|
|
if root is not None: |
229 |
|
|
c = UpgradeClass(flags.expert) |
230 |
|
|
c.setSteps(dispatch) |
231 |
|
|
c.setInstallData(id) |
232 |
|
|
|
233 |
|
|
id.upgradeRoot = [(root[0], root[1])] |
234 |
|
|
id.rootParts = parts |
235 |
|
|
dispatch.skipStep("installtype", skip = 1) |
236 |
|
|
else: |
237 |
|
|
id.upgradeRoot = None |
238 |
|
|
|
239 |
|
|
return INSTALL_OK |
240 |
|
|
|
241 |
|
|
class CustomizeUpgradeWindow: |
242 |
|
|
def __call__ (self, screen, dispatch, intf, id, chroot): |
243 |
|
|
if id.upgradeRoot is None: |
244 |
|
|
return INSTALL_NOOP |
245 |
|
|
rc = ButtonChoiceWindow (screen, _("Customize Packages to Upgrade"), |
246 |
|
|
_("The packages you have installed, " |
247 |
|
|
"and any other packages which are " |
248 |
|
|
"needed to satisfy their " |
249 |
|
|
"dependencies, have been selected " |
250 |
|
|
"for installation. Would you like " |
251 |
|
|
"to customize the set of packages " |
252 |
|
|
"that will be upgraded?"), |
253 |
|
|
buttons = [ _("Yes"), _("No"), |
254 |
|
|
TEXT_BACK_BUTTON], |
255 |
|
|
help = "custupgrade") |
256 |
|
|
|
257 |
|
|
if rc == TEXT_BACK_CHECK: |
258 |
|
|
return INSTALL_BACK |
259 |
|
|
|
260 |
|
|
if rc == string.lower (_("No")): |
261 |
|
|
dispatch.skipStep("indivpackage") |
262 |
|
|
else: |
263 |
|
|
dispatch.skipStep("indivpackage", skip = 0) |
264 |
|
|
|
265 |
|
|
return INSTALL_OK |
266 |
|
|
|