Joshua M. Clulow
2020-10-04 780de6bb51170fd2cf117f1adca5c89e8d4db0b1
mark encumbered packages in mapping.json

2 files modified
27 ■■■■ changed files
components/Makefile 4 ●●● patch | view | raw | blame | history
tools/userland-mapping 23 ●●●● patch | view | raw | blame | history
components/Makefile
@@ -44,7 +44,9 @@
# between component path and component FMRI.
$(WS_TOP)/components/mapping.json:
    @echo "Generating component mapping..."
    @$(WS_TOOLS)/userland-mapping --workspace=$(WS_TOP)
    $(WS_TOOLS)/userland-mapping --workspace=$(WS_TOP) \
        --repo=$(PUBLISHER) \
        --repo-map=encumbered/=$(PUBLISHER)-encumbered
mapping.json: $(WS_TOP)/components/mapping.json
# dependencies.json is auto-generate by the build tools. It provides information
tools/userland-mapping
@@ -72,7 +72,7 @@
    return component_fmris, component_name, component_relative_path
def generate_userland_mapping(workspace_path, subdir='components'):
def generate_userland_mapping(workspace_path, subdir='components', repo='userland', repo_map=[]):
    mapping = []
    paths = find_component_paths(path=workspace_path, subdir=subdir)
@@ -81,9 +81,15 @@
    for component_fmris, component_name, component_relative_path in results:
        for component_fmri in component_fmris:
            component_repo = repo
            for rm in repo_map:
                if component_relative_path.startswith(rm['pfx']):
                    component_repo = rm['repo']
            mapping.append({'name': component_name,
                            'fmri': component_fmri,
                            'path': component_relative_path})
                            'path': component_relative_path,
                            'repo': component_repo})
    component_mapping_file = os.path.join(workspace_path, subdir, COMPONENT_MAPPING_FILENAME)
    with open(component_mapping_file, 'w') as f:
@@ -95,13 +101,24 @@
    parser.add_argument('-w', '--workspace', default=os.getenv('WS_TOP'), help='Path to workspace')
    parser.add_argument('--subdir', default='components', help='Directory holding components')
    parser.add_argument('--repo', default='userland', help='Default target repository')
    parser.add_argument('--repo-map', help='Target repository for this directory; e.g., encumbered/=userland-encumbered', action='append')
    args = parser.parse_args()
    workspace = args.workspace
    subdir = args.subdir
    generate_userland_mapping(workspace_path=workspace, subdir=subdir)
    repo = args.repo
    repo_map = []
    if args.repo_map:
        for rm in args.repo_map:
            l = rm.split("=")
            if len(l) != 2:
                raise ValueError('invalid --repo-map: ' + rm)
            repo_map.append({'pfx': l[0], 'repo': l[1]})
    generate_userland_mapping(workspace_path=workspace, subdir=subdir, repo=repo, repo_map=repo_map)
if __name__ == '__main__':
    main()