blob: 1dcca713dad02c275ddcd95ec9d5869dc60cfe8f [file] [log] [blame]
David Hendricks6583a812013-11-01 19:37:44 -07001#!/bin/sh
2#
3# This file is part of the coreboot project.
4#
5# Copyright (C) 2013 Google Inc.
Martin Roth8e0071b2014-07-10 15:00:35 -06006# Copyright (C) 2014 Sage Electronic Engineering, LLC.
Zheng Bao86655cf2013-11-07 18:03:05 +08007#
David Hendricks6583a812013-11-01 19:37:44 -07008
9EXIT_SUCCESS=0
10EXIT_FAILURE=1
David Hendricks6583a812013-11-01 19:37:44 -070011
12# Stuff from command-line switches
David Hendricks1173bf32015-11-19 13:04:27 -080013COREBOOT_IMAGE="build/coreboot.rom"
David Hendricks6583a812013-11-01 19:37:44 -070014REMOTE_HOST=""
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +020015REMOTE_PORT_OPTION=""
David Hendricks6583a812013-11-01 19:37:44 -070016CLOBBER_OUTPUT=0
17UPLOAD_RESULTS=0
Martin Roth8e0071b2014-07-10 15:00:35 -060018SERIAL_PORT_SPEED=115200
David Hendricks6583a812013-11-01 19:37:44 -070019
David Hendricks1b6e7a62013-11-11 18:44:05 -080020# Used to specify whether a command should always be run locally or
21# if command should be run remoteley when a remote host is specified.
22LOCAL=0
23REMOTE=1
Martin Rothbe5340b2014-06-22 21:46:24 -060024FATAL=0
25NONFATAL=1
David Hendricks1b6e7a62013-11-11 18:44:05 -080026
David Hendricks6583a812013-11-01 19:37:44 -070027# test a command
28#
Martin Rothbcd09932014-07-10 15:02:19 -060029# $1: 0 ($LOCAL) to run command locally,
30# 1 ($REMOTE) to run remotely if remote host defined
David Hendricks6583a812013-11-01 19:37:44 -070031# $2: command to test
Martin Rothbe5340b2014-06-22 21:46:24 -060032# $3: 0 ($FATAL) Exit with an error if the command fails
33# 1 ($NONFATAL) Don't exit on command test failure
David Hendricks6583a812013-11-01 19:37:44 -070034test_cmd()
35{
36 local rc
37
38 if [ -e "$2" ]; then
39 return
40 fi
41
Vladimir Serbinenko77005b42014-01-21 02:39:46 +010042 if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +020043 ssh $REMOTE_PORT_OPTION root@${REMOTE_HOST} command -v "$2" > /dev/null
David Hendricks6583a812013-11-01 19:37:44 -070044 rc=$?
45 else
Patrick Georgi1cbef1c2015-08-10 10:21:14 +020046 command -v "$2" >/dev/null
David Hendricks6583a812013-11-01 19:37:44 -070047 rc=$?
48 fi
49
50 if [ $rc -eq 0 ]; then
Martin Rothbe5340b2014-06-22 21:46:24 -060051 return 0
52 fi
53
Patrick Georgi4ef309e2014-08-10 15:44:04 +020054 if [ "$3" = "1" ]; then
Martin Rothbe5340b2014-06-22 21:46:24 -060055 return 1
David Hendricks6583a812013-11-01 19:37:44 -070056 fi
57
58 echo "$2 not found"
59 exit $EXIT_FAILURE
60}
61
David Hendricksf8b90e42013-11-12 17:24:42 -080062_cmd()
David Hendricks6583a812013-11-01 19:37:44 -070063{
64 if [ -e "$2" ]; then
David Hendricksf8b90e42013-11-12 17:24:42 -080065 return $EXIT_FAILURE
David Hendricks6583a812013-11-01 19:37:44 -070066 fi
67
Martin Roth22461772014-07-10 14:57:34 -060068 if [ -n "$3" ]; then
69 pipe_location="${3}"
David Hendricks6583a812013-11-01 19:37:44 -070070 else
Martin Roth22461772014-07-10 14:57:34 -060071 pipe_location="/dev/null"
72 fi
73
74 if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +020075 ssh $REMOTE_PORT_OPTION "root@${REMOTE_HOST}" "$2" > "$pipe_location" 2>&1
Martin Roth22461772014-07-10 14:57:34 -060076 else
77 $2 > "$pipe_location" 2>&1
David Hendricks6583a812013-11-01 19:37:44 -070078 fi
David Hendricks406ce8a2013-11-12 18:10:23 -080079
80 return $?
David Hendricksf8b90e42013-11-12 17:24:42 -080081}
82
83# run a command
84#
Martin Rothbcd09932014-07-10 15:02:19 -060085# $1: 0 ($LOCAL) to run command locally,
86# 1 ($REMOTE) to run remotely if remote host defined
David Hendricksf8b90e42013-11-12 17:24:42 -080087# $2: command
David Hendricks406ce8a2013-11-12 18:10:23 -080088# $3: filename to direct output of command into
David Hendricksf8b90e42013-11-12 17:24:42 -080089cmd()
90{
David Hendricks406ce8a2013-11-12 18:10:23 -080091 _cmd $1 "$2" "$3"
David Hendricks6583a812013-11-01 19:37:44 -070092
93 if [ $? -eq 0 ]; then
94 return
95 fi
Zheng Bao86655cf2013-11-07 18:03:05 +080096
David Hendricks406ce8a2013-11-12 18:10:23 -080097 echo "Failed to run \"$2\", aborting"
98 rm -f "$3" # don't leave an empty file
David Hendricks6583a812013-11-01 19:37:44 -070099 exit $EXIT_FAILURE
100}
101
David Hendricksf8b90e42013-11-12 17:24:42 -0800102# run a command where failure is considered to be non-fatal
103#
Martin Rothbcd09932014-07-10 15:02:19 -0600104# $1: 0 ($LOCAL) to run command locally,
105# 1 ($REMOTE) to run remotely if remote host defined
David Hendricksf8b90e42013-11-12 17:24:42 -0800106# $2: command
David Hendricks406ce8a2013-11-12 18:10:23 -0800107# $3: filename to direct output of command into
David Hendricksf8b90e42013-11-12 17:24:42 -0800108cmd_nonfatal()
109{
David Hendricks406ce8a2013-11-12 18:10:23 -0800110 _cmd $1 "$2" "$3"
David Hendricksf8b90e42013-11-12 17:24:42 -0800111
112 if [ $? -eq 0 ]; then
113 return
114 fi
115
David Hendricks406ce8a2013-11-12 18:10:23 -0800116 echo "Failed to run \"$2\", ignoring"
117 rm -f "$3" # don't leave an empty file
David Hendricksf8b90e42013-11-12 17:24:42 -0800118}
119
Martin Roth8e0071b2014-07-10 15:00:35 -0600120# read from a serial port device
121#
122# $1: serial device to read from
123# $2: serial port speed
124# $3: filename to direct output of command into
125get_serial_bootlog () {
126
Martin Rothd0128df2015-12-17 12:02:45 -0700127 local TTY=$1
128 local SPEED=$2
129 local FILENAME=$3
130
131 if [ ! -c "$TTY" ]; then
132 echo "$TTY is not a valid serial device"
Martin Roth8e0071b2014-07-10 15:00:35 -0600133 exit $EXIT_FAILURE
134 fi
135
136 # make the text more noticible
137 test_cmd $LOCAL "tput" $NONFATAL
138 tput_not_available=$?
139 if [ $tput_not_available -eq 0 ]; then
140 tput bold
141 tput setaf 10 # set bright green
142 fi
143
144 echo
Martin Rothd0128df2015-12-17 12:02:45 -0700145 echo "Waiting to receive boot log from $TTY"
Martin Roth8e0071b2014-07-10 15:00:35 -0600146 echo "Press [Enter] when the boot is complete and the"
147 echo "system is ready for ssh to get the dmesg log."
Martin Rothd0128df2015-12-17 12:02:45 -0700148 echo
Martin Roth8e0071b2014-07-10 15:00:35 -0600149
150 if [ $tput_not_available -eq 0 ]; then
151 tput sgr0
152 fi
153
154 # set up the serial port
Martin Rothd0128df2015-12-17 12:02:45 -0700155 stty -F $TTY $SPEED cs8 -cstopb -parenb clocal
Martin Roth8e0071b2014-07-10 15:00:35 -0600156
157 # read from the serial port - user must press enter when complete
158 test_cmd $LOCAL "tee"
Martin Rothd0128df2015-12-17 12:02:45 -0700159 while read LINE; do
160 echo "$LINE" | tee -a "$FILENAME"
161 done < "$SERIAL_DEVICE" &
Martin Roth8e0071b2014-07-10 15:00:35 -0600162 PID=$!
163
Martin Rothd0128df2015-12-17 12:02:45 -0700164 read foo
165 kill "$PID" 2>/dev/null
Martin Roth8e0071b2014-07-10 15:00:35 -0600166
Martin Rothd0128df2015-12-17 12:02:45 -0700167 echo "Finished reading boot log."
Martin Roth8e0071b2014-07-10 15:00:35 -0600168}
169
David Hendricks1fc65f72013-11-12 16:49:45 -0800170show_help() {
171 echo "Usage:
172 ${0} <option>
173
174Options
David Hendricksb2aa5282016-05-07 11:44:05 -0700175 -C, --clobber
David Hendricks1fc65f72013-11-12 16:49:45 -0800176 Clobber temporary output when finished. Useful for debugging.
David Hendricksb2aa5282016-05-07 11:44:05 -0700177 -h, --help
178 Show this message.
179 -i, --image <image>
David Hendricks1173bf32015-11-19 13:04:27 -0800180 Path to coreboot image (Default is $COREBOOT_IMAGE).
David Hendricksb2aa5282016-05-07 11:44:05 -0700181 -r, --remote-host <host>
David Hendricks1fc65f72013-11-12 16:49:45 -0800182 Obtain machine information from remote host (using ssh).
David Hendricksb2aa5282016-05-07 11:44:05 -0700183 -s, --serial-device </dev/xxx>
184 Obtain boot log via serial device.
185 -S, --serial-speed <speed>
186 Set the port speed for the serial device (Default is $SERIAL_PORT_SPEED).
187 -u, --upload-results
188 Upload results to coreboot.org.
189
190Long options:
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +0200191 --ssh-port <port>
192 Use a specific SSH port.
David Hendricks1fc65f72013-11-12 16:49:45 -0800193"
194}
195
David Hendricks292be872016-04-26 14:07:42 -0700196getopt -T
197if [ $? -ne 4 ]; then
198 echo "GNU-compatible getopt(1) required."
199 exit $EXIT_FAILURE
200fi
201
David Hendricksb2aa5282016-05-07 11:44:05 -0700202LONGOPTS="clobber,help,image:,remote-host:,upload-results"
203LONGOPTS="${LONGOPTS},serial-device:,serial-speed:"
204LONGOPTS="${LONGOPTS},ssh-port:"
205
206ARGS=$(getopt -o Chi:r:s:S:u -l "$LONGOPTS" -n "$0" -- "$@");
David Hendricks292be872016-04-26 14:07:42 -0700207if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
208eval set -- "$ARGS"
209while true ; do
210 case "$1" in
David Hendricksb2aa5282016-05-07 11:44:05 -0700211 # generic options
212 -C|--clobber)
213 CLOBBER_OUTPUT=1
214 ;;
215 -h|--help)
David Hendricks6583a812013-11-01 19:37:44 -0700216 show_help
217 exit $EXIT_SUCCESS
218 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700219 -i|--image)
David Hendricks292be872016-04-26 14:07:42 -0700220 shift
221 COREBOOT_IMAGE="$1"
David Hendricks1173bf32015-11-19 13:04:27 -0800222 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700223 -r|--remote-host)
David Hendricks292be872016-04-26 14:07:42 -0700224 shift
225 REMOTE_HOST="$1"
David Hendricks6583a812013-11-01 19:37:44 -0700226 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700227 -u|--upload-results)
228 UPLOAD_RESULTS=1
229 ;;
230
231 # serial port options
232 -s|--serial-device)
233 shift
234 SERIAL_DEVICE="$1"
235 ;;
236 -S|--serial-speed)
237 shift
238 SERIAL_PORT_SPEED="$1"
239 ;;
240
241 # ssh options
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +0200242 --ssh-port)
243 shift
244 REMOTE_PORT_OPTION="-p $1"
245 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700246
247 # error handling
David Hendricks292be872016-04-26 14:07:42 -0700248 --)
249 shift
250 if [ -n "$*" ]; then
251 echo "Non-option parameters detected: '$*'"
252 exit $EXIT_FAILURE
253 fi
254 break
255 ;;
256 *)
257 echo "error processing options at '$1'"
258 exit $EXIT_FAILURE
David Hendricks6583a812013-11-01 19:37:44 -0700259 esac
David Hendricks292be872016-04-26 14:07:42 -0700260 shift
David Hendricks6583a812013-11-01 19:37:44 -0700261done
262
David Hendricks1b6e7a62013-11-11 18:44:05 -0800263grep -rH 'coreboot.org' .git/config >/dev/null 2>&1
264if [ $? -ne 0 ]; then
265 echo "Script must be run from root of coreboot directory"
David Hendricks6583a812013-11-01 19:37:44 -0700266 exit $EXIT_FAILURE
267fi
268
Jonathan Neuschäfer0e962ee2016-05-17 17:38:10 +0200269if [ ! -e "$COREBOOT_IMAGE" ]; then
270 echo "board_status needs $COREBOOT_IMAGE, but it does not exist."
271 echo "Use \"-i IMAGE_FILE\" to select a different image, or \"--help\" for more options."
272 exit $EXIT_FAILURE
273fi
274
David Hendricks1b6e7a62013-11-11 18:44:05 -0800275# Results will be placed in a temporary location until we're ready to upload.
276# If the user does not wish to upload, results will remain in /tmp.
Patrick Georgiaa7dcef2015-08-13 07:57:26 +0200277tmpdir=$(mktemp -d --tmpdir coreboot_board_status.XXXXXXXX)
David Hendricks1b6e7a62013-11-11 18:44:05 -0800278
David Hendricks9f542972015-11-19 13:08:51 -0800279# Obtain coreboot config by running cbfstool on the ROM image. cbfstool may
280# already exist in build/ or util/cbfstool/, but if not then we'll build it
281# now and clean it when we're done.
Idwer Volleringb37ee1e2014-07-16 22:22:59 +0200282cbfstool_cmd="build/cbfstool"
David Hendricks9f542972015-11-19 13:08:51 -0800283do_clean_cbfstool=0
284if [ ! -x $cbfstool_cmd ]; then
285 cbfstool_cmd="util/cbfstool/cbfstool"
286 if [ -e $cbfstool_cmd ]; then
287 if test ! -x $cbfstool_cmd; then
288 echo "Cannot execute $cbfstool_cmd."
289 exit $EXIT_FAILURE
290 fi
291 else
292 make -C util/cbfstool/
293 do_clean_cbfstool=1
294 fi
Idwer Volleringb37ee1e2014-07-16 22:22:59 +0200295fi
David Hendricks1b6e7a62013-11-11 18:44:05 -0800296test_cmd $LOCAL "$cbfstool_cmd"
David Hendricks9f542972015-11-19 13:08:51 -0800297
298tmpcfg=$(mktemp coreboot_config.XXXXXX)
David Hendricks1173bf32015-11-19 13:04:27 -0800299echo "Extracting config.txt from $COREBOOT_IMAGE"
300$cbfstool_cmd "$COREBOOT_IMAGE" extract -n config -f "${tmpdir}/config.txt" >/dev/null 2>&1
Martin Roth9f25da12015-12-17 12:49:15 -0700301mv "${tmpdir}/config.txt" "${tmpdir}/config.short.txt"
302cp "${tmpdir}/config.short.txt" "${tmpcfg}"
303yes "" | make "DOTCONFIG=${tmpcfg}" oldconfig 2>/dev/null >/dev/null
304mv "${tmpcfg}" "${tmpdir}/config.txt"
305rm -f "${tmpcfg}.old"
David Hendricks1173bf32015-11-19 13:04:27 -0800306$cbfstool_cmd "$COREBOOT_IMAGE" print > "${tmpdir}/cbfs.txt"
307rom_contents=$($cbfstool_cmd "$COREBOOT_IMAGE" print 2>&1)
Martin Roth2e44ea22015-12-17 12:33:39 -0700308if [ -n "$(echo $rom_contents | grep payload_config)" ]; then
David Hendricks1173bf32015-11-19 13:04:27 -0800309 echo "Extracting payload_config from $COREBOOT_IMAGE"
310 $cbfstool_cmd "$COREBOOT_IMAGE" extract -n payload_config -f "${tmpdir}/payload_config.txt" >/dev/null 2>&1
Martin Roth2e44ea22015-12-17 12:33:39 -0700311fi
312if [ -n "$(echo $rom_contents | grep payload_version)" ]; then
David Hendricks1173bf32015-11-19 13:04:27 -0800313 echo "Extracting payload_version from $COREBOOT_IMAGE"
314 $cbfstool_cmd "$COREBOOT_IMAGE" extract -n payload_version -f "${tmpdir}/payload_version.txt" >/dev/null 2>&1
Martin Roth2e44ea22015-12-17 12:33:39 -0700315fi
David Hendricks1173bf32015-11-19 13:04:27 -0800316md5sum -b "$COREBOOT_IMAGE" > "${tmpdir}/rom_checksum.txt"
Paul Menzel1cc77e02015-02-19 19:35:58 +0100317
David Hendricks9f542972015-11-19 13:08:51 -0800318if test $do_clean_cbfstool -eq 1; then
319 make -C util/cbfstool clean
320fi
321
Paul Menzel1cc77e02015-02-19 19:35:58 +0100322# Obtain board and revision info to form the directory structure:
323# <vendor>/<board>/<revision>/<timestamp>
Martin Roth9f25da12015-12-17 12:49:15 -0700324mainboard_dir="$(grep CONFIG_MAINBOARD_DIR "${tmpdir}/config.txt" | awk -F '"' '{ print $2 }')"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800325vendor=$(echo "$mainboard_dir" | awk -F '/' '{ print $1 }')
326mainboard=$(echo "$mainboard_dir" | awk -F '/' '{ print $2 }')
David Hendricks6583a812013-11-01 19:37:44 -0700327
David Hendricksc5e947ef2013-11-11 18:43:39 -0800328getrevision="util/board_status/getrevision.sh"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800329test_cmd $LOCAL $getrevision
330tagged_version=$($getrevision -T)
331timestamp=$($getrevision -t)
David Hendricks6583a812013-11-01 19:37:44 -0700332
David Hendricks1b6e7a62013-11-11 18:44:05 -0800333results="${vendor}/${mainboard}/${tagged_version}/${timestamp}"
David Hendricks6583a812013-11-01 19:37:44 -0700334
David Hendricks1b6e7a62013-11-11 18:44:05 -0800335echo "Temporarily placing output in ${tmpdir}/${results}"
336mkdir -p "${tmpdir}/${results}"
David Hendricks6583a812013-11-01 19:37:44 -0700337
David Hendricks1b6e7a62013-11-11 18:44:05 -0800338mv "${tmpdir}/config.txt" "${tmpdir}/${results}"
Martin Roth2e44ea22015-12-17 12:33:39 -0700339test -f "${tmpdir}/payload_config.txt" && mv "${tmpdir}/payload_config.txt" "${tmpdir}/${results}"
340test -f "${tmpdir}/payload_version.txt" && mv "${tmpdir}/payload_version.txt" "${tmpdir}/${results}"
Patrick Georgi368488a2015-06-12 11:35:10 +0200341mv "${tmpdir}/config.short.txt" "${tmpdir}/${results}"
Paul Menzel4b10bb72014-05-30 09:26:46 +0200342mv "${tmpdir}/cbfs.txt" "${tmpdir}/${results}"
Martin Roth072b5aa2015-12-17 12:44:35 -0700343mv "${tmpdir}/rom_checksum.txt" "${tmpdir}/${results}"
David Hendricks6583a812013-11-01 19:37:44 -0700344
Martin Roth9f25da12015-12-17 12:49:15 -0700345touch "${tmpdir}/${results}/revision.txt"
346printf "Local revision: %s\n" "$($getrevision -l)" >> "${tmpdir}/${results}/revision.txt"
347printf "Tagged revision: %s\n" "${tagged_version}" >> "${tmpdir}/${results}/revision.txt"
348printf "Upstream revision: %s\n" "$($getrevision -u)" >> "${tmpdir}/${results}/revision.txt"
349printf "Upstream URL: %s\n" "$($getrevision -U)" >> "${tmpdir}/${results}/revision.txt"
350printf "Timestamp: %s\n" "$timestamp" >> "${tmpdir}/${results}/revision.txt"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800351
Martin Roth8e0071b2014-07-10 15:00:35 -0600352if [ -z "$SERIAL_DEVICE" ]; then
Martin Roth574d1652015-12-17 12:38:45 -0700353 echo "Verifying that CBMEM is available on remote device"
Martin Roth8e0071b2014-07-10 15:00:35 -0600354 test_cmd $REMOTE "cbmem"
Martin Roth574d1652015-12-17 12:38:45 -0700355 echo "Getting coreboot boot log"
Martin Roth8e0071b2014-07-10 15:00:35 -0600356 cmd $REMOTE "cbmem -c" "${tmpdir}/${results}/coreboot_console.txt"
Martin Roth574d1652015-12-17 12:38:45 -0700357 echo "Getting timestamp data"
Martin Roth8e0071b2014-07-10 15:00:35 -0600358 cmd_nonfatal $REMOTE "cbmem -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
359else
360 get_serial_bootlog "$SERIAL_DEVICE" "$SERIAL_PORT_SPEED" "${tmpdir}/${results}/coreboot_console.txt"
361fi
David Hendricks1b6e7a62013-11-11 18:44:05 -0800362
Martin Roth574d1652015-12-17 12:38:45 -0700363echo "Getting remote dmesg"
David Hendricks406ce8a2013-11-12 18:10:23 -0800364cmd $REMOTE dmesg "${tmpdir}/${results}/kernel_log.txt"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800365
David Hendricksa4affe12013-11-12 18:17:19 -0800366#
367# Finish up.
368#
Martin Rothbcd09932014-07-10 15:02:19 -0600369coreboot_dir=$(pwd)
David Hendricks1b6e7a62013-11-11 18:44:05 -0800370if [ $UPLOAD_RESULTS -eq 1 ]; then
371 # extract username from ssh://<username>@review.coreboot.org/blah
Patrick Georgi77b182a2014-08-10 15:18:22 +0200372 bsrepo=$(git config --get remote.origin.url | sed "s,\(.*\)/coreboot,\1/board-status,")
David Hendricks1b6e7a62013-11-11 18:44:05 -0800373
374 cd "util/board_status/"
375 if [ ! -e "board-status" ]; then
David Hendricksa4affe12013-11-12 18:17:19 -0800376 # FIXME: the board-status directory might get big over time.
377 # Is there a way we can push the results without fetching the
378 # whole repo?
Martin Roth9f25da12015-12-17 12:49:15 -0700379 git clone "$bsrepo"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800380 if [ $? -ne 0 ]; then
Paul Menzel749e0752015-05-20 22:32:15 +0200381 echo "Error cloning board-status repo, aborting."
David Hendricks1b6e7a62013-11-11 18:44:05 -0800382 exit $EXIT_FAILURE
383 fi
384 fi
385
386 cd "board-status"
Huimin Zhang2fb24832016-03-30 00:54:16 -0700387
388 echo "Checking for duplicate results"
389 # get any updates to board-status
390 git pull
391
392 echo "${tagged_version}" | grep dirty >/dev/null 2>&1
393 clean_version=$?
394 existing_results=$(git ls-files "${mainboard_dir}/${tagged_version}")
395
396 # reject duplicate results of non-dirty versions
397 if [ "${clean_version}" -eq 1 ] && [ -n "${existing_results}" ] ; then
398 echo "Result is a duplicate, aborting"
399 exit $EXIT_FAILURE
400 fi
401
David Hendricks1b6e7a62013-11-11 18:44:05 -0800402 echo "Copying results to $(pwd)/${results}"
403
404 # Note: Result directory should be unique due to the timestamp.
405 cp -R "${tmpdir}/${vendor}" .
406
407 echo "Uploading results"
408 git add "${vendor}"
Paul Menzel04eb2e82014-02-09 10:24:22 +0100409 git commit -a -m "${mainboard_dir}/${tagged_version}/${timestamp}"
Paul Menzel54e6aa72015-05-20 07:35:56 +0200410 count=0
Jonathan Neuschäfer478c8892016-05-10 17:43:53 +0200411 until git push origin master || test $count -eq 3; do
Paul Menzel54e6aa72015-05-20 07:35:56 +0200412 git pull --rebase
413 count=$((count + 1))
414 done
David Hendricks1b6e7a62013-11-11 18:44:05 -0800415
416 # Results have been uploaded so it's pointless to keep the
417 # temporary files around.
418 rm -rf "${tmpdir}"
Paul Menzel54e6aa72015-05-20 07:35:56 +0200419 if test $count -eq 3; then
420 echo "Error uploading to board-status repo, aborting."
421 exit $EXIT_FAILURE
422 fi
David Hendricks1b6e7a62013-11-11 18:44:05 -0800423fi
424cd "$coreboot_dir"
David Hendricks6583a812013-11-01 19:37:44 -0700425
426if [ $CLOBBER_OUTPUT -eq 1 ]; then
Martin Roth9f25da12015-12-17 12:49:15 -0700427 rm -rf "${tmpdir}"
Martin Roth13c7db82014-07-10 14:59:11 -0600428else
429 echo
430 echo "output files are in ${tmpdir}/${results}"
David Hendricks6583a812013-11-01 19:37:44 -0700431fi
432
433exit $EXIT_SUCCESS