Merge lp:~sergiusens/phablet-tools/1218270 into lp:phablet-tools

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 216
Merged at revision: 219
Proposed branch: lp:~sergiusens/phablet-tools/1218270
Merge into: lp:phablet-tools
Diff against target: 149 lines (+34/-23)
3 files modified
phabletutils/arguments.py (+11/-6)
phabletutils/environment.py (+1/-1)
phabletutils/projects.py (+22/-16)
To merge this branch: bzr merge lp:~sergiusens/phablet-tools/1218270
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+192927@code.launchpad.net

Commit message

phablet-flash: not formatting data when already on a system image and not doing a bootstrap and removing support from cdimage -> upgradable image backup support. --no-backup is a deprecated option

Description of the change

validated that system-image-cli -i is a good approach with barry to figure out if I'm on a upgradeable image

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
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Tested this by adding some content including an Ubuntu One account, some music and a few photos to a clean phone running trusty-proposed, then reflashed it with this phablet-flash and after flashing my content was still there.

review: Approve
Revision history for this message
Andy Doan (doanac) wrote :

looks good and tested locally

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phabletutils/arguments.py'
2--- phabletutils/arguments.py 2013-10-15 20:02:19 +0000
3+++ phabletutils/arguments.py 2013-10-28 18:50:20 +0000
4@@ -63,6 +63,12 @@
5 setattr(namespace, 'uri', uri)
6
7
8+class DeprecatedBackup(argparse.Action):
9+ def __call__(self, parser, namespace, values, option_string=None):
10+ log.warn('--no-backup is deprecated, use --bootstrap instead')
11+ setattr(namespace, 'bootstrap', True)
12+
13+
14 class RevisionAction(argparse.Action):
15 def __call__(self, parser, namespace, values, option_string=None):
16 log.debug('RevisionAction: %r %r %r' %
17@@ -141,14 +147,13 @@
18 server is %(default)s''')
19 group = parser.add_mutually_exclusive_group()
20 group.add_argument('--no-backup',
21- action='store_false',
22- dest='backup',
23- help='''Disables backup procedure of current the
24- Ubuntu install.''')
25+ action=DeprecatedBackup,
26+ nargs=0,
27+ help='''(Deprecated) Disables backup procedure of
28+ current the Ubuntu install.''')
29 group.add_argument('-b',
30 '--bootstrap',
31- action='store_false',
32- dest='backup',
33+ action='store_true',
34 help='''Bootstraps the system into Ubuntu
35 wiping all data while doing so.''')
36 return parser
37
38=== modified file 'phabletutils/environment.py'
39--- phabletutils/environment.py 2013-10-28 17:13:37 +0000
40+++ phabletutils/environment.py 2013-10-28 18:50:20 +0000
41@@ -185,7 +185,7 @@
42 file_list=files,
43 command_part=command_part,
44 device=device,
45- backup=args.backup)
46+ wipe=args.bootstrap)
47
48
49 def setup_community(args):
50
51=== modified file 'phabletutils/projects.py'
52--- phabletutils/projects.py 2013-10-22 19:13:40 +0000
53+++ phabletutils/projects.py 2013-10-28 18:50:20 +0000
54@@ -20,11 +20,11 @@
55 import os.path
56 import tempfile
57 import logging
58+import subprocess
59 import gzip
60
61 from phabletutils.downloads import checksum_verify
62 from phabletutils.resources import (File, SignedFile)
63-from phabletutils import backup
64 from phabletutils import downloads
65 from phabletutils import fileutils
66 from time import sleep
67@@ -214,16 +214,15 @@
68 class UbuntuTouchSystem(BaseProject):
69
70 ubuntu_recovery_script = dedent('''\
71- format data
72 format system
73 load_keyring image-master.tar.xz image-master.tar.xz.asc
74 load_keyring image-signing.tar.xz image-signing.tar.xz.asc
75 mount system
76 ''')
77
78- def __init__(self, file_list, device, command_part, backup):
79+ def __init__(self, file_list, device, command_part, wipe):
80 log.debug('UbuntuTouchSystem')
81- super(UbuntuTouchSystem, self).__init__(wipe=True)
82+ super(UbuntuTouchSystem, self).__init__(wipe=wipe)
83 for item in file_list:
84 if item and not isinstance(item, File):
85 raise TypeError('%s is not of type File' % item)
86@@ -231,7 +230,6 @@
87 self._list.append(item)
88 self._recovery_list = file_list
89 self._command_part = command_part
90- self._backup = backup
91 self._device = device
92
93 def _is_device_file(self, entry):
94@@ -251,13 +249,22 @@
95 log.debug('Recovery found in %s' % recovery_path)
96 return recovery_path
97
98- def install(self, adb, fastboot=None):
99- """
100- Deploys recovery files, recovery script and then reboots to install.
101- """
102+ def _get_current_version(self, adb):
103 try:
104- backup_file = backup.backup(adb) if self._backup else None
105- except:
106+ image_info = adb.shell('system-image-cli -i',
107+ ignore_errors=False).split('\r\n')
108+ version = [i.split(':')[1].strip() for i in image_info
109+ if 'build number: ' in i][0]
110+ log.debug('Current version on system is %s' % version)
111+ return version
112+ except subprocess.CalledProcessError:
113+ return '0'
114+
115+ def install(self, adb, fastboot=None):
116+ """
117+ Deploys recovery files, recovery script and then reboots to install.
118+ """
119+ if not self._wipe and self._get_current_version(adb) == '0':
120 raise RuntimeError('Backup requested but cannot be completed '
121 'succesfully, try with --no-backup if data '
122 'saving is not important.')
123@@ -266,7 +273,8 @@
124 adb.reboot(bootloader=True)
125 fastboot.boot(recovery_path)
126 adb.wait_for_recovery()
127- wipe_device(adb)
128+ if self._wipe:
129+ wipe_device(adb)
130
131 for entry in self._recovery_list:
132 adb.push(entry.path, '/cache/recovery/')
133@@ -281,14 +289,12 @@
134 fastboot.flash('recovery', recovery_path)
135 fastboot.boot(recovery_path)
136 self._loop_until_installed(adb)
137- if backup_file:
138- log.warning('Restoring from backup')
139- backup.restore(adb, backup_file)
140- os.unlink(backup_file)
141
142 def create_ubuntu_command_file(self):
143 ubuntu_command_file = tempfile.NamedTemporaryFile(delete=False)
144 with ubuntu_command_file as output_file:
145+ if self._wipe:
146+ output_file.write('format data\n')
147 output_file.write(self.ubuntu_recovery_script)
148 output_file.write(self._command_part)
149 output_file.write('unmount system\n')

Subscribers

People subscribed via source and target branches