~doanac/phablet-tools/rndis

« back to all changes in this revision

Viewing changes to phablet-flash

  • Committer: Tarmac
  • Author(s): Sergio Schvezov
  • Date: 2013-07-18 14:38:23 UTC
  • mfrom: (131.2.3 trunk)
  • Revision ID: tarmac-20130718143823-23e0mgvny1gehyik
Removing fastboot -w and adding manual cleanups in adb for recovery zips with a new --wipe option, bootstrap uses this safe wipe mechanism as well. Fixes: https://bugs.launchpad.net/bugs/1185074.

Approved by Alan Pope ㋛, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
                               if target device is not connected.''',
76
76
                       action='store_true',
77
77
                      )
 
78
    parser.add_argument('--wipe',
 
79
                       help='''Cleans up all data.''',
 
80
                       action='store_true',
 
81
                      )
78
82
    parser.add_argument('--legacy',
79
83
                       action='store_true',
80
84
                       default=False,
194
198
 
195
199
@adb_errors
196
200
def create_recovery_file(adb, device_img, ubuntu_file):
 
201
    template = settings.recovery_script_template
197
202
    # Setup recovery rules
198
203
    recovery_file = tempfile.NamedTemporaryFile(delete=False)
199
204
    # Find out version
204
209
    else:
205
210
        log.info('Updating from non multi user setup')
206
211
        sdcard_path = '/sdcard'
207
 
    recovery_script = settings.recovery_script_template.format(
 
212
    recovery_script = template.format(
208
213
        sdcard_path,
209
214
        path.basename(device_img),
210
215
        path.basename(ubuntu_file))
221
226
        return
222
227
    # Can't wait-for-device here
223
228
    sleep(15)
 
229
    wipe_device(adb)
224
230
    adb.push(artifact, '/sdcard/autodeploy.zip')
225
231
    log.info('Deploying Ubuntu')
226
232
    adb.reboot(recovery=True)
239
245
    return target_path
240
246
        
241
247
 
 
248
def wipe_device(adb):
 
249
    log.info('Clearing /data and /cache')
 
250
    adb.shell('rm -Rf /cache/* /data/*')
 
251
    adb.shell('mkdir /cache/recovery')
 
252
    adb.shell('mkdir /data/media')
 
253
 
 
254
 
242
255
@adb_errors
243
 
def deploy_recovery_image(adb, device_zip, ubuntu_zip, recovery_file):
 
256
def deploy_recovery_image(adb, device_zip, ubuntu_zip, recovery_file,
 
257
                          wipe=False):
244
258
    ''''
245
259
    Deploys recovery files, recovery script and then reboots to install.
246
260
    '''
 
261
    if wipe:
 
262
        wipe_device(adb)
247
263
    adb.push(device_zip, '/sdcard/')
248
264
    adb.push(ubuntu_zip, '/sdcard/')
249
265
    adb.push(recovery_file, '/cache/recovery/command')
283
299
    fastboot.flash('boot', boot_img)
284
300
    if recovery_img:
285
301
        fastboot.flash('recovery', recovery_img)
286
 
        fastboot.wipe()
287
302
        fastboot.boot(recovery_img)
288
303
    else:
289
304
        log.info('Successfully flashed, now rebooting device')
381
396
            recovery_file = create_recovery_file(adb, 
382
397
                env.device_zip_path, env.ubuntu_zip_path)
383
398
            deploy_recovery_image(adb, env.device_zip_path,
384
 
                env.ubuntu_zip_path, recovery_file)
 
399
                env.ubuntu_zip_path, recovery_file, args.wipe)
385
400
 
386
401
 
387
402
def import_alt_settings(alternate_settings):