~pwlars/phablet-tools/phablet-config-autopilot-errors

251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
1
#! /bin/sh
2
3
set -eu
4
253.1.1 by Oliver Grawert
phablet-bootchart: fix tmpdir creation to not try to use the full path of the command
5
TMPDIR=$(mktemp -d /tmp/$(basename $0).XXXXX)
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
6
SUITE="trusty"
7
PREFIX="ubuntu-phablet"
256.3.1 by Andy Doan
phablet-bootchart: allow custom arguments to be passed to bootchart
8
CHARTOPTS="${CHARTOPTS---crop-after=unity8 --annotate=unity8}"
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
9
SKIPINST=""
10
KEEPTAR=""
11
PNOPTS=""
12
BUILDID=""
13
OUTDIR="."
14
SFX="png"
15
ERROR=""
16
ADBOPTS=""
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
17
YESTOALL=""
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
18
19
cleanup(){
20
    [ -n "$ERROR" ] && echo "Error: $ERROR"
21
	[ -d "$TMPDIR" ] && rm -rf $TMPDIR >/dev/null 2>&1
22
}
23
24
usage(){
251.1.2 by Oliver Grawert
fix "bashism", tsk ...
25
cat <<EOF 
26
Usage: $(basename $0) (Options) [build id]
27
28
Options:
29
	-n|--noinstall				do not perform installation
30
	-k|--keeptarball			keep tarball around
31
	-w|--wlancfg <path to wlan file>	point to wlan config
32
	-o|--outdir <path to output directory>	define (and create) output dir
33
	-f|--format (png|svg)			output format (default: png)
34
	-s|--serial <adb serial>		operate on certain adb device
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
35
	-y|--yes-to-all				do not ask when wiping (for automation)
251.1.2 by Oliver Grawert
fix "bashism", tsk ...
36
37
	If [build id] is provided this image will be used for installation
38
EOF
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
39
	exit 0
40
}
41
42
reboot_and_wait(){
43
	adb $ADBOPTS reboot && adb $ADBOPTS wait-for-device
44
	[ -n "$1" ] && sleep $1
45
}
46
47
do_install(){
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
48
	if [ -z "$YESTOALL" ]; then
49
		echo -n "This will wipe all data on the device, proceed ? (y/n) "
50
		read yesno
51
		[ "$yesno" != "y" ] && exit 1
52
	fi
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
53
	echo "Installing Image $1"
54
	if [ -z "$(fastboot devices)" ]; then
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
55
		adb $ADBOPTS reboot bootloader || \
56
			ERROR="can not reboot to bootloader" exit 1
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
57
	fi
331.1.1 by Oliver Grawert
fix phablet-bootchart to properly work with the new phablet-config, developer mode and password settings
58
	FLASHOPTS="--developer-mode --password 0000 --channel devel-proposed --bootstrap"
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
59
	[ -n "$1" ] && FLASHOPTS="${FLASHOPTS} --revision $1"
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
60
	ubuntu-device-flash $FLASHOPTS
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
61
	adb $ADBOPTS wait-for-device
62
}
63
64
trap cleanup EXIT INT QUIT ILL KILL SEGV TERM
65
251.1.4 by Oliver Grawert
fail if pybootchartgui is not available and executable
66
[ -x /usr/bin/pybootchartgui ] || ERROR="please install pybootchartgui" exit 1
67
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
68
while [ $# -gt 0 ]; do
69
	case "$1" in
70
		-n|--noinstall)
71
			SKIPINST=1
72
			;;
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
73
		-y|--yes-to-all)
74
			YESTOALL=1
75
			;;
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
76
		-k|--keeptarball)
77
			KEEPTAR=1
78
			;;
79
		-w|--wlancfg)
80
		 	[ -n "$2" ] && PNOPTS="-n $2" shift || \
81
				ERROR="-w needs a file path" exit 1
82
		 	;;
83
		-s|--serial)
84
			[ -n "$2" ] && ADBOPTS="$ADBOPTS -s $2" shift || \
85
				ERROR="-s needs serial" exit 1
86
			;;
87
		-f|--format)
88
		 	if [ -n "$2" ]; then
89
				SFX="$2" shift || \
90
					ERROR="-f needs png or svg as argument" exit 1
91
				CHARTOPTS="$CHARTOPTS -f $SFX"
92
			fi
93
		 	;;
94
		-o|--outdir)
95
			[ -n "$2" ] && OUTDIR="$2" shift || \
96
				ERROR="-o needs a path" exit 1
97
			[ -d "$OUTDIR" ] || mkdir -p $OUTDIR
98
			;;
99
		-h|--help)
100
			usage
101
			;;
102
		*[0-9])
103
			BUILDID=$1
104
			;;
105
		*)
106
			ERROR="$1 is unknown" exit 1
107
			;;
108
	esac
109
	shift
110
done
111
112
[ -z "$SKIPINST" ] && do_install "$BUILDID"
113
echo "Enabling network"
114
phablet-network $PNOPTS || \
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
115
	ERROR="need working network on the device" exit 1
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
116
331.1.3 by Oliver Grawert
use an explicit install commend for the bootchart package and make sure FLASH_KERNEL_SKIP=true is ending up in the right environment
117
echo "Making Image writable"
118
phablet-config writable-image || \
119
	ERROR="could not make image writable" exit 1
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
120
reboot_and_wait 30
121
331.1.3 by Oliver Grawert
use an explicit install commend for the bootchart package and make sure FLASH_KERNEL_SKIP=true is ending up in the right environment
122
echo "Installing bootchart"
123
adb $ADBOPTS shell "echo 0000|sudo -p \"\" -S \
124
	FLASH_KERNEL_SKIP=true apt-get install -yq --force-yes bootchart"
125
283.1.2 by Michael Terry
Disable wizard for bootchart
126
echo "Disabling Welcome Wizard"
127
phablet-config welcome-wizard --disable || \
283.1.4 by Michael Terry
fix typo
128
	ERROR="could not disable welcome wizard" exit 1
283.1.2 by Michael Terry
Disable wizard for bootchart
129
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
130
echo "Disabling Intro Demo"
251.1.5 by Oliver Grawert
add better return value handling of subcommands, add confirmation dialog foe flashing and option to override the question
131
phablet-config edges-intro --disable || \
283.1.4 by Michael Terry
fix typo
132
	ERROR="could not disable intro" exit 1
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
133
134
echo "Rebooting three times to get accurate data"
135
reboot_and_wait 60
136
reboot_and_wait 60
137
reboot_and_wait 1
331.1.2 by Oliver Grawert
force skipping of flash-kernel, some arches are unsupported in that tool, make sure the cleaning of the bootchart output dir uses the sudoo password
138
adb $ADBOPTS shell "echo 0000|sudo -p \"\" -S rm -rf /var/log/bootchart/*"
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
139
sleep 60
140
141
echo "Pulling and processing bootchart tarball"
142
while [ -n "$(adb $ADBOPTS shell pgrep collector)" ]; do
143
	sleep 30
144
done
145
sleep 30
146
adb $ADBOPTS pull /var/log/bootchart $TMPDIR/
147
148
VER="$(adb $ADBOPTS shell system-image-cli -i | grep "^.* ver" | tr -d '[:cntrl:]')"
149
VER="${VER##* }"
251.1.6 by Oliver Grawert
remove ctrl chars from $SUITE
150
SUITE="$(adb $ADBOPTS shell lsb_release -cs | tr -d '[:cntrl:]')"
251.1.1 by Oliver Grawert
add phablet-bootchart script to generate bootcharts for touch devices
151
152
echo "Creating $SFX for $VER."
153
OUTNAME="$OUTDIR/$PREFIX-$SUITE-$VER"
154
CHARTOPTS="$CHARTOPTS -o $OUTNAME.$SFX"
155
pybootchartgui -q $CHARTOPTS $TMPDIR/*.tgz >/dev/null 2>&1
156
157
if [ -n "$KEEPTAR" ]; then
158
	cp $TMPDIR/*.tgz $OUTNAME.tgz
159
	echo "Keeping tarball at $OUTNAME.tgz"
160
fi
161
echo "Created $OUTNAME.$SFX"