Ultima: fix the activate_date script
fix the wrong char on scripts.
BUG=chrome-os-partner:44053
TEST=confirm FUD write to battery after time sync
Signed-off-by: Keith Tzeng <Keith.Tzeng@quantatw.com>
Change-Id: I8a3fa4ba659032a3debfc51655a5adda237f4ca8
Reviewed-on: https://chromium-review.googlesource.com/321181
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
(cherry picked from commit 8d0984a14e18ee2b870c44e06d9a5f756f752ede)
Reviewed-on: https://chromium-review.googlesource.com/321509
Commit-Queue: Keith Tzeng <keith.tzeng@quantatw.com>
diff --git a/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/chromeos-activate-date-ultima-0.0.1-r1.ebuild b/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/chromeos-activate-date-ultima-0.0.1-r2.ebuild
similarity index 100%
rename from overlay-ultima/chromeos-base/chromeos-activate-date-ultima/chromeos-activate-date-ultima-0.0.1-r1.ebuild
rename to overlay-ultima/chromeos-base/chromeos-activate-date-ultima/chromeos-activate-date-ultima-0.0.1-r2.ebuild
diff --git a/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date b/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date
index 9240ee6..401ea20 100755
--- a/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date
+++ b/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyrightght 2016 The Chromium OS Authors. All rights reserved.
+# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
@@ -38,7 +38,7 @@
clean_activate_date() {
echo "Clean Activate Date."
${VPD} -i "${PARTITION}" -d "${FIELD_NAME}" ||
- echo "Can't delete ${FIELD_NAME}, it may not exist in ${PARTITION}."
+ echo "Can't delete ${FIELD_NAME}, it may not exist in ${PARTITION}."
}
main() {
@@ -47,7 +47,7 @@
else
CLEAN=0
fi
-
+
# Get the current value in VPD. The output format is followed:
#
# "ActivateDate"="2011-33"
diff --git a/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date.conf b/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date.conf
index 7d8c60a..8d9273e 100644
--- a/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date.conf
+++ b/overlay-ultima/chromeos-base/chromeos-activate-date-ultima/files/activate_date.conf
@@ -1,84 +1,84 @@
-# Copyright 2016 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description "Update the Activation Date"
-author "chromium-os-dev@chromium.org"
-
-start on started system-services
-stop on stopping system-services
-
-# This sets the activation date to the RW_VPD of a device. Here we wait
-# for a proper time sync to have taken place before setting the value
-# to ensure that the time is correct.
-
-script
- FIELD_NAME="ActivateDate"
- OOBE_COMPLETED_FILE="/home/chronos/.oobe_completed"
- PARTITION="RW_VPD"
- # TIMEFILE is updated by tlsdated whenever a time remote sync occurs.
- TIMEFILE="/var/cache/tlsdated/timestamp"
-
- check_timestamp() {
- stat -c %Y "${TIMEFILE}" || :
- }
-
- # Get initial timestamp of TIMEFILE - we don't care about the contents
- # of this file, only its timestamp. We will check the timestamp later
- # to see if a remote time sync occurred. There is a race condition here,
- # tlsdated only updates the time every 24 hours by default, so if we
- # don't get the timefile timestamp before tlsdated updates the time on
- # boot we will end up waiting 24 hours. This upstart should almost
- # always win the race as tlsdated depends on having a valid network
- # connection up.
- # TODO(bhthompson): find a way to avoid the race.
- TIMESTAMP=$(check_timestamp)
-
- # Never run from a factory image.
- if [ -f /root/.factory_test -o -f /root/.factory_installer ] ; then
- exit 0
- fi
-
- # Wait for OOBE to have completed.
- while [ ! -f "${OOBE_COMPLETED_FILE}" ]; do
- sleep 60
- done
-
- # Wait for remote sync of clock, then write activation date.
- while true; do
- sleep 200
- # Only a non-empty TIMEFILE guarantees that a time sync has happened.
- if [ "${TIMESTAMP}" != "$(check_timestamp)" -a -s "${TIMEFILE}" ] ; then
- # Get system date with proper format for FUD.
- year=$(expr \( $(date +%Y) \- 1980 \) \* 512)
- month=$(expr $(date +%m) \* 32)
- fuddata=$(expr $year \+ $month \+ $(date +%d))
- # Write FUD to battery. We could call it every time.
- # EC firmware would only write once to battery if the FUD is cleared.
- # The call will already return failed, but write would be succeed.
- if ! ectool batteryparam set 0 $fuddata 2>&1; then
- logger -t "$UPSTART_JOB" "Battery FUD already set."
- fi
-
- # Don't run if we have set the date already, we use dump_vpd_log so that
- # we can leverage the cached VPD file.
- # This is a soft check, the activate_date script will also check the vpd
- # directly to see if a date has been set.
- #
- ACTIVATE_DATE=$(dump_vpd_log --stdout | grep ${FIELD_NAME} | cut -d '"' -f 4)
- if [ -n "${ACTIVATE_DATE}" ]; then
- exit 0
- fi
- if ! activate_date 2>&1; then
- logger -t "$UPSTART_JOB" "activate_date failed."
- exit 0
- fi
- if ! dump_vpd_log --force 2>&1; then
- logger -t "$UPSTART_JOB" "dump_vpd_log failed."
- exit 0
- fi
- logger -t "$UPSTART_JOB" "Activation date set."
- exit 0
- fi
- done
-end script
+# Copyright 2016 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description "Update the Activation Date"
+author "chromium-os-dev@chromium.org"
+
+start on started system-services
+stop on stopping system-services
+
+# This sets the activation date to the RW_VPD of a device. Here we wait
+# for a proper time sync to have taken place before setting the value
+# to ensure that the time is correct.
+
+script
+ FIELD_NAME="ActivateDate"
+ OOBE_COMPLETED_FILE="/home/chronos/.oobe_completed"
+ PARTITION="RW_VPD"
+ # TIMEFILE is updated by tlsdated whenever a time remote sync occurs.
+ TIMEFILE="/var/cache/tlsdated/timestamp"
+
+ check_timestamp() {
+ stat -c %Y "${TIMEFILE}" || :
+ }
+
+ # Get initial timestamp of TIMEFILE - we don't care about the contents
+ # of this file, only its timestamp. We will check the timestamp later
+ # to see if a remote time sync occurred. There is a race condition here,
+ # tlsdated only updates the time every 24 hours by default, so if we
+ # don't get the timefile timestamp before tlsdated updates the time on
+ # boot we will end up waiting 24 hours. This upstart should almost
+ # always win the race as tlsdated depends on having a valid network
+ # connection up.
+ # TODO(bhthompson): find a way to avoid the race.
+ TIMESTAMP=$(check_timestamp)
+
+ # Never run from a factory image.
+ if [ -f /root/.factory_test -o -f /root/.factory_installer ] ; then
+ exit 0
+ fi
+
+ # Wait for OOBE to have completed.
+ while [ ! -f "${OOBE_COMPLETED_FILE}" ]; do
+ sleep 60
+ done
+
+ # Wait for remote sync of clock, then write activation date.
+ while true; do
+ sleep 200
+ # Only a non-empty TIMEFILE guarantees that a time sync has happened.
+ if [ "${TIMESTAMP}" != "$(check_timestamp)" -a -s "${TIMEFILE}" ] ; then
+ # Get system date with proper format for FUD.
+ year=$(expr \( $(date +%Y) \- 1980 \) \* 512)
+ month=$(expr $(date +%m) \* 32)
+ fuddata=$(expr $year \+ $month \+ $(date +%d))
+ # Write FUD to battery. We could call it every time.
+ # EC firmware would only write once to battery if the FUD is cleared.
+ # The call will always return failed, but write would be succeed.
+ if ! ectool batteryparam set 0 $fuddata 2>&1; then
+ logger -t "$UPSTART_JOB" "Battery FUD already set."
+ fi
+
+ # Don't run if we have set the date already, we use dump_vpd_log so that
+ # we can leverage the cached VPD file.
+ # This is a soft check, the activate_date script will also check the vpd
+ # directly to see if a date has been set.
+ #
+ ACTIVATE_DATE=$(dump_vpd_log --stdout | grep ${FIELD_NAME} | cut -d '"' -f 4)
+ if [ -n "${ACTIVATE_DATE}" ]; then
+ exit 0
+ fi
+ if ! activate_date 2>&1; then
+ logger -t "$UPSTART_JOB" "activate_date failed."
+ exit 0
+ fi
+ if ! dump_vpd_log --force 2>&1; then
+ logger -t "$UPSTART_JOB" "dump_vpd_log failed."
+ exit 0
+ fi
+ logger -t "$UPSTART_JOB" "Activation date set."
+ exit 0
+ fi
+ done
+end script
diff --git a/overlay-ultima/virtual/chromeos-activate-date/chromeos-activate-date-2-r1.ebuild b/overlay-ultima/virtual/chromeos-activate-date/chromeos-activate-date-2-r2.ebuild
similarity index 100%
rename from overlay-ultima/virtual/chromeos-activate-date/chromeos-activate-date-2-r1.ebuild
rename to overlay-ultima/virtual/chromeos-activate-date/chromeos-activate-date-2-r2.ebuild