File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727from packageurl import PackageURL
2828from packageurl .contrib .route import NoRouteAvailable
2929from packageurl .contrib .route import Router
30+ import re
3031
3132DEFAULT_MAVEN_REPOSITORY = "https://repo.maven.apache.org/maven2"
3233
@@ -181,10 +182,13 @@ def build_generic_repo_url(purl):
181182 name = purl_data .name
182183 namespace = purl_data .namespace
183184 version = purl_data .version
185+
184186 if namespace .startswith ("git.kernel.org" ):
185187 return f"https://{ namespace } /{ name } /commit/?id={ version } "
186- if namespace .startswith ("android.googlesource.com" ):
188+
189+ if re .match (r"^(android|aomedia)\.googlesource\.com(/.*)?$" , namespace ):
187190 return f"https://{ namespace } /{ name } /+/{ version } "
191+
188192 if namespace .startswith ("sourceforge.net" ):
189193 return f"https://{ namespace } /{ name } /ci/{ version } "
190194
Original file line number Diff line number Diff line change @@ -697,28 +697,29 @@ def build_kernel_purl(url):
697697 )
698698
699699
700- @purl_router .route ("https?://android\.googlesource\ \ .com/.*" )
701- def build_android_purl (url ):
700+ @purl_router .route (r "https?://( android|aomedia) \.googlesource\.com/.*" )
701+ def build_googlesource_purl (url ):
702702 """
703703 Return a PackageURL object from Android `url`.
704704 For example:
705705 https://android.googlesource.com/platform/packages/apps/Settings/+/2968ccc911956fa5813a9a6a5e5c8970e383a60f
706+ https://aomedia.googlesource.com/libavifinfo/+/43716e9c34d3389b4882fbd1a81c04543ed04fe3
706707 """
707708
708709 commit_pattern = (
709- r"^https?://android\.googlesource\.com/ "
710- r"(?P<name>. +)"
710+ r"^https?://(?P<namespace>( android|aomedia) \.googlesource\.com(?:/.*)?) "
711+ r"/ (?P<name>[^/] +)"
711712 r"/\+/"
712713 r"(?P<version>[0-9a-fA-F]{7,64})"
713714 )
714715
715- commit_matche = re .search (commit_pattern , url )
716- if commit_matche :
716+ match = re .search (commit_pattern , url )
717+ if match :
717718 return PackageURL (
718719 type = "generic" ,
719- namespace = "android.googlesource.com" ,
720- name = commit_matche .group ("name" ),
721- version = commit_matche .group ("version" ),
720+ namespace = match . group ( "namespace" ) ,
721+ name = match .group ("name" ),
722+ version = match .group ("version" ),
722723 qualifiers = {},
723724 subpath = "" ,
724725 )
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ def test_purl2url_get_repo_url():
7373 "pkg:generic/git.kernel.org/pub/scm/libs/liba2i/liba2i.git@4fc8196d7811c26abefaf3a3ae6b5c67c4c9cbc9" : "https://git.kernel.org/pub/scm/libs/liba2i/liba2i.git/commit/?id=4fc8196d7811c26abefaf3a3ae6b5c67c4c9cbc9" ,
7474 "pkg:generic/git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/configfs.git@bc3372351d0c8b2726b7d4229b878342e3e6b0e8" : "https://git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/configfs.git/commit/?id=bc3372351d0c8b2726b7d4229b878342e3e6b0e8" ,
7575 "pkg:generic/android.googlesource.com/accessories/manifest@9ad7ef740dc39834a88bf95c69f35f18b8f45543" : "https://android.googlesource.com/accessories/manifest/+/9ad7ef740dc39834a88bf95c69f35f18b8f45543" ,
76+ "pkg:generic/aomedia.googlesource.com/libavifinfo@43716e9c34d3389b4882fbd1a81c04543ed04fe3" : "https://aomedia.googlesource.com/libavifinfo/+/43716e9c34d3389b4882fbd1a81c04543ed04fe3" ,
7677 "pkg:generic/sourceforge.net/p/infrarecorder/code@8fab704119ff23691f075f6a281521b6c7d7e55f" : "https://sourceforge.net/p/infrarecorder/code/ci/8fab704119ff23691f075f6a281521b6c7d7e55f" ,
7778 }
7879
You can’t perform that action at this time.
0 commit comments