From 4885d32a045e10ceddbf00a6d72c6a4adb56ae62 Mon Sep 17 00:00:00 2001 From: Cyrille Pontvieux Date: Sat, 9 Feb 2013 03:01:59 +0100 Subject: [PATCH] New rewriting of the Salix Live Installer using the salix_livetools_library. For now, only the first tab, the timezone is done. --- src/.gitignore | 1 + src/salix-live-installer.glade | 119 +-- src/salix-live-installer.py | 861 ++++++++++++++++++ .../__init__.py | 0 .../assertPlus.py | 0 .../bootloader.py | 0 .../chroot.py | 0 .../disk.py | 0 .../execute.py | 0 .../freesize.py | 0 .../fs.py | 0 .../fstab.py | 0 .../kernel.py | 0 .../keyboard.py | 0 .../language.py | 0 .../mounting.py | 0 .../salt.py | 0 .../timezone.py | 34 + .../user.py | 0 src/test.sh | 11 + 20 files changed, 967 insertions(+), 59 deletions(-) create mode 100755 src/salix-live-installer.py rename src/{salix-live-installer => salix_livetools_library}/__init__.py (100%) rename src/{salix-live-installer => salix_livetools_library}/assertPlus.py (100%) rename src/{salix-live-installer => salix_livetools_library}/bootloader.py (100%) rename src/{salix-live-installer => salix_livetools_library}/chroot.py (100%) rename src/{salix-live-installer => salix_livetools_library}/disk.py (100%) rename src/{salix-live-installer => salix_livetools_library}/execute.py (100%) rename src/{salix-live-installer => salix_livetools_library}/freesize.py (100%) rename src/{salix-live-installer => salix_livetools_library}/fs.py (100%) rename src/{salix-live-installer => salix_livetools_library}/fstab.py (100%) rename src/{salix-live-installer => salix_livetools_library}/kernel.py (100%) rename src/{salix-live-installer => salix_livetools_library}/keyboard.py (100%) rename src/{salix-live-installer => salix_livetools_library}/language.py (100%) rename src/{salix-live-installer => salix_livetools_library}/mounting.py (100%) rename src/{salix-live-installer => salix_livetools_library}/salt.py (100%) rename src/{salix-live-installer => salix_livetools_library}/timezone.py (77%) rename src/{salix-live-installer => salix_livetools_library}/user.py (100%) create mode 100755 src/test.sh diff --git a/src/.gitignore b/src/.gitignore index 0d20b64..1b2be22 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1 +1,2 @@ *.pyc +locale diff --git a/src/salix-live-installer.glade b/src/salix-live-installer.glade index 6a36380..11a793e 100644 --- a/src/salix-live-installer.glade +++ b/src/salix-live-installer.glade @@ -374,7 +374,7 @@ True True none - + @@ -393,7 +393,7 @@ True - + @@ -445,7 +445,7 @@ True True none - + @@ -492,7 +492,7 @@ True True none - + @@ -537,7 +537,7 @@ True True none - + @@ -581,7 +581,7 @@ True True none - + @@ -625,7 +625,7 @@ True True none - + @@ -670,7 +670,7 @@ True True none - + @@ -913,7 +913,7 @@ True - + 580 @@ -989,7 +989,7 @@ Contextual help triggered by the mouse position is available each step of the wa True - + @@ -1224,7 +1224,7 @@ Contextual help triggered by the mouse position is available each step of the wa True - + @@ -1262,6 +1262,7 @@ Contextual help triggered by the mouse position is available each step of the wa True country_zone_list_store + @@ -1292,7 +1293,7 @@ Contextual help triggered by the mouse position is available each step of the wa True True - + @@ -1319,7 +1320,7 @@ Contextual help triggered by the mouse position is available each step of the wa True True True - + @@ -1336,7 +1337,7 @@ Contextual help triggered by the mouse position is available each step of the wa True True True - + @@ -1393,7 +1394,7 @@ Contextual help triggered by the mouse position is available each step of the wa False True 0 - + @@ -1438,7 +1439,7 @@ Contextual help triggered by the mouse position is available each step of the wa False True - + @@ -1456,7 +1457,7 @@ Contextual help triggered by the mouse position is available each step of the wa none True - + @@ -1478,7 +1479,7 @@ Contextual help triggered by the mouse position is available each step of the wa True - + @@ -1542,7 +1543,7 @@ Contextual help triggered by the mouse position is available each step of the wa True True True - + @@ -1557,7 +1558,7 @@ Contextual help triggered by the mouse position is available each step of the wa True True True - + @@ -1639,7 +1640,7 @@ Contextual help triggered by the mouse position is available each step of the wa False True 0 - + @@ -1677,7 +1678,7 @@ Contextual help triggered by the mouse position is available each step of the wa True - + @@ -1741,7 +1742,7 @@ Contextual help triggered by the mouse position is available each step of the wa True True True - + @@ -1756,7 +1757,7 @@ Contextual help triggered by the mouse position is available each step of the wa True True True - + @@ -1950,7 +1951,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True 0 - + @@ -2015,7 +2016,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True - + @@ -2047,7 +2048,7 @@ If you already have all the needed partitions, please click on the button 'Do no True - + @@ -2105,7 +2106,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -2186,7 +2187,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True 0 - + @@ -2313,7 +2314,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -2397,7 +2398,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True 0 - + @@ -2502,7 +2503,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -2558,7 +2559,7 @@ If you already have all the needed partitions, please click on the button 'Do no True - + @@ -2681,7 +2682,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -2708,7 +2709,7 @@ If you already have all the needed partitions, please click on the button 'Do no - + @@ -2724,7 +2725,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True - + @@ -2748,7 +2749,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -2765,7 +2766,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -2806,7 +2807,7 @@ If you already have all the needed partitions, please click on the button 'Do no True - + @@ -2846,7 +2847,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True - + @@ -2878,7 +2879,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True - + @@ -2896,7 +2897,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True - + @@ -2927,7 +2928,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True - + @@ -2979,7 +2980,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -2996,7 +2997,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -3065,7 +3066,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True - + @@ -3083,7 +3084,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True - + @@ -3114,7 +3115,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True - + @@ -3165,7 +3166,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -3182,7 +3183,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -3250,7 +3251,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True full_radiobutton - + @@ -3296,7 +3297,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True full_radiobutton - + @@ -3372,7 +3373,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True True - + @@ -3556,7 +3557,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -3573,7 +3574,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -3625,7 +3626,7 @@ If you already have all the needed partitions, please click on the button 'Do no True True True - + @@ -3638,7 +3639,7 @@ If you already have all the needed partitions, please click on the button 'Do no True - + @@ -3646,7 +3647,7 @@ If you already have all the needed partitions, please click on the button 'Do no False True True - + @@ -3705,7 +3706,7 @@ If you already have all the needed partitions, please click on the button 'Do no True main_window SalixLive Installer - 0.3 + 0.4 Copyright © 2010-2011 Pierrick Le Brun SalixOS installation from SalixLive's graphic environment http://www.salixos.org diff --git a/src/salix-live-installer.py b/src/salix-live-installer.py new file mode 100755 index 0000000..37394e6 --- /dev/null +++ b/src/salix-live-installer.py @@ -0,0 +1,861 @@ +#!/usr/bin/env python +# vim: set et ai sta sw=2 st=2 tw=0: + +#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# +# # +# Salix installer will install Salix on your computer from the comfort of # +# SalixLive's graphic environment. # +# # +# Copyright Pierrick Le Brun . # +# # +# This program is free software; you can redistribute it and/or # +# modify it under the terms of the GNU General Public License # +# as published by the Free Software Foundation; either version 2 # +# of the License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # +# # +#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# + +# version = '0.4' + +import gettext +import gobject +import gtk +import gtk.glade +import os +import sys +import glob +import re +from datetime import * +import salix_livetools_library as sltl + +APP = 'salix-live-installer' + +class SalixLiveInstaller: + def __init__(self, isTest = False): + self.isTest = isTest + builder = gtk.Builder() + for d in ('.', '/usr/share/salix-live-installer', '../share/salix-live-installer'): + if os.path.exists(d + '/salix-live-installer.glade'): + builder.add_from_file(d + '/salix-live-installer.glade') + break + # Get a handle on the glade file widgets we want to interact with + self.Window = builder.get_object("main_window") + self.ProgressWindow = builder.get_object("progress_dialog") + self.InstallProgressBar = builder.get_object("install_progressbar") + self.AboutDialog = builder.get_object("about_dialog") + self.TimeTab = builder.get_object("time_tab") + self.KeyboardTab = builder.get_object("keyboard_tab") + self.LocaleTab = builder.get_object("locale_tab") + self.PartitionTab = builder.get_object("partition_tab") + self.UsersTab = builder.get_object("users_tab") + self.PackagesTab = builder.get_object("packages_tab") + self.TimeCheck = builder.get_object("time_check") + self.KeyboardCheck = builder.get_object("keyboard_check") + self.LocaleCheck = builder.get_object("locale_check") + self.PartitionCheck = builder.get_object("partition_check") + self.UsersCheck = builder.get_object("users_check") + self.PackagesCheck = builder.get_object("packages_check") + self.TimeCheckMarker = builder.get_object("time_check_marker") + self.KeyboardCheckMarker = builder.get_object("keyboard_check_marker") + self.LocaleCheckMarker = builder.get_object("locale_check_marker") + self.PartitionCheckMarker = builder.get_object("partition_check_marker") + self.UsersCheckMarker = builder.get_object("users_check_marker") + self.PackagesCheckMarker = builder.get_object("packages_check_marker") + self.IntroBox = builder.get_object("intro_box") + self.TimeBox = builder.get_object("time_box") + self.KeyboardBox = builder.get_object("keyboard_box") + self.LocaleBox = builder.get_object("locale_box") + self.PartitioningBox = builder.get_object("partitioning_box") + self.MainPartitionBox = builder.get_object("main_partition_box") + self.LinuxPartitionBox = builder.get_object("linux_partition_box") + self.WindowsPartitionBox = builder.get_object("windows_partition_box") + self.RecapPartitionBox = builder.get_object("recap_partition_box") + self.UsersBox = builder.get_object("users_box") + self.PackagesBox = builder.get_object("packages_box") + self.KeyboardList = builder.get_object("keyboard_list") + self.KeyboardListStore = builder.get_object("keymap_list_store") + self.KeyboardSelection = builder.get_object("keyboard_selection") + self.LocaleList = builder.get_object("locale_list") + self.LocaleListStore = builder.get_object("locale_list_store") + self.LocaleSelection = builder.get_object("locale_selection") + self.MainPartitionList = builder.get_object("main_partition_list") + self.MainPartitionListStore = builder.get_object("main_partition_list_store") + self.MainFormatCombobox = builder.get_object("main_format_combobox") + self.LinuxPartitionList = builder.get_object("linux_partition_list") + self.LinuxPartitionListStore = builder.get_object("linux_partition_list_store") + self.WindowsPartitionList = builder.get_object("win_partition_list") + self.WindowsPartitionListStore = builder.get_object("win_partition_list_store") + self.RecapPartitionList = builder.get_object("recap_partition_list") + self.RecapPartitionListStore = builder.get_object("recap_partition_list_store") + self.YesNoDialog = builder.get_object("yes_no_dialog") + self.YesNoLabel = builder.get_object("yes_no_label") + self.LinuxNewSysComboCell = builder.get_object("linux_newsys_renderer_combo") + self.LinuxNewSysColumn = builder.get_object("linux_newsys_column") + self.LinuxFormatListStore = builder.get_object("linux_format_list_store") + self.LinuxNewMountComboCell = builder.get_object("linux_newmount_renderer_combo") + self.LinuxNewMountColumn = builder.get_object("linux_newmount_column") + self.LinuxMountListStore = builder.get_object("linux_mountpoint_list_store") + self.LinuxPartitionApply = builder.get_object("linux_partition_apply") + self.WindowsPartitionApply = builder.get_object("windows_partition_apply") + self.WinMountComboCell = builder.get_object("win_newmount_renderer_combo") + self.WinMountColumn = builder.get_object("win_newmount_column") + self.WinMountListStore = builder.get_object("win_mountpoint_list_store") + self.MainPartRecapLabel = builder.get_object("main_part_recap_label") + self.LinPartRecapLabel = builder.get_object("lin_part_recap_label") + self.WinPartRecapLabel = builder.get_object("win_part_recap_label") + self.SwapPartRecapLabel = builder.get_object("swap_part_recap_label") + self.CoreRadioButton = builder.get_object("core_radiobutton") + self.CoreHBox = builder.get_object("core_hbox") + self.BasicRadioButton = builder.get_object("basic_radiobutton") + self.BasicHBox = builder.get_object("basic_hbox") + self.FullRadioButton = builder.get_object("full_radiobutton") + self.PackagesApplyButton = builder.get_object("packages_apply") + self.TimeApplyButton = builder.get_object("time_apply") + self.KeyboardApplyButton = builder.get_object("keyboard_apply") + self.LocaleApplyButton = builder.get_object("locale_apply") + self.CloneLoginEventbox = builder.get_object("clone_login_eventbox") + self.UsersEventbox = builder.get_object("users_eventbox") + self.CloneLoginCheckbutton = builder.get_object("clone_login_checkbutton") + self.CloneLoginUndo = builder.get_object("clone_login_undo") + self.CloneLoginApply = builder.get_object("clone_login_apply") + self.RootPass1Entry = builder.get_object("root_pass1_entry") + self.RootPass2Entry = builder.get_object("root_pass2_entry") + self.UserPass1Entry = builder.get_object("user_pass1_entry") + self.UserPass2Entry = builder.get_object("user_pass2_entry") + self.UserLoginEntry = builder.get_object("user_login_entry") + self.UserVisibleCheckButton = builder.get_object("user_visible_checkbutton") + self.RootVisibleCheckButton = builder.get_object("root_visible_checkbutton") + self.ExternalDeviceCheckButton = builder.get_object("external_device_checkbutton") + self.NumLockCheckButton = builder.get_object("numlock_checkbutton") + self.IBusCheckButton = builder.get_object("ibus_checkbutton") + self.RootPassCreated = builder.get_object("root_pass_created") + self.NewUserLogin = builder.get_object("new_user_login") + self.UsersApplyButton = builder.get_object("users_apply") + self.RootPassApplyButton = builder.get_object("rootpass_apply") + self.InstallButton = builder.get_object("install_button") + self.YearCombobox = builder.get_object("year_combobox") + self.MonthCombobox = builder.get_object("month_combobox") + self.DayCombobox = builder.get_object("day_combobox") + self.ContinentZoneCombobox = builder.get_object("continent_zone_combobox") + self.CountryZoneCombobox = builder.get_object("country_zone_combobox") + self.YearListStore = builder.get_object("year_list_store") + self.MonthListStore = builder.get_object("month_list_store") + self.DayListStore = builder.get_object("day_list_store") + self.ContinentZoneListStore = builder.get_object("continent_zone_list_store") + self.CountryZoneListStore = builder.get_object("country_zone_list_store") + self.NTPCheckButton = builder.get_object("ntp_checkbutton") + self.ManualTimeBox = builder.get_object("manual_time_box") + self.HourSpinButton = builder.get_object("hour_spinbutton") + self.MinuteSpinButton = builder.get_object("minute_spinbutton") + self.SecondSpinButton = builder.get_object("second_spinbutton") + self.TimeZoneBox = builder.get_object("time_zone_box") + self.ContextLabel = builder.get_object("context_label") + self.LayoutColumn = builder.get_object("layout_column") + self.TypeColumn = builder.get_object("type_column") + self.LocaleColumn = builder.get_object("locale_column") + self.DescriptColumn = builder.get_object("descript_column") + self.MainDiskColumn = builder.get_object("main_disk_column") + self.MainPartColumn = builder.get_object("main_part_column") + self.MainSizeColumn = builder.get_object("main_size_column") + self.MainFormatColumn = builder.get_object("main_format_column") + self.LinuxPartColumn = builder.get_object("linux_part_column") + self.LinuxSizeColumn = builder.get_object("linux_size_column") + self.LinuxOldSysColumn = builder.get_object("linux_oldsys_column") + self.LinuxNewSysColumn = builder.get_object("linux_newsys_column") + self.LinuxNewMountColumn = builder.get_object("linux_newmount_column") + self.WinPartColumn = builder.get_object("win_part_column") + self.WinSizeColumn = builder.get_object("win_size_column") + self.WinOldSysColumn = builder.get_object("win_oldsys_column") + self.WinNewMountColumn = builder.get_object("win_newmount_column") + # Initialize the contextual help box + self.context_intro = _("Contextual help.") + self.on_leave_notify_event(None) + # Prevent tab switching + self.switch_tab_lock = False + # Indicate if the partition wizard is done or not + self.partition_done = False + # Initialize the lock system preventing the Install button to be activated prematurely + self.configurations = {'time':False, 'keyboard':False, 'locale':False, 'partitions':False, 'user':False, 'root':False, 'packages':False} + self.get_current_config() + self.update_install_button() + # Connect signals + builder.connect_signals(self) + + # General contextual help + def on_leave_notify_event(self, widget, data=None): + self.ContextLabel.set_text(self.context_intro) + def on_intro_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("General usage.")) + def on_about_link_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("About Salix Installer.")) + def on_context_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Contextual help.")) + def on_button_quit_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Exit Salix Installer.")) + def on_install_button_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Launch Salix installation. This button will not be active until \ +all settings are configured correctly.")) + def on_launch_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Launch Salix installation. This button will not be active until \ +all settings are configured correctly.")) + + # Time contextual help + def on_time_tab_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Access the time settings.")) + def on_ntp_checkbutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Use Network Time Protocol daemon to synchronize time via Internet.")) + def on_time_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel time settings.")) + def on_time_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Activate the time settings after options have been defined.")) + def on_manual_time_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Set the date & time manually if you do not use NTP service.")) + def on_timezone_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Set the time zone.")) + + # Keyboard contextual help + def on_keyboard_tab_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Access the keyboard settings.")) + def on_keyboard_list_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Highlight your favorite keyboard layout \ +from this \nlist before clicking on the 'Select keyboard' button.")) + def on_numlock_checkbutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Check this box if you want your numeric keypad \ +to be activated during the boot process.")) + def on_ibus_checkbutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Check this box if you want iBus to be \ +activated during the boot process. IBus is an input method (IM) framework for multilingual input.")) + def on_keyboard_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel keyboard layout selection.")) + def on_keyboard_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Confirm your selection after highlighting the keyboard layout.")) + def on_keyboard_selection_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("This is the keyboard layout you have selected. \ +'None' will be displayed until you have confirmed that selection.")) + + # Locale contextual help + def on_locale_tab_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Access the language settings.")) + def on_locale_list_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Highlight your language from this list before \ +clicking on the 'Select language' button.")) + def on_locale_selection_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("This is the system language you have selected. \ +'None' will be displayed until you have confirmed that selection. ")) + def on_locale_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel language selection.")) + def on_locale_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Confirm your selection after highlighting the system language.")) + + # Partitions contextual help + def on_partition_tab_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Access the partitions settings.")) + def on_main_partition_list_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Highlight the partition from this list before \ +clicking on the 'Select partition' button.")) + def on_external_device_checkbutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Check this box if you want your external disk drive(s) \ +to be displayed in the list above. ")) + def on_main_partition_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Confirm your selection after highlighting the partition.")) + def on_main_format_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("The filesystem that will be used to format Salix main partition.")) + def on_linux_partition_list_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Click on the appropriate 'Select...' cell if you wish to modify the \ +filesystem of a partition and/or if you wish to assign its mount point.\ +You can either choose one of the suggested mount points or enter \ +your own. You must configure all the desired partitions before clicking \ +on the 'Apply settings' button. Any unset parameters will be ignored. ")) + def on_linux_partition_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Confirm the Linux partition(s) settings from the list.")) + def on_win_partition_list_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Click on the appropriate 'Select...' cell if you wish to assign \ +the mount point of a partition. You must configure all the \ +desired partitions before clicking on the 'Apply settings' button. \ +Any unset parameters will be ignored. ")) + def on_windows_partition_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Confirm the Windows partition(s) settings from the list above.")) + def on_partition_recap_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Summary of your partition(s) settings.")) + def on_partition_recap_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel all partition(s) settings.")) + + # Users contextual help + def on_users_tab_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Access the users and passwords settings.")) + def on_clone_login_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Salix Live Installer has detected a \ +LiveClone customized environment. You can transfer your existing LiveClone \ +login accounts along with matching personnal directories to the installation \ +target or you can wipe them out & create a complete new login account instead.")) + def on_clone_login_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Transfer existing users.")) + def on_clone_login_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel users transfer.")) + def on_users_eventbox_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("A Linux system can manage many registered users and requires each \ +one to log in, and to produce some form of authentication (usually a \ +login name coupled with a password) before allowing the user access \ +to system resources.")) + def on_user_login_entry_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Here you must define your login name which should only include \ +alphanumerical characters with no space or upper case letters. ")) + def on_user_pass1_entry_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Choose a password or passphrase to be coupled with your login \ +name. Your password or passprase should include a mix of upper \ +and lower case letters, numbers, and even symbols (such as the \ +@, !, and &)")) + def on_user_pass2_entry_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Here you must retype your password as a confirmation \ +of your choice.")) + def on_user_visible_checkbutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Check this box if you want to be able to see the password you \ +are typing.")) + def on_users_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Create new user.")) + def on_users_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel new user creation.")) + def on_root_pass1_entry_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("On Linux systems, the superuser, or root, is a special user account\ +used for system administration. Here you must set its password or\ +passphrase. Remember, this password or passphrase should include \ +a mix of upper and lower case letters, numbers, and even symbols \ +(such as the @, !, and &)")) + def on_root_pass2_entry_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Here you must retype the superuser (root) password as a \ +confirmation of your choice.")) + def on_root_visible_checkbutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Check this box if you want to be able to see the password you \ +are typing.")) + def on_rootpass_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Apply new root password.")) + def on_rootpass_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel new root password.")) + + # Packages contextual help + def on_packages_tab_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Access the packages selection.")) + def on_core_radiobutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_markup(_("Core installation:\n\ +Only the minimum essentials for a console system to start are \ +included. A graphical environment is not provided. This is ideal \ +if you are an experienced user and want to customize your \ +installation for any specific purpose, such as a web server, \ +file server etc. ")) + def on_basic_radiobutton_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_markup(_("Basic installation:\n\ +This installs only a basic desktop environment, with very few extra applications \ +installed on top, such as a web browser and the gslapt package manager. Ideal \ +for advanced users that would like to install a lightweight system and \ +add their own choice of applications. ")) + def on_full_radiobutton_enter_notify_event(self, widget, data=None): + if liveclone_install == False : + self.ContextLabel.set_markup(_('Full installation:\n\ +Everything that is included in the iso is installed. That includes a complete \ +desktop environment and a complete selection of matching applications, \ +always following the "one application per task" rationale. ')) + elif liveclone_install == True : + self.ContextLabel.set_markup(_("Full installation:\n\ +Salix Live Installer has detected a LiveClone customized environment. \ +Core and Basic installation modes are therefore not available. \n\ +You can only perform a full installation: all software \ +included in your customized LiveClone will be installed.")) + def on_packages_apply_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Confirm your packages selection.")) + def on_packages_undo_enter_notify_event(self, widget, data=None): + self.ContextLabel.set_text(_("Cancel all packages selection.")) + + # What to do when Salix Installer logo is clicked + def on_about_link_clicked(self, widget, data=None): + self.AboutDialog.show() + + # What to do when the about dialog quit button is clicked + def on_about_dialog_close(self, widget, data=None): + self.AboutDialog.hide() + return True + + # What to do when the exit X on the main window upper right is clicked + def gtk_main_quit(self, widget, data=None): + self.on_button_quit_clicked(widget, data) + + # What to do when the Salix Installer quit button is clicked + def on_button_quit_clicked(self, widget, data=None): + gtk.main_quit() + + ### CURRENT CONFIG ### + def get_current_config(self): + self.cur_tz = sltl.getDefaultTimeZone() + if '/' in self.cur_tz: + self.cur_tz_continent = self.cur_tz.split('/', 1)[0] + self.cur_tz_city = self.cur_tz.split('/', 1)[1] + else: + self.cur_tz = None + self.cur_tz_continent = None + self.cur_tz_city = None + self.cur_use_ntp = sltl.isNTPEnabledByDefault() + # TODO rest of config + + def update_install_button(self): + self.InstallButton.set_sensitive(not (self.isTest or False in self.configurations.values())) + + ### CONFIGURATION TABS ### + + def hide_all_tabs(self): + self.IntroBox.hide() + self.TimeBox.hide() + self.KeyboardBox.hide() + self.LocaleBox.hide() + self.PartitioningBox.hide() + self.MainPartitionBox.hide() + self.RecapPartitionBox.hide() + self.UsersBox.hide() + self.PackagesBox.hide() + self.TimeTab.set_relief(gtk.RELIEF_NONE) + self.KeyboardTab.set_relief(gtk.RELIEF_NONE) + self.LocaleTab.set_relief(gtk.RELIEF_NONE) + self.PartitionTab.set_relief(gtk.RELIEF_NONE) + self.UsersTab.set_relief(gtk.RELIEF_NONE) + self.PackagesTab.set_relief(gtk.RELIEF_NONE) + + # What to do when the time tab is clicked + def on_time_tab_clicked(self, widget, data=None): + if not self.switch_tab_lock: + self.hide_all_tabs() + self.time_settings() + self.TimeTab.set_relief(gtk.RELIEF_HALF) + self.TimeBox.show() + + # What to do when the keyboard tab is clicked + def on_keyboard_tab_clicked(self, widget, data=None): + if not self.switch_tab_lock: + self.hide_all_tabs() + self.keyboard_settings() + self.KeyboardTab.set_relief(gtk.RELIEF_HALF) + self.KeyboardBox.show() + + # What to do when the language tab is clicked + def on_locale_tab_clicked(self, widget, data=None): + if not self.switch_tab_lock: + self.hide_all_tabs() + self.locale_settings() + self.LocaleTab.set_relief(gtk.RELIEF_HALF) + self.LocaleBox.show() + + # What to do when the partitions tab is clicked + def on_partition_tab_clicked(self, widget, data=None): + if not self.switch_tab_lock: + self.hide_all_tabs() + self.partitions_settings() + self.PartitionTab.set_relief(gtk.RELIEF_HALF) + if self.partition_done: + self.RecapPartitionBox.show() + else: + self.PartitioningBox.show() + + # What to do when the users tab is clicked + def on_users_tab_clicked(self, widget, data=None): + if not self.switch_tab_lock: + self.hide_all_tabs() + self.users_settings() + self.UsersTab.set_relief(gtk.RELIEF_HALF) + self.UsersBox.show() + + # What to do when the packages tab is clicked + def on_packages_tab_clicked(self, widget, data=None): + if not self.switch_tab_lock: + self.hide_all_tabs() + self.packages_settings() + self.PackagesTab.set_relief(gtk.RELIEF_HALF) + self.PackagesBox.show() + + def time_settings(self): + self.ContinentZoneListStore.clear() + self.ContinentZoneListStore.append([_("Select...")]) + self.ContinentZoneCombobox.set_active(0) + continents = sltl.listTZContinents() + index = 1 + for continent in continents: + self.ContinentZoneListStore.append([continent]) + if continent == self.cur_tz_continent: + self.ContinentZoneCombobox.set_active(index) + index += 1 + self.time_set_cities_list() + self.NTPCheckButton.set_active(self.cur_use_ntp) + self.ManualTimeBox.set_sensitive(not self.cur_use_ntp) + year, month, day, hour, minute, second, __, __, __ = datetime.now().timetuple() + self.YearListStore.clear() + self.MonthListStore.clear() + self.DayListStore.clear() + index = 0 + for y in range(2000, 2051): + self.YearListStore.append([y]) + if year == y: + self.YearCombobox.set_active(index) + index += 1 + index = 0 + for m in [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), + _('July'), _('August'), _('September'), _('October'), _('November'), _('December')]: + self.MonthListStore.append([m]) + if month == index + 1: + self.MonthCombobox.set_active(index) + index += 1 + index = 0 + for d in range(1, 32): + self.DayListStore.append([d]) + if day == index + 1: + self.DayCombobox.set_active(index) + index += 1 + self.HourSpinButton.set_value(hour) + self.MinuteSpinButton.set_value(minute) + self.SecondSpinButton.set_value(second) + def time_set_cities_list(self): + self.CountryZoneListStore.clear() + self.CountryZoneListStore.append([_("Select...")]) + self.CountryZoneCombobox.set_active(0) + if self.cur_tz_continent: + cities = sltl.listTZCities(self.cur_tz_continent) + if cities: + index = 1 + for city in cities: + self.CountryZoneListStore.append([city]) + if city == self.cur_tz_city: + self.CountryZoneCombobox.set_active(index) + index += 1 + def on_continent_zone_combobox_changed(self, widget, data=None): + if self.ContinentZoneCombobox.get_active() > 0: + continent = self.ContinentZoneCombobox.get_active_text() + if continent != self.cur_tz_continent: + self.cur_tz_continent = continent + self.cur_tz_city = None + self.time_set_cities_list() + def on_country_zone_combobox_changed(self, widget, data=None): + if self.CountryZoneCombobox.get_active() > 0: + self.cur_tz_city = self.CountryZoneCombobox.get_active_text() + self.cur_tz = self.cur_tz_continent + '/' + self.cur_tz_city + def on_ntp_checkbutton_toggled(self, widget, data=None): + self.cur_use_ntp = self.NTPCheckButton.get_active() + self.ManualTimeBox.set_sensitive(not self.cur_use_ntp) + def on_time_undo_clicked(self, widget, data=None): + self.TimeCheck.hide() + self.TimeCheckMarker.show() + self.ManualTimeBox.set_sensitive(True) + self.NTPCheckButton.set_sensitive(True) + self.TimeZoneBox.set_sensitive(True) + self.TimeApplyButton.set_sensitive(True) + self.time_settings() + self.configurations['time'] = False + self.update_install_button() + def on_time_apply_clicked(self, widget, data=None): + self.ManualTimeBox.set_sensitive(False) + self.NTPCheckButton.set_sensitive(False) + self.TimeZoneBox.set_sensitive(False) + self.TimeApplyButton.set_sensitive(False) + self.configurations['time'] = True + self.update_install_button() + self.TimeCheck.show() + self.TimeCheckMarker.hide() + + def keyboard_settings(self): + pass + + def locale_settings(self): + pass + + def partitions_settings(self): + pass + + def users_settings(self): + pass + + def packages_settings(self): + pass + + + + ################################################################### + # LISTS ROWS ### + + # What to do when a keymap list row is added + def on_keymap_list_store_row_inserted(self, widget, value, treeiter): + # Check if it is the path of the used keymap to set the cursor on it + if keyb_item == UsedKeyMap: + global UsedKeybRow + UsedKeybRow = value + + # What to do when a locale list row is added + def on_locale_list_store_row_inserted(self, widget, value, treeiter): + # Check if it is the path of the used locale to set the cursor on it + if UsedLocale in locale_set: + global UsedLocaleRow + UsedLocaleRow = value + + ### CHECKBUTTONS ### + + # What to do when the liveclone login checkbutton is toggled + def on_clone_login_checkbutton_toggled(self, widget, data=None): + if self.CloneLoginCheckbutton.get_active() == True: + users_undo(self) + rootpass_undo(self) + self.UsersEventbox.set_sensitive(False) + self.CloneLoginUndo.set_sensitive(True) + self.CloneLoginApply.set_sensitive(True) + else: + self.UsersEventbox.set_sensitive(True) + self.CloneLoginUndo.set_sensitive(False) + self.CloneLoginApply.set_sensitive(False) + + # What to do when the NTP checkbutton is toggled + + # What to do when the numlock checkbutton is toggled + def on_numlock_checkbutton_toggled(self, widget, data=None): + global set_numlock + if self.NumLockCheckButton.get_active() == True : + set_numlock = 'on' + else : + set_numlock = 'off' + + # SaLT changes # + # What to do when the iBus checkbutton is toggled + def on_ibus_checkbutton_toggled(self, widget, data=None): + global set_ibus + if self.IBusCheckButton.get_active() == True : + set_ibus = 'on' + else : + set_ibus = 'off' + + # What to do when the user's password visible checkbutton is toggled + def on_user_visible_checkbutton_toggled(self, widget, data=None): + if self.UserVisibleCheckButton.get_active() == True : + self.UserPass1Entry.set_visibility(True) + self.UserPass2Entry.set_visibility(True) + if self.UserVisibleCheckButton.get_active() == False : + self.UserPass1Entry.set_visibility(False) + self.UserPass2Entry.set_visibility(False) + + # What to do when the root's password visible checkbutton is toggled + def on_root_visible_checkbutton_toggled(self, widget, data=None): + if self.RootVisibleCheckButton.get_active() == True : + self.RootPass1Entry.set_visibility(True) + self.RootPass2Entry.set_visibility(True) + if self.RootVisibleCheckButton.get_active() == False : + self.RootPass1Entry.set_visibility(False) + self.RootPass2Entry.set_visibility(False) + + # What to do when the external device checkbutton is toggled + def on_external_device_checkbutton_toggled (self, widget, data=None): + global show_external_device + if self.ExternalDeviceCheckButton.get_active() == True : + show_external_device = 'yes' + else : + show_external_device = 'no' + partition_list_initialization () + + ### COMBOBOX LINES ### + + # What to do when a combo line is edited in the Linux New system column + def on_linux_newsys_renderer_combo_edited(self, widget, row_number, new_text): + # Retrieve the selected Linux partition row iter + linuxnewsyschoice = self.LinuxPartitionList.get_selection() + self.LinuxPartitionListStore, iter = linuxnewsyschoice.get_selected() + # Set the new partition row value on the fifth column (4) + if new_text in ('ext2', 'ext3', 'ext4', 'reiserfs', 'xfs', 'jfs', 'Select...' ): + self.LinuxPartitionListStore.set_value(iter, 4, new_text) + if new_text != _("Select..."): + self.LinuxPartitionListStore.set_value(iter, 6, 'gtk-yes') + else: + self.LinuxPartitionListStore.set_value(iter, 6, 'gtk-edit') + self.LinuxPartitionApply.set_sensitive(True) + + def on_linux_newsys_renderer_combo_editing_started(self, widget, path, data): + self.LinuxPartitionApply.set_sensitive(False) + + def on_linux_newsys_renderer_combo_editing_canceled(self, data): + self.LinuxPartitionApply.set_sensitive(True) + + # What to do when a combo line is edited in the Linux mountpoint column + def on_linux_newmount_renderer_combo_edited(self, widget, row_number, new_text): + # Retrieve the selected Linux partition row iter + linuxnewmountchoice = self.LinuxPartitionList.get_selection() + self.LinuxPartitionListStore, iter = linuxnewmountchoice.get_selected() + # Set the new partition row value on the sixth column (5) + self.LinuxPartitionListStore.set_value(iter, 5, new_text) + if new_text != _("Select..."): + self.LinuxPartitionListStore.set_value(iter, 7, 'gtk-yes') + else: + self.LinuxPartitionListStore.set_value(iter, 7, 'gtk-edit') + self.LinuxPartitionApply.set_sensitive(True) + + def on_linux_newmount_renderer_combo_editing_started(self, widget, path, data): + self.LinuxPartitionApply.set_sensitive(False) + + def on_linux_newmount_renderer_combo_editing_canceled(self, data): + self.LinuxPartitionApply.set_sensitive(True) + + # What to do when a combo line is edited in the Windows mountpoint column + def on_win_newmount_renderer_combo_edited(self, widget, row_number, new_text,): + # Retrieve the selected Windows partition row iter + windowsnewmountchoice = self.WindowsPartitionList.get_selection() + self.WindowsPartitionListStore, iter = windowsnewmountchoice.get_selected() + # Set the new mountpoint row value on the fifth column (4) + self.WindowsPartitionListStore.set_value(iter, 4, new_text) + if new_text != _("Select..."): + self.WindowsPartitionListStore.set_value(iter, 5, 'gtk-yes') + else: + self.WindowsPartitionListStore.set_value(iter, 5, 'gtk-edit') + self.WindowsPartitionApply.set_sensitive(True) + + def on_win_newmount_renderer_combo_editing_started(self, widget, path, data): + self.WindowsPartitionApply.set_sensitive(False) + + def on_win_newmount_renderer_combo_editing_canceled(self, data): + self.WindowsPartitionApply.set_sensitive(True) + + # CONFIGURATION APPLY BUTTONS ### + + # What to do when the time selection button is clicked + + # What to do when the keyboard selection button is clicked + def on_keyboard_apply_clicked(self, widget, data=None): + pass + + # What to do when the language selection button is clicked + def on_locale_apply_clicked(self, widget, data=None): + pass + + # What to do when the main partition selection button is clicked + def on_main_partition_apply_clicked(self, widget, data=None): + pass + + # What to do when the Linux partition Apply settings button is clicked + def on_linux_partition_apply_clicked(self, widget, data=None): + pass + + # What to do when the Windows partition Apply settings button is clicked + def on_windows_partition_apply_clicked(self, widget, data=None): + pass + + # What to do when the clone login apply button is clicked + def on_clone_login_apply_clicked(self, widget, data=None): + pass + + # What to do when the user's settings apply button is clicked + def on_users_apply_clicked(self, widget, data=None): + pass + + # What to do when the root password settings apply button is clicked + def on_rootpass_apply_clicked(self, widget, data=None): + pass + + # What to do when the package selection apply button is clicked + def on_packages_apply_clicked(self, widget, data=None): + pass + + # What to do when the Install Salix button is clicked + def on_install_button_clicked(self, widget, data=None): + pass + + ### CONFIGURATION UNDO BUTTONS ### + + # What to do when the time undo button is clicked + + # What to do when the keyboard undo button is clicked + def on_keyboard_undo_clicked(self, widget, data=None): + pass + + # What to do when the language undo button is clicked + def on_locale_undo_clicked(self, widget, data=None): + pass + + # What to do when the 'Do modify partition' button is clicked + def on_modify_partition_button_clicked(self, widget, data=None): + pass + + # What to do when the 'Do not modify partition' button is clicked + def on_do_not_modify_partition_button_clicked(self, widget, data=None): + pass + + # What to do when the partition recap undo button is clicked + def on_partition_recap_undo_clicked(self, widget, data=None): + pass + + # What to do when the clone login undo button is clicked + def on_clone_login_undo_clicked(self, widget, data=None): + pass + + # What to do when the user's settings undo button is clicked + def on_users_undo_clicked(self, widget, data=None): + pass + + # What to do when the root password settings undo button is clicked + def on_rootpass_undo_clicked(self, widget, data=None): + pass + + # What to do when the package selection undo button is clicked + def on_packages_undo_clicked(self, widget, data=None): + pass + + ### YESNO CONFIRMATION NEEDED DIALOG ### + + # What to do when the yes button of the YesNo Confirmation Needed dialog is clicked + def on_confirm_button_clicked(self, widget, data=None): + pass + + # What to do when the yes button of the YesNo Confirmation Needed dialog is 'released' + def on_confirm_button_released(self, widget, data=None): + pass + + # What to do when the no button of the YesNo dialog is clicked + def on_do_not_confirm_button_clicked(self, widget, data=None): + pass + + +# Info window skeleton: +def info_dialog(message, parent = None): + """ + Display an information message. + + """ + dialog = gtk.MessageDialog(parent = parent, type = gtk.MESSAGE_INFO, buttons = gtk.BUTTONS_OK, flags = gtk.DIALOG_MODAL) + dialog.set_markup(message) + global result_info + result_info = dialog.run() + dialog.destroy() + +# Error window skeleton: +def error_dialog(message, parent = None): + """ + Displays an error message. + """ + dialog = gtk.MessageDialog(parent = parent, type = gtk.MESSAGE_ERROR, buttons = gtk.BUTTONS_CLOSE, flags = gtk.DIALOG_MODAL) + dialog.set_markup(message) + global result_error + result_error = dialog.run() + dialog.destroy() + +# Launch the application +if __name__ == '__main__': + # If no root privilege, displays error message & exit + isTest = (len(sys.argv) > 1 and sys.argv[1] == '--test') + if isTest: + gettext.install(APP, './locale', True) + gtk.glade.bindtextdomain(APP, './locale') + else: + gettext.install(APP, '/usr/share/locale', True) + gtk.glade.bindtextdomain(APP, '/usr/share/locale') + gtk.glade.textdomain(APP) + + if not isTest and os.getuid() != 0: + error_dialog(_("Sorry! \n\nRoot privileges are required to run this program. ")) + sys.exit(1) + # show the gui and wait for signals + SalixLiveInstaller(isTest) + gtk.main() diff --git a/src/salix-live-installer/__init__.py b/src/salix_livetools_library/__init__.py similarity index 100% rename from src/salix-live-installer/__init__.py rename to src/salix_livetools_library/__init__.py diff --git a/src/salix-live-installer/assertPlus.py b/src/salix_livetools_library/assertPlus.py similarity index 100% rename from src/salix-live-installer/assertPlus.py rename to src/salix_livetools_library/assertPlus.py diff --git a/src/salix-live-installer/bootloader.py b/src/salix_livetools_library/bootloader.py similarity index 100% rename from src/salix-live-installer/bootloader.py rename to src/salix_livetools_library/bootloader.py diff --git a/src/salix-live-installer/chroot.py b/src/salix_livetools_library/chroot.py similarity index 100% rename from src/salix-live-installer/chroot.py rename to src/salix_livetools_library/chroot.py diff --git a/src/salix-live-installer/disk.py b/src/salix_livetools_library/disk.py similarity index 100% rename from src/salix-live-installer/disk.py rename to src/salix_livetools_library/disk.py diff --git a/src/salix-live-installer/execute.py b/src/salix_livetools_library/execute.py similarity index 100% rename from src/salix-live-installer/execute.py rename to src/salix_livetools_library/execute.py diff --git a/src/salix-live-installer/freesize.py b/src/salix_livetools_library/freesize.py similarity index 100% rename from src/salix-live-installer/freesize.py rename to src/salix_livetools_library/freesize.py diff --git a/src/salix-live-installer/fs.py b/src/salix_livetools_library/fs.py similarity index 100% rename from src/salix-live-installer/fs.py rename to src/salix_livetools_library/fs.py diff --git a/src/salix-live-installer/fstab.py b/src/salix_livetools_library/fstab.py similarity index 100% rename from src/salix-live-installer/fstab.py rename to src/salix_livetools_library/fstab.py diff --git a/src/salix-live-installer/kernel.py b/src/salix_livetools_library/kernel.py similarity index 100% rename from src/salix-live-installer/kernel.py rename to src/salix_livetools_library/kernel.py diff --git a/src/salix-live-installer/keyboard.py b/src/salix_livetools_library/keyboard.py similarity index 100% rename from src/salix-live-installer/keyboard.py rename to src/salix_livetools_library/keyboard.py diff --git a/src/salix-live-installer/language.py b/src/salix_livetools_library/language.py similarity index 100% rename from src/salix-live-installer/language.py rename to src/salix_livetools_library/language.py diff --git a/src/salix-live-installer/mounting.py b/src/salix_livetools_library/mounting.py similarity index 100% rename from src/salix-live-installer/mounting.py rename to src/salix_livetools_library/mounting.py diff --git a/src/salix-live-installer/salt.py b/src/salix_livetools_library/salt.py similarity index 100% rename from src/salix-live-installer/salt.py rename to src/salix_livetools_library/salt.py diff --git a/src/salix-live-installer/timezone.py b/src/salix_livetools_library/timezone.py similarity index 77% rename from src/salix-live-installer/timezone.py rename to src/salix_livetools_library/timezone.py index 19ccbe6..d7b6e33 100644 --- a/src/salix-live-installer/timezone.py +++ b/src/salix_livetools_library/timezone.py @@ -8,6 +8,8 @@ - listTZCities - getDefaultTimeZone - setDefaultTimeZone + - isNTPEnabledByDefault + - setNTPDefault """ import os import glob @@ -81,6 +83,31 @@ def setDefaultTimeZone(timezone, mountPoint = None): else: raise Exception('This timezone ({0}) is incorrect.'.format(timezone)) +def isNTPEnabledByDefault(mountPoint = None): + """ + Returns True if the NTP service is enabled by default. + For this, the execute bit of /etc/rc.d/rc.ntpd is checked. + """ + if mountPoint and not os.path.isdir(mountPoint): + raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) + if mountPoint == None: + mountPoint = '' + return os.access('{0}/etc/rc.d/rc.ntpd'.format(mountPoint), os.X_OK) + +def setNTPDefault(enabled, mountPoint = None): + """ + Fix the configuration for default NTP service activated on boot or not. + """ + checkRoot() + if mountPoint and not os.path.isdir(mountPoint): + raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) + if mountPoint == None: + mountPoint = '/' + if enabled: + os.chmod('{0}/etc/rc.d/rc.ntpd'.format(mountPoint), 0755) + else: + os.chmod('{0}/etc/rc.d/rc.ntpd'.format(mountPoint), 0644) + # Unit test if __name__ == '__main__': from assertPlus import * @@ -107,3 +134,10 @@ def setDefaultTimeZone(timezone, mountPoint = None): assertEquals(2, len(tz.split('/'))) assertEquals('Etc/Zulu', tz) setDefaultTimeZone(deftz) + ntp = isNTPEnabledByDefault() + assertTrue(type(ntp) == bool) + setNTPDefault(True) + assertTrue(isNTPEnabledByDefault()) + setNTPDefault(False) + assertFalse(isNTPEnabledByDefault()) + setNTPDefault(ntp) diff --git a/src/salix-live-installer/user.py b/src/salix_livetools_library/user.py similarity index 100% rename from src/salix-live-installer/user.py rename to src/salix_livetools_library/user.py diff --git a/src/test.sh b/src/test.sh new file mode 100755 index 0000000..ae5311f --- /dev/null +++ b/src/test.sh @@ -0,0 +1,11 @@ +#!/bin/sh +cd $(dirname "$0") +for p in ../po/*.po; do + d=$(basename $p .po) + if [ ! -d locale/$d ]; then + mkdir -p locale/$d/LC_MESSAGES + echo "$p..." + msgfmt $p -o locale/$d/LC_MESSAGES/salix-live-installer.mo + fi +done +./salix-live-installer.py --test