Skip to content

Commit 77d9faa

Browse files
committed
Support GNU package indexing
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 1306c5b commit 77d9faa

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

minecode/visitors/gnu.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# purldb is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/purldb for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
11+
import logging
12+
13+
from packageurl import PackageURL
14+
15+
from minecode import priority_router
16+
from minecode.visitors.generic import map_directory_listed_package
17+
18+
logger = logging.getLogger(__name__)
19+
handler = logging.StreamHandler()
20+
logger.addHandler(handler)
21+
logger.setLevel(logging.INFO)
22+
23+
24+
@priority_router.route("pkg:gnu/.*")
25+
def process_request(purl_str):
26+
"""
27+
Process `priority_resource_uri` containing a GNU Package URL (PURL) as a
28+
URI.
29+
30+
This involves obtaining Package information for the PURL using
31+
https://github.com/nexB/fetchcode and using it to create a new
32+
PackageDB entry. The package is then added to the scan queue afterwards.
33+
"""
34+
package_url = PackageURL.from_string(purl_str)
35+
if not package_url.version:
36+
return
37+
38+
error_msg = map_directory_listed_package(package_url)
39+
40+
if error_msg:
41+
return error_msg

0 commit comments

Comments
 (0)