~toykeeper/+junk/flash-helper

« back to all changes in this revision

Viewing changes to flash.sh

  • Committer: Selene Scriven
  • Date: 2016-03-31 21:45:51 UTC
  • Revision ID: selene.scriven@canonical.com-20160331214551-nf1xduclrov84swz
Merged power test's flash.sh (mostly).
Did some other small cleanup or notes in flash.sh.
(mostly notes for things to fix)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
 
 
3
 
# recovery images:
4
 
# https://wiki.ubuntu.com/Touch/Devices#Working_with_ubuntu-device-flash
5
 
 
6
 
# customized vivid images:
7
 
# <alesage> ToyKeeper, FWIW cwayne advises it's in
8
 
# --channel=ubuntu-touch/devel-proposed/krillin.en-proposed or
9
 
# bla/devel-proposed-customized-here
10
 
# ...
11
 
# <davmor2> vrruiz: you need to flash ubuntu-touch/devel-proposed/krillin.en
 
2
#
 
3
# Convenience script for flashing Ubuntu phones
 
4
# and making common configurations.
 
5
#
 
6
# recovery images:  (see 'urls' file)
12
7
 
13
8
WIFI=no
14
9
MEDIA=no
24
19
WIZARD=yes
25
20
EDGEINTRO=yes
26
21
CHANNELOVERRIDE=
 
22
APTUPDATE=no
27
23
BEEP=yes
28
24
DEVTAR=no
29
25
 
39
35
      ;;
40
36
    --spanish)
41
37
      SPANISH=yes
 
38
      echo "Spanish channul URL not known; ignoring option."
42
39
      shift
43
40
      ;;
44
41
    --network)
73
70
      EDGEINTRO=no
74
71
      shift
75
72
      ;;
 
73
    --apt-update)
 
74
      APTUPDATE=yes
 
75
      shift
 
76
      ;;
76
77
    --channel)
77
78
      shift
78
79
      CHANNELOVERRIDE=$1
87
88
      DEVTAR="$1"
88
89
      shift
89
90
      ;;
 
91
    --device)
 
92
      shift
 
93
      MODEL=$1
 
94
      shift
 
95
      ;;
 
96
    --rev)
 
97
      shift
 
98
      REVISION=$1
 
99
      shift
 
100
      ;;
90
101
    *)
91
102
      #echo "Arg: $arg"
92
103
      ;;
93
104
esac
94
105
done
95
 
#MODEL=$(adb devices -l | grep : | cut -d : -f 5)
96
 
MODEL=$1 ; shift
97
 
REVISION=$1 ; shift
98
 
if [ x"$REVISION" = xrtm ]; then
99
 
  REVISION=$1 ; shift
100
 
  FEED=rtm
101
 
fi
 
106
# Positional arguments
 
107
if [ x"$MODEL" = x ]; then MODEL=$1 ; shift ; fi
 
108
if [ x"$REVISION" = x ]; then REVISION=$1 ; shift ; fi
 
109
 
102
110
REVARGS=
103
111
SERVER=
104
112
CHANNEL=ubuntu-touch/devel-proposed
105
113
FASTBOOT=no
106
114
RECOVERY=
107
115
 
 
116
# Figure out the channel and other options based on the phone type
108
117
echo "Model: $MODEL"
109
118
if [ x"$REVISION" != x ]; then
110
119
  echo "Revision: $REVISION"
117
126
  DEVTAR="--device-tarball $DEVTAR --run-script ./disable-gpg"
118
127
fi
119
128
 
120
 
#if [ x"$SPANISH" = xyes ]; then
121
 
#  FEED=rtm.es
122
 
#  if [ x"$CUSTOM" == xyes ]; then
123
 
#    CHANNEL=ubuntu-touch/ubuntu-rtm/14.09.es-proposed-customized
124
 
#  else
125
 
#    CHANNEL=ubuntu-touch/ubuntu-rtm/14.09.es-proposed
126
 
#  fi
127
 
#else
128
 
#  if [ x"$FEED" = xrtm ]; then
129
 
#    if [ x"$CUSTOM" == xyes ]; then
130
 
#      CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-proposed-customized
131
 
#    else
132
 
#      #SERVER='--server=https://system-image.startx.ro:10446'
133
 
#      CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-proposed
134
 
#      #CHANNEL=ubuntu-touch/rc/bq-aquaris.en # release candidates
135
 
#      #CHANNEL=ubuntu-touch/stable/bq-aquaris.en # released
136
 
#      #CHANNEL=ubuntu-touch/ubuntu-rtm/devel-proposed
137
 
#    fi
138
 
#  else
139
 
#    #if [ x"$CUSTOM" == xyes ]; then
140
 
#    #  CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-proposed-customized
141
 
#    #else
142
 
#    #  CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-proposed
143
 
#    #fi
144
 
#    if [ x"$CUSTOM" == xyes ]; then
145
 
#      #CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-proposed-customized
146
 
#      echo "Not sure what feed to use."
147
 
#      CHANNEL=ubuntu-touch/devel-proposed-customized
148
 
#    else
149
 
#      CHANNEL=ubuntu-touch/devel-proposed
150
 
#    fi
151
 
#  fi
152
 
#fi
153
 
 
154
 
if [ x"$MODEL" = xmako ]; then
 
129
# FIXME: Rewrite all this to use a separate file with device channels
 
130
# FIXME: Remove everything related to rtm and other obsolete options
 
131
if [ x"$MODEL" = x"mako" ]; then
155
132
  CHANNEL=ubuntu-touch/devel-proposed
156
133
  FASTBOOT=no
157
134
  if [ x"$FEED" = xrtm ]; then
173
150
    if [ x"$CUSTOM" == xyes ]; then
174
151
      CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-proposed-customized
175
152
    else
176
 
      #SERVER='--server=https://system-image.startx.ro:10446'
177
153
      CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-proposed
178
 
      CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-factory-proposed
 
154
      #CHANNEL=ubuntu-touch/ubuntu-rtm/14.09-factory-proposed
179
155
      #CHANNEL=ubuntu-touch/rc/bq-aquaris.en # release candidates
180
156
      #CHANNEL=ubuntu-touch/stable/bq-aquaris.en # released
181
157
      #CHANNEL=ubuntu-touch/ubuntu-rtm/devel-proposed
182
158
    fi
183
159
    echo "Feed: $FEED"
184
160
  fi
185
 
  #if [ x"$SPANISH" = xyes ]; then
186
 
  #  FEED=rtm.es
187
 
  #  if [ x"$CUSTOM" == xyes ]; then
188
 
  #    CHANNEL=ubuntu-touch/ubuntu-rtm/14.09.es-proposed-customized
189
 
  #  else
190
 
  #    CHANNEL=ubuntu-touch/ubuntu-rtm/14.09.es-proposed
191
 
  #  fi
192
 
  #fi
193
161
fi
194
162
 
195
163
if [ x"$MODEL" = xm75  -o  x"$MODEL" = xarale ]; then
196
 
  if [ x"$GU" = "xyes" ]; then
 
164
  if [ x"$GU" = x"yes" ]; then
197
165
    GU=21
198
166
  fi
199
167
 
200
 
  # Old temp server
201
 
  #SERVER="--server https://system-image.startx.ro:10450"
202
 
  #CHANNEL=ubuntu-touch/vivid-proposed
203
 
  #FASTBOOT=yes
204
 
 
205
168
  # Capomastro
206
169
  #MODEL=arale
207
170
  #SERVER="--server https://sis.capomastro.canonical.com"
208
 
  ##CHANNEL=ubuntu-touch/tangxi-vivid-proposed
209
 
  ##CHANNEL=ubuntu-touch/tangxi/devel-proposed
210
171
  #CHANNEL=ubuntu-touch/rc-proposed/meizu
211
172
  #FASTBOOT=yes
212
 
  ##FASTBOOT_RECOVERY='arale/recovery.img'
213
 
  ##RECOVERY='--recovery-image $FASTBOOT_RECOVERY'
214
173
  ##RECOVERY='--recovery-image arale/recovery.img'
215
 
  ##RECOVERY='--recovery-image arale/recovery-6.img'
216
174
 
217
175
  # Public server
218
176
  MODEL=arale
219
177
  CHANNEL=ubuntu-touch/rc-proposed/meizu.en
220
178
  FASTBOOT=yes
221
179
  RECOVERY='--recovery-image arale/recovery.img'
222
 
  #RECOVERY='--recovery-image arale/recovery-6.img'
223
180
fi
224
181
 
 
182
# FIXME: unify mako sections
225
183
if [ x"$MODEL" = xmako ]; then
226
184
  CHANNEL=ubuntu-touch/rc-proposed/bq-aquaris.en
227
185
  #FASTBOOT=yes
232
190
  CHANNEL=$CHANNELOVERRIDE
233
191
fi
234
192
 
235
 
function rootcmd {
236
 
  adb shell "echo $PASSWD | sudo -S $*"
237
 
}
238
 
 
 
193
# Summarize what we're going to do
239
194
echo "Server: $SERVER"
240
195
echo "Channel: $CHANNEL"
241
196
echo "Feed: $FEED"
242
197
echo "Wifi: $WIFI"
243
198
echo "Media: $MEDIA"
 
199
echo "Fastboot: $FASTBOOT"
 
200
echo "Recovery: $RECOVERY"
244
201
echo ubuntu-device-flash $SERVER $REVARGS query --channel=$CHANNEL --device $MODEL --show-image
245
202
ubuntu-device-flash $SERVER $REVARGS query --channel=$CHANNEL --device $MODEL --show-image
246
203
 
 
204
# Ask the user to confirm, maybe
247
205
if [ x"$ASK" = x"yes" ]; then
248
206
  echo -n "Press enter to continue, or ^C to exit: "
249
207
  read
250
208
fi
251
209
 
 
210
function rootcmd {
 
211
  adb shell "echo $PASSWD | sudo -S $*"
 
212
}
 
213
 
 
214
# Handle fastboot mode and fastboot recovery mode
252
215
if [ x"$FASTBOOT_RECOVERY" != x ]; then
253
216
  echo 'Rebooting to bootloader/fastboot'
254
217
  adb reboot bootloader
255
218
  sleep 10
256
219
  echo "Flashing recovery image $FASTBOOT_RECOVERY"
257
220
  fastboot flash recovery $FASTBOOT_RECOVERY
258
 
  #echo "Rebooting into fastboot again..."
259
 
  #fastboot reboot-bootloader
260
221
  echo "Rebooting into recovery"
261
222
  fastboot boot $FASTBOOT_RECOVERY
262
223
  sleep 10
265
226
  EXTRA="--bootstrap"
266
227
  echo 'Rebooting to bootloader/fastboot'
267
228
  adb reboot bootloader
268
 
  #adb reboot recovery
269
 
  #adb wait-for-device
270
229
  sleep 10
271
230
fi
272
231
 
273
 
#echo 'entering recovery mode, enabling adb access'
274
 
#adb reboot recovery
275
 
##adb wait-for-device
276
 
#sleep 30
277
 
## FIXME: this is too early; need to touch this *after* flashing
278
 
#adb shell touch /data/.amb_unlock /data/.adb_unlock
279
 
 
280
232
echo 'flashing device'
281
233
echo ubuntu-device-flash $SERVER $REVARGS touch --channel=$CHANNEL --device $MODEL $DEVMODE $RECOVERY --wipe $DEVTAR $EXTRA
282
234
ubuntu-device-flash $SERVER $REVARGS touch --channel=$CHANNEL --device $MODEL $DEVMODE $RECOVERY --wipe $DEVTAR $EXTRA
286
238
echo 'waiting a few seconds for boot'
287
239
sleep 5
288
240
 
 
241
# Try to ensure adb is going to work
 
242
# (may require a human to help)
289
243
if [ x$ADB = xyes ]; then
290
244
  # make sure adb shell works
291
245
  FAILED=no
306
260
  exit 0
307
261
fi
308
262
 
309
 
# Does this actually work?  Can't 'adb shell' but 'adb push' might work?
310
 
#echo 'enabling adb access...  again'
311
 
#adb reboot recovery
312
 
#sleep 30
313
 
#adb shell touch /data/.adb_onlock /data/.adb_unlock
314
 
#adb reboot
315
 
#echo 'waiting for device to boot'
316
 
#adb wait-for-device
317
 
#echo 'waiting a few seconds for boot'
318
 
#sleep 5
319
 
 
 
263
# Override the widget sizes, maybe
320
264
if [ x"$GU" != x  -a  x"$GU" != xyes  -a  x"$GU" != xno ]; then
321
265
  echo 'Setting better GU value'
322
266
  adb shell 'printf "start on starting dbus\nexec initctl set-env --global GRID_UNIT_PX='$GU'\n" > ~/.config/upstart/gu.conf'
323
267
fi
324
268
 
 
269
# Set up wifi!
 
270
# (configure this via phablet-network)
 
271
# (or uncomment the other lines here)
325
272
if [ x"$WIFI" = xyes ]; then
326
273
  echo 'connecting to the network'
327
274
  #WIFINAME=$(grep ^name $HOME/.wifi_auth | cut -d '=' -f 2)
330
277
  phablet-network  # woot, I finally fixed this tool to make it not stupid
331
278
fi
332
279
 
 
280
# Push some media files to play
 
281
# (you'll probably need to configure this manually)
333
282
if [ x"$MEDIA" = xyes ]; then
334
 
  echo 'pushing videos'
335
 
  adb push ~/.cache/mwc/videos.tgz /home/phablet/Videos
336
 
  echo 'extracting videos'
337
 
  adb shell 'cd /home/phablet/Videos && tar xfvz videos.tgz && rm -f videos.tgz && chown phablet.phablet *'
338
283
  echo 'pushing music'
339
 
  #pushd /mnt/shared/music/selene/flat/EvilWezil/Chronophobe/
340
 
  pushd ~/touch/sync/mako/Music/
 
284
  pushd media/music
341
285
  for f in *.mp3 ; do adb push $f /home/phablet/Music ; done
342
286
  popd
343
287
  adb shell 'cd /home/phablet/Music && chown phablet.phablet *'
 
288
 
 
289
  echo 'pushing videos'
 
290
  pushd media/video
 
291
  # FIXME: rewrite this to be more generic
 
292
  #adb push ~/.cache/mwc/videos.tgz /home/phablet/Videos
 
293
  #echo 'extracting videos'
 
294
  #adb shell 'cd /home/phablet/Videos && tar xfvz videos.tgz && rm -f videos.tgz && chown phablet.phablet *'
 
295
  for f in * ; do adb push $f /home/phablet/Videos ; done
 
296
  popd
 
297
  adb shell 'cd /home/phablet/Videos && chown phablet.phablet *'
 
298
 
 
299
  # FIXME: rewrite this to be more generic
344
300
  echo 'pushing pictures'
 
301
  # FIXME: rewrite this to be more generic
345
302
  adb push ~/.cache/torches/torches.tar.gz /home/phablet/Pictures
346
303
  echo 'extracting pictures'
347
304
  adb shell 'cd /home/phablet/Pictures && tar xfvz torches.tar.gz && rm -f torches.tar.gz && chown phablet.phablet * .'
348
305
fi
349
306
 
350
 
echo 'pushing scripts'
351
 
rootcmd mount -o remount,rw /
352
 
for f in $HOME/touch/scripts/* ; do
353
 
  echo $f
354
 
  adb push $f /home/phablet
355
 
done
356
 
rootcmd 'mount -o remount,ro /'
 
307
# Maybe push some extra scripts?
 
308
#echo 'pushing scripts'
 
309
#rootcmd mount -o remount,rw /
 
310
#for f in $HOME/touch/scripts/* ; do
 
311
#  echo $f
 
312
#  adb push $f /home/phablet
 
313
#done
 
314
#rootcmd 'mount -o remount,ro /'
357
315
 
 
316
# Disable the welcome wizard
358
317
if [ x"$WIZARD" = x"no" ]; then
359
318
  echo 'disabling wizard'
360
319
  phablet-config welcome-wizard --disable
362
321
  REBOOT_NEEDED=yes
363
322
fi
364
323
 
 
324
# Disable the edges intro
365
325
if [ x"$EDGEINTRO" = x"no" ]; then
366
326
  echo 'disabling edges intro'
367
327
  phablet-config edges-intro --disable
368
328
  adb wait-for-device
369
329
fi
370
330
 
 
331
# force an apt-get update
 
332
if [ x"$APTUPDATE" = x"yes" ]; then
 
333
  echo 'apt-get update'
 
334
  rootcmd mount -o remount,rw /
 
335
  rootcmd apt-get update
 
336
  rootcmd mount -o remount,ro /
 
337
  REBOOT_NEEDED=yes
 
338
fi
 
339
 
371
340
if [ x"$REBOOT_NEEDED" = x"yes" ]; then
 
341
  echo 'rebooting to activate previous changes'
372
342
  adb reboot
373
343
  adb wait-for-device
374
344
fi
375
345
 
376
 
#echo 'connect your device to the network, then press enter:'
377
 
#read
378
 
#echo 'restoring home'
379
 
#cd sync && ./put.sh $MODEL
380
 
#echo 'rebooting one last time'
381
 
#adb shell reboot
382
 
 
 
346
# All done, beep to notify the user.
383
347
if [ x"$BEEP" = x"yes" ]; then beep ; fi