Exemplo n.º 1
0
def run(common_args, cmd_argv):
    args = docopt(__doc__, argv=cmd_argv)

    # Load the package file
    json_dict = utils.load_package_file()

    # Setting all fields
    if (args['<desc>']):
        utils.json_update_package_file_info(json_dict, args['<pkgname>'],
                                            args['<desc>'], args['<owner>'],
                                            args['<email>'], args['<url>'],
                                            args['<rname>'], args['<rtype>'],
                                            args['<rorigin>'])

    # Update the packname
    if (args['--pkgname'] != None):
        utils.json_update_package_file_info(json_dict,
                                            pkgname=args['--pkgname'])
        pass

    # Update the description
    if (args['--desc'] != None):
        utils.json_update_package_file_info(json_dict, desc=args['--desc'])
        pass

    # Update the owner
    if (args['--owner'] != None):
        utils.json_update_package_file_info(json_dict, owner=args['--owner'])
        pass

    # Update the email
    if (args['--email'] != None):
        utils.json_update_package_file_info(json_dict, email=args['--email'])
        pass

    # Update the url
    if (args['--url'] != None):
        utils.json_update_package_file_info(json_dict, url=args['--url'])
        pass

    # Update the repo name
    if (args['--rname'] != None):
        utils.json_update_package_file_info(json_dict, rname=args['--rname'])
        pass

    # Update the repo type
    if (args['--rtype'] != None):
        utils.json_update_package_file_info(json_dict, rtype=args['--rtype'])
        pass

    # Update the repo origin
    if (args['--rorigin'] != None):
        utils.json_update_package_file_info(json_dict,
                                            rorigin=args['--rorigin'])
        pass

    # save updates
    utils.write_package_file(json_dict)
    info_dict = utils.json_copy_info(json_dict)
    print(json.dumps(info_dict, indent=2))
Exemplo n.º 2
0
def show_primary_dirs():
    package_json = utils.load_package_file()
    pdirs = utils.json_get_package_primary_dirs(package_json)
    if (pdirs == None):
        print("No primary directories are currently set for the package")
    else:
        for d in pdirs:
            print(d)
Exemplo n.º 3
0
def show_extra_dirs():
    package_json = utils.load_package_file()
    pdirs = utils.json_get_package_extra_dirs(package_json)
    if (pdirs == None):
        print(
            "No adopted 'extra' directories are currently set for the package")
    else:
        for d in pdirs:
            print(d)
Exemplo n.º 4
0
def run(common_args, cmd_argv):
    args = docopt(__doc__, argv=cmd_argv)
    if (args['<wildcard>'] == None):
        args['<wildcard>'] = '*'

    # Get the list of adopted packages
    json_dict = utils.load_package_file()

    # Get Dependencies
    pkgs = utils.get_dependency_list(json_dict,
                                     include_immediate=not args['-w'],
                                     include_weak=not args['-s'])

    # Sort the list
    pkgs = sorted(pkgs, key=lambda i: i['pkgname'])
    if (not args['-x']):
        header = "PkgName          D PkType    AdoptedDate               ParentDir        "
        rheader = "RepoName         RepoType RepoOrigin                               "
        vheader = "SemVer   Branch           Tag"
        if (args['-l'] or args['-r']):
            header = header + rheader
        if (args['-l'] or args['-v']):
            header = header + vheader
        print(header)

    # display the list
    for p in pkgs:
        if (fnmatch.fnmatch(p['pkgname'], args['<wildcard>'])):
            info = f"{p['pkgname']:<16} {p['depType']} {p['pkgtype']:<8}  {p['adoptedDate']}  {utils.json_get_dep_parentdir(p):<16}"

            # Repo info
            if (args['-l'] or args['-r']):
                info = info + f" {utils.json_get_dep_repo_name(p):<16} {utils.json_get_dep_repo_type(p):<8} {utils.json_get_dep_repo_origin(p):40}"

            # Version info
            if (args['-l'] or args['-v']):
                info = info + f" {utils.json_get_dep_semver(p):<8} {utils.json_get_dep_branch(p):<16} {utils.json_get_dep_tag(p)}"

            # display output
            print(info)
Exemplo n.º 5
0
def run(common_args, cmd_argv):
    args = docopt(__doc__, argv=cmd_argv)

    # Display my package info
    if (not args['<adoptedpkg>']):
        utils.cat_package_file(int(args['--indent']))

    # Display an adopted package
    else:
        # Check if the adopted package is actually adopted
        json_dict = utils.load_package_file()
        pkgobj, deptype, pkgidx = utils.json_find_dependency(
            json_dict, args['<adoptedpkg>'])
        if (pkgobj == None):
            sys.exit(
                f"ERROR: The package - {args['<adoptedpkg>']} is NOT an adopted package"
            )

        # OVERLAY package
        if (pkgobj['pkgtype'] == 'overlay'):
            utils.cat_package_file(int(args['--indent']),
                                   path=os.path.join(OVERLAY_PKGS_DIR(),
                                                     args['<adoptedpkg>'],
                                                     PACKAGE_INFO_DIR()))

        # Readonly/Foreign Packages
        else:
            if (pkgobj['parentDir'] == None):
                sys.exit(
                    f"ERROR: the {PACKAGE_FILE()} file is corrupt. There is no parent directory for the package: {args['<adoptedpkg>']}"
                )
            json_dict = utils.cat_package_file(int(args['--indent']),
                                               path=os.path.join(
                                                   pkgobj['parentDir'],
                                                   args['<adoptedpkg>'],
                                                   PACKAGE_INFO_DIR()))
            if (json_dict == None):
                sys.exit(
                    f"ERROR: No package information is available for the Readonly/Foreign package: {args['<adoptedpkg>']}"
                )
Exemplo n.º 6
0
def run( common_args, cmd_argv ):
    args = docopt(__doc__, argv=cmd_argv)

    # Get the list of adopted packages
    json_dict = utils.load_package_file()

    # Make sure the package is adopted and the it is 'moveable'
    pkg = args["<pkg>"]
    if ( json_dict == None ):
        sys.exit( 'ERROR: No packages have been adopted' )
    pkgobj, deptype, pkgidx = utils.json_find_dependency( json_dict, pkg )
    if ( pkgobj == None ):
        sys.exit( f"ERROR: Package ({args['<pkg>']}) not adopted." )
    if ( pkgobj['pkgtype'] == 'overlay' ):
        sys.exit( "ERROR: The mv command cannot move an overlay package" )

    # Make sure that '<dst>' does NOT already exist
    if ( not os.path.isdir( args['<dst>'] ) ):
        sys.exit( f"ERROR: The parent directory ({args['<dst>']}) does NOT exist" )

    # Make sure that '<pkg>' does NOT already exist under '<dst>'
    dst = os.path.join( args['<dst>'], args["<pkg>"] )
    if ( os.path.exists( dst ) ):
        sys.exit( f"ERROR: {args['<dst>']} already exists under {args['<dst>']}" )


    # Physically move the package
    src = os.path.join( pkgobj["parentDir"], args["<pkg>"]  ) 
    try:
        shutil.move( src, dst )
    except Exception as e:
        sys.exit( f"ERROR: Unable to move the package ({e})" )

    # Update the package
    pkgobj['parentDir'] = args['<dst>']
    json_dict['dependencies'][deptype].pop(pkgidx)
    utils.json_update_package_file_with_new_dep_entry( json_dict, pkgobj, is_weak_dep = True if deptype=='weak' else False )
    utils.write_package_file( json_dict )
    print( f"Package {src} moved to {dst}" )
Exemplo n.º 7
0
def run( common_args, cmd_argv ):
    args = docopt(__doc__, argv=cmd_argv)

    # Housekeeping
    exit_code = 0;
    
    # Load my package info
    json_dict = utils.load_package_file()

    # Build dependency tree. 
    root = utils.Node( (json_dict, "ROOT") )
    build_tree( root, json_dict )

    # Get generation lists
    children = root.get_children().copy()
    grand_children = []
    for c in children:
        grand_children.extend( c.get_children() )

    # MOVE a dependency
    if ( args['mv'] ):
        # Look up the details of the package to be moved
        pkgobj, deptype, pkgidx = utils.json_find_dependency( json_dict, args['<adoptedpkg>']  )
        if ( pkgobj == None ):
            sys.exit( f"Cannot find the package - {args['<adoptedpkg>'] } - in the list of adopted packages" );
       
        # Remove then add the package from the deps list
        now_is_weak = True if deptype == 'strong' else False
        json_dict['dependencies'][deptype].pop(pkgidx)
        utils.json_update_package_file_with_new_dep_entry( json_dict, pkgobj, now_is_weak )
        print( f"Package - {args['<adoptedpkg>']} is now a {'weak' if now_is_weak else 'strong'} dependency " )
        sys.exit( 0 )

    # CHECK dependencies
    if ( args['check'] ):
        print( f"Checking dependencies for package: {utils.json_get_package_name(json_dict)}" )

        # Perform checks
        missing_list   = check_missing( root, children, grand_children )
        noncompat_list = check_compatibility( root, children, grand_children ) 
        cyclical_list  = check_cylical( missing_list, root.get_pkgname() )

        # Cyclical deps
        if ( not args['--noweak'] ):
            cyclical = filter_for_weak_dependency( cyclical_list )
            print_cyclical_list( cyclical, "Warning", "weak" )

        if ( not args['--nostrong'] ):
            cyclical = filter_for_strong_dependency( cyclical_list )
            print_cyclical_list( cyclical, "ERROR", "strong" )
            if ( len(cyclical) > 0 ):
                exit_code = 1
        
        # Missing deps
        if ( not args['--noweak'] ):
            missing = filter_for_weak_dependency( missing_list )
            print_missing_list( missing, "Warning", "weak" )

        if ( not args['--nostrong'] ):
            missing = filter_for_strong_dependency( missing_list )
            print_missing_list( missing, "ERROR", "strong" )
            if ( len(missing) > 0 ):
                exit_code = 1

        # Compatible check
        if ( not args['--noweak'] ):
            noncompat = filter_for_weak_dependency( noncompat_list )
            print_noncompat_list( noncompat, "Warning", "weak", children )

        if ( not args['--nostrong'] ):
            noncompat = filter_for_strong_dependency( noncompat_list )
            print_noncompat_list( noncompat, "ERROR", "strong", children )
            if ( len(noncompat) > 0 ):
                exit_code = 1

        print("All dependency checks completed." )
        sys.exit( exit_code )


    # SHOW dependencies
    if ( not args['<adoptedpkg>'] ):
        print( root )
        sys.exit( 0 )

    # Filter the tree for a specific adopted package
    for c in children:
        if ( c.get_pkgname() != args['<adoptedpkg>'] ):
            root.remove_child_node( c )
    print( root )
    sys.exit( 0 )
Exemplo n.º 8
0
def run(common_args, cmd_argv):
    args = docopt(__doc__, argv=cmd_argv)

    # Help on the publish sequence
    if (args['help']):
        print(help_text)
        sys.exit(0)

    # Get the package data
    json_dict = utils.load_package_file()

    # Edit in place
    if (args['--edit']):
        prev = utils.json_get_current_version(json_dict)
        v = utils.json_create_version_entry(args['<comments>'],
                                            args['<semver>'], prev['date'])
        utils.json_update_current_version(json_dict, v)

    # Edit a history entry
    elif (args['--edithist']):
        utils.json_update_history_version(json_dict, args['--edithist'],
                                          args['<comments>'], args['<semver>'])

    # Create new entry
    elif (args['<semver>']):
        v = utils.json_create_version_entry(args['<comments>'],
                                            args['<semver>'])
        utils.json_add_new_version(json_dict, v)

    # Important files...
    dirs_file = os.path.join(PACKAGE_INFO_DIR(), PKG_DIRS_FILE())
    ignore_file = os.path.join(PACKAGE_INFO_DIR(), IGNORE_DIRS_FILE())

    # Ensure the 'dirs list' is up to date
    if (not args['--nodirs'] and args['<semver>']):
        if (os.path.isfile(ignore_file)):
            owndirs = utils.get_owned_dirs(PACKAGE_ROOT())
            utils.save_dirs_list_file(owndirs)

    # display publish info
    p = utils.json_get_published(json_dict)
    print(json.dumps(p, indent=2))

    # Display warnings
    if (not args['-w']):
        warning = False
        if (not os.path.isfile(dirs_file)):
            print(
                f"Warning: NO {dirs_file} file has been created for the package.  See the 'orc dirs' command"
            )
            warning = True
        if (not os.path.isfile(ignore_file)):
            print(
                f"Warning: NO {ignore_file} file has been created for the package. Create using a text editor. The file has same semantics as a .gitignore file."
            )
            warning = True
        if (warning):
            print()
            print(
                f"The above warning(s) can be ignored if the package is NOT intended to be to be adopted as an 'overlay' package."
            )
Exemplo n.º 9
0
def run(common_args, cmd_argv):
    args = docopt(__doc__, argv=cmd_argv)

    # Verbose option for subcommand
    vopt = ' -v ' if common_args['-v'] else ''

    # Look up the details of the package to be removed
    pkg = args['<adoptedpkg>']
    json_dict = utils.load_package_file()
    pkgobj, deptype, pkgidx = utils.json_find_dependency(json_dict, pkg)
    if (pkgobj == None):
        sys.exit(
            f'Cannot find the package - {pkg} - in the list of adopted packages'
        )

    # default branch option
    branch_opt = ""
    if (pkgobj['version']['branch'] != None):
        branch_opt = '-b ' + args['-b']

    # READONLY Package
    if (pkgobj['pkgtype'] == 'readonly'):
        if (pkgobj['parentDir'] == None):
            sys.exit(
                f"ERROR: the {PACKAGE_FILE()} file is corrupt - there is no parent directory for the package"
            )

        # Remove the package
        cmd = f"evie.py {vopt} --scm {pkgobj['repo']['type']} umount -p {pkgobj['pkgname']} {branch_opt} {pkgobj['parentDir']} {pkgobj['repo']['name']} {pkgobj['repo']['origin']} {pkgobj['version']['tag']}"
        t = utils.run_shell(cmd, common_args['-v'])
        utils.check_results(
            t,
            f"ERROR: Failed to umount the repo: {pkgobj['repo']['name']}, 'umount', 'get-error-msg', common_args['--scm']"
        )

        # Remove the package from the deps list
        json_dict['dependencies'][deptype].pop(pkgidx)
        utils.write_package_file(json_dict)

        # Display parting message (if there is one)
        utils.display_scm_message('umount', 'get-success-msg',
                                  common_args['--scm'])

    # FOREIGN Package
    elif (pkgobj['pkgtype'] == 'foreign'):
        if (pkgobj['parentDir'] == None):
            sys.exit(
                f"ERROR: the {PACKAGE_FILE()} file is corrupt - there is no parent directory for the package"
            )

        # Remove the package
        cmd = f"evie.py {vopt} --scm {pkgobj['repo']['type']} rm -p {pkgobj['pkgname']} {branch_opt} {pkgobj['parentDir']} {pkgobj['repo']['name']} {pkgobj['repo']['origin']} {pkgobj['version']['tag']}"
        t = utils.run_shell(cmd, common_args['-v'])
        utils.check_results(
            t,
            f"ERROR: Failed to remove the package: {pkgobj['repo']['name']}, 'rm', 'get-error-msg', common_args['--scm']"
        )

        # Remove the package from the deps list
        json_dict['dependencies'][deptype].pop(pkgidx)
        utils.write_package_file(json_dict)

        # Display parting message (if there is one)
        utils.display_scm_message('rm', 'get-success-msg',
                                  common_args['--scm'])

    # OVERALY Package
    elif (pkgobj['pkgtype'] == 'overlay'):
        dstpkgpath = os.path.join(OVERLAY_PKGS_DIR(), pkg)
        if (not os.path.isdir(dstpkgpath)):
            sys.exit(
                f"ERROR: The {pkg} does not exist under the {OVERLAY_PKGS_DIR()}/ directory"
            )

        # Remove the overlaid directories/files
        dirs = utils.load_overlaid_dirs_list_file(pkg)
        try:
            for d in dirs:
                utils.delete_directory_files(d)
        except:
            sys.exit("ERROR: Failed to remove overlaid directories")

        # Remove 'overlaid' directory
        utils.remove_tree(dstpkgpath)

        # Remove the package from the deps list
        json_dict['dependencies'][deptype].pop(pkgidx)
        utils.write_package_file(json_dict)

        # Remove the pkgs.overlaid dir if there are no more overlaid packages
        try:
            os.rmdir(OVERLAY_PKGS_DIR())
        except:
            pass

        # Display parting message
        print(f"Overlay package - {pkg} - removed")

    # Unsupported package type
    else:
        sys.exit(
            f"ERROR: Unsupport package type: {pkgobj['pkgtype']}. The {PACKAGE_FILE()} file has been corrupted"
        )
Exemplo n.º 10
0
def run( common_args, cmd_argv ):
    args = docopt(__doc__, argv=cmd_argv)

    # Verbose option for subcommand
    vopt = ' -v ' if common_args['-v'] else ''

    # Default Package name
    pkg = args['<repo>']
    if ( args['-p'] ):
        pkg = args['-p']

    # CLEAN-UP (for a failed overlay adoption)
    if ( args['clean'] ):
        tmpdst = os.path.join( PACKAGE_ROOT(), PACKAGE_INFO_DIR(), TEMP_DIR_NAME() )
        utils.remove_tree( tmpdst, "error", "warn" )
        sys.exit(0)

    # default branch option
    branch_opt = ""
    if ( args['-b'] ):
        branch_opt = '-b ' + args['-b']

    # Get the current time
    dt_string = time.asctime(time.gmtime())

    # check for already adopted
    json_dict = utils.load_package_file()
    pkgobj, deptype, pkgidx = utils.json_find_dependency( json_dict, pkg )
    if ( pkgobj != None ):
        sys.exit( f'Package {pkg} already has been adopted as {deptype} dependency' );
        
    # double check if the package has already been adopted (i.e. there was manual edits to the package.json file)
    if ( not args['overlay'] ):
        dstpkg = os.path.join( args['<dst>'], pkg)
        if ( os.path.exists( dstpkg ) ):
            sys.exit( f"ERROR: The destination - {dstpkg} - already exists" )

    #
    # Adopt: Foreign
    # 
    if ( args['foreign'] ):
        # Copy the FO package
        cmd = f"evie.py {vopt} --scm {common_args['--scm']} copy -p {pkg} {branch_opt} {args['<dst>']} {args['<repo>']} {args['<origin>']} {args['<id>']}"
        t   = utils.run_shell( cmd, common_args['-v'] )
        utils.check_results( t, f"ERROR: Failed to make a copy of the repo: {args['<repo>']}", 'copy', 'get-error-msg', common_args['--scm']  )

        # update the package.json file
        dst_pkg_info    = os.path.join( args['<dst>'], pkg, PACKAGE_INFO_DIR() )
        incoming_semver = utils.get_adopted_semver( dst_pkg_info, args['--semver'], pkg, not args['--nowarn'] )
        d = utils.json_create_dep_entry( pkg, "foreign", args['<dst>'], dt_string, incoming_semver, args['-b'], args['<id>'], args['<repo>'], common_args['--scm'], args['<origin>'] )

        # Verify there is package file for package being adopted
        if ( check_for_package_file( d, args ) ):

            # Check for cyclical deps
            if ( check_cyclical_deps( json_dict, d, args) == False ):
                # Remove the package
                cmd = f"evie.py {vopt} --scm {d['repo']['type']} rm -p {d['pkgname']} {branch_opt} {d['parentDir']} {d['repo']['name']} {d['repo']['origin']} {d['version']['tag']}"
                t   = utils.run_shell( cmd, common_args['-v'] )
                utils.check_results( t, f"ERROR: Failed to remove the package: {d['repo']['name']}, 'rm', 'get-error-msg', common_args['--scm']" )
            
                # Display parting message (if there is one)
                print("Adoption was 'reverted'")
                utils.display_scm_message( 'rm', 'get-success-msg', common_args['--scm'] )
                sys.exit(1)

        # Save changes
        utils.json_update_package_file_with_new_dep_entry( json_dict, d, args['--weak'] )
        
        # Display parting message (if there is one)
        utils.display_scm_message( 'copy', 'get-success-msg', common_args['--scm'] )

    #
    # Adopt: ReadOnly 
    # 
    elif ( args['readonly'] ):
        # Mount the RO package
        cmd = f"evie.py {vopt} --scm {common_args['--scm']} mount -p {pkg} {branch_opt} {args['<dst>']} {args['<repo>']} {args['<origin>']} {args['<id>']}"
        t   = utils.run_shell( cmd, common_args['-v'] )
        utils.check_results( t, f"ERROR: Failed to mount the repo: {args['<repo>']}", 'mount', 'get-error-msg', common_args['--scm'] )

        # update the package.json file
        dst_pkg_info    = os.path.join( args['<dst>'], pkg, PACKAGE_INFO_DIR() )
        incoming_semver = utils.get_adopted_semver( dst_pkg_info, args['--semver'], pkg, not args['--nowarn'] )
        d = utils.json_create_dep_entry( pkg, "readonly", args['<dst>'], dt_string, incoming_semver, args['-b'], args['<id>'], args['<repo>'], common_args['--scm'], args['<origin>'] )

        # Verify there is package file for package being adopted
        if ( check_for_package_file( d, args ) ):

            # Check for cyclical deps
            if ( check_cyclical_deps( json_dict, d, args) == False ):
                # Remove the package
                cmd = f"evie.py {vopt} --scm {d['repo']['type']} umount -p {d['pkgname']} {branch_opt} {d['parentDir']} {d['repo']['name']} {d['repo']['origin']} {d['version']['tag']}"
                t   = utils.run_shell( cmd, common_args['-v'] )
                utils.check_results( t, f"ERROR: Failed to umount the repo: {d['repo']['name']}, 'umount', 'get-error-msg', common_args['--scm']" )

                # Display parting message (if there is one)
                print("Adoption was 'reverted'")
                utils.display_scm_message( 'umount', 'get-success-msg', common_args['--scm'] )
                sys.exit(1)


        # Save changes
        utils.json_update_package_file_with_new_dep_entry( json_dict, d, args['--weak'] )

        # Mark files as readonly
        utils.set_tree_readonly( dstpkg )

        # Display parting message (if there is one)
        utils.display_scm_message( 'mount', 'get-success-msg', common_args['--scm'] )
        
    #
    # Adopt: overlay
    # 
    else:
        # Get a temporary copy of the OV package
        tmpdst = os.path.join( PACKAGE_INFO_DIR(), TEMP_DIR_NAME() )
        cmd = f"evie.py {vopt} --scm {common_args['--scm']} copy --force -p {pkg} {branch_opt} {tmpdst} {args['<repo>']} {args['<origin>']} {args['<id>']}"
        t   = utils.run_shell( cmd, common_args['-v'] )
        utils.check_results( t, f"ERROR: Failed to make a copy of the repo: {args['<repo>']}", 'copy', 'get-error-msg', common_args['--scm']  )

        # Fail if missing outcast info
        src_pkg      = os.path.join( tmpdst, pkg )
        dst_pkg      = os.path.join( OVERLAY_PKGS_DIR(), pkg )
        dst_pkg_info = os.path.join( dst_pkg, PACKAGE_INFO_DIR() )
        src_pkg_info = os.path.join( src_pkg, PACKAGE_INFO_DIR() )
        if ( not os.path.isfile( os.path.join(src_pkg_info, PACKAGE_FILE() ) ) ):
            utils.remove_tree(tmpdst)
            sys.exit( f"ERROR: Package - {pkg} - does NOT have {PACKAGE_FILE()} file")
        if ( not os.path.isfile( os.path.join(src_pkg_info, PKG_DIRS_FILE() ) )):
            utils.remove_tree(tmpdst)
            sys.exit( f"ERROR: Package - {pkg} - does NOT have {PKG_DIRS_FILE()} file")
        if ( not os.path.isfile( os.path.join(src_pkg_info, IGNORE_DIRS_FILE() ) )):
            utils.remove_tree(tmpdst)
            sys.exit( f"ERROR: Package - {pkg} - does NOT have {IGNORE_DIRS_FILE()} file")

        # Copy the adoptee's package info directory
        utils.copy_pkg_info_dir( dst_pkg_info, src_pkg_info )

        # Create the dependency entry for the adopted package
        incoming_semver = utils.get_adopted_semver( dst_pkg_info, args['--semver'], pkg, not args['--nowarn'] )
        d = utils.json_create_dep_entry( pkg, "overlay", args['<dst>'], dt_string, incoming_semver, args['-b'], args['<id>'], args['<repo>'], common_args['--scm'], args['<origin>'] )

        # Check for cyclical deps
        if ( check_cyclical_deps( json_dict, d, args) == False ):
            # Remove the the package from the overlaid directory
            utils.remove_tree( dst_pkg )
            sys.exit("Adoption was 'reverted'")


        # Copy the adoptee's extra info directories
        utils.copy_extra_dirs( dst_pkg, src_pkg )

        # Get list of directories to copy/overlay
        dirs = utils.get_adoptee_owned_dirs( os.path.join( tmpdst, pkg, PACKAGE_INFO_DIR()), tmpdst )
        if ( dirs != None ):
            for dir in dirs:
                src = os.path.join( src_pkg, dir )
                dst = os.path.join( PACKAGE_ROOT(), dir )
                utils.copy_files( src, dst )

        # Clean-up
        utils.remove_tree( tmpdst )
        
        # Save changes
        utils.json_update_package_file_with_new_dep_entry( json_dict, d, args['--weak'] )
        print( f"Package - {pkg} - adopted as an OVERLAY package. Remember to add the new files to your SCM" )
Exemplo n.º 11
0
def run(common_args, cmd_argv):
    args = docopt(__doc__, argv=cmd_argv)

    # Show existing dirs file
    if (args['-s']):
        dirs = utils.load_dirs_list_file()
        if (dirs != None):
            for d in dirs:
                print(d)

        sys.exit(0)

    # Show the currently defined overlay directories
    if (args['-o']):
        show_primary_dirs()
        sys.exit(0)

    # Set directories
    if (args['set']):
        newdirs = args['<primary>']
        newdirs = check_dirs(newdirs)
        package_json = utils.load_package_file()
        pdirs = utils.json_get_package_primary_dirs(package_json)
        if (pdirs == None):
            utils.json_update_package_file_with_new_primary_dirs(
                package_json, newdirs)
        else:
            # Filter out would-be-duplicates
            for d in newdirs:
                if (not d in pdirs):
                    pdirs.append(d)

            # Sort the list and update the file
            pdirs.sort()
            utils.json_update_package_file_with_new_primary_dirs(
                package_json, pdirs)

        # Show update list
        show_primary_dirs()
        sys.exit(0)

    # Remove directories
    if (args['rm']):
        rmdirs = standardize_input_dirs(args['<primary>'])
        package_json = utils.load_package_file()
        pdirs = utils.json_get_package_primary_dirs(package_json)
        if (pdirs == None):
            pass
        else:
            # Delete dirs
            newlist = []
            for d in pdirs:
                if (not d in rmdirs):
                    newlist.append(d)

            # Sort the list and update the file
            newlist.sort()
            utils.json_update_package_file_with_new_primary_dirs(
                package_json, newlist)

        # Show update list
        show_primary_dirs()
        sys.exit(0)

    # derive directories
    if (args['ls']):
        owndirs = utils.get_owned_dirs(PACKAGE_ROOT())
        for d in owndirs:
            print(d)

        # Update the directory list file
        if (args['-u']):
            utils.save_dirs_list_file(owndirs)

        sys.exit(0)

    # Set 'extra' directories
    if (args['xset']):
        newdirs = args['<adoptedExtra>']
        newdirs = check_dirs(newdirs)
        package_json = utils.load_package_file()
        pdirs = utils.json_get_package_extra_dirs(package_json)
        if (pdirs == None):
            utils.json_update_package_file_with_new_extra_dirs(
                package_json, newdirs)
        else:
            # Filter out would-be-duplicates
            for d in newdirs:
                if (not d in pdirs):
                    pdirs.append(d)

            # Sort the list and update the file
            pdirs.sort()
            utils.json_update_package_file_with_new_extra_dirs(
                package_json, pdirs)

        # Show update list
        show_extra_dirs()
        sys.exit(0)

    # Remove directories
    if (args['xrm']):
        rmdirs = standardize_input_dirs(args['<adoptedExtra>'])
        package_json = utils.load_package_file()
        pdirs = utils.json_get_package_extra_dirs(package_json)
        if (pdirs == None):
            pass
        else:
            # Delete dirs
            newlist = []
            for d in pdirs:
                if (not d in rmdirs):
                    newlist.append(d)

            # Sort the list and update the file
            newlist.sort()
            utils.json_update_package_file_with_new_extra_dirs(
                package_json, newlist)

        # Show update list
        show_extra_dirs()
        sys.exit(0)

    # List extra directories
    if (args['xls']):
        package_json = utils.load_package_file()
        pdirs = utils.json_get_package_extra_dirs(package_json)
        for d in pdirs:
            print(d)
        sys.exit(0)