| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 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 source `dirname "$0"`/memento_updater_logging.sh | 7 source `dirname "$0"`/memento_updater_logging.sh |
| 8 | 8 |
| 9 # Example Omaha ping and response (converted to 80 char width w/ backslashes): | 9 # Example Omaha ping and response (converted to 80 char width w/ backslashes): |
| 10 | 10 |
| 11 # <?xml version="1.0" encoding="UTF-8"?> | 11 # <?xml version="1.0" encoding="UTF-8"?> |
| 12 # <o:gupdate xmlns:o="http://www.google.com/update2/request" \ | 12 # <o:gupdate xmlns:o="http://www.google.com/update2/request" \ |
| 13 # version="Keystone-1.0.5.0" protocol="2.0" \ | 13 # version="Keystone-1.0.5.0" protocol="2.0" \ |
| 14 # machineid="{177255303f3cc519182a103069489327}" ismachine="0" \ | 14 # machineid="{177255303f3cc519182a103069489327}" ismachine="0" \ |
| 15 # userid="{706F576A-ACF9-4611-B608-E5528EAC106A}"> | 15 # userid="{706F576A-ACF9-4611-B608-E5528EAC106A}"> |
| 16 # <o:os version="MacOSX" platform="mac" sp="10.5.6_i486"></o:os> | 16 # <o:os version="MacOSX" platform="mac" sp="10.5.6_i486"></o:os> |
| 17 # <o:app appid="com.google.GoogleAppEngineLauncher" version="1.2.2.380" \ | 17 # <o:app appid="com.google.GoogleAppEngineLauncher" version="1.2.2.380" \ |
| 18 # lang="en-us" brand="GGLG"> | 18 # lang="en-us" brand="GGLG" board="x86-generic"> |
| 19 # <o:ping active="0"></o:ping> | 19 # <o:ping active="0"></o:ping> |
| 20 # <o:updatecheck></o:updatecheck> | 20 # <o:updatecheck></o:updatecheck> |
| 21 # </o:app> | 21 # </o:app> |
| 22 # </o:gupdate> | 22 # </o:gupdate> |
| 23 | 23 |
| 24 # Response (converted to 80 char width w/ backslashes): | 24 # Response (converted to 80 char width w/ backslashes): |
| 25 | 25 |
| 26 # <?xml version="1.0" encoding="UTF-8"?><gupdate \ | 26 # <?xml version="1.0" encoding="UTF-8"?><gupdate \ |
| 27 # xmlns="http://www.google.com/update2/response" protocol="2.0"><app \ | 27 # xmlns="http://www.google.com/update2/response" protocol="2.0"><app \ |
| 28 # appid="com.google.GoogleAppEngineLauncher" status="ok"><ping \ | 28 # appid="com.google.GoogleAppEngineLauncher" status="ok"><ping \ |
| 29 # status="ok"/><updatecheck status="noupdate"/></app></gupdate> | 29 # status="ok"/><updatecheck status="noupdate"/></app></gupdate> |
| 30 | 30 |
| 31 # If you change version= above to "0.0.0.0", you get (again, 80 chars w/ \s): | 31 # If you change version= above to "0.0.0.0", you get (again, 80 chars w/ \s): |
| 32 | 32 |
| 33 # <?xml version="1.0" encoding="UTF-8"?><gupdate \ | 33 # <?xml version="1.0" encoding="UTF-8"?><gupdate \ |
| 34 # xmlns="http://www.google.com/update2/response" protocol="2.0"><app \ | 34 # xmlns="http://www.google.com/update2/response" protocol="2.0"><app \ |
| 35 # appid="com.google.GoogleAppEngineLauncher" status="ok"><ping \ | 35 # appid="com.google.GoogleAppEngineLauncher" status="ok"><ping \ |
| 36 # status="ok"/><updatecheck DisplayVersion="1.2.2.0" \ | 36 # status="ok"/><updatecheck DisplayVersion="1.2.2.0" \ |
| 37 # MoreInfo="http://appenginesdk.appspot.com" Prompt="true" \ | 37 # MoreInfo="http://appenginesdk.appspot.com" Prompt="true" \ |
| 38 # codebase="http://googleappengine.googlecode.com/files/GoogleAppEngine\ | 38 # codebase="http://googleappengine.googlecode.com/files/GoogleAppEngine\ |
| 39 # Launcher-1.2.2.dmg" hash="vv8ifTj79KivBMTsCDsgKPpsmOo=" needsadmin="false" \ | 39 # Launcher-1.2.2.dmg" hash="vv8ifTj79KivBMTsCDsgKPpsmOo=" needsadmin="false" \ |
| 40 # size="4018650" status="ok"/></app></gupdate> | 40 # size="4018650" status="ok"/></app></gupdate> |
| 41 | 41 |
| 42 # Parameters of the update request: | 42 # Parameters of the update request: |
| 43 OS=Memento | 43 OS=Memento |
| 44 PLATFORM=memento | 44 PLATFORM=memento |
| 45 APP_ID={87efface-864d-49a5-9bb3-4b050a7c227a} | 45 APP_ID={87efface-864d-49a5-9bb3-4b050a7c227a} |
| 46 APP_VERSION="$1" | 46 APP_VERSION="$1" |
| 47 APP_BOARD="$2" |
| 47 OS_VERSION=${APP_VERSION}_$(uname -m) | 48 OS_VERSION=${APP_VERSION}_$(uname -m) |
| 48 LANG=en-us | 49 LANG=en-us |
| 49 BRAND=GGLG | 50 BRAND=GGLG |
| 50 | 51 |
| 51 OMAHA_ID_FILE=/mnt/stateful_partition/etc/omaha_id | 52 OMAHA_ID_FILE=/mnt/stateful_partition/etc/omaha_id |
| 52 if [ ! -f "$OMAHA_ID_FILE" ] | 53 if [ ! -f "$OMAHA_ID_FILE" ] |
| 53 then | 54 then |
| 54 # omaha file isn't a regular file | 55 # omaha file isn't a regular file |
| 55 if [ -e "$OMAHA_ID_FILE" ] | 56 if [ -e "$OMAHA_ID_FILE" ] |
| 56 then | 57 then |
| 57 # but the omaha file does exist. delete it | 58 # but the omaha file does exist. delete it |
| 58 rm -rf "$OMAHA_ID_FILE" | 59 rm -rf "$OMAHA_ID_FILE" |
| 59 fi | 60 fi |
| 60 # Generate Omaha ID: | 61 # Generate Omaha ID: |
| 61 dd if=/dev/urandom bs=16 count=1 status=noxfer | xxd -c 32 -g 1 -u | \ | 62 dd if=/dev/urandom bs=16 count=1 status=noxfer | xxd -c 32 -g 1 -u | \ |
| 62 cut -d ' ' -f 2-17 | awk \ | 63 cut -d ' ' -f 2-17 | awk \ |
| 63 '{print "{" $1 $2 $3 $4 "-" $5 $6 "-" $7 $8 "-" $9 $10 "-" \ | 64 '{print "{" $1 $2 $3 $4 "-" $5 $6 "-" $7 $8 "-" $9 $10 "-" \ |
| 64 $11 $12 $13 $14 $15 $16 "}"; }' > "$OMAHA_ID_FILE" | 65 $11 $12 $13 $14 $15 $16 "}"; }' > "$OMAHA_ID_FILE" |
| 65 chmod 0444 "$OMAHA_ID_FILE" | 66 chmod 0444 "$OMAHA_ID_FILE" |
| 66 fi | 67 fi |
| 67 | 68 |
| 68 MACHINE_ID=$(cat "$OMAHA_ID_FILE") | 69 MACHINE_ID=$(cat "$OMAHA_ID_FILE") |
| 69 if [ "x" = "x$MACHINE_ID" ] | 70 if [ "x" = "x$MACHINE_ID" ] |
| 70 then | 71 then |
| 71 log missing Omaha ID and unable to generate one | 72 log missing Omaha ID and unable to generate one |
| 72 exit 1 | 73 exit 1 |
| 73 fi | 74 fi |
| 74 USER_ID=$MACHINE_ID | 75 USER_ID=$MACHINE_ID |
| 75 AU_VERSION=MementoSoftwareUpdate-0.1.0.0 | 76 AU_VERSION=MementoSoftwareUpdate-0.1.0.0 |
| 76 APP_TRACK=$(grep ^CHROMEOS_RELEASE_TRACK /mnt/stateful_partition/etc/lsb-release
| \ | 77 |
| 78 for dir in /mnt/stateful_partition /; do |
| 79 value=$(grep ^CHROMEOS_RELEASE_TRACK $dir/etc/lsb-release | \ |
| 77 cut -d = -f 2-) | 80 cut -d = -f 2-) |
| 78 if [ "x" = "x$APP_TRACK" ] | 81 if [ -z "$APP_TRACK" -a -n "$value" ]; then |
| 79 then | 82 APP_TRACK="$value" |
| 80 # look in the main file | 83 fi |
| 81 APP_TRACK=$(grep ^CHROMEOS_RELEASE_TRACK /etc/lsb-release | cut -d = -f 2-) | 84 value=$(grep ^CHROMEOS_RELEASE_BOARD $dir/etc/lsb-release | \ |
| 82 fi | 85 cut -d = -f 2-) |
| 86 if [ -z "$APP_BOARD" -a -n "$value" ]; then |
| 87 APP_BOARD="$value" |
| 88 fi |
| 89 done |
| 83 | 90 |
| 84 AUSERVER_URL=$(grep ^CHROMEOS_AUSERVER /etc/lsb-release | cut -d = -f 2-) | 91 AUSERVER_URL=$(grep ^CHROMEOS_AUSERVER /etc/lsb-release | cut -d = -f 2-) |
| 85 | 92 |
| 86 if [ "x" = "x$AUSERVER_URL" ] | 93 if [ "x" = "x$AUSERVER_URL" ] |
| 87 then | 94 then |
| 88 AUSERVER_URL="https://tools.google.com/service/update2" | 95 AUSERVER_URL="https://tools.google.com/service/update2" |
| 89 log using default update server | 96 log using default update server |
| 90 fi | 97 fi |
| 91 | 98 |
| 92 # for testing. Uncomment and use these to reproduce the examples above | 99 # for testing. Uncomment and use these to reproduce the examples above |
| 93 # OS=MacOSX | 100 # OS=MacOSX |
| 94 # PLATFORM=mac | 101 # PLATFORM=mac |
| 95 # OS_VERSION=10.5.6_i486 | 102 # OS_VERSION=10.5.6_i486 |
| 96 # APP_ID=com.google.GoogleAppEngineLauncher | 103 # APP_ID=com.google.GoogleAppEngineLauncher |
| 97 # #APP_VERSION=0.0.0.0 | 104 # #APP_VERSION=0.0.0.0 |
| 98 # APP_VERSION=1.2.2.380 | 105 # APP_VERSION=1.2.2.380 |
| 106 # #APP_BOARD=arm-generic |
| 107 # APP_BOARD=x86-generic |
| 99 # LANG=en-us | 108 # LANG=en-us |
| 100 # BRAND=GGLG | 109 # BRAND=GGLG |
| 101 # MACHINE_ID={177255303f3cc519182a103069489327} | 110 # MACHINE_ID={177255303f3cc519182a103069489327} |
| 102 # USER_ID={706F576A-ACF9-4611-B608-E5528EAC106A} | 111 # USER_ID={706F576A-ACF9-4611-B608-E5528EAC106A} |
| 103 # AU_VERSION=Keystone-1.0.5.0 | 112 # AU_VERSION=Keystone-1.0.5.0 |
| 104 | 113 |
| 105 # post file must be a regular file for wget: | 114 # post file must be a regular file for wget: |
| 106 POST_FILE=/tmp/memento_au_post_file | 115 POST_FILE=/tmp/memento_au_post_file |
| 107 cat > "/tmp/memento_au_post_file" << EOF | 116 cat > "/tmp/memento_au_post_file" << EOF |
| 108 <?xml version="1.0" encoding="UTF-8"?> | 117 <?xml version="1.0" encoding="UTF-8"?> |
| 109 <o:gupdate xmlns:o="http://www.google.com/update2/request" \ | 118 <o:gupdate xmlns:o="http://www.google.com/update2/request" \ |
| 110 version="$AU_VERSION" protocol="2.0" machineid="$MACHINE_ID" \ | 119 version="$AU_VERSION" protocol="2.0" machineid="$MACHINE_ID" \ |
| 111 ismachine="0" userid="$USER_ID"> | 120 ismachine="0" userid="$USER_ID"> |
| 112 <o:os version="$OS" platform="$PLATFORM" sp="$OS_VERSION"></o:os> | 121 <o:os version="$OS" platform="$PLATFORM" sp="$OS_VERSION"></o:os> |
| 113 <o:app appid="$APP_ID" version="$APP_VERSION" lang="$LANG" brand="$BRAND" \ | 122 <o:app appid="$APP_ID" version="$APP_VERSION" lang="$LANG" brand="$BRAND" \ |
| 114 track="$APP_TRACK"> | 123 track="$APP_TRACK" board="$APP_BOARD"> |
| 115 <o:ping active="0"></o:ping> | 124 <o:ping active="0"></o:ping> |
| 116 <o:updatecheck></o:updatecheck> | 125 <o:updatecheck></o:updatecheck> |
| 117 </o:app> | 126 </o:app> |
| 118 </o:gupdate> | 127 </o:gupdate> |
| 119 EOF | 128 EOF |
| 120 | 129 |
| 121 log sending this request to omaha at $AUSERVER_URL | 130 log sending this request to omaha at $AUSERVER_URL |
| 122 cat "$POST_FILE" >> "$MEMENTO_AU_LOG" | 131 cat "$POST_FILE" >> "$MEMENTO_AU_LOG" |
| 123 | 132 |
| 124 RESPONSE=$(wget -q --header='Content-Type: text/xml' \ | 133 RESPONSE=$(wget -q --header='Content-Type: text/xml' \ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 150 then | 159 then |
| 151 log No https url | 160 log No https url |
| 152 exit 0 | 161 exit 0 |
| 153 fi | 162 fi |
| 154 fi | 163 fi |
| 155 | 164 |
| 156 | 165 |
| 157 echo URL=$CODEBASE | 166 echo URL=$CODEBASE |
| 158 echo HASH=$HASH | 167 echo HASH=$HASH |
| 159 echo SIZE=$SIZE | 168 echo SIZE=$SIZE |
| OLD | NEW |