1 |
Author: codeman |
2 |
Date: 2008-05-26 02:53:12 +0000 (Mon, 26 May 2008) |
3 |
New Revision: 1908 |
4 |
|
5 |
Modified: |
6 |
trunk/src/GLIArchitectureTemplate.py |
7 |
Log: |
8 |
committing changes to gtkfe in stages. |
9 |
adding internalization support written by |
10 |
Jesus Rivero (Neurogeek) |
11 |
basically sets everything in gettext. |
12 |
|
13 |
|
14 |
|
15 |
Modified: trunk/src/GLIArchitectureTemplate.py |
16 |
=================================================================== |
17 |
--- trunk/src/GLIArchitectureTemplate.py 2008-05-26 02:32:19 UTC (rev 1907) |
18 |
+++ trunk/src/GLIArchitectureTemplate.py 2008-05-26 02:53:12 UTC (rev 1908) |
19 |
@@ -18,11 +18,21 @@ |
20 |
import GLIPortage |
21 |
from GLIException import * |
22 |
import Partitioning |
23 |
+import gettext |
24 |
|
25 |
MEGABYTE = 1024 * 1024 |
26 |
LOGFILE = '/var/log/install.log' |
27 |
COMPILE_LOGFILE = '/tmp/compile_output.log' |
28 |
|
29 |
+#Start Gettext Support |
30 |
+try: |
31 |
+ gettext.install('gli-gtk', './languages') |
32 |
+ translator = gettext.translation('gli-gtk', './languages') |
33 |
+ _ = translator.gettext |
34 |
+except: |
35 |
+ _ = gettext.gettext |
36 |
+#End Gettext Support |
37 |
+ |
38 |
class ArchitectureTemplate: |
39 |
## |
40 |
# Initialization of the ArchitectureTemplate. Called from some other arch template. |
41 |
@@ -63,37 +73,37 @@ |
42 |
|
43 |
self._architecture_name = "generic" |
44 |
self._install_steps = { |
45 |
- 'do_recommended_partitioning': "Automatically partition the drive", |
46 |
- 'mount_local_partitions': "Mount local partitions", |
47 |
- 'mount_network_shares': "Mount network (NFS) shares", |
48 |
- 'unpack_stage_tarball': "Unpack stage tarball", |
49 |
- 'update_config_files': "Updating config files", |
50 |
- 'configure_make_conf': "Configure /etc/make.conf", |
51 |
- 'prepare_chroot': "Preparing chroot", |
52 |
- 'install_portage_tree': "Syncing the Portage tree", |
53 |
- 'stage1': "Performing bootstrap", |
54 |
- 'stage2': "Performing 'emerge system'", |
55 |
- 'set_root_password': "Set the root password", |
56 |
- 'set_timezone': "Setting timezone", |
57 |
- 'emerge_kernel_sources': "Emerge kernel sources", |
58 |
- 'build_kernel': "Building kernel", |
59 |
- 'install_distcc': "Install distcc", |
60 |
- 'install_mta': "Installing MTA", |
61 |
- 'install_logging_daemon': "Installing system logger", |
62 |
- 'install_cron_daemon': "Installing Cron daemon", |
63 |
- 'install_filesystem_tools': "Installing filesystem tools", |
64 |
- 'setup_network_post': "Configuring post-install networking", |
65 |
- 'install_bootloader': "Configuring and installing bootloader", |
66 |
- 'setup_and_run_bootloader': "Setting up and running bootloader", |
67 |
+ 'do_recommended_partitioning': _("Automatically partition the drive"), |
68 |
+ 'mount_local_partitions': _("Mount local partitions"), |
69 |
+ 'mount_network_shares': _("Mount network (NFS) shares"), |
70 |
+ 'unpack_stage_tarball': _("Unpack stage tarball"), |
71 |
+ 'update_config_files': _("Updating config files"), |
72 |
+ 'configure_make_conf': _("Configure /etc/make.conf"), |
73 |
+ 'prepare_chroot': _("Preparing chroot"), |
74 |
+ 'install_portage_tree': _("Syncing the Portage tree"), |
75 |
+ 'stage1': _("Performing bootstrap"), |
76 |
+ 'stage2': _("Performing 'emerge system'"), |
77 |
+ 'set_root_password': _("Set the root password"), |
78 |
+ 'set_timezone': _("Setting timezone"), |
79 |
+ 'emerge_kernel_sources': _("Emerge kernel sources"), |
80 |
+ 'build_kernel': _("Building kernel"), |
81 |
+ 'install_distcc': _("Install distcc"), |
82 |
+ 'install_mta': _("Installing MTA"), |
83 |
+ 'install_logging_daemon': _("Installing system logger"), |
84 |
+ 'install_cron_daemon': _("Installing Cron daemon"), |
85 |
+ 'install_filesystem_tools': _("Installing filesystem tools"), |
86 |
+ 'setup_network_post': _("Configuring post-install networking"), |
87 |
+ 'install_bootloader': _("Configuring and installing bootloader"), |
88 |
+ 'setup_and_run_bootloader': _("Setting up and running bootloader"), |
89 |
# 'update_config_files': "Re-Updating config files", #second run. |
90 |
- 'set_users': "Add additional users.", |
91 |
- 'install_packages': "Installing additional packages.", |
92 |
+ 'set_users': _("Add additional users."), |
93 |
+ 'install_packages': _("Installing additional packages."), |
94 |
# services for startup need to come after installing extra packages |
95 |
# otherwise some of the scripts will not exist. |
96 |
- 'set_services': "Setting up services for startup", |
97 |
- 'run_post_install_script': "Running custom post-install script", |
98 |
- 'finishing_cleanup': "Cleanup and unmounting local filesystems.", |
99 |
- 'install_failed_cleanup': "Cleaning up after a failed install" |
100 |
+ 'set_services': _("Setting up services for startup"), |
101 |
+ 'run_post_install_script': _("Running custom post-install script"), |
102 |
+ 'finishing_cleanup': _("Cleanup and unmounting local filesystems."), |
103 |
+ 'install_failed_cleanup' : _("Cleaning up after a failed install") |
104 |
} |
105 |
|
106 |
## |
107 |
@@ -291,7 +301,7 @@ |
108 |
|
109 |
mounts = self._install_profile.get_mounts() |
110 |
mount_progress = 1 |
111 |
- self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Generating mount list")) |
112 |
+ self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), _("Generating mount list"))) |
113 |
parts_to_mount = {} |
114 |
for mount in mounts: |
115 |
Partitioning.wait_for_device_node(mount['devnode']) |
116 |
@@ -300,7 +310,7 @@ |
117 |
partition_type = mount['type'] |
118 |
if partition_type in ("linux-swap", "swap"): |
119 |
mount_progress += 1 |
120 |
- self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Activating swap on " + mount['devnode'])) |
121 |
+ self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), _("Activating swap on ") + mount['devnode'])) |
122 |
ret = GLIUtility.spawn("swapon " + mount['devnode']) |
123 |
if not GLIUtility.exitsuccess(ret): |
124 |
self._logger.log("ERROR! : Could not activate swap (" + mount['devnode'] + ")!") |
125 |
@@ -334,7 +344,7 @@ |
126 |
partition_type = parts_to_mount[mountpoint][1] |
127 |
partition = parts_to_mount[mountpoint][2] |
128 |
mount_progress += 1 |
129 |
- self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Mounting %s at %s" % (partition, mountpoint))) |
130 |
+ self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), _("Mounting %(partition)s at %(mountpoint)s") % {'partition' : partition, 'mountpoint' : mountpoint})) |
131 |
if not GLIUtility.is_file(self._chroot_dir + mountpoint): |
132 |
if self._debug: self._logger.log("DEBUG: making mountpoint: "+mountpoint) |
133 |
exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint) |
134 |
@@ -413,9 +423,9 @@ |
135 |
syspkglen = len(systempkgs) |
136 |
for i, pkg in enumerate(systempkgs): |
137 |
pkg = pkg.strip() |
138 |
- self.notify_frontend("progress", (float(i) / (syspkglen+1), "Copying " + pkg + " (" + str(i+1) + "/" + str(syspkglen) + ")")) |
139 |
+ self.notify_frontend("progress", (float(i) / (syspkglen+1), _("Copying ") + pkg + " (" + str(i+1) + "/" + str(syspkglen) + ")")) |
140 |
self._portage.copy_pkg_to_chroot(pkg, True, ignore_missing=True) |
141 |
- self.notify_frontend("progress", (float(syspkglen) / (syspkglen+1), "Finishing")) |
142 |
+ self.notify_frontend("progress", (float(syspkglen) / (syspkglen+1), _("Finishing"))) |
143 |
GLIUtility.spawn("cp /etc/make.conf " + self._chroot_dir + "/etc/make.conf") |
144 |
# Remove warning from make.conf |
145 |
GLIUtility.spawn("sed -i '/^##/d' " + self._chroot_dir + "/etc/make.conf") |
146 |
@@ -456,7 +466,7 @@ |
147 |
script.close() |
148 |
GLIUtility.spawn("chmod 755 /tmp/extrastuff.sh && /tmp/extrastuff.sh", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True) |
149 |
GLIUtility.spawn("rm -rf /var/tmp/portage/* /usr/portage /tmp/*", chroot=self._chroot_dir) |
150 |
- self.notify_frontend("progress", (1, "Done")) |
151 |
+ self.notify_frontend("progress", (1, _("Done"))) |
152 |
if not GLIUtility.is_file("/etc/make.conf"): |
153 |
raise GLIException("CreateStage3Error", "fatal", "unpack_stage_tarball", "Something went wrong during stage3 generation, /etc/make.conf doesn't exist on the new system! ") |
154 |
self._logger.log("Stage3 was generated successfully") |
155 |
@@ -671,17 +681,17 @@ |
156 |
# Special case, livecd kernel |
157 |
elif kernel_pkg == "livecd-kernel": |
158 |
if self._debug: self._logger.log("DEBUG: starting livecd-kernel setup") |
159 |
- self.notify_frontend("progress", (0, "Determining files to copy")) |
160 |
+ self.notify_frontend("progress", (0, _("Determining files to copy"))) |
161 |
GLIUtility.spawn(r"find /var/db/pkg -type f -name CONTENTS | xargs awk '/^obj \/lib\/modules\// { print $2; }' > /tmp/kernel_modules") |
162 |
files = GLIUtility.spawn('ls -1 --color=no /boot/System* /boot/kernel* /boot/initr* $(for i in $(find "/lib/modules/" -type f); do grep --quiet "^${i}$" /tmp/kernel_modules || echo ${i}; done); rm /tmp/kernel_modules 2>/dev/null', return_output=True)[1].strip().split("\n") |
163 |
if not files: |
164 |
raise GLIException("LiveCDKernelError", 'fatal','emerge_kernel_sources', "Could not determine files to copy for livecd-kernel") |
165 |
- self.notify_frontend("progress", (0.2, "Copying kernel, initramfs, and modules")) |
166 |
+ self.notify_frontend("progress", (0.2, _("Copying kernel, initramfs, and modules"))) |
167 |
if not GLIUtility.exitsuccess(GLIUtility.spawn("cp -p --parents %s %s/" % (" ".join(files), self._chroot_dir), logfile=self._compile_logfile, append_log=True)): |
168 |
raise GLIException("LiveCDKernelError", 'fatal','emerge_kernel_sources', "Could not copy kernel, initramfs, or modules") |
169 |
- self.notify_frontend("progress", (0.4, "Generating module dependencies")) |
170 |
+ self.notify_frontend("progress", (0.4, _("Generating module dependencies"))) |
171 |
GLIUtility.spawn("depmod -a", logfile=self._compile_logfile, append_log=True) |
172 |
- self.notify_frontend("progress", (0.6, "Gathering portage configuration")) |
173 |
+ self.notify_frontend("progress", (0.6, _("Gathering portage configuration"))) |
174 |
portage_info = {} |
175 |
for line in GLIUtility.spawn(r"emerge --info 2>/dev/null | grep '^[A-Z0-9_]\+=' | sed -e 's:\" \([A-Z]\):\"\n\1:g'", chroot=self._chroot_dir, return_output=True)[1].strip().split("\n"): |
176 |
parts = line.split("=", 1) |
177 |
@@ -711,7 +721,7 @@ |
178 |
'SLOT': "0", |
179 |
'USE': arch |
180 |
} |
181 |
- self.notify_frontend("progress", (0.8, "Creating VDB entry for livecd-kernel")) |
182 |
+ self.notify_frontend("progress", (0.8, _("Creating VDB entry for livecd-kernel"))) |
183 |
vdbdir = self._chroot_dir + "/var/db/pkg/sys-kernel/livecd-kernel-1" |
184 |
os.mkdir(vdbdir) |
185 |
for tmpfile in values: |
186 |
@@ -726,7 +736,7 @@ |
187 |
counter_f.write(str(counter)) |
188 |
counter_f.close() |
189 |
GLIUtility.spawn("echo | bzip2 > %s/environment.bz2" % vdbdir) |
190 |
- self.notify_frontend("progress", (1, "Done copying livecd-kernel to chroot")) |
191 |
+ self.notify_frontend("progress", (1, _("Done copying livecd-kernel to chroot"))) |
192 |
|
193 |
if self._install_profile.get_kernel_bootsplash(): |
194 |
self._logger.log("Bootsplash enabled for livecd-kernel...this is currently broken, so we're skipping the package install") |
195 |
@@ -860,7 +870,7 @@ |
196 |
genkernel_options = genkernel_options + " --no-gensplash" |
197 |
# Run genkernel in chroot |
198 |
#print "genkernel all " + genkernel_options |
199 |
- self.notify_frontend("progress", (0, "Compiling kernel. Please be patient!")) |
200 |
+ self.notify_frontend("progress", (0, _("Compiling kernel. Please be patient!"))) |
201 |
if self._debug: self._logger.log("DEBUG: build_kernel(): running: genkernel all " + genkernel_options + " in chroot.") |
202 |
exitstatus = GLIUtility.spawn("genkernel all " + genkernel_options, chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True) |
203 |
if not GLIUtility.exitsuccess(exitstatus): |
204 |
@@ -1418,9 +1428,9 @@ |
205 |
steps = len(self._mounted_devices) + len(self._swap_devices) + 2 |
206 |
|
207 |
if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: mv /tmp/compile_output.log /tmp/compile_output.log.failed") |
208 |
- self.notify_frontend("progress", (float(1) / (steps), "Moving compile output logfile")) |
209 |
+ self.notify_frontend("progress", (float(1) / (steps), _("Moving compile output logfile"))) |
210 |
GLIUtility.spawn("cp " + self._compile_logfile + " " + self._compile_logfile + ".failed && rm " + self._compile_logfile) |
211 |
- self.notify_frontend("progress", (float(2) / (steps), "Moving install logfile")) |
212 |
+ self.notify_frontend("progress", (float(2) / (steps), _("Moving install logfile"))) |
213 |
GLIUtility.spawn("mv " + LOGFILE + " " + LOGFILE + ".failed") |
214 |
cur_step = 2 |
215 |
|
216 |
@@ -1432,7 +1442,7 @@ |
217 |
mounted_devices.reverse() |
218 |
for mount in mounted_devices: |
219 |
cur_step += 1 |
220 |
- self.notify_frontend("progress", (float(cur_step) / (steps), "Unmounting " + mount)) |
221 |
+ self.notify_frontend("progress", (float(cur_step) / (steps), _("Unmounting ") + mount)) |
222 |
if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: umount -l " + mount) |
223 |
ret = GLIUtility.spawn("umount -l " + self._chroot_dir + mount) |
224 |
if not GLIUtility.exitsuccess(ret): |
225 |
@@ -1442,7 +1452,7 @@ |
226 |
# we need to find the swap devices |
227 |
for swap_device in self._swap_devices: |
228 |
cur_step += 1 |
229 |
- self.notify_frontend("progress", (float(cur_step) / (steps), "Deactivating swap on " + swap_device)) |
230 |
+ self.notify_frontend("progress", (float(cur_step) / (steps), _("Deactivating swap on ") + swap_device)) |
231 |
if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: swapoff "+swap_device) |
232 |
ret = GLIUtility.spawn("swapoff "+swap_device) |
233 |
if not GLIUtility.exitsuccess(ret): |
234 |
|
235 |
-- |
236 |
gentoo-commits@l.g.o mailing list |