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

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 178
Merged at revision: 177
Proposed branch: lp:~sergiusens/phablet-tools/recovery_from_system_images
Merge into: lp:phablet-tools
Diff against target: 107 lines (+27/-5)
4 files modified
debian/control (+1/-0)
phabletutils/environment.py (+1/-1)
phabletutils/fileutils.py (+12/-0)
phabletutils/projects.py (+13/-4)
To merge this branch: bzr merge lp:~sergiusens/phablet-tools/recovery_from_system_images
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Stéphane Graber Approve
Review via email: mp+183868@code.launchpad.net

Commit message

Using device file from system image server to extract recovery instead of downloading the latest from cdimage.

Description of the change

Keep in mind that by accepting this, you are marking partitions/recovery.img as a stable interface.

I can add some magic to finding and extracting the right file, but this may as well be stable.

To post a comment you must log in.
Revision history for this message
Stéphane Graber (stgraber) wrote :

Assuming this was tested, the code change looks good.

Note that in python3 python-tarfile supports opening xz-compressed files directly ("r:xz" mode) but I had reliability problems when doing that as part of the server work, so using lzma + uncompressed tarfile is probably safest at this point.

Revision history for this message
Stéphane Graber (stgraber) wrote :

Oh, the above comment was meant to be an ack.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2013-08-20 20:45:44 +0000
+++ debian/control 2013-09-04 12:58:37 +0000
@@ -5,6 +5,7 @@
5Build-Depends: debhelper (>= 9.0.0),5Build-Depends: debhelper (>= 9.0.0),
6 python (>= 2.7),6 python (>= 2.7),
7 python-configobj,7 python-configobj,
8 python-lzma,
8 python-mock,9 python-mock,
9 python-requests,10 python-requests,
10 python-setuptools,11 python-setuptools,
1112
=== modified file 'phabletutils/environment.py'
--- phabletutils/environment.py 2013-08-28 14:17:46 +0000
+++ phabletutils/environment.py 2013-09-04 12:58:37 +0000
@@ -216,7 +216,7 @@
216 return projects.UbuntuTouchSystem(216 return projects.UbuntuTouchSystem(
217 file_list=files,217 file_list=files,
218 command_part=command_part,218 command_part=command_part,
219 recovery=recovery,219 device=device,
220 backup=args.backup)220 backup=args.backup)
221221
222222
223223
=== modified file 'phabletutils/fileutils.py'
--- phabletutils/fileutils.py 2013-08-22 22:25:37 +0000
+++ phabletutils/fileutils.py 2013-09-04 12:58:37 +0000
@@ -15,9 +15,12 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import atexit17import atexit
18import contextlib
18import logging19import logging
20import lzma
19import os.path21import os.path
20import shutil22import shutil
23import tarfile
21import tempfile24import tempfile
2225
2326
@@ -48,3 +51,12 @@
48 else:51 else:
49 raise e52 raise e
50 return directory53 return directory
54
55
56def lzma_extract_file(lzma_tarfile, file_name):
57 log.info('Decompressing %s from %s' % (file_name, lzma_tarfile))
58 temp_dir = create_temp_dir()
59 with contextlib.closing(lzma.LZMAFile(lzma_tarfile)) as xz:
60 with tarfile.open(fileobj=xz) as tar:
61 tar.extract(member=file_name, path=temp_dir)
62 return os.path.join(temp_dir, file_name)
5163
=== modified file 'phabletutils/projects.py'
--- phabletutils/projects.py 2013-08-24 12:18:07 +0000
+++ phabletutils/projects.py 2013-09-04 12:58:37 +0000
@@ -26,6 +26,7 @@
26from phabletutils.resources import (File, SignedFile)26from phabletutils.resources import (File, SignedFile)
27from phabletutils import backup27from phabletutils import backup
28from phabletutils import downloads28from phabletutils import downloads
29from phabletutils import fileutils
29from time import sleep30from time import sleep
30from textwrap import dedent31from textwrap import dedent
3132
@@ -218,9 +219,9 @@
218 mount system219 mount system
219 ''')220 ''')
220221
221 def __init__(self, file_list, recovery, command_part, backup):222 def __init__(self, file_list, device, command_part, backup):
222 log.debug('UbuntuTouchSystem')223 log.debug('UbuntuTouchSystem')
223 super(UbuntuTouchSystem, self).__init__(recovery=recovery, wipe=True)224 super(UbuntuTouchSystem, self).__init__(wipe=True)
224 for item in file_list:225 for item in file_list:
225 if item and not isinstance(item, File):226 if item and not isinstance(item, File):
226 raise TypeError('%s is not of type File' % item)227 raise TypeError('%s is not of type File' % item)
@@ -229,6 +230,11 @@
229 self._recovery_list = file_list230 self._recovery_list = file_list
230 self._command_part = command_part231 self._command_part = command_part
231 self._backup = backup232 self._backup = backup
233 self._device = device
234
235 def _is_device_file(self, entry):
236 f = os.path.basename(entry.path)
237 return f.startswith(self._device) and f.endswith('.xz')
232238
233 def install(self, adb, fastboot=None):239 def install(self, adb, fastboot=None):
234 """240 """
@@ -250,11 +256,14 @@
250 adb.push(entry.sig_path, '/cache/recovery/')256 adb.push(entry.sig_path, '/cache/recovery/')
251 except AttributeError:257 except AttributeError:
252 pass258 pass
259 if self._is_device_file(entry):
260 recovery_path = fileutils.lzma_extract_file(
261 entry.path, 'partitions/recovery.img')
253 adb.push(self.create_ubuntu_command_file(),262 adb.push(self.create_ubuntu_command_file(),
254 '/cache/recovery/ubuntu_command')263 '/cache/recovery/ubuntu_command')
255 adb.reboot(bootloader=True)264 adb.reboot(bootloader=True)
256 fastboot.flash('recovery', self._recovery.path)265 fastboot.flash('recovery', recovery_path)
257 fastboot.boot(self._recovery.path)266 fastboot.boot(recovery_path)
258 self._loop_until_installed(adb)267 self._loop_until_installed(adb)
259 if backup_file:268 if backup_file:
260 log.warning('Restoring from backup')269 log.warning('Restoring from backup')

Subscribers

People subscribed via source and target branches