| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # | 2 # |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # THIS FILE DEPENDS ON common.sh. | 7 # THIS FILE DEPENDS ON common.sh. |
| 8 | 8 |
| 9 # ---------------------------------------------------------------------------- | 9 # ---------------------------------------------------------------------------- |
| 10 # ChromeOS Specific Utilities | 10 # ChromeOS Specific Utilities |
| 11 | 11 |
| 12 # Compares two files on Chrome OS (there may be no cmp/diff) | 12 # Compares two files on Chrome OS (there may be no cmp/diff) |
| 13 cros_compare_file() { | 13 cros_compare_file() { |
| 14 local hash1="$(md5sum -b "$1" 2>/dev/null | sed 's/ .*//')" | 14 local hash1="$(md5sum -b "$1" 2>/dev/null | sed 's/ .*//')" |
| 15 local hash2="$(md5sum -b "$2" 2>/dev/null | sed 's/ .*//')" | 15 local hash2="$(md5sum -b "$2" 2>/dev/null | sed 's/ .*//')" |
| 16 debug_msg "cros_compare_file($1, $2): $hash1, $hash2)" | 16 debug_msg "cros_compare_file($1, $2): $hash1, $hash2)" |
| 17 [ -n "$hash1" ] && [ "$hash1" = "$hash2" ] | 17 [ -n "$hash1" ] && [ "$hash1" = "$hash2" ] |
| 18 } | 18 } |
| 19 | 19 |
| 20 # Gets a Chrome OS system property (must exist). | 20 # Gets a Chrome OS system property (must exist). |
| 21 cros_get_prop() { | 21 cros_get_prop() { |
| 22 crossystem "$@" || err_die "cannot get crossystem property: $@" | 22 crossystem "$@" || err_die "cannot get crossystem property: $@" |
| 23 } | 23 } |
| 24 | 24 |
| 25 # Sets a Chrome OS system property. | 25 # Sets a Chrome OS system property. |
| 26 cros_set_prop() { | 26 cros_set_prop() { |
| 27 if [ "${FLAGS_dry_run}" = "${FLAGS_TRUE}" ]; then | 27 if [ "${FLAGS_dry_run}" = "${FLAGS_TRUE}" ]; then |
| 28 alert "dry_run: cros_set_prop $@" | 28 alert "dry_run: cros_set_prop $@" |
| 29 return {$FLAGS_TRUE} | 29 return ${FLAGS_TRUE} |
| 30 fi | 30 fi |
| 31 crossystem "$@" || err_die "cannot SET crossystem property: $@" | 31 crossystem "$@" || err_die "cannot SET crossystem property: $@" |
| 32 } | 32 } |
| 33 | 33 |
| 34 # Queries a Chrome OS system property, return error if not available. | 34 # Queries a Chrome OS system property, return error if not available. |
| 35 cros_query_prop() { | 35 cros_query_prop() { |
| 36 crossystem "$@" 2>/dev/null || debug_msg "FAILURE: crossystem $@" | 36 crossystem "$@" 2>/dev/null || debug_msg "FAILURE: crossystem $@" |
| 37 } | 37 } |
| 38 | 38 |
| 39 # Sets the "startup update tries" counter. | 39 # Sets the "startup update tries" counter. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 cat $keyfile1 | sed 's/\xff*$//g; s/\x00*$//g;' >$keyfile1_strip | 100 cat $keyfile1 | sed 's/\xff*$//g; s/\x00*$//g;' >$keyfile1_strip |
| 101 cat $keyfile2 | sed 's/\xff*$//g; s/\x00*$//g;' >$keyfile2_strip | 101 cat $keyfile2 | sed 's/\xff*$//g; s/\x00*$//g;' >$keyfile2_strip |
| 102 cros_compare_file "$keyfile1_strip" "$keyfile2_strip" || ret=$FLAGS_FALSE | 102 cros_compare_file "$keyfile1_strip" "$keyfile2_strip" || ret=$FLAGS_FALSE |
| 103 else | 103 else |
| 104 debug_msg "warning: cannot get rootkey from $1" | 104 debug_msg "warning: cannot get rootkey from $1" |
| 105 ret=$FLAGS_ERROR | 105 ret=$FLAGS_ERROR |
| 106 fi | 106 fi |
| 107 return $ret | 107 return $ret |
| 108 } | 108 } |
| 109 | 109 |
| OLD | NEW |