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
1=== modified file 'phablet-flash'
2--- phablet-flash 2013-07-19 22:44:08 +0000
3+++ phablet-flash 2013-07-30 17:22:25 +0000
4@@ -102,7 +102,10 @@
5 required=False,
6 default=None,
7 help='''Choose a specific release to install from
8- cdimage, the format is [series]/[rev].''',
9+ cdimage, the format is [series]/[rev].
10+ However for ubuntu-bootstrap it's a
11+ relative number 0 being latest -1 being
12+ the previous version and so on''',
13 )
14 group.add_argument('-l',
15 '--latest-revision',
16@@ -129,12 +132,12 @@
17 required=False,
18 help='Get pending link from cdimage',
19 )
20- group.add_argument('--ubuntu-bootstrap',
21- action='store_true',
22- required=False,
23- help='''Flash the image based upgrade Ubuntu system.
24- This action wipes the system'''
25- )
26+ parser.add_argument('--ubuntu-bootstrap',
27+ action='store_true',
28+ required=False,
29+ help='''Flash the image based upgrade Ubuntu system.
30+ This action wipes the system'''
31+ )
32 return parser.parse_args()
33
34
35@@ -266,7 +269,7 @@
36
37 def wipe_device(adb):
38 log.info('Clearing /data and /cache')
39- adb.shell('rm -Rf /cache/* /data/*')
40+ adb.shell('rm -Rf /cache/* /data/* /data/.developer_mode')
41 adb.shell('mkdir /cache/recovery')
42 adb.shell('mkdir /data/media')
43
44@@ -346,12 +349,12 @@
45
46
47 @adb_errors
48-def setup_ubuntu_image_update(device):
49+def setup_ubuntu_image_update(device, revision=-1):
50 '''
51 Sets up as described in https://wiki.ubuntu.com/ImageBasedUpgrades.
52 '''
53 # This is temporary until more commonality is found.
54- json_latest = ubuntuimage.get_json_latest_from_index(device)
55+ json_latest = ubuntuimage.get_json_from_index(device, revision)
56 download_dir = environment.get_download_dir_full_path(
57 os.path.join(settings.download_dir,'imageupdates',
58 str(json_latest['version'])))
59@@ -380,6 +383,14 @@
60 if args.legacy and args.pending:
61 log.error('Cannot use legacy and pending together')
62 exit(1)
63+ if args.ubuntu_bootstrap and args.revision:
64+ ubuntu_revision = int(args.revision) - 1
65+ if ubuntu_revision >= 0:
66+ log.error('Revision must be 0 for current or negative number')
67+ exit(1)
68+ args.revision = None
69+ else:
70+ ubuntu_revision = -1
71 if args.list_revisions:
72 # Easy hack to get rid of the logger and inhibit requests from logging
73 log.setLevel(logging.FATAL)
74@@ -437,7 +448,7 @@
75 if not args.download_only:
76 if args.ubuntu_bootstrap:
77 ubuntu_files, ubuntu_command_path = \
78- setup_ubuntu_image_update(device)
79+ setup_ubuntu_image_update(device, ubuntu_revision)
80 deploy_ubuntu_image_update(adb, fastboot, env.recovery_img_path,
81 ubuntu_files, ubuntu_command_path)
82 elif args.bootstrap:
83
84=== modified file 'phabletutils/ubuntuimage.py'
85--- phabletutils/ubuntuimage.py 2013-07-19 22:55:09 +0000
86+++ phabletutils/ubuntuimage.py 2013-07-30 17:22:25 +0000
87@@ -20,16 +20,17 @@
88 from phabletutils import downloads
89 from phabletutils import settings
90
91-def get_json_latest_from_index(device):
92+
93+def get_json_from_index(device, index=-1):
94 """Returns json index for device"""
95 json_index_uri = '%s/daily/%s/index.json' % \
96 (settings.system_image_uri, device)
97 json_index_request = requests.get(json_index_uri)
98 json_index = json.loads(json_index_request.content)
99- latest = sorted([entry for entry in json_index['images']
100- if entry['type'] == "full"],
101- key=lambda entry: entry['version'])[-1]
102- return latest
103+ version_data = sorted([entry for entry in json_index['images']
104+ if entry['type'] == "full"],
105+ key=lambda entry: entry['version'])[index]
106+ return version_data
107
108
109 def download_images(download_dir, json_list):
110@@ -44,8 +45,8 @@
111 signame_uri = '%s/%s' % (settings.system_image_uri, entry['signature'])
112 downloads.download(filename_uri, filename_path)
113 downloads.download(signame_uri, signame_path)
114- files['updates'].append({'filename': filename_path,
115- 'signame': signame_path})
116+ files['updates'].append({'filename': filename_path,
117+ 'signame': signame_path})
118 files['base'] = []
119 for keyring in ('image-master', 'image-signing'):
120 filename = '%s.tar.xz' % keyring
121@@ -56,6 +57,6 @@
122 signame_uri = '%s.asc' % filename_uri
123 downloads.download(filename_uri, filename_path)
124 downloads.download(signame_uri, signame_path)
125- files['base'].append({'filename': filename_path,
126- 'signame': signame_path})
127+ files['base'].append({'filename': filename_path,
128+ 'signame': signame_path})
129 return files

Subscribers

People subscribed via source and target branches