示例#1
0
def backup_repo(backup_base_dir, directory_to_be_backed_up):
    backup_full_path = os.path.join(backup_base_dir, TIMESTAMP)
    # create dirs
    bldinstallercommon.create_dirs(backup_full_path)
    # backup
    bldinstallercommon.copy_tree(directory_to_be_backed_up, backup_full_path)
    print('Created backup of repository:')
    print('Source:      {0}'.format(directory_to_be_backed_up))
    print('Destination: {0}'.format(backup_full_path))
示例#2
0
def backup_repo(backup_base_dir, directory_to_be_backed_up):
    backup_full_path = os.path.join(backup_base_dir, TIMESTAMP)
    # create dirs
    bldinstallercommon.create_dirs(backup_full_path)
    # backup
    bldinstallercommon.copy_tree(directory_to_be_backed_up, backup_full_path)
    print('Created backup of repository:')
    print('Source:      {0}'.format(directory_to_be_backed_up))
    print('Destination: {0}'.format(backup_full_path))
示例#3
0
def swap_repository(parser_args):
    if not parser_args:
        raise RuntimeError(
            '*** No options available to swap online reposities')

    source_match_list = get_directory_list(parser_args.source,
                                           parser_args.component)
    if not source_match_list:
        raise RuntimeError(
            '*** Nothing to update? Did not find any component named: %s' %
            parser_args.component)
    dest_match_list = get_directory_list(parser_args.destination,
                                         parser_args.component)

    match_list = generate_match_list(source_match_list, dest_match_list,
                                     parser_args.component,
                                     parser_args.destination)
    for swap_option in match_list:
        print()
        print('###################################################')
        print('Replacing: {0}'.format(swap_option.destination_dir))
        print('With:      {0}'.format(swap_option.source_dir))
        print()
        print('y: Yes')
        print('n: No (abort)')
        print()
        keep_asking = True
        while (keep_asking):
            var = raw_input("Proceed? ")
            if var in ['n', 'N']:
                keep_asking = False
                break
            if var in ['y', 'Y']:
                keep_asking = False
                print()
                # if the repo exists, take backup
                if os.path.exists(swap_option.destination_dir):
                    backup_dir = swap_option.destination_dir + '_old_' + generate_random_string(
                    )
                    bldinstallercommon.create_dirs(backup_dir)
                    bldinstallercommon.copy_tree(swap_option.destination_dir,
                                                 backup_dir)
                    print('Backup taken into: {0}'.format(backup_dir))
                    shutil.rmtree(swap_option.destination_dir)
                bldinstallercommon.create_dirs(swap_option.destination_dir)
                bldinstallercommon.copy_tree(swap_option.source_dir,
                                             swap_option.destination_dir)
                print('Repository updated: {0}'.format(
                    swap_option.destination_dir))
示例#4
0
def swap_repository(parser_args):
    if not parser_args:
        raise RuntimeError("*** No options available to swap online reposities")

    source_match_list = get_directory_list(parser_args.source, parser_args.component)
    if not source_match_list:
        raise RuntimeError("*** Nothing to update? Did not find any component named: %s" % parser_args.component)
    dest_match_list = get_directory_list(parser_args.destination, parser_args.component)

    match_list = generate_match_list(source_match_list, dest_match_list, parser_args.component, parser_args.destination)
    for swap_option in match_list:
        print()
        print("###################################################")
        print("Replacing: {0}".format(swap_option.destination_dir))
        print("With:      {0}".format(swap_option.source_dir))
        print()
        print("y: Yes")
        print("n: No (abort)")
        print()
        keep_asking = True
        while keep_asking:
            var = raw_input("Proceed? ")
            if var in ["n", "N"]:
                keep_asking = False
                break
            if var in ["y", "Y"]:
                keep_asking = False
                print()
                # if the repo exists, take backup
                if os.path.exists(swap_option.destination_dir):
                    backup_dir = swap_option.destination_dir + "_old_" + generate_random_string()
                    bldinstallercommon.create_dirs(backup_dir)
                    bldinstallercommon.copy_tree(swap_option.destination_dir, backup_dir)
                    print("Backup taken into: {0}".format(backup_dir))
                    shutil.rmtree(swap_option.destination_dir)
                bldinstallercommon.create_dirs(swap_option.destination_dir)
                bldinstallercommon.copy_tree(swap_option.source_dir, swap_option.destination_dir)
                print("Repository updated: {0}".format(swap_option.destination_dir))
示例#5
0
 if CALLER_ARGUMENTS.source_repo:
     source_repo = os.path.join(CALLER_ARGUMENTS.source_repo, 'online_repository')
     if not os.path.isdir(source_repo) or not os.path.isfile(os.path.join(source_repo, 'Updates.xml')):
         print('*** The given source directory does not seem to be proper repository? Abort!')
         print('Given source repository: {0}'.format(source_repo))
         raise RuntimeError()
     if os.path.isfile(os.path.join(CALLER_ARGUMENTS.target_repo, 'Updates.xml')):
         print('The given destination directory already contains a repository.')
         print('We just update the existing repository:')
         print('Given target repository: {0}'.format(CALLER_ARGUMENTS.target_repo))
     else:
         print('Initializing the repository for the first time!')
         # create dirs
         bldinstallercommon.create_dirs(CALLER_ARGUMENTS.target_repo)
         # copy repository
         bldinstallercommon.copy_tree(source_repo, CALLER_ARGUMENTS.target_repo)
         # everything done now!
         print('Repository initialized:')
         print('Source:      {0}'.format(source_repo))
         print('Destination: {0}'.format(CALLER_ARGUMENTS.target_repo))
         sys.exit()
 # fetch tools
 fetch_repogen_tools(CALLER_ARGUMENTS.repogen_tools)
 # components to update
 COMPONENTS_TO_UPDATE = []
 if not CALLER_ARGUMENTS.components_to_update or CALLER_ARGUMENTS.components_to_update == '':
     # ask user which components to update
     COMPONENTS_TO_UPDATE = ask_for_components(CALLER_ARGUMENTS.source_pkg)
 else:
     COMPONENTS_TO_UPDATE = parse_components_from_argument(CALLER_ARGUMENTS)
 # sanity check
示例#6
0
         print('Given source repository: {0}'.format(source_repo))
         raise RuntimeError()
     if os.path.isfile(
             os.path.join(CALLER_ARGUMENTS.target_repo, 'Updates.xml')):
         print(
             'The given destination directory already contains a repository.'
         )
         print('We just update the existing repository:')
         print('Given target repository: {0}'.format(
             CALLER_ARGUMENTS.target_repo))
     else:
         print('Initializing the repository for the first time!')
         # create dirs
         bldinstallercommon.create_dirs(CALLER_ARGUMENTS.target_repo)
         # copy repository
         bldinstallercommon.copy_tree(source_repo,
                                      CALLER_ARGUMENTS.target_repo)
         # everything done now!
         print('Repository initialized:')
         print('Source:      {0}'.format(source_repo))
         print('Destination: {0}'.format(CALLER_ARGUMENTS.target_repo))
         sys.exit()
 # fetch tools
 fetch_repogen_tools(CALLER_ARGUMENTS.repogen_tools)
 # components to update
 COMPONENTS_TO_UPDATE = []
 if not CALLER_ARGUMENTS.components_to_update or CALLER_ARGUMENTS.components_to_update == '':
     # ask user which components to update
     COMPONENTS_TO_UPDATE = ask_for_components(CALLER_ARGUMENTS.source_pkg)
 else:
     COMPONENTS_TO_UPDATE = parse_components_from_argument(CALLER_ARGUMENTS)
 # sanity check