def test_prime_without_architectures_records_current_arch(self):
        """Test the recorded manifest for a basic snap

        This snap doesn't have stage or build packages and it is not declared
        that it works on all architectures, which makes it specific to the
        current architecture.
        """
        self.run_snapcraft('prime', project_dir='basic-without-arch')

        recorded_yaml_path = os.path.join(
            self.prime_dir, 'snap', 'manifest.yaml')
        with open(recorded_yaml_path) as recorded_yaml_file:
            recorded_yaml = yaml.load(recorded_yaml_file)

        self.assertThat(
            recorded_yaml['architectures'],
            Equals([snapcraft.ProjectOptions().deb_arch]))
Exemple #2
0
    def setUp(self):
        super().setUp()

        patcher = mock.patch.dict(os.environ, {})
        self.env_mock = patcher.start()
        self.addCleanup(patcher.stop)

        class Options:
            makefile = None
            make_parameters = []
            rust_features = []
            rust_revision = ''
            rust_channel = ''
            source_subdir = ''

        self.options = Options()
        self.project_options = snapcraft.ProjectOptions()
Exemple #3
0
    def test_kernel_image_target_non_existent(self):
        class Options:
            build_parameters = []
            kconfigfile = None
            kdefconfig = []
            kconfigs = []
            kernel_with_firmware = True
            kernel_initrd_modules = []
            kernel_initrd_firmware = []
            kernel_device_trees = []
            kernel_initrd_compression = 'gz'

        project_options = snapcraft.ProjectOptions(target_deb_arch='arm64')
        plugin = kernel.KernelPlugin('test-part', self.options,
                                     project_options)

        self.assertEqual(plugin.make_targets, ['bzImage', 'modules'])
Exemple #4
0
    def setUp(self):
        super().setUp()

        class Options:
            build_parameters = []
            kconfigfile = None
            kconfigflavour = None
            kdefconfig = []
            kconfigs = []
            kernel_image_target = "bzImage"
            kernel_with_firmware = True
            kernel_initrd_modules = []
            kernel_initrd_firmware = []
            kernel_device_trees = []
            kernel_initrd_compression = "gz"
            build_attributes = []

        self.options = Options()
        self.project_options = snapcraft.ProjectOptions()

        patcher = mock.patch("subprocess.check_call")
        self.check_call_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch.object(kernel.KernelPlugin, "run")
        self.run_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch.object(kernel.KernelPlugin, "run_output")
        self.run_output_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch("snapcraft.BasePlugin.build")
        self.base_build_mock = patcher.start()
        self.addCleanup(patcher.stop)

        @contextlib.contextmanager
        def tempdir():
            self.tempdir = "temporary-directory"
            os.mkdir(self.tempdir)
            yield self.tempdir

        patcher = mock.patch("tempfile.TemporaryDirectory")
        self.tempdir_mock = patcher.start()
        self.tempdir_mock.side_effect = tempdir
        self.addCleanup(patcher.stop)
Exemple #5
0
    def test_enable_cross_compilation(self):
        project_options = snapcraft.ProjectOptions(target_deb_arch="arm64")
        plugin = kernel.KernelPlugin("test-part", self.options,
                                     project_options)
        plugin.enable_cross_compilation()

        self.assertThat(
            plugin.make_cmd,
            Equals([
                "make",
                "-j2",
                "ARCH=arm64",
                "CROSS_COMPILE=aarch64-linux-gnu-",
                "PATH={}:/usr/{}/bin".format(os.environ.copy().get("PATH", ""),
                                             "aarch64-linux-gnu"),
            ]),
        )
Exemple #6
0
    def test_get_package_trusted_parts_already_imported(
            self, mock_apt_pkg, mock_fetch_binary):
        fake_package_path = os.path.join(self.path, "fake-package.deb")
        open(fake_package_path, "w").close()
        mock_fetch_binary.return_value = fake_package_path
        self.mock_cache().is_virtual_package.return_value = False

        def _fake_find_file(key: str):
            if key == "Dir::Etc::TrustedParts":
                return os.path.join(ubuntu._cache.base_dir, "trusted")
            else:
                return DEFAULT

        mock_apt_pkg.config.find_file.side_effect = _fake_find_file

        project_options = snapcraft.ProjectOptions()
        ubuntu = repo.Ubuntu(self.tempdir, project_options=project_options)
        ubuntu.get(["fake-package"])

        mock_apt_pkg.assert_has_calls([
            call.config.set("Apt::Install-Recommends", "False"),
            call.config.set("Acquire::AllowInsecureRepositories", "False"),
            call.config.find_file("Dir::Etc::Trusted"),
            call.config.set("Dir::Etc::Trusted", ANY),
            call.config.find_file("Dir::Etc::TrustedParts"),
            call.config.clear("APT::Update::Post-Invoke-Success"),
        ])

        self.mock_cache.assert_has_calls([
            call(memonly=True, rootdir=ANY),
            call().update(fetch_progress=ANY, sources_list=ANY),
            call().open(),
        ])

        # __getitem__ is tricky
        self.assertThat(
            self.mock_cache.return_value.__getitem__.call_args_list,
            Contains(call("fake-package")),
        )

        # Verify that the package was actually fetched and copied into the
        # requested location.
        self.assertThat(
            os.path.join(self.tempdir, "download", "fake-package.deb"),
            FileExists())
Exemple #7
0
    def load_part(self,
                  part_name,
                  plugin_name=None,
                  part_properties=None,
                  project_options=None,
                  stage_packages_repo=None,
                  confinement='strict'):
        if not plugin_name:
            plugin_name = 'nil'
        properties = {'plugin': plugin_name}
        if part_properties:
            properties.update(part_properties)
        if not project_options:
            project_options = snapcraft.ProjectOptions()

        validator = snapcraft.internal.project_loader.Validator()
        schema = validator.part_schema
        definitions_schema = validator.definitions_schema
        plugin = snapcraft.internal.pluginhandler.load_plugin(
            part_name=part_name,
            plugin_name=plugin_name,
            properties=properties,
            project_options=project_options,
            part_schema=schema,
            definitions_schema=definitions_schema)

        if not stage_packages_repo:
            stage_packages_repo = mock.Mock()
        grammar_processor = grammar_processing.PartGrammarProcessor(
            plugin=plugin,
            properties=properties,
            project_options=project_options,
            repo=stage_packages_repo)

        return snapcraft.internal.pluginhandler.PluginHandler(
            plugin=plugin,
            part_properties=properties,
            project_options=project_options,
            part_schema=schema,
            definitions_schema=definitions_schema,
            grammar_processor=grammar_processor,
            stage_packages_repo=stage_packages_repo,
            snap_base_path='/snap/fake-name/current',
            confinement=confinement,
            soname_cache=elf.SonameCache())
Exemple #8
0
    def setUp(self):
        super().setUp()

        class Options:
            configflags = []
            install_via = 'destdir'
            disable_parallel = False
            makefile = None
            make_parameters = []
            make_install_var = 'DESTDIR'
            artifacts = []

        self.options = Options()
        self.project_options = snapcraft.ProjectOptions()

        patcher = mock.patch('snapcraft.repo.Ubuntu')
        self.ubuntu_mock = patcher.start()
        self.addCleanup(patcher.stop)
Exemple #9
0
    def setUp(self):
        super().setUp()

        class Options:
            gradle_options = []
            gradle_output_dir = 'build/libs'

        self.options = Options()

        self.project_options = snapcraft.ProjectOptions()

        patcher = mock.patch('snapcraft.repo.Ubuntu')
        self.ubuntu_mock = patcher.start()
        self.addCleanup(patcher.stop)

        # unset http and https proxies.
        self.useFixture(fixtures.EnvironmentVariable('http_proxy', None))
        self.useFixture(fixtures.EnvironmentVariable('https_proxy', None))
Exemple #10
0
    def setUp(self):
        super().setUp()
        self.project = snapcraft.ProjectOptions()

        self.rosdep = rosdep.Rosdep(ros_distro='kinetic',
                                    ros_package_path='package_path',
                                    rosdep_path='rosdep_path',
                                    ubuntu_distro='xenial',
                                    ubuntu_sources='sources',
                                    project=self.project)

        patcher = mock.patch('snapcraft.repo.Ubuntu')
        self.ubuntu_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('subprocess.check_output')
        self.check_output_mock = patcher.start()
        self.addCleanup(patcher.stop)
Exemple #11
0
    def test_config_adds_extra_build_tools_when_cross_compiling(self):
        with unittest.mock.patch('platform.machine') as machine_mock:
            machine_mock.return_value = 'x86_64'
            project_options = snapcraft.ProjectOptions(target_deb_arch='armhf')

        yaml = """name: test
version: "1"
summary: test
description: test

parts:
  part1:
    plugin: nil
"""
        self.make_snapcraft_yaml(yaml)
        config = internal_yaml.Config(project_options)

        self.assertEqual(config.build_tools, ['gcc-arm-linux-gnueabihf'])
Exemple #12
0
    def test(self, to_arch, body, else_bodies, target_arch,
             expected_exception):
        with pytest.raises(grammar.errors.ToStatementSyntaxError) as error:
            processor = grammar.GrammarProcessor(
                None,
                snapcraft.ProjectOptions(target_deb_arch=target_arch),
                lambda x: True,
            )
            statement = to.ToStatement(to=to_arch,
                                       body=body,
                                       processor=processor)

            for else_body in else_bodies:
                statement.add_else(else_body)

            statement.process()

        assert re.match(expected_exception, str(error.value))
Exemple #13
0
    def setUp(self):
        super().setUp()

        self.useFixture(fixture_setup.CleanEnvironment())

        self.project_options = snapcraft.ProjectOptions()

        patcher = mock.patch('snapcraft.internal.common.run')
        self.run_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('snapcraft.internal.common.run_output')
        self.run_output_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('sys.stdout')
        patcher.start()
        self.addCleanup(patcher.stop)
Exemple #14
0
def loadplugin(part_name,
               plugin_name=None,
               part_properties=None,
               project_options=None):
    if not plugin_name:
        plugin_name = 'nil'
    properties = {'plugin': plugin_name}
    if part_properties:
        properties.update(part_properties)
    if not project_options:
        project_options = snapcraft.ProjectOptions()

    schema = project_loader.Validator().part_schema
    return pluginhandler.load_plugin(part_name=part_name,
                                     plugin_name=plugin_name,
                                     part_properties=properties,
                                     project_options=project_options,
                                     part_schema=schema)
Exemple #15
0
    def test_kernel_image_target_non_existent(self):
        class Options:
            build_parameters = []
            kconfigfile = None
            kdefconfig = []
            kconfigs = []
            kernel_with_firmware = True
            kernel_initrd_modules = []
            kernel_initrd_firmware = []
            kernel_device_trees = []
            kernel_initrd_compression = "gz"

        project_options = snapcraft.ProjectOptions(target_deb_arch="arm64")
        plugin = kernel.KernelPlugin("test-part", self.options,
                                     project_options)

        self.assertThat(plugin.make_targets,
                        Equals(["bzImage", "modules", "dtbs"]))
Exemple #16
0
    def test_on_statement_invalid_grammar(self):
        with testtools.ExpectedException(self.expected_exception,
                                         self.expected_message):
            processor = grammar.GrammarProcessor(
                None, snapcraft.ProjectOptions(target_deb_arch="armhf"),
                self.checker)
            statements = [
                on.OnStatement(on=self.on, body=None, processor=processor),
                to.ToStatement(to=self.to, body=None, processor=processor),
            ]
            statement = compound.CompoundStatement(statements=statements,
                                                   body=self.body,
                                                   processor=processor)

            for else_body in self.else_bodies:
                statement.add_else(else_body)

            statement.process()
    def test_else_fail(self, platform_machine_mock,
                       platform_architecture_mock):
        platform_machine_mock.return_value = "x86_64"
        platform_architecture_mock.return_value = ("64bit", "ELF")

        processor = grammar.GrammarProcessor(None, snapcraft.ProjectOptions(),
                                             self.checker)
        statement = on.OnStatement(on="on i386",
                                   body=["foo"],
                                   processor=processor)

        statement.add_else(None)

        with testtools.ExpectedException(
                grammar.errors.UnsatisfiedStatementError,
                "Unable to satisfy 'on i386', failure forced",
        ):
            statement.process()
Exemple #18
0
    def setUp(self):
        super().setUp()
        self.project = snapcraft.ProjectOptions()

        self.rosdep = rosdep.Rosdep(
            ros_distro="kinetic",
            ros_package_path="package_path",
            rosdep_path="rosdep_path",
            ubuntu_distro="xenial",
        )

        patcher = mock.patch("snapcraft.repo.Ubuntu")
        self.ubuntu_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch("subprocess.check_output")
        self.check_output_mock = patcher.start()
        self.addCleanup(patcher.stop)
Exemple #19
0
    def __init__(self, project_options=None):
        if project_options is None:
            project_options = snapcraft.ProjectOptions()

        self.build_snaps = set()
        self.build_tools = []
        self._project_options = project_options

        self.snapcraft_yaml_path = get_snapcraft_yaml()
        snapcraft_yaml = _snapcraft_yaml_load(self.snapcraft_yaml_path)

        self._validator = Validator(snapcraft_yaml)
        self._validator.validate()

        snapcraft_yaml = self._process_remote_parts(snapcraft_yaml)
        snapcraft_yaml = self._expand_filesets(snapcraft_yaml)

        # both confinement type and build quality are optionals
        _ensure_confinement_default(snapcraft_yaml, self._validator.schema)
        _ensure_grade_default(snapcraft_yaml, self._validator.schema)

        self.data = self._expand_env(snapcraft_yaml)
        self._ensure_no_duplicate_app_aliases()

        grammar_processor = grammar_processing.GlobalGrammarProcessor(
            properties=self.data, project_options=project_options)

        self.build_tools = grammar_processor.get_build_packages()
        self.build_tools |= set(project_options.additional_build_packages)

        # This is required for patching to work correctly
        if _requires_patchelf_snap(self.data['confinement']):
            # TODO use stable once possible
            self.build_snaps.add('patchelf/latest/edge')

        self.parts = PartsConfig(parts=self.data,
                                 project_options=self._project_options,
                                 validator=self._validator,
                                 build_snaps=self.build_snaps,
                                 build_tools=self.build_tools,
                                 snapcraft_yaml=self.snapcraft_yaml_path)

        if 'architectures' not in self.data:
            self.data['architectures'] = [self._project_options.deb_arch]
Exemple #20
0
    def test_config_with_wiki_part_after(self, mock_get_part, mock_load):
        self.make_snapcraft_yaml("""name: test
version: "1"
summary: test
description: test
confinement: strict

parts:
  part1:
    after:
      - part2wiki
    plugin: go
    stage-packages: [fswebcam]
""")

        def load_effect(*args, **kwargs):
            mock_part = unittest.mock.Mock()
            mock_part.code.build_packages = []
            mock_part.deps = []
            mock_part.name = args[0]

            return mock_part

        mock_load.side_effect = load_effect
        mock_get_part.return_value = {
            'plugin': 'go',
            'source': 'http://somesource'
        }

        project_options = snapcraft.ProjectOptions()

        internal_yaml.Config(project_options)

        call1 = unittest.mock.call('part1', 'go', {
            'stage': [],
            'snap': [],
            'stage-packages': ['fswebcam']
        }, project_options, self.part_schema)
        call2 = unittest.mock.call('part2wiki', 'go',
                                   {'source': 'http://somesource'},
                                   project_options, self.part_schema)

        mock_load.assert_has_calls([call1, call2])
        self.assertTrue(mock_get_part.called)
Exemple #21
0
    def setUp(self):
        super().setUp()
        dirs.setup_dirs()

        patcher = unittest.mock.patch(
            'snapcraft.internal.project_loader.get_snapcraft_yaml')
        self.mock_get_yaml = patcher.start()
        self.mock_get_yaml.return_value = os.path.join('snap',
                                                       'snapcraft.yaml')
        self.addCleanup(patcher.stop)

        patcher = unittest.mock.patch(
            'snapcraft.internal.project_loader._parts_config.PartsConfig'
            '.load_part')
        self.mock_plugin_loader = patcher.start()
        self.addCleanup(patcher.stop)

        self.part_schema = project_loader.Validator().part_schema
        self.deb_arch = snapcraft.ProjectOptions().deb_arch
Exemple #22
0
    def setUp(self):
        super().setUp()

        self.project_options = snapcraft.ProjectOptions()

        patcher = mock.patch('snapcraft.internal.common.run')
        self.run_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('sys.stdout')
        patcher.start()
        self.addCleanup(patcher.stop)

        class Options:
            options = []
            qt_version = 'qt5'
            project_files = []

        self.options = Options()
Exemple #23
0
    def test_opencv(self):
        snap_path = self.build_snap(self.snap_content_dir)

        bin_path = os.path.join(os.path.dirname(snap_path), 'prime', 'bin',
                                'example')
        self.assertThat(bin_path, FileExists())

        interpreter = subprocess.check_output(
            ['patchelf', '--print-interpreter', bin_path]).decode()
        expected_interpreter = r'^/snap/core/current/.*'
        self.assertThat(interpreter, MatchesRegex(expected_interpreter))

        arch_triplet = snapcraft.ProjectOptions().arch_triplet

        # test $ORIGIN in action
        rpath = subprocess.check_output(
            ['patchelf', '--print-rpath', bin_path]).decode()
        expected_rpath = '$ORIGIN/../usr/lib/{}:'.format(arch_triplet)
        self.assertThat(rpath, Contains(expected_rpath))

        # test $ORIGIN applied
        ldd = subprocess.check_output(['ldd', bin_path]).decode()
        expected_opencv_path = (
            '/prime/bin/../usr/lib/{}/libopencv_core'.format(arch_triplet))
        self.assertThat(ldd, Contains(expected_opencv_path))

        self.install_snap(snap_path, 'opencv-example', '1.0', classic=True)
        if not snaps_tests.config.get('skip-install', False):
            output = self.run_command_in_snappy_testbed(
                '/snap/bin/opencv-example.example').splitlines()

            # Depending on opencv the result is now displayed differently
            # so let's do a lazy match.
            # On artful you see:
            # [  1,   3;
            #    2,   4]
            # And on others:
            # [1, 3;
            #  2, 4]
            expected_in_first_line = ['[', '1', ',', '3', ';']
            self.assertThat(output[0], ContainsAll(expected_in_first_line))
            expected_in_second_line = ['2', ',', '4', ']']
            self.assertThat(output[1], ContainsAll(expected_in_second_line))
Exemple #24
0
    def setUp(self):
        super().setUp()

        self.project_options = snapcraft.ProjectOptions()

        patcher = mock.patch('snapcraft.internal.common.run')
        self.run_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('snapcraft.sources.Tar')
        self.tar_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('sys.stdout')
        patcher.start()
        self.addCleanup(patcher.stop)

        self.nodejs_url = nodejs.get_nodejs_release(
            nodejs._NODEJS_VERSION, self.project_options.deb_arch)
    def setUp(self):
        super().setUp()

        self.project_options = snapcraft.ProjectOptions()

        patcher = mock.patch('snapcraft.internal.common.run')
        self.run_mock = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = mock.patch('sys.stdout')
        patcher.start()
        self.addCleanup(patcher.stop)

        class Options:
            source = 'src'
            go_importpath = 'github.com/foo/bar'
            godeps_file = 'dependencies.tsv'

        self.options = Options()
Exemple #26
0
    def setUp(self):
        super().setUp()

        self.installdir = os.path.join(os.getcwd(), 'installdir')
        os.makedirs(self.installdir)

        self.stagedir = os.path.join(os.getcwd(), 'stagedir')
        os.makedirs(self.stagedir)

        self.bindir = os.path.join(os.getcwd(), 'bin')
        os.makedirs(self.bindir)

        project_options = snapcraft.ProjectOptions()
        env = internal_yaml._create_pkg_config_override(
            self.bindir, self.installdir, self.stagedir,
            project_options.arch_triplet)
        self.assertEqual(env, ['PATH={}:$PATH'.format(self.bindir)])

        self.pkg_config_bin = os.path.join(self.bindir, 'pkg-config')
Exemple #27
0
    def __init__(self, project_options=None):
        if project_options is None:
            project_options = snapcraft.ProjectOptions()

        self.build_snaps = set()
        self.build_tools = []
        self._project_options = project_options

        self.snapcraft_yaml_path = get_snapcraft_yaml()
        snapcraft_yaml = _snapcraft_yaml_load(self.snapcraft_yaml_path)

        self._validator = Validator(snapcraft_yaml)
        self._validator.validate()

        snapcraft_yaml = self._process_remote_parts(snapcraft_yaml)
        snapcraft_yaml = self._expand_filesets(snapcraft_yaml)

        # both confinement type and build quality are optionals
        _ensure_confinement_default(snapcraft_yaml, self._validator.schema)
        _ensure_grade_default(snapcraft_yaml, self._validator.schema)

        self.data = self._expand_env(snapcraft_yaml)
        self._ensure_no_duplicate_app_aliases()

        grammar_processor = grammar_processing.GlobalGrammarProcessor(
            properties=self.data, project_options=project_options)

        self.build_tools = grammar_processor.get_build_packages()
        self.build_tools |= set(project_options.additional_build_packages)

        # Install patchelf to enable patching in classic
        if self.data['confinement'] == 'classic' and not common.is_snap():
            self.build_tools.add('patchelf')

        self.parts = PartsConfig(parts=self.data,
                                 project_options=self._project_options,
                                 validator=self._validator,
                                 build_snaps=self.build_snaps,
                                 build_tools=self.build_tools,
                                 snapcraft_yaml=self.snapcraft_yaml_path)

        if 'architectures' not in self.data:
            self.data['architectures'] = [self._project_options.deb_arch]
Exemple #28
0
    def test_compound_statement_grammar(self, platform_machine_mock,
                                        platform_architecture_mock):
        platform_machine_mock.return_value = self.host_arch
        platform_architecture_mock.return_value = ("64bit", "ELF")
        processor = grammar.GrammarProcessor(
            None, snapcraft.ProjectOptions(target_deb_arch="armhf"),
            self.checker)
        statements = [
            on.OnStatement(on=self.on, body=None, processor=processor),
            to.ToStatement(to=self.to, body=None, processor=processor),
        ]
        statement = compound.CompoundStatement(statements=statements,
                                               body=self.body,
                                               processor=processor)

        for else_body in self.else_bodies:
            statement.add_else(else_body)

        self.assertThat(statement.process(), Equals(self.expected_packages))
Exemple #29
0
    def test_sources_is_none_uses_default(self, mock_cc):
        project_options = snapcraft.ProjectOptions(use_geoip=True)
        mock_cc.return_value = 'ar'

        self.maxDiff = None
        sources_list = repo._format_sources_list('', project_options)

        expected_sources_list = \
            '''deb http://ar.archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://ar.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://ar.archive.ubuntu.com/ubuntu/ xenial universe
deb http://ar.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://ar.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://ar.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
'''
        self.assertEqual(sources_list, expected_sources_list)
Exemple #30
0
    def test_sources_armhf_trusty(self, mock_cc):
        project_options = snapcraft.ProjectOptions(use_geoip=True,
                                                   target_deb_arch='armhf')
        sources_list = repo._format_sources_list(repo._DEFAULT_SOURCES,
                                                 project_options, 'trusty')

        expected_sources_list = \
            '''deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse
deb http://ports.ubuntu.com/ubuntu-ports trusty-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports trusty-security universe
deb http://ports.ubuntu.com/ubuntu-ports trusty-security multiverse
'''
        self.assertEqual(sources_list, expected_sources_list)
        self.assertFalse(mock_cc.called)