Merge lp:~sergiusens/phablet-tools/revision-ub into lp:phablet-tools

Proposed by Sergio Schvezov
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 146
Merged at revision: 146
Proposed branch: lp:~sergiusens/phablet-tools/revision-ub
Merge into: lp:phablet-tools
Diff against target: 129 lines (+32/-20)
2 files modified
phablet-flash (+22/-11)
phabletutils/ubuntuimage.py (+10/-9)
To merge this branch: bzr merge lp:~sergiusens/phablet-tools/revision-ub
Reviewer Review Type Date Requested Status
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Ricardo Salveti (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+177656@code.launchpad.net

Commit message

Adding option to ubuntu bootstrap a relative revision and explicitly delete /data/.developer_mode. Cosmetic pep8 fixes as well

Description of the change

To flash the latest ubuntu bootstrap (system image based upgrade) do
phablet-flash --ubuntu-bootstrap

To flash with a revision,
This will flash the latest:
phablet-flash --ubuntu-bootstrap --revision 0

While this will flash the version prior to the latest:
phablet-flash --ubuntu-bootstrap --revision -1

Notice that after flashing you should NOT be in developer mode.

phablet-flash is under a refactor to clean up the latest hacks and support different install options so don't be to focused on where the code is, just that it does the right thing.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Good.

review: Approve
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Works well!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'phablet-flash'
--- phablet-flash 2013-07-19 22:44:08 +0000
+++ phablet-flash 2013-07-30 17:22:25 +0000
@@ -102,7 +102,10 @@
102 required=False,102 required=False,
103 default=None,103 default=None,
104 help='''Choose a specific release to install from 104 help='''Choose a specific release to install from
105 cdimage, the format is [series]/[rev].''',105 cdimage, the format is [series]/[rev].
106 However for ubuntu-bootstrap it's a
107 relative number 0 being latest -1 being
108 the previous version and so on''',
106 )109 )
107 group.add_argument('-l',110 group.add_argument('-l',
108 '--latest-revision',111 '--latest-revision',
@@ -129,12 +132,12 @@
129 required=False,132 required=False,
130 help='Get pending link from cdimage',133 help='Get pending link from cdimage',
131 )134 )
132 group.add_argument('--ubuntu-bootstrap',135 parser.add_argument('--ubuntu-bootstrap',
133 action='store_true',136 action='store_true',
134 required=False,137 required=False,
135 help='''Flash the image based upgrade Ubuntu system.138 help='''Flash the image based upgrade Ubuntu system.
136 This action wipes the system'''139 This action wipes the system'''
137 )140 )
138 return parser.parse_args()141 return parser.parse_args()
139142
140143
@@ -266,7 +269,7 @@
266269
267def wipe_device(adb):270def wipe_device(adb):
268 log.info('Clearing /data and /cache')271 log.info('Clearing /data and /cache')
269 adb.shell('rm -Rf /cache/* /data/*')272 adb.shell('rm -Rf /cache/* /data/* /data/.developer_mode')
270 adb.shell('mkdir /cache/recovery')273 adb.shell('mkdir /cache/recovery')
271 adb.shell('mkdir /data/media')274 adb.shell('mkdir /data/media')
272275
@@ -346,12 +349,12 @@
346349
347350
348@adb_errors351@adb_errors
349def setup_ubuntu_image_update(device):352def setup_ubuntu_image_update(device, revision=-1):
350 '''353 '''
351 Sets up as described in https://wiki.ubuntu.com/ImageBasedUpgrades.354 Sets up as described in https://wiki.ubuntu.com/ImageBasedUpgrades.
352 '''355 '''
353 # This is temporary until more commonality is found.356 # This is temporary until more commonality is found.
354 json_latest = ubuntuimage.get_json_latest_from_index(device)357 json_latest = ubuntuimage.get_json_from_index(device, revision)
355 download_dir = environment.get_download_dir_full_path(358 download_dir = environment.get_download_dir_full_path(
356 os.path.join(settings.download_dir,'imageupdates',359 os.path.join(settings.download_dir,'imageupdates',
357 str(json_latest['version'])))360 str(json_latest['version'])))
@@ -380,6 +383,14 @@
380 if args.legacy and args.pending:383 if args.legacy and args.pending:
381 log.error('Cannot use legacy and pending together')384 log.error('Cannot use legacy and pending together')
382 exit(1)385 exit(1)
386 if args.ubuntu_bootstrap and args.revision:
387 ubuntu_revision = int(args.revision) - 1
388 if ubuntu_revision >= 0:
389 log.error('Revision must be 0 for current or negative number')
390 exit(1)
391 args.revision = None
392 else:
393 ubuntu_revision = -1
383 if args.list_revisions:394 if args.list_revisions:
384 # Easy hack to get rid of the logger and inhibit requests from logging395 # Easy hack to get rid of the logger and inhibit requests from logging
385 log.setLevel(logging.FATAL)396 log.setLevel(logging.FATAL)
@@ -437,7 +448,7 @@
437 if not args.download_only:448 if not args.download_only:
438 if args.ubuntu_bootstrap:449 if args.ubuntu_bootstrap:
439 ubuntu_files, ubuntu_command_path = \450 ubuntu_files, ubuntu_command_path = \
440 setup_ubuntu_image_update(device) 451 setup_ubuntu_image_update(device, ubuntu_revision)
441 deploy_ubuntu_image_update(adb, fastboot, env.recovery_img_path,452 deploy_ubuntu_image_update(adb, fastboot, env.recovery_img_path,
442 ubuntu_files, ubuntu_command_path)453 ubuntu_files, ubuntu_command_path)
443 elif args.bootstrap:454 elif args.bootstrap:
444455
=== modified file 'phabletutils/ubuntuimage.py'
--- phabletutils/ubuntuimage.py 2013-07-19 22:55:09 +0000
+++ phabletutils/ubuntuimage.py 2013-07-30 17:22:25 +0000
@@ -20,16 +20,17 @@
20from phabletutils import downloads20from phabletutils import downloads
21from phabletutils import settings21from phabletutils import settings
2222
23def get_json_latest_from_index(device):23
24def get_json_from_index(device, index=-1):
24 """Returns json index for device"""25 """Returns json index for device"""
25 json_index_uri = '%s/daily/%s/index.json' % \26 json_index_uri = '%s/daily/%s/index.json' % \
26 (settings.system_image_uri, device)27 (settings.system_image_uri, device)
27 json_index_request = requests.get(json_index_uri)28 json_index_request = requests.get(json_index_uri)
28 json_index = json.loads(json_index_request.content)29 json_index = json.loads(json_index_request.content)
29 latest = sorted([entry for entry in json_index['images']30 version_data = sorted([entry for entry in json_index['images']
30 if entry['type'] == "full"],31 if entry['type'] == "full"],
31 key=lambda entry: entry['version'])[-1]32 key=lambda entry: entry['version'])[index]
32 return latest33 return version_data
3334
3435
35def download_images(download_dir, json_list):36def download_images(download_dir, json_list):
@@ -44,8 +45,8 @@
44 signame_uri = '%s/%s' % (settings.system_image_uri, entry['signature'])45 signame_uri = '%s/%s' % (settings.system_image_uri, entry['signature'])
45 downloads.download(filename_uri, filename_path)46 downloads.download(filename_uri, filename_path)
46 downloads.download(signame_uri, signame_path)47 downloads.download(signame_uri, signame_path)
47 files['updates'].append({'filename': filename_path, 48 files['updates'].append({'filename': filename_path,
48 'signame': signame_path})49 'signame': signame_path})
49 files['base'] = []50 files['base'] = []
50 for keyring in ('image-master', 'image-signing'):51 for keyring in ('image-master', 'image-signing'):
51 filename = '%s.tar.xz' % keyring52 filename = '%s.tar.xz' % keyring
@@ -56,6 +57,6 @@
56 signame_uri = '%s.asc' % filename_uri57 signame_uri = '%s.asc' % filename_uri
57 downloads.download(filename_uri, filename_path)58 downloads.download(filename_uri, filename_path)
58 downloads.download(signame_uri, signame_path)59 downloads.download(signame_uri, signame_path)
59 files['base'].append({'filename': filename_path, 60 files['base'].append({'filename': filename_path,
60 'signame': signame_path})61 'signame': signame_path})
61 return files62 return files

Subscribers

People subscribed via source and target branches