diff --git a/acbs/base.py b/acbs/base.py index 0a20c47..7c9ba95 100644 --- a/acbs/base.py +++ b/acbs/base.py @@ -14,6 +14,7 @@ def __init__(self, type: str, url: str, revision=None, branch=None, depth=None) self.depth: Optional[int] = depth self.chksum: Tuple[str, str] = ('', '') self.source_name: Optional[str] = '' + self.use_url_name: bool = False # where the source file/folder is located (on local filesystem) self.source_location: Optional[str] = None self.enabled: bool = True diff --git a/acbs/parser.py b/acbs/parser.py index 7b58e90..ca4f093 100644 --- a/acbs/parser.py +++ b/acbs/parser.py @@ -4,6 +4,7 @@ import re from collections import OrderedDict from typing import Dict, List, Optional +from urllib.parse import urlparse from acbs import bashvar from acbs.base import ACBSPackageInfo, ACBSSourceInfo @@ -51,6 +52,11 @@ def parse_url_schema(url: str, checksum: str) -> ACBSSourceInfo: acbs_source_info.chksum = ( chksum_[0], chksum_[1]) if checksum != 'SKIP' else ('none', '') acbs_source_info.url = url_plain + if acbs_source_info.use_url_name and acbs_source_info.source_name: + raise ValueError("Option 'use-url-name' can NOT be used with the 'rename' option.") + if acbs_source_info.use_url_name: + parsed = urlparse(url_plain) + acbs_source_info.source_name = os.path.basename(parsed.path) return acbs_source_info @@ -62,6 +68,8 @@ def parse_fetch_options(options: str, acbs_source_info: ACBSSourceInfo): acbs_source_info.branch = v.strip() elif k == 'rename': acbs_source_info.source_name = v.strip() + elif k == 'use-url-name': + acbs_source_info.use_url_name = v.strip() == 'true' elif k == 'commit': acbs_source_info.revision = v.strip() elif k == 'copy-repo':