Skip to content

Commit 4f3cca0

Browse files
Enable scanning more debian package files
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 02dab2e commit 4f3cca0

File tree

7 files changed

+458
-14
lines changed

7 files changed

+458
-14
lines changed

src/packagedcode/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,17 @@
208208
debian_copyright.DebianCopyrightFileInPackageHandler,
209209
debian_copyright.DebianCopyrightFileInSourceHandler,
210210

211-
# TODO: consider activating? debian_copyright.StandaloneDebianCopyrightFileHandler,
212-
213211
debian.DebianDistrolessInstalledDatabaseHandler,
214212

215213
debian.DebianInstalledFilelistHandler,
216214
debian.DebianInstalledMd5sumFilelistHandler,
217215
debian.DebianInstalledStatusDatabaseHandler,
216+
debian.DebianControlFileInSourceHandler,
217+
debian.DebianDscFileHandler,
218+
debian.DebianSourcePackageTarballHandler,
219+
debian.DebianSourcePackageMetadataTarballHandler,
220+
debian.DebianDebPackageHandler,
221+
debian_copyright.StandaloneDebianCopyrightFileHandler
218222
]
219223

220224
if on_linux:

src/packagedcode/debian.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def parse(cls, location):
138138
debian_data=get_paragraph_data_from_file(location=location),
139139
datasource_id=cls.datasource_id,
140140
package_type=cls.default_package_type,
141+
distro='debian',
141142
)
142143

143144
@classmethod
@@ -538,6 +539,9 @@ def build_package_data_from_package_filename(filename, datasource_id, package_ty
538539
"""
539540

540541
# TODO: we cannot know the distro from the name only
542+
# PURLs without namespace is invalid, so we need to
543+
# have a default value for this
544+
distro = 'debian'
541545
deb = DebArchive.from_filename(filename=filename)
542546

543547
if deb.architecture:
@@ -553,6 +557,7 @@ def build_package_data_from_package_filename(filename, datasource_id, package_ty
553557
datasource_id=datasource_id,
554558
type=package_type,
555559
name=deb.name,
560+
namespace=distro,
556561
version=version,
557562
qualifiers=qualifiers,
558563
)
@@ -645,21 +650,25 @@ def build_package_data(debian_data, datasource_id, package_type='deb', distro=No
645650

646651
# Get distro/namespace information from clues in package data
647652
if not distro:
648-
for clue, namespace in version_clues_for_namespace.items():
649-
if clue in version:
650-
distro = namespace
651-
652-
for clue, namespace in maintainer_clues_for_namespace.items():
653-
if clue in maintainer:
654-
distro = namespace
653+
if version:
654+
for clue, namespace in version_clues_for_namespace.items():
655+
if clue in version:
656+
distro = namespace
657+
break
658+
659+
if maintainer:
660+
for clue, namespace in maintainer_clues_for_namespace.items():
661+
if clue in maintainer:
662+
distro = namespace
663+
break
655664

656665
source_packages = []
657666
source = debian_data.get('source')
658667
if source:
659668
source_pkg_purl = PackageURL(
660669
type=package_type,
661670
name=source,
662-
namespace=distro
671+
namespace=distro,
663672
).to_string()
664673

665674
source_packages.append(source_pkg_purl)
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
{
2+
"packages": [
3+
{
4+
"type": "deb",
5+
"namespace": "debian",
6+
"name": "gzip",
7+
"version": null,
8+
"qualifiers": {
9+
"architecture": "any"
10+
},
11+
"subpath": null,
12+
"primary_language": null,
13+
"description": "GNU compression utilities\n This package provides the standard GNU file compression utilities, which \n are also the default compression tools for Debian. They typically operate \n on files with names ending in '.gz', but can also decompress files ending \n in '.Z' created with 'compress'.",
14+
"release_date": null,
15+
"parties": [],
16+
"keywords": [],
17+
"homepage_url": null,
18+
"download_url": null,
19+
"size": null,
20+
"sha1": null,
21+
"md5": null,
22+
"sha256": null,
23+
"sha512": null,
24+
"bug_tracking_url": null,
25+
"code_view_url": null,
26+
"vcs_url": null,
27+
"copyright": null,
28+
"holder": null,
29+
"declared_license_expression": null,
30+
"declared_license_expression_spdx": null,
31+
"license_detections": [],
32+
"other_license_expression": null,
33+
"other_license_expression_spdx": null,
34+
"other_license_detections": [],
35+
"extracted_license_statement": null,
36+
"notice_text": null,
37+
"source_packages": [],
38+
"extra_data": {},
39+
"repository_homepage_url": null,
40+
"repository_download_url": null,
41+
"api_data_url": null,
42+
"package_uid": "pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
43+
"datafile_paths": [
44+
"control/debian/control"
45+
],
46+
"datasource_ids": [
47+
"debian_control_in_source"
48+
],
49+
"purl": "pkg:deb/debian/gzip?architecture=any"
50+
},
51+
{
52+
"type": "deb",
53+
"namespace": "debian",
54+
"name": "gzip-win32",
55+
"version": null,
56+
"qualifiers": {
57+
"architecture": "all"
58+
},
59+
"subpath": null,
60+
"primary_language": null,
61+
"description": "GNU compression utility (win32 build)\n This is a win32 version of gzip, meant to be used by the win32-loader\n component of Debian-Installer.",
62+
"release_date": null,
63+
"parties": [],
64+
"keywords": [],
65+
"homepage_url": null,
66+
"download_url": null,
67+
"size": null,
68+
"sha1": null,
69+
"md5": null,
70+
"sha256": null,
71+
"sha512": null,
72+
"bug_tracking_url": null,
73+
"code_view_url": null,
74+
"vcs_url": null,
75+
"copyright": null,
76+
"holder": null,
77+
"declared_license_expression": null,
78+
"declared_license_expression_spdx": null,
79+
"license_detections": [],
80+
"other_license_expression": null,
81+
"other_license_expression_spdx": null,
82+
"other_license_detections": [],
83+
"extracted_license_statement": null,
84+
"notice_text": null,
85+
"source_packages": [],
86+
"extra_data": {},
87+
"repository_homepage_url": null,
88+
"repository_download_url": null,
89+
"api_data_url": null,
90+
"package_uid": "pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758",
91+
"datafile_paths": [
92+
"control/debian/control"
93+
],
94+
"datasource_ids": [
95+
"debian_control_in_source"
96+
],
97+
"purl": "pkg:deb/debian/gzip-win32?architecture=all"
98+
}
99+
],
100+
"dependencies": [],
101+
"files": [
102+
{
103+
"path": "control",
104+
"type": "directory",
105+
"package_data": [],
106+
"for_packages": [
107+
"pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
108+
"pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758"
109+
],
110+
"scan_errors": []
111+
},
112+
{
113+
"path": "control/debian",
114+
"type": "directory",
115+
"package_data": [],
116+
"for_packages": [
117+
"pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
118+
"pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758"
119+
],
120+
"scan_errors": []
121+
},
122+
{
123+
"path": "control/debian/control",
124+
"type": "file",
125+
"package_data": [
126+
{
127+
"type": "deb",
128+
"namespace": "debian",
129+
"name": null,
130+
"version": null,
131+
"qualifiers": {},
132+
"subpath": null,
133+
"primary_language": null,
134+
"description": null,
135+
"release_date": null,
136+
"parties": [
137+
{
138+
"type": null,
139+
"role": "maintainer",
140+
"name": "Bdale Garbee <bdale@gag.com>",
141+
"email": null,
142+
"url": null
143+
}
144+
],
145+
"keywords": [
146+
"utils"
147+
],
148+
"homepage_url": "https://www.gnu.org/software/gzip/",
149+
"download_url": null,
150+
"size": null,
151+
"sha1": null,
152+
"md5": null,
153+
"sha256": null,
154+
"sha512": null,
155+
"bug_tracking_url": null,
156+
"code_view_url": null,
157+
"vcs_url": null,
158+
"copyright": null,
159+
"holder": null,
160+
"declared_license_expression": null,
161+
"declared_license_expression_spdx": null,
162+
"license_detections": [],
163+
"other_license_expression": null,
164+
"other_license_expression_spdx": null,
165+
"other_license_detections": [],
166+
"extracted_license_statement": null,
167+
"notice_text": null,
168+
"source_packages": [
169+
"pkg:deb/gzip"
170+
],
171+
"file_references": [],
172+
"extra_data": {},
173+
"dependencies": [],
174+
"repository_homepage_url": null,
175+
"repository_download_url": null,
176+
"api_data_url": null,
177+
"datasource_id": "debian_control_in_source",
178+
"purl": null
179+
},
180+
{
181+
"type": "deb",
182+
"namespace": "debian",
183+
"name": "gzip",
184+
"version": null,
185+
"qualifiers": {
186+
"architecture": "any"
187+
},
188+
"subpath": null,
189+
"primary_language": null,
190+
"description": "GNU compression utilities\n This package provides the standard GNU file compression utilities, which \n are also the default compression tools for Debian. They typically operate \n on files with names ending in '.gz', but can also decompress files ending \n in '.Z' created with 'compress'.",
191+
"release_date": null,
192+
"parties": [],
193+
"keywords": [],
194+
"homepage_url": null,
195+
"download_url": null,
196+
"size": null,
197+
"sha1": null,
198+
"md5": null,
199+
"sha256": null,
200+
"sha512": null,
201+
"bug_tracking_url": null,
202+
"code_view_url": null,
203+
"vcs_url": null,
204+
"copyright": null,
205+
"holder": null,
206+
"declared_license_expression": null,
207+
"declared_license_expression_spdx": null,
208+
"license_detections": [],
209+
"other_license_expression": null,
210+
"other_license_expression_spdx": null,
211+
"other_license_detections": [],
212+
"extracted_license_statement": null,
213+
"notice_text": null,
214+
"source_packages": [],
215+
"file_references": [],
216+
"extra_data": {},
217+
"dependencies": [],
218+
"repository_homepage_url": null,
219+
"repository_download_url": null,
220+
"api_data_url": null,
221+
"datasource_id": "debian_control_in_source",
222+
"purl": "pkg:deb/debian/gzip?architecture=any"
223+
},
224+
{
225+
"type": "deb",
226+
"namespace": "debian",
227+
"name": "gzip-win32",
228+
"version": null,
229+
"qualifiers": {
230+
"architecture": "all"
231+
},
232+
"subpath": null,
233+
"primary_language": null,
234+
"description": "GNU compression utility (win32 build)\n This is a win32 version of gzip, meant to be used by the win32-loader\n component of Debian-Installer.",
235+
"release_date": null,
236+
"parties": [],
237+
"keywords": [],
238+
"homepage_url": null,
239+
"download_url": null,
240+
"size": null,
241+
"sha1": null,
242+
"md5": null,
243+
"sha256": null,
244+
"sha512": null,
245+
"bug_tracking_url": null,
246+
"code_view_url": null,
247+
"vcs_url": null,
248+
"copyright": null,
249+
"holder": null,
250+
"declared_license_expression": null,
251+
"declared_license_expression_spdx": null,
252+
"license_detections": [],
253+
"other_license_expression": null,
254+
"other_license_expression_spdx": null,
255+
"other_license_detections": [],
256+
"extracted_license_statement": null,
257+
"notice_text": null,
258+
"source_packages": [],
259+
"file_references": [],
260+
"extra_data": {},
261+
"dependencies": [],
262+
"repository_homepage_url": null,
263+
"repository_download_url": null,
264+
"api_data_url": null,
265+
"datasource_id": "debian_control_in_source",
266+
"purl": "pkg:deb/debian/gzip-win32?architecture=all"
267+
}
268+
],
269+
"for_packages": [
270+
"pkg:deb/debian/gzip?architecture=any&uuid=fixed-uid-done-for-testing-5642512d1758",
271+
"pkg:deb/debian/gzip-win32?architecture=all&uuid=fixed-uid-done-for-testing-5642512d1758"
272+
],
273+
"scan_errors": []
274+
}
275+
]
276+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Source: gzip
2+
Section: utils
3+
Priority: required
4+
Maintainer: Bdale Garbee <bdale@gag.com>
5+
Uploaders: Carl Worth <cworth@cworth.org>
6+
Build-Depends: debhelper (>= 11), texinfo, autoconf, automake, less
7+
Build-Depends-Indep: mingw-w64
8+
Rules-Requires-Root: no
9+
Standards-Version: 4.3.0
10+
Vcs-Git: https://salsa.debian.org/debian/gzip.git
11+
Vcs-Browser: https://salsa.debian.org/debian/gzip
12+
Homepage: https://www.gnu.org/software/gzip/
13+
14+
Package: gzip
15+
Architecture: any
16+
Essential: yes
17+
Pre-Depends: ${shlibs:Depends}
18+
Depends: dpkg (>= 1.15.4) | install-info
19+
Suggests: less
20+
Description: GNU compression utilities
21+
This package provides the standard GNU file compression utilities, which
22+
are also the default compression tools for Debian. They typically operate
23+
on files with names ending in '.gz', but can also decompress files ending
24+
in '.Z' created with 'compress'.
25+
26+
Package: gzip-win32
27+
Architecture: all
28+
Priority: optional
29+
Suggests: wine
30+
Description: GNU compression utility (win32 build)
31+
This is a win32 version of gzip, meant to be used by the win32-loader
32+
component of Debian-Installer.

0 commit comments

Comments
 (0)