Merge ~raharper/curtin:fix/support-txz-tbz into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: c155457d3904223ae085814d14e0e8f868b87f7f
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/curtin:fix/support-txz-tbz
Merge into: curtin:master
Diff against target: 62 lines (+40/-2)
2 files modified
curtin/util.py (+3/-2)
tests/unittests/test_util.py (+37/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Scott Moser (community) Approve
Review via email: mp+372501@code.launchpad.net

Commit message

util: add support for 'tbz', 'txz' tar format types to sanitize_source

Curtin already supports tar.bz[2] and tar.xz via the helpers/smtar
tool but is missing the short-hand used in santize_sources to convert
a source URI into a source dictionary. This branch adds the two types
and adds unittest.

LP: #1843266

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) :
review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/util.py b/curtin/util.py
2index ebe219d..88426e6 100644
3--- a/curtin/util.py
4+++ b/curtin/util.py
5@@ -906,8 +906,9 @@ def sanitize_source(source):
6 if type(source) is dict:
7 # already sanitized?
8 return source
9- supported = ['tgz', 'dd-tgz', 'dd-tbz', 'dd-txz', 'dd-tar', 'dd-bz2',
10- 'dd-gz', 'dd-xz', 'dd-raw', 'fsimage', 'fsimage-layered']
11+ supported = ['tgz', 'dd-tgz', 'tbz', 'dd-tbz', 'txz', 'dd-txz', 'dd-tar',
12+ 'dd-bz2', 'dd-gz', 'dd-xz', 'dd-raw', 'fsimage',
13+ 'fsimage-layered']
14 deftype = 'tgz'
15 for i in supported:
16 prefix = i + ":"
17diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
18index d14a5f8..1339f5c 100644
19--- a/tests/unittests/test_util.py
20+++ b/tests/unittests/test_util.py
21@@ -1095,4 +1095,41 @@ class TestLoadKernelModule(CiTestCase):
22 self.assertEqual(0, self.m_subp.call_count)
23
24
25+class TestSanitizeSource(CiTestCase):
26+
27+ # copied from curtin.util.sanitize_source
28+ supported = ['tgz', 'dd-tgz', 'tbz', 'dd-tbz', 'txz', 'dd-txz', 'dd-tar',
29+ 'dd-bz2', 'dd-gz', 'dd-xz', 'dd-raw', 'fsimage',
30+ 'fsimage-layered']
31+ source_url = 'http://curtin.io/root-fs.foo'
32+
33+ def test_supported_sources(self):
34+ """ Verify supported sources types return expected dictionary. """
35+ for stype in self.supported:
36+ expected = {'type': stype, 'uri': self.source_url}
37+ result = util.sanitize_source("%s:%s" % (stype, self.source_url))
38+ self.assertEqual(expected, result)
39+
40+ def test_supported_squashfs_source_type(self):
41+ """ Verify squashfs: prefix returns type=fsimage and correct uri."""
42+ stype = 'fsimage'
43+ expected = {'type': stype, 'uri': self.source_url}
44+ result = util.sanitize_source("%s:%s" % (stype, self.source_url))
45+ self.assertEqual(expected, result)
46+
47+ def test_supported_squashfs_suffix(self):
48+ """ Verify .squash[fs] suffix returns type=fsimage and correct uri."""
49+ for suff in ['squash', 'squashfs']:
50+ source_url = "%s.%s" % (self.source_url, suff)
51+ expected = {'type': 'fsimage', 'uri': source_url}
52+ result = util.sanitize_source(source_url)
53+ self.assertEqual(expected, result)
54+
55+ def test_unknown_type_assumed_to_be_tgz(self):
56+ """ Verify unknown source type returns default type. """
57+ expected = {'type': 'tgz', 'uri': self.source_url}
58+ result = util.sanitize_source(self.source_url)
59+ self.assertEqual(expected, result)
60+
61+
62 # vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches