Example #1
0
 def parse(cls, location):
     # note that we do not know yet the distro at this stage
     # we could get it... but we get that later during assemble()
     for debian_data in get_paragraphs_data_from_file(location):
         yield build_package_data(
             debian_data,
             datasource_id=cls.datasource_id,
             package_type=cls.default_package_type,
         )
Example #2
0
 def parse(cls, location):
     # TODO: we cannot know the distro from the name only
     # NOTE: a control file in a source repo or debina.tar tarball can contain more than one package
     for debian_data in get_paragraphs_data_from_file(location=location):
         yield build_package_data(
             debian_data,
             datasource_id=cls.datasource_id,
             package_type=cls.default_package_type,
         )
Example #3
0
def parse_status_file(location, distro='debian'):
    """
    Yield Debian Package objects from a dpkg `status` file or None.
    """
    if not os.path.exists(location):
        raise FileNotFoundError(
            '[Errno 2] No such file or directory: {}'.format(repr(location)))
    if not filetype.is_file(location):
        raise Exception(f'Location is not a file: {location}')
    for debian_pkg_data in debcon.get_paragraphs_data_from_file(location):
        yield build_package(debian_pkg_data, distro)
Example #4
0
 def parse(cls, location):
     """
     Yield installed PackageData objects given a ``location``
     var/lib/dpkg/status.d/<status> file as found in a distroless container
     rootfs installation. distroless is derived from Debian but each package
     has its own status file.
     """
     for debian_data in get_paragraphs_data_from_file(location):
         yield build_package_data(
             debian_data,
             datasource_id=cls.datasource_id,
             package_type=cls.default_package_type,
             distro='distroless',
         )
Example #5
0
 def test_get_paragraphs_data_from_file__from_status(self):
     test_file = self.get_test_loc('debcon/status/simple_status')
     expected_loc = 'debcon/status/simple_status-expected.json'
     results = list(debcon.get_paragraphs_data_from_file(test_file))
     self.check_json(results, expected_loc, regen=False)
Example #6
0
 def test_get_paragraphs_data_from_file__from_copyrights_dep5_dropbear(
         self):
     test_file = self.get_test_loc('debcon/copyright/dropbear.copyright')
     expected_loc = 'debcon/copyright/dropbear.copyright-expected.json'
     results = list(debcon.get_paragraphs_data_from_file(test_file))
     self.check_json(results, expected_loc, regen=False)
Example #7
0
 def from_file(cls, location):
     paragraphs = iter(debcon.get_paragraphs_data_from_file(location))
     return cls._from_paragraph_data(paragraphs)