1+ import hashlib
12import http .client
23import logging
34import os
910from urllib .parse import urlparse
1011
1112from acbs .base import ACBSPackageInfo , ACBSSourceInfo
12- from acbs .crypto import check_hash_hashlib , hash_url
13+ from acbs .crypto import check_hash_hashlib
1314from acbs .utils import guess_extension_name
1415
1516fetcher_signature = Callable [[ACBSSourceInfo ,
@@ -28,8 +29,8 @@ def fetch_source(info: List[ACBSSourceInfo], source_location: str, package_name:
2829 # in generate mode, we need to fetch all the sources
2930 if not i .enabled and not generate_mode :
3031 logging .info (f'Source { count } skipped.' )
31- url_hash = hash_url ( i . url )
32- fetch_source_inner (i , source_location , url_hash )
32+ uri_hash = hash_source_uri ( i )
33+ fetch_source_inner (i , source_location , uri_hash )
3334 return None
3435
3536
@@ -64,13 +65,21 @@ def process_source(info: ACBSPackageInfo, source_name: str) -> None:
6465 return
6566
6667
68+ def hash_source_uri (uri : ACBSSourceInfo ) -> str :
69+ hash_obj = hashlib .new ("sha256" )
70+ hash_obj .update (uri .type .encode ("utf-8" ))
71+ hash_obj .update (uri .url .encode ("utf-8" ))
72+ hash_obj .update (uri .revision .encode ("utf-8" ) if uri .revision else b'NONE' )
73+ hash_obj .update (uri .branch .encode ("utf-8" ) if uri .branch else b"NONE" )
74+ return hash_obj .hexdigest ()
75+
76+
6777# Fetchers implementations
6878def tarball_fetch (info : ACBSSourceInfo , source_location : str , name : str ) -> Optional [ACBSSourceInfo ]:
6979 if source_location :
70- filename = hash_url (info .url )
7180 if not info .chksum [1 ] and not generate_mode :
7281 raise ValueError ('No checksum found. Please specify the checksum!' )
73- full_path = os .path .join (source_location , filename )
82+ full_path = os .path .join (source_location , name )
7483 try :
7584 wget_download (info .url , full_path )
7685 info .source_location = full_path
0 commit comments