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

Proposed by Sergio Schvezov
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 167
Merged at revision: 166
Proposed branch: lp:~sergiusens/phablet-tools/1211956
Merge into: lp:phablet-tools
Diff against target: 146 lines (+71/-9)
4 files modified
phabletutils/cdimage.py (+10/-4)
phabletutils/environment.py (+1/-1)
phabletutils/fileutils.py (+50/-0)
phabletutils/ubuntuimage.py (+10/-4)
To merge this branch: bzr merge lp:~sergiusens/phablet-tools/1211956
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Chris Johnston (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+181644@code.launchpad.net

Commit message

Separating Ubuntu Image Based Upgrade downloads into specific device download directories

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~sergiusens/phablet-tools/1211956 updated
167. By Sergio Schvezov

Using a clear namespace separation for each download based on the server indexes.

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

Looks good. Thanks!

review: Approve
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks fine, tested and worked as expected.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phabletutils/cdimage.py'
2--- phabletutils/cdimage.py 2013-08-05 18:15:30 +0000
3+++ phabletutils/cdimage.py 2013-08-22 22:26:28 +0000
4@@ -22,6 +22,7 @@
5 import urlparse
6
7 from phabletutils import hashes
8+from phabletutils import fileutils
9 from phabletutils import resources
10 from phabletutils import settings
11
12@@ -122,15 +123,20 @@
13
14 def get_file(file_key, series, download_dir, project='ubuntu-touch',
15 device=None):
16- uri = '%s/%s/daily-preinstalled/current' % (
17- settings.cdimage_uri_base, project)
18- hash_dict = hashes.load_hash(uri, 'SHA256SUMS')
19+ uri = '%s/%s/daily-preinstalled' % (settings.cdimage_uri_base, project)
20+ build = get_build(uri)
21+ hash_dict = hashes.load_hash('%s/%s' % (uri, build), 'SHA256SUMS')
22 if device:
23 file_name = settings.files_arch_any[project][file_key] %\
24 (series, device)
25+ download_dir = fileutils.create_path(
26+ download_dir, os.path.join(device, build))
27 else:
28 file_name = settings.files_arch_all[project][file_key] % series
29+ download_dir = fileutils.create_path(
30+ download_dir, build)
31+ log.debug('Download dir for %s set to %s' % (file_name, download_dir))
32 return resources.File(
33 file_path=os.path.join(download_dir, file_name),
34- file_uri='%s/%s' % (uri, file_name),
35+ file_uri='%s/%s/%s' % (uri, build, file_name),
36 file_hash=hash_dict[file_name])
37
38=== modified file 'phabletutils/environment.py'
39--- phabletutils/environment.py 2013-08-15 15:33:44 +0000
40+++ phabletutils/environment.py 2013-08-22 22:26:28 +0000
41@@ -204,7 +204,7 @@
42 else:
43 raise EnvironmentError('Specific version retrieve not supported yet')
44 download_dir = downloads.get_full_path(os.path.join(
45- settings.download_dir, args.project, str(json['version'])))
46+ settings.download_dir, args.project))
47 uri = settings.system_image_uri
48 files, command_part = ubuntuimage.get_files(download_dir, uri, json)
49 recovery = cdimage.get_file(file_key='recovery_img',
50
51=== added file 'phabletutils/fileutils.py'
52--- phabletutils/fileutils.py 1970-01-01 00:00:00 +0000
53+++ phabletutils/fileutils.py 2013-08-22 22:26:28 +0000
54@@ -0,0 +1,50 @@
55+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
56+# Copyright (C) 2013 Canonical Ltd.
57+# Author: Sergio Schvezov <sergio.schvezov@canonical.com>
58+
59+# This program is free software: you can redistribute it and/or modify
60+# it under the terms of the GNU General Public License as published by
61+# the Free Software Foundation; version 3 of the License.
62+#
63+# This program is distributed in the hope that it will be useful,
64+# but WITHOUT ANY WARRANTY; without even the implied warranty of
65+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66+# GNU General Public License for more details.
67+#
68+# You should have received a copy of the GNU General Public License
69+# along with this program. If not, see <http://www.gnu.org/licenses/>.
70+
71+import atexit
72+import logging
73+import os.path
74+import shutil
75+import tempfile
76+
77+
78+log = logging.getLogger()
79+
80+
81+def cleanup(directory):
82+ if os.path.exists(directory) and os.path.isdir(directory):
83+ print('Removing directory %s' % directory)
84+ shutil.rmtree(directory)
85+
86+
87+def create_temp_dir():
88+ directory = tempfile.mkdtemp()
89+ atexit.register(cleanup, directory)
90+ return directory
91+
92+
93+def create_path(directory, subdir):
94+ directory = os.path.join(directory, subdir)
95+ if not os.path.exists(directory):
96+ log.debug('Creating directory %s' % directory)
97+ try:
98+ os.makedirs(directory)
99+ except OSError as e:
100+ if e.errno == 17:
101+ pass
102+ else:
103+ raise e
104+ return directory
105
106=== modified file 'phabletutils/ubuntuimage.py'
107--- phabletutils/ubuntuimage.py 2013-08-14 05:57:43 +0000
108+++ phabletutils/ubuntuimage.py 2013-08-22 22:26:28 +0000
109@@ -18,6 +18,7 @@
110 import os.path
111
112 from phabletutils import downloads
113+from phabletutils import fileutils
114 from phabletutils import resources
115 from phabletutils import settings
116
117@@ -44,20 +45,25 @@
118 for entry in sorted(json['files'], key=lambda entry: entry['order']):
119 filename = entry['path'].split("/")[-1]
120 signame = entry['signature'].split("/")[-1]
121+ paths = {}
122+ for path in ('path', 'signature'):
123+ paths[path] = fileutils.create_path(
124+ download_dir, os.path.dirname(entry[path].strip(os.path.sep)))
125 f = resources.SignedFile(
126- file_path=os.path.join(download_dir, filename),
127- sig_path=os.path.join(download_dir, signame),
128+ file_path=os.path.join(paths['path'], filename),
129+ sig_path=os.path.join(paths['signature'], signame),
130 file_uri='%s%s' % (uri, entry['path']),
131 sig_uri='%s%s' % (uri, entry['signature']),
132 file_hash=entry['checksum'])
133 files.append(f)
134 command_part += 'update %s %s\n' % (filename, signame)
135+ gpg_download_dir = fileutils.create_temp_dir()
136 for keyring in ('image-master', 'image-signing'):
137 filename = '%s.tar.xz' % keyring
138 signame = '%s.asc' % filename
139 f = resources.SignedFile(
140- file_path=os.path.join(download_dir, filename),
141- sig_path=os.path.join(download_dir, signame),
142+ file_path=os.path.join(gpg_download_dir, filename),
143+ sig_path=os.path.join(gpg_download_dir, signame),
144 file_uri='%s/gpg/%s' % (uri, filename),
145 sig_uri='%s/gpg/%s.asc' % (uri, filename),
146 file_hash=None)

Subscribers

People subscribed via source and target branches