Commit 869e35db authored by Diego Pasqualin's avatar Diego Pasqualin

Implement some changes proposed by Picharski

- Fix automated partitioning
- Fix user configuration
- Calls le-save-contents to save educational contents previously installed
  on the machine.
Signed-off-by: default avatarDiego Pasqualin <dpasqualin@c3sl.ufpr.br>
parent bc3abdc9
......@@ -3,7 +3,7 @@ Version:
Architecture: i386
Maintainer: LE Maintainer <le-maintainer@c3sl.ufpr.br>
Installed-Size: 14193
Depends: libc6 (>= 2.15), libdebconfclient0 (>= 0.145), libdebian-installer4 (>= 0.79ubuntu2), libiw30 (>= 30~pre1), libparted0debian1 (>= 2.2-1), libxml2 (>= 2.7.4), debconf (>= 1.4.72ubuntu5), upstart-job, python (>=2.7.1-0ubuntu2), ubiquity-frontend-le, ubiquity-le-artwork, laptop-detect, lsb-release, ubiquity-casper, python-apt (>= 0.7.100.3~), console-setup (>= 1.70ubuntu5), iso-codes, passwd, adduser, os-prober, rdate, ntfs-3g (>= 1:2011.1.15AR.4+2011.4.12-1) | ntfsprogs, ecryptfs-utils, cryptsetup, python-pyicu (>= 1.0), reiserfsprogs, language-selector-common (>= 0.4.16), archdetect-deb, dpkg-repack, apt-clone, wget, grub-common, realpath, dbus-x11
Depends: le-save-contents-gtk, libc6 (>= 2.15), libdebconfclient0 (>= 0.145), libdebian-installer4 (>= 0.79ubuntu2), libiw30 (>= 30~pre1), libparted0debian1 (>= 2.2-1), libxml2 (>= 2.7.4), debconf (>= 1.4.72ubuntu5), upstart-job, python (>=2.7.1-0ubuntu2), ubiquity-frontend-le, ubiquity-le-artwork, laptop-detect, lsb-release, ubiquity-casper, python-apt (>= 0.7.100.3~), console-setup (>= 1.70ubuntu5), iso-codes, passwd, adduser, os-prober, rdate, ntfs-3g (>= 1:2011.1.15AR.4+2011.4.12-1) | ntfsprogs, ecryptfs-utils, cryptsetup, python-pyicu (>= 1.0), reiserfsprogs, language-selector-common (>= 0.4.16), archdetect-deb, dpkg-repack, apt-clone, wget, grub-common, realpath, dbus-x11
Recommends: grub-pc | grub | grub-efi, dmraid, btrfs-tools
Conflicts: espresso, espresso-grub, espresso-kbd-chooser, espresso-keyboard-setup, espresso-locale, espresso-timezone, espresso-utils, espresso-yaboot, partman, ubuntu-express, user-setup (<< 0.05ubuntu6)
Replaces: espresso, espresso-grub, espresso-kbd-chooser, espresso-keyboard-setup, espresso-locale, espresso-timezone, espresso-utils, espresso-yaboot, partman, ubiquity, ubuntu-express, user-setup (<< 0.05ubuntu6)
......
......@@ -54,7 +54,7 @@ def main():
fp.write('-1000')
# Lock HAL's storage subsystem (or DeviceKit-disks or udisks).
if osextras.find_on_path('udisks'):
toexec.extend(['udisks', '--inhibit', '--'])
toexec.extend(['lock-udisks'])
toexec.extend(inner)
elif osextras.find_on_path('devkit-disks'):
toexec.extend(['devkit-disks', '--inhibit', '--'])
......
......@@ -22,6 +22,8 @@ import os
import re
import shutil
import signal
import syslog
import subprocess
import debconf
......@@ -190,12 +192,14 @@ class PageGtk(PageBase):
self.plugin_optional_widgets = [self.page_auto, self.page_advanced]
self.current_page = self.page_ask
self.saved_contents = False
# Set some parameters that do not change between runs of the plugin
release = misc.get_release()
self.partitionbox.set_property('title', release.name + ' ' + release.version)
self.partitionbox.set_property('title', release.name)
# New partition
self.resizewidget.get_child2().get_child().set_property('title', release.name + ' ' + release.version)
self.resizewidget.get_child2().get_child().set_property('title', release.name)
# Annoyingly, you can't set packing properties for cell renderers
# in Glade.
......@@ -250,6 +254,13 @@ class PageGtk(PageBase):
done_partitioning = (resize and biggest_free) or reuse or replace
if self.current_page == self.page_ask and not done_partitioning:
if use_device:
process = subprocess.Popen(['save-contents.py'])
if process.returncode is None:
process.wait()
self.saved_contents = process.returncode == 0
#out, err = process.communicate()
#syslog.syslog(syslog.LOG_ERR, "save-contents: " + err)
if custom:
title = self.custom_partitioning_title.get_text()
elif resize:
......@@ -357,7 +368,7 @@ class PageGtk(PageBase):
self.part_auto_hidden_label.set_markup(hidden)
else:
hidden = self.controller.get_string('part_auto_hidden_label')
self.part_auto_hidden_label.set_markup(hidden % partition_count)
self.part_auto_hidden_label.set_markup(hidden % partition_count + ' (conteúdos educacionais serão recuperados)')
def part_ask_option_is_install(self):
if (self.reuse_partition.get_active() or
......@@ -458,7 +469,11 @@ class PageGtk(PageBase):
self.part_auto_hidden_label.set_markup(deleted)
else:
deleted = self.controller.get_string('part_auto_deleted_label')
self.part_auto_hidden_label.set_markup(deleted % partition_count)
if self.saved_contents:
self.part_auto_hidden_label.set_markup((deleted %
partition_count) + ' ( conteudos serão recuperados)')
else:
self.part_auto_hidden_label.set_markup(deleted % partition_count)
self.partition_container.set_current_page(1)
# Set the filesystem and size of the partition.
ext = '%s (%s)' % (disk_id.replace('=', '/'), self.default_filesystem)
......@@ -1849,7 +1864,7 @@ class Page(plugin.Plugin):
if system and system != 'swap':
if not system.startswith('Windows Recovery'):
operating_systems.append(system)
ubuntu_systems = filter(lambda x: x.find('LE 5.0') != -1,
ubuntu_systems = filter(lambda x: x.lower().find('buntu') != -1,
operating_systems)
return (operating_systems, ubuntu_systems)
......@@ -1886,7 +1901,7 @@ class Page(plugin.Plugin):
# We always have the manual partitioner, and it always has the same
# title and description.
q = 'ubiquity/partitioner/advanced'
self.db.subst(q, 'DISTRO', release.name + ' ' + release.version)
self.db.subst(q, 'DISTRO', release.name)
title = self.description(q)
desc = self.extended_description(q)
options['manual'] = PartitioningOption(title, desc)
......@@ -1894,7 +1909,7 @@ class Page(plugin.Plugin):
if os_count == 0:
# "There are no operating systems present" case
q = 'ubiquity/partitioner/no_systems_format'
self.db.subst(q, 'DISTRO', release.name + ' ' + release.version)
self.db.subst(q, 'DISTRO', release.name)
title = self.description(q)
desc = self.extended_description(q)
opt = PartitioningOption(title, desc)
......@@ -1916,7 +1931,7 @@ class Page(plugin.Plugin):
pass
elif resize_option:
q = 'ubiquity/partitioner/ubuntu_resize'
self.db.subst(q, 'DISTRO', release.name + ' ' + release.version)
self.db.subst(q, 'DISTRO', release.name)
self.db.subst(q, 'VER', release.version)
self.db.subst(q, 'CURDISTRO', system)
title = self.description(q)
......@@ -1931,7 +1946,7 @@ class Page(plugin.Plugin):
# "Just Windows (or Mac, ...) is present" case
q = 'ubiquity/partitioner/single_os_replace'
self.db.subst(q, 'OS', system)
self.db.subst(q, 'DISTRO', release.name + ' ' + release.version)
self.db.subst(q, 'DISTRO', release.name)
title = self.description(q)
desc = self.extended_description(q)
opt = PartitioningOption(title, desc)
......@@ -1943,7 +1958,7 @@ class Page(plugin.Plugin):
else:
q = 'ubiquity/partitioner/ubuntu_inside'
self.db.subst(q, 'OS', system)
self.db.subst(q, 'DISTRO', release.name + ' ' + release.version)
self.db.subst(q, 'DISTRO', release.name)
title = self.description(q)
desc = self.extended_description(q)
opt = PartitioningOption(title, desc)
......@@ -1976,7 +1991,7 @@ class Page(plugin.Plugin):
else:
# "There are multiple operating systems present" case
q = 'ubiquity/partitioner/multiple_os_format'
self.db.subst(q, 'DISTRO', release.name + ' ' + release.version)
self.db.subst(q, 'DISTRO', release.name)
title = self.description(q)
desc = self.extended_description(q)
opt = PartitioningOption(title, desc)
......@@ -1986,7 +2001,7 @@ class Page(plugin.Plugin):
pass
elif resize_option:
q = 'ubiquity/partitioner/multiple_os_resize'
self.db.subst(q, 'DISTRO', release.name + ' ' + release.version)
self.db.subst(q, 'DISTRO', release.name)
title = self.description(q)
desc = self.extended_description(q)
opt = PartitioningOption(title, desc)
......
......@@ -26,7 +26,6 @@
import os
import re
import syslog
import debconf
......@@ -168,27 +167,30 @@ class PageGtk(PageBase):
self.hostname_edited = False
self.hostname_timeout_id = 0
result = os.popen('/usr/lib/ubiquity/le-utils/le-env')
if result.readline() == 'escola':
self.page = None
result.close()
return
result.close()
builder = Gtk.Builder()
self.controller.add_builder(builder)
builder.add_from_file(os.path.join(os.environ['UBIQUITY_GLADE'], 'stepUserInfo.ui'))
builder.connect_signals(self)
self.page = builder.get_object('stepUserInfo')
self.username = builder.get_object('username')
self.hostname = builder.get_object('hostname')
self.fullname = builder.get_object('fullname')
self.password = builder.get_object('password')
self.username_error_label = builder.get_object('username_error_label')
self.username_label = builder.get_object('username_label')
self.fullname_label = builder.get_object('fullname_label')
self.password_label = builder.get_object('password_label')
self.password_error_label = builder.get_object('password_error_label')
self.verified_password_label = builder.get_object('verified_password_label')
self.verified_password = builder.get_object('verified_password')
self.login_auto = builder.get_object('login_auto')
self.login_encrypt = builder.get_object('login_encrypt')
self.login_pass = builder.get_object('login_pass')
self.check_enviroment()
self.username_error_label = builder.get_object('username_error_label')
self.hostname_error_label = builder.get_object('hostname_error_label')
self.password_error_label = builder.get_object('password_error_label')
......@@ -234,6 +236,22 @@ class PageGtk(PageBase):
self.resolver_ok = True
self.plugin_widgets = self.page
def check_enviroment(self):
if os.path.exists('/etc/le/home_alunos'):
self.username.hide()
self.fullname.hide()
self.password.hide()
self.verified_password.hide()
self.login_auto.hide()
self.login_encrypt.hide()
self.login_pass.hide()
self.username_label.hide()
self.username_error_label.hide()
self.fullname_label.hide()
self.password_label.hide()
self.password_error_label.hide()
self.verified_password_label.hide()
def plugin_translate(self, lang):
# TODO Move back into the frontend as we can check
# isinstance(LabelledEntry and just call set_label. We'll need to
......@@ -318,82 +336,85 @@ class PageGtk(PageBase):
"""check if all entries from Identification screen are filled. Callback
defined in ui file."""
if (self.username_changed_id is None or
self.hostname_changed_id is None):
return
if (widget is not None and widget.get_name() == 'fullname' and
not self.username_edited):
self.username.handler_block(self.username_changed_id)
new_username = misc.utf8(widget.get_text().split(' ')[0])
new_username = new_username.encode('ascii', 'ascii_transliterate')
new_username = new_username.lower()
new_username = re.sub('^[^a-z]+', '', new_username)
new_username = re.sub('[^-a-z0-9_]', '', new_username)
self.username.set_text(new_username)
self.username.handler_unblock(self.username_changed_id)
elif (widget is not None and widget.get_name() == 'username' and
not self.hostname_edited):
self.hostname.handler_block(self.hostname_changed_id)
t = widget.get_text()
if t:
self.hostname.set_text(re.sub(r'\W', '', t) + self.suffix)
self.hostname.handler_unblock(self.hostname_changed_id)
# Do some initial validation. We have to process all the widgets so we
# can know if we can really show the next button. Otherwise we'd show
# it on any field being valid.
home = not os.path.exists('/etc/le/home_alunos')
complete = True
if self.fullname.get_text():
self.fullname_ok.show()
else:
self.fullname_ok.hide()
text = self.username.get_text()
if text:
errors = check_username(text)
if errors:
self.username_error(make_error_string(self.controller, errors))
complete = False
if home:
if (self.username_changed_id is None or
self.hostname_changed_id is None):
return
if (widget is not None and widget.get_name() == 'fullname' and
not self.username_edited):
self.username.handler_block(self.username_changed_id)
new_username = misc.utf8(widget.get_text().split(' ')[0])
new_username = new_username.encode('ascii', 'ascii_transliterate')
new_username = new_username.lower()
new_username = re.sub('^[^a-z]+', '', new_username)
new_username = re.sub('[^-a-z0-9_]', '', new_username)
self.username.set_text(new_username)
self.username.handler_unblock(self.username_changed_id)
elif (widget is not None and widget.get_name() == 'username' and
not self.hostname_edited):
self.hostname.handler_block(self.hostname_changed_id)
t = widget.get_text()
if t:
self.hostname.set_text(re.sub(r'\W', '', t) + self.suffix)
self.hostname.handler_unblock(self.hostname_changed_id)
# Do some initial validation. We have to process all the widgets so we
# can know if we can really show the next button. Otherwise we'd show
# it on any field being valid.
if self.fullname.get_text():
self.fullname_ok.show()
else:
self.username_ok.show()
self.fullname_ok.hide()
text = self.username.get_text()
if text:
errors = check_username(text)
if errors:
self.username_error(make_error_string(self.controller, errors))
complete = False
else:
self.username_ok.show()
self.username_error_label.hide()
else:
self.username_ok.hide()
self.username_error_label.hide()
else:
self.username_ok.hide()
self.username_error_label.hide()
complete = False
complete = False
passw = self.password.get_text()
vpassw = self.verified_password.get_text()
allow_empty = self.allow_password_empty
if passw != vpassw:
complete = False
self.password_ok.hide()
if passw and (len(vpassw) / float(len(passw)) > 0.8):
# TODO Cache, use a custom string.
txt = self.controller.get_string('ubiquity/text/password_mismatch')
txt = '<small><span foreground="darkred"><b>%s</b></span></small>' % txt
self.password_error_label.set_markup(txt)
self.password_error_label.show()
else:
self.password_error_label.hide()
passw = self.password.get_text()
vpassw = self.verified_password.get_text()
allow_empty = self.allow_password_empty
if passw != vpassw:
complete = False
self.password_ok.hide()
if passw and (len(vpassw) / float(len(passw)) > 0.8):
# TODO Cache, use a custom string.
txt = self.controller.get_string('ubiquity/text/password_mismatch')
txt = '<small><span foreground="darkred"><b>%s</b></span></small>' % txt
self.password_error_label.set_markup(txt)
self.password_error_label.show()
else:
self.password_error_label.hide()
if allow_empty:
self.password_strength.hide()
elif not passw:
self.password_strength.hide()
complete = False
else:
(txt, color) = validation.human_password_strength(passw)
# TODO Cache
txt = self.controller.get_string('ubiquity/text/password/' + txt)
txt = '<small><span foreground="%s"><b>%s</b></span></small>' \
% (color, txt)
self.password_strength.set_markup(txt)
self.password_strength.show()
if passw == vpassw:
self.password_ok.show()
if allow_empty:
self.password_strength.hide()
elif not passw:
self.password_strength.hide()
complete = False
else:
(txt, color) = validation.human_password_strength(passw)
# TODO Cache
txt = self.controller.get_string('ubiquity/text/password/' + txt)
txt = '<small><span foreground="%s"><b>%s</b></span></small>' \
% (color, txt)
self.password_strength.set_markup(txt)
self.password_strength.show()
if passw == vpassw:
self.password_ok.show()
txt = self.hostname.get_text()
self.hostname_ok.show()
......
......@@ -174,6 +174,13 @@ class Install(install_misc.InstallBase):
raise
syslog.syslog('Terminated ubiquity update process.')
def restore_contents(self, target):
restore_config = '/var/lib/save-contents/result'
if os.path.exists(restore_config):
os.mkdir(target + '/home/ConteudoMEC')
os.system('cp -r "$(cat %s)"/* "%s"' % (restore_config, target + '/ConteudoMEC'))
def find_cd_kernel(self):
"""Find the boot kernel on the CD, if possible."""
......@@ -501,6 +508,8 @@ class Install(install_misc.InstallBase):
with open('/proc/sys/vm/dirty_expire_centisecs', 'w') as dec:
print >>dec, dirty_expire_centisecs
self.restore_contents(self.target)
# Try some possible locations for the kernel we used to boot. This
# lets us save a couple of megabytes of CD space.
bootdir = os.path.join(self.target, 'boot')
......@@ -522,6 +531,7 @@ class Install(install_misc.InstallBase):
os.umask(old_umask)
self.db.progress('SET', 100)
self.db.progress('STOP')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment