summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2011-05-07 23:19:17 +0200
committerDieter Plaetinck <dieter@plaetinck.be>2011-05-07 23:40:00 +0200
commit3c9483c433ec200a8cb35cb978ae4d9e9c994f3c (patch)
treeeb42bfd81d97cef09c900a53a436f5ad5413b268
parentcfeaf0e3b7d8c2b75cf66361e330906f4fed5f7d (diff)
bugfix: deal correctly with /etc/localtime. Fixes FS#24119
* always execute copy_timezone_file (), whether the user changed the timezone or not, and no matter which procedure we're running. (specifically automatic procedure!) if $TIMEZONE is set, it will create /etc/localtime appropriately on the live system * make target_localtime () - executed through postconfigure_target () - compatible with the case where no /etc/localtime file exists.
-rw-r--r--src/core/libs/lib-misc.sh8
-rw-r--r--src/core/libs/lib-ui-interactive.sh23
-rw-r--r--src/core/procedures/automatic4
-rw-r--r--src/core/procedures/base4
4 files changed, 29 insertions, 10 deletions
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index 2dee841..f9fd06a 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -165,6 +165,14 @@ target_configure_time () {
${var_TARGET_DIR}/etc/rc.conf
}
+target_localtime () {
+ if [ -f /etc/localtime ]
+ then
+ cp /etc/localtime ${var_TARGET_DIR}/etc/localtime || return 1
+ fi
+ return 0
+}
+
# apped string after last line matching regex in a file.
# $1 regex
# $2 string (can contain "\n", "\t" etc)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 1600cef..05dd234 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -44,7 +44,7 @@ postconfigure_target () {
local failed=()
target_run_mkinitcpio || failed+=('mkinitcpio creation')
target_locale-gen || failed+=('locale generation')
- cp /etc/localtime ${var_TARGET_DIR}/etc/localtime || failed+=('localtime copying')
+ target_localtime || failed+=('localtime copying')
[ ${#failed[@]} -gt 0 ] && warn_failed 'Postconfigure' "${failed[@]}" && return 1
return 0
}
@@ -122,14 +122,23 @@ interactive_configure_system()
interactive_timezone () {
ask_timezone || return 1
TIMEZONE=$ANSWER_TIMEZONE
- inform "Setting Timezone to $TIMEZONE"
- if [ -n "$TIMEZONE" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]
+ return 0
+}
+
+# this should be executed, whether the user changed $TIMEZONE or not
+copy_timezone_file () {
+ if [ -z "$TIMEZONE" ]
then
- # This changes probably also the systemtime (UTC->$TIMEZONE)!
- # localtime users will have a false time after that!
- /bin/rm -f /etc/localtime || return 1
- /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime || return 1
+ debug UI-INTERACTIVE "\$TIMEZONE is empty, not creating/updating /etc/localtime"
+ return 0
fi
+ debug UI-INTERACTIVE "Setting Timezone to $TIMEZONE"
+ local file="/usr/share/zoneinfo/$TIMEZONE"
+ [ -e "$file" ] || die_error "No such timezone file: $file, did you choose a non-existing timezone?"
+ # This changes probably also the systemtime (UTC->$TIMEZONE)!
+ # localtime users will have a false time after that!
+ /bin/rm -f /etc/localtime || return 1
+ /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime || return 1
return 0
}
diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic
index 407a35b..ce773e1 100644
--- a/src/core/procedures/automatic
+++ b/src/core/procedures/automatic
@@ -102,8 +102,8 @@ worker_install_packages ()
worker_set_clock ()
{
- #TODO implement this
- true
+ # uses $TIMEZONE, clock itself remains untouched.
+ copy_timezone_file
}
diff --git a/src/core/procedures/base b/src/core/procedures/base
index 4e41c81..dba70d1 100644
--- a/src/core/procedures/base
+++ b/src/core/procedures/base
@@ -105,13 +105,14 @@ worker_runtime_packages ()
worker_set_clock ()
{
local default=no
+ local timezone_file_copied=0
while true; do
ask_option $default "Date/time configuration" '' required \
"1" "Select region and timezone" \
"2" "Set time and date" \
"3" "Return to Main Menu" || return 1
case $ANSWER_OPTION in
- "1") execute worker interactive_timezone && default=2 || return 1 ;;
+ "1") execute worker interactive_timezone && copy_timezone_file && timezone_file_copied=1 && default=2 || return 1 ;;
"2") if check_depend worker interactive_timezone
then
execute worker interactive_time && default=3 || return 1
@@ -119,6 +120,7 @@ worker_set_clock ()
"3") break ;;
esac
done
+ [ $timezone_file_copied -eq 1 ] || copy_timezone_file || return 1
return 0
}